Repository navigation
Conversation
…hema elements Add typed CreateEventTrigger, AlterEventTrigger, Reindex and SecurityLabel statements. Event triggers reuse the CREATE TRIGGER routine invocation and the shared trigger and rule enable states; SECURITY LABEL addresses routines through RoutineReference. REINDEX becomes a non-reserved keyword. CREATE SCHEMA parses PostgreSQL schema elements (CREATE TABLE, VIEW, INDEX, SEQUENCE, TRIGGER and GRANT), keeps their names as written and renders them, together with the PATH clause, in toString() and StatementDeParser. Signed-off-by: minleejae <mmj9808@gmail.com>
minleejae
force-pushed
the
feat/postgresql-admin-statements-20261014
branch
from
October 14, 2026 08:21
3134a20 to
10dbb26
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Parse PostgreSQL administration statements that fail in every configuration today. pg_dump output and maintenance scripts contain them, for example:
CREATE EVENT TRIGGER etg ON ddl_command_start WHEN TAG IN ('CREATE TABLE') EXECUTE FUNCTION abort_any_command()ALTER EVENT TRIGGER etg ENABLE ALWAYSREINDEX INDEX CONCURRENTLY idxSECURITY LABEL FOR selinux ON TABLE t1 IS 'system_u:object_r:sepgsql_table_t:s0'CREATE SCHEMA hollywood CREATE TABLE films (…) CREATE VIEW winners AS SELECT …Current design (As-is)
REINDEXorSECURITY LABEL.CREATE EVENT …andALTER EVENT …reach only the MySQL event productions, which fail at the trigger name.CREATE SCHEMAhandles schema elements only partly:CREATE TABLEelement, and also aVIEW …element withoutCREATE. A secondCREATEelement fails.toString()andStatementDeParserdrop all elements and thePATHclause.CREATE TABLEelement's name to carry the schema name.TablesNamesFinderthrows for everyCREATE SCHEMA.Target design (To-be)
CreateEventTrigger(statement.create.trigger) records:WHENfilters in source order, each a variable with its string values;CreateTrigger.ExecuteKeywordand theFunctionreference ofCREATE TRIGGER, with an empty argument list.OR REPLACE, and empty or non-string tag lists.AlterEventTrigger(statement.alter):ENABLE [REPLICA | ALWAYS]andDISABLEreuseRelationAlterAction.EnableStateand thePostgreSqlEnableState()production from Share PostgreSQL trigger and rule enable states #2718.OWNER TOandRENAME TO.EVENT TRIGGERstarts a PostgreSQL event trigger only when the name is followed byON(CREATE) or by an action keyword (ALTER). A MySQL event namedtriggerstill parses toCreateEvent/AlterEvent.Reindex(newstatement.reindexpackage) records:Target(INDEX, TABLE, SCHEMA, DATABASE, SYSTEM) and theCONCURRENTLYkeyword;CONCURRENTLY,TABLESPACEandVERBOSEoptions, with values as written;REINDEXbecomes a non-reserved token. A statement that starts with a plain identifier adds choice conflicts at several optional trailing identifiers, so it needs a token, likeNOTIFYin Support PostgreSQL rewrite rules with reusable statement actions #2723. The word remains usable as an identifier, andKeywordsTestcovers it.SecurityLabel(newstatement.securitylabelpackage) records the provider as written and one target.getObjectType()covers all 21 object kinds that PostgreSQL documents:Table;COLUMN;FUNCTION/PROCEDURE/ROUTINE/AGGREGATEsignatures, using the sharedRoutineReference;LARGE OBJECTOIDs.IS NULLis a null label.CommentTarget, which has no TABLE/COLUMN/VIEW kinds and is being extended by the COMMENT ON targets PR. Qualified names reuseCommentObjectName().CREATE SCHEMAelements:SchemaElement()production reusesCreate()andGrant(). It accepts PostgreSQL's element kinds:CREATE TABLE,VIEW,INDEX,SEQUENCE,TRIGGERandGRANT.CREATEstatements, theVIEWform withoutCREATE, and elements afterIF NOT EXISTS.CREATE TABLEelements.toString()andStatementDeParserrenderPATHand the elements.TablesNamesFinderandStatementVisitorAdaptertraverse the elements.GRANTis never read as an implicit alias (… FROM films GRANT SELECT …). Elsewheregrantremains an alias.StatementVisitordefaults, the adapter,StatementDeParser,TablesNamesFinder,StatementValidatorandStatementFeatureVisitor.REINDEXalso reads data.REINDEXandSECURITY LABELinstead of capturing them as opaque.createEventTrigger,alterEventTrigger,reindex,reindexConcurrently(PostgreSQL 12) andsecurityLabel. They are inPostgresqlVersion, and the event trigger features are also inFeaturesAllowed.CREATE/ALTER.Validation
PostgreSqlEventTriggerTest23,ReindexTest27,SecurityLabelTest39, and 11 more inCreateSchemaTest.Dialect.POSTGRESQL, plus the AST fields.trigger, and the new words used as identifiers.CREATE SCHEMAtests pass unchanged.spotlessApply check: 10,477 tests, 10,452 passed, 25 skipped, zero failures or errors. The grammar choice conflict check passes.master(bdf8ac31) on a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, plus variants:Dialect.POSTGRESQLand without a dialect:CREATE EVENT TRIGGER,REINDEX INDEX CONCURRENTLY,REINDEX TABLE,SECURITY LABELandCREATE SCHEMAwith schema elements. Each renders identically to the source.reindex,securityandlabelas names), the variants and the scripts.toString()on a second, identical server, in the same order. All 205 MySQL and 332 PostgreSQL statements give the same result (success, or the same error).Integration validation
Applied #2806–#2819 together on
master(bdf8ac31), with the stacked PRs on top of their bases (#2806 → #2807 → #2808, #2806 → #2809 → #2810 and #2811 → #2812).master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, visitor and feature lists, one enum line and one alias guard).spotlessApply check: 11,494 tests, 11,469 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master: 206) and 363 of 364 PostgreSQL statements (master: 328). Every MySQL 8.4 non-reserved word and PostgreSQL 18 unreserved or column-name keyword parses as a column and table name.