Skip to content

fix(parser): allow VERSION in ALTER column clauses - #2530

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/version-alter-column
Sep 3, 2026
Merged

fix(parser): allow VERSION in ALTER column clauses#2530
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/version-alter-column

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

What

  • Allow the non-reserved VERSION keyword to be used as a column identifier in the restricted KeywordOrIdentifier production used by ALTER TABLE.
  • Allow VERSION in CreateParameter, which currently captures PostgreSQL USING expressions attached to ALTER COLUMN ... TYPE.
  • Add parse/deparse regressions for DROP COLUMN version and ALTER COLUMN version TYPE ... USING version::....

Why

VERSION is already declared as a non-reserved keyword, but two narrower legacy productions do not accept it. As a result, valid PostgreSQL statements such as these fail on the current master branch:

ALTER TABLE test_table DROP COLUMN version, DROP COLUMN other_column;
ALTER TABLE test_table ALTER COLUMN version TYPE VARCHAR(32) USING version::VARCHAR(32);

PostgreSQL allows non-reserved keywords to be used as identifiers. This change is intentionally limited to the two productions exercised by these statements and introduces no new JavaCC choice conflicts.

PostgreSQL keyword reference: https://www.postgresql.org/docs/current/sql-keywords-appendix.html

Testing

  • ./gradlew check
  • Added both statements to AlterTest and verified parse/deparse round trips.

AI assistance

OpenAI Codex was used to identify the regression from a PostgreSQL ALTER corpus, prepare the focused grammar change, and run validation. The generated change and tests were reviewed against the PostgreSQL documentation.

VERSION is non-reserved, but restricted legacy productions reject it in DROP COLUMN and USING clauses. Accept the token in those productions and cover both PostgreSQL corpus cases.
@minleejae
minleejae force-pushed the fix/version-alter-column branch from 7837250 to 744dfc1 Compare September 3, 2026 06:26
@manticore-projects
manticore-projects merged commit a6da400 into JSQLParser:master Sep 3, 2026
7 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