Skip to content

feat: share PostgreSQL foreign table DDL and FDW options - #2714

Merged
manticore-projects merged 5 commits into
JSQLParser:masterfrom
minleejae:feat/postgresql-foreign-table-ddl
Sep 25, 2026
Merged

manticore-projects merged 5 commits into
JSQLParser:masterfrom
minleejae:feat/postgresql-foreign-table-ddl

Conversation

@minleejae

@minleejae minleejae commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

PostgreSQL FOREIGN TABLE definitions retained SERVER and OPTIONS as raw tokens, and ALTER/DROP FOREIGN TABLE were unsupported. This reuses CreateTable, column definitions, Alter and Drop while giving foreign server and table/column FDW options explicit AST nodes.

ForeignDataOption is shared by CREATE options and ALTER's implicit ADD, ADD, SET and DROP forms. SERVER stays in the existing TableOption list so replacing legacy string options also removes the previous structured server. AlterForeignDataOptions reuses the existing ALTER action pipeline; DROP FOREIGN TABLE exposes typed multi-target names. Rendering and expression/table traversal share these models without treating foreign servers as local table references.

The ALTER target prefix is shared between toString and the deparser, supports the descendant marker, and emits IF EXISTS before ONLY as PostgreSQL requires. Existing table/column action parsers are reused; remote queries, FDW-specific option validation and internal procedural ASTs are outside this change.

Validation: full Gradle check, including JavaCC ambiguity, unit tests and static analysis. Tests cover CREATE/ALTER/DROP variants, options mutation and deletion, legacy replacement, visitors, boundaries, invalid forms and both output paths. Original/toString/deparser execution and catalog comparison passed for 22 PostgreSQL 18.6 cases using a handler-free local FDW; no external service was contacted. Six additional foreign-table boundary cases and four AST mutations (server replacement, legacy replacement, option DROP and column-option replacement) also passed PostgreSQL execution and catalog comparison.

Sources: CREATE FOREIGN TABLE, ALTER FOREIGN TABLE, DROP FOREIGN TABLE.

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

Copy link
Copy Markdown
Contributor

Please resolve conflicts.

Signed-off-by: minleejae <mmj9808@gmail.com>
Signed-off-by: minleejae <mmj9808@gmail.com>
Signed-off-by: minleejae <mmj9808@gmail.com>
@manticore-projects
manticore-projects merged commit 78d3de8 into JSQLParser:master Sep 25, 2026
4 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