Skip to content

feat: preserve DROP INDEX owner tables in the AST - #2640

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/drop-index-table
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/drop-index-table

Conversation

@minleejae

@minleejae minleejae commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

DROP INDEX ix ON app.t currently puts the owner in raw parameter tokens, so consumers cannot obtain or rewrite it through a Table node. Table discovery also reports the index name as a table. This exposes the explicit owner through Drop.getTable() and makes visitors, validation and custom deparsers use it. Index names and DROP names with quoted dots retain their identifier components.

DROP rendering is shared by Drop and DropDeParser. The legacy getParameters() still includes ON and the table, but returns a snapshot when an owner is structured. Owner mutations update that snapshot and SQL output; addParameters() preserves the owner; setParameters() replaces the complete clause with raw tokens and clears the structured owner. MySQL ALGORITHM/LOCK order and optional equals signs are preserved.

This covers the single-owner ON form used by MySQL and SQL Server. PostgreSQL DROP INDEX has no explicit owner, so getTable() is null and table discovery does not invent one. SQL Server's multi-owner list and WITH options remain outside this change.

Validation

  • Merged locally with fix: preserve PostgreSQL quoted names, numeric scales and comment literals #2638, feat: support additional PostgreSQL COMMENT targets #2639 and feat: structure column attributes and generated expressions #2641 without conflicts: 7,126 Gradle tests, zero failures/errors, 25 skipped; the grammar ambiguity check passed. All 193 new audit cases produced identical parser/rendering results in the combined build.

  • Full Gradle check, including the JavaCC ambiguity gate, formatting, Checkstyle, PMD and SpotBugs: 6,919 tests, zero failures/errors, 25 skipped. Spotless ratchet pinned to base 6312f9e5.

  • EXPORT_TEST_TO_FILE=False mvn -B clean verify: 6,901 tests, zero failures/errors, 25 skipped.

  • MySQL 8.4.11 and PostgreSQL 18.6 differential checks: 34 valid statements retained the same index-deletion result after parsing and both rendering paths; two malformed ON clauses were rejected by the parser and MySQL. Coverage includes quoted/qualified names, the quoted PRIMARY index and ALGORITHM/LOCK variants.

  • SQL Server bracketed and database-qualified owners, IF EXISTS, AST mutations, legacy setters, custom deparsing and statement boundaries are covered by regression tests. SQL Server was not executed locally.

This is independent of the general AST querying API discussed in #2620. Related PostgreSQL quoted-name fixes in #2638 remain applicable to other statement contexts.

Syntax references: MySQL DROP INDEX, SQL Server DROP INDEX, PostgreSQL DROP INDEX.

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.

1 participant