Skip to content

fix: find tables in SET values instead of throwing - #2873

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/tables-names-finder-set-20261029
Oct 29, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/tables-names-finder-set-20261029

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

TablesNamesFinder threw UnsupportedOperationException for every SET statement except the SQL Server ON/OFF options. A subquery in a value, as in SET @a = (SELECT MAX(id) FROM t1), was never reached. A MySQL trigger whose body is or contains SET, such as CREATE TRIGGER trg BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a = …, failed the same way, although its table is known. The trigger examples in the MySQL manual use this form.

The finder now visits the value expressions of each assignment, as it does for the values of UPDATE … SET. A subquery in a SET value reports its tables, and other SET statements report none. The deliberate UnsupportedOperationException for other statements, such as CREATE SYNONYM, is unchanged.

Public method signatures are retained.

Syntax reference: MySQL 8.4 SET for variables, trigger syntax.

Validation:

  • TablesNamesFinderTest adds a SET with a subquery, a SET without tables and two MySQL triggers, one with a SET body and one with SET inside BEGIN … END. Both new tests fail on master c84ad0ebc with UnsupportedOperationException: Finding tables from SetStatement is not supported.
  • MySQL 8.4.11 accepts the two triggers and the SET statement.
  • Java 17 Gradle check: 12,264 tests, 0 failures, 25 skipped. Grammar ambiguity, formatting (Spotless ratchet against upstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass. The grammar is unchanged.

AI assistance: prepared with Claude Code.

TablesNamesFinder threw UnsupportedOperationException for every SET
statement except SQL Server ON/OFF options. A MySQL trigger whose body
is or contains SET, such as FOR EACH ROW SET NEW.a = ..., failed the
same way, although its table is known.

The finder now visits the value expressions of each assignment, so a
subquery in a SET value reports its tables and other SET statements
report none.

Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 4dff61a into JSQLParser:master Oct 29, 2026
10 checks passed
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