Skip to content

fix: parse MySQL events as SHOW CREATE EVENT prints them - #2871

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/mysql-event-definer-body-20261029
Oct 29, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/mysql-event-definer-body-20261029

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

SHOW CREATE EVENT prints DEFINER=user@host before EVENT, prints DISABLE ON REPLICA for an event that is disabled on replicas, and keeps a BEGIN … END body as written. None of these parsed as an event. CREATE DEFINER=… EVENT and ALTER DEFINER=… EVENT fell back to UnsupportedStatement, and DISABLE ON REPLICA and a BEGIN … END body failed. Of seven SHOW CREATE EVENT outputs from MySQL 8.4.11, five became UnsupportedStatement and two failed.

CREATE EVENT and ALTER EVENT now read the optional DEFINER with the production that stored routines use, and keep it as a MySqlDefiner in EventStatement.getDefiner(). The body reuses MySqlTriggerBody, so a block of SQL statements becomes a Block, and other compound statements such as IF … END IF keep their tokens, as in triggers. EventStatus gains DISABLE_ON_REPLICA. DISABLE ON SLAVE, which MySQL 8.4 still accepts with a deprecation warning, gives DISABLE_ON_SLAVE as before.

Public method signatures are retained. One existing test expected CREATE DEFINER = x EVENT … to fall back to UnsupportedStatement (#2864); it now expects a CreateEvent.

Syntax reference: MySQL 8.4 CREATE EVENT, ALTER EVENT, SHOW CREATE EVENT.

Validation:

  • EventStatementTest adds 9 statements. Each is parsed with and without the MySQL dialect, deparsed, and parsed again inside a script. Further tests check the definer, the block body and the replica status. On master c84ad0ebc, 5 of the 9 fail and 3 become UnsupportedStatement; only DISABLE ON SLAVE parses as an event.
  • The seven SHOW CREATE EVENT outputs now parse as CreateEvent and round-trip.
  • MySQL 8.4.11 accepts all 9 statements.
  • Java 17 Gradle check: 12,275 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet against upstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.
  • JaCoCo instrumentation headroom of CCJSqlParser (JaCoCo instrumentation of CCJSqlParser is approaching the constant-pool limit #2866): 808 entries on master, 720 with this change.

AI assistance: prepared with Claude Code.

SHOW CREATE EVENT prints DEFINER=user@host before EVENT, and MySQL 8.4
prints DISABLE ON REPLICA for an event that is disabled on replicas.
Event bodies are often BEGIN ... END blocks. CREATE and ALTER EVENT with
a DEFINER fell back to UnsupportedStatement, and DISABLE ON REPLICA and
a BEGIN ... END body failed.

CREATE EVENT and ALTER EVENT now read DEFINER with the production that
stored routines use and keep it in EventStatement.getDefiner(). The body
reuses MySqlTriggerBody, so a block of SQL statements is a Block and
other compound statements keep their tokens, as in triggers. EventStatus
gains DISABLE_ON_REPLICA; DISABLE ON SLAVE still gives DISABLE_ON_SLAVE.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 8330f6b into JSQLParser:master Oct 29, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants