Skip to content

Structure PostgreSQL column type and generated expression replacements - #2716

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-column-replacements-20260925
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-column-replacements-20260925

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

PostgreSQL accepts ALTER TABLE t ALTER COLUMN id SET DATA TYPE bigint USING id::bigint, but the parser rejected SET DATA TYPE. ALTER COLUMN g SET EXPRESSION AS (...) could parse as a column type change, leaving the expression inaccessible through the appropriate AST node.

Share the TYPE/SET DATA TYPE prefix between ALTER TABLE and ALTER TYPE, and share generated-expression parsing/rendering with CREATE TABLE. Add a distinct SET_EXPRESSION action whose expression participates in visitors and deparsing, while retaining existing type-change accessors.

Tests cover both type prefixes, USING/COLLATE, composite attributes, optional COLUMN, expression mutation and custom deparsing, multiple actions, and invalid contexts. Relevant corpus cases were executed on PostgreSQL 18.6 using original SQL, toString output, and StatementDeParser output; resulting catalog definitions match.

Syntax references: ALTER TABLE, ALTER TYPE.

Validation: focused tests, JavaCC ambiguity checks, Checkstyle and Spotless on this independent branch. The combined implementation also passes the full Gradle check and Maven verify; the 1,304-input prior regression corpus has no previously successful input regressions.

…ements

Signed-off-by: minleejae <mmj9808@gmail.com>

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