Skip to content

Fix index definition and reference roles in ALTER validation - #2776

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/alter-index-name-validation-20261011
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:fix/alter-index-name-validation-20261011

Conversation

@minleejae

@minleejae minleejae commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Validate index names according to their role in an ALTER operation. ALTER TABLE child ADD INDEX ix (id) should validate a new index name and an existing column; currently metadata validation incorrectly requires ix to exist already.

Current design (As-is)

ALTER validation treats every stored index name as an existing object. This rejects new ADD names, queries an absent name for unnamed indexes, and checks a RENAME destination as existing while omitting its source.

Target design (To-be)

Extract index metadata validation into one helper:

  • ADD: optional new index name, existing key columns.
  • DROP INDEX/KEY: existing index name.
  • RENAME INDEX/KEY: existing source name and new destination name.
  • PostgreSQL PRIMARY KEY/UNIQUE USING INDEX: keep the existing reference validation path.

Quoted names are passed through unchanged. Expression-key columns continue through the expression visitor exactly once. These rules use the existing optional database-metadata validation capability; parsing behavior and dialect acceptance do not change.

Validation

  • 16 new regression cases cover named/unnamed/functional/quoted indexes, ADD/DROP/RENAME, PostgreSQL USING INDEX and programmatic builders, including missing-column/source and existing-destination errors.
  • Rebased onto master (166f0a27) after Separate ALTER key definitions from column drop targets #2771. The only conflict was in AlterValidator: Separate ALTER key definitions from column drop targets #2771's constraint and drop-target validation are kept, and only the index block is replaced by the role-aware helper.
  • Java 17 offline Gradle spotlessApply check after the rebase: 10,110 tests, 10,085 passed, 25 skipped, zero failures/errors. Grammar, Checkstyle, PMD, SpotBugs and coverage checks pass.
  • Default PMD comparison against the previous base (066f581e): no new method violations; existing ALTER validator complexity decreases (cyclomatic 14→12, NPath 1249→417).

Integration validation

Applied #2770, #2771 and all four follow-ups (#2775–#2778) together on master (066f581e), resolving overlapping validator edits while preserving their respective behavior. The integrated build passes Java 17 offline Gradle spotlessApply check: 10,141 tests, 10,116 passed, 25 skipped, zero failures/errors. The combined ALTER validator has zero findings under the default PMD complexity and field-placement rules.

Replayed 882 previously DB-validated MySQL/PostgreSQL DDL fixtures: 875 pass and the same seven existing parse gaps remain. SQL output, reparsing and AST node-type sets match the preceding integration baseline, with no new differences. This replay did not rerun the databases.

The published head passes grammar checks, Gradle and Maven on Ubuntu/Windows/macOS, and Codacy. Deployment-only jobs are skipped as expected for a PR.

Signed-off-by: minleejae <mmj9808@gmail.com>
@minleejae
minleejae force-pushed the fix/alter-index-name-validation-20261011 branch from c5064a8 to d23d6d6 Compare October 13, 2026 03:32

This branch has not been deployed

No deployments
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