Skip to content

Support PostgreSQL rewrite rules with reusable statement actions - #2723

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

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-rewrite-rules-20260925

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

PostgreSQL accepts CREATE RULE r AS ON INSERT TO t DO ALSO NOTIFY ddl_probe, but JSqlParser could not parse the rule or its NOTIFY action.

Add a structured CREATE RULE node that reuses existing SELECT/INSERT/UPDATE/DELETE/TABLE statement ASTs for actions, plus a NOTIFY node usable both independently and inside a rule. Preserve event, condition, ALSO/INSTEAD behavior, NOTHING, and grouped action lists. Route nested actions through normal visitors/deparsers so SQL expressions and table references remain accessible. NOTIFY stays usable as an unquoted identifier.

Tests cover nested actions and mutations, custom expression deparsing, semicolon and following-statement boundaries, parenthesized set operations, and invalid actions/payloads. Executed 16 rule scenarios and two standalone NOTIFY scenarios on PostgreSQL 18.6, comparing rule catalog definitions and, where applicable, effects on table contents after original and rendered SQL.

Syntax references: CREATE RULE, NOTIFY. Event/NEW/OLD restrictions that require database catalog analysis remain the server's responsibility.

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.

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