Repository navigation
Conversation
Model the remaining common PostgreSQL COMMENT ON object kinds with the existing CommentTarget: TRIGGER, POLICY and RULE within a table; PROCEDURE, ROUTINE and AGGREGATE signatures through RoutineReference; CAST; and ACCESS METHOD, COLLATION, DATABASE, EVENT TRIGGER, EXTENSION, FOREIGN DATA WRAPPER, FOREIGN TABLE, [PROCEDURAL] LANGUAGE, PUBLICATION, ROLE, SERVER, STATISTICS, SUBSCRIPTION and TABLESPACE. The grammar reads the kind first and lets it select the reference shape. Kind words without a token stay non-reserved. Shared routine signatures now accept ordered-set aggregates without direct arguments, such as mode(ORDER BY anyelement). Signed-off-by: minleejae <mmj9808@gmail.com>
This was referenced Oct 14, 2026
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 the remaining common PostgreSQL
COMMENT ONtargets.COMMENT ON TRIGGER trg ON users IS '...', as well asPOLICY,EXTENSION,DATABASEandROLEcomments, fail in every configuration. Schema dumps and migrations routinely contain these statements. #2639 added eight target kinds; this change covers most of the rest of the PostgreSQL 18 list with the same model.Current design (As-is)
CommentTargetmodelsINDEX,SCHEMA,SEQUENCE,DOMAIN,TYPE,MATERIALIZED VIEW,FUNCTIONandCONSTRAINT.CONSTRAINThas an owning relation, and onlyFUNCTIONhas a signature.ParseException, for exampleEncountered: <K_TRIGGER>.RoutineReferenceproduction readsORDERas an argument name. Ordered-set aggregate signatures without direct arguments, such asmode(ORDER BY anyelement), therefore fail. This also affectsALTER EXTENSION ... ADD AGGREGATE.Target design (To-be)
CommentTarget.Kindinstead of adding a parallel model:TRIGGER,POLICYandRULEusegetName()andgetRelation(), likeCONSTRAINT. OnlyCONSTRAINTacceptsON DOMAIN.PROCEDURE,ROUTINEandAGGREGATEuse the sharedRoutineReference, likeFUNCTION.AGGREGATErequires a signature and accepts(*)andORDER BY.CAST (source AS target)exposesgetSourceType()andgetTargetType(). This is the same shape as theCASTmember ofALTER EXTENSION.getName().COLLATION,FOREIGN TABLEandSTATISTICS, which may be schema-qualified.DATABASE,ROLE,TABLESPACE,ACCESS METHOD,EXTENSION,FOREIGN DATA WRAPPER,SERVER,EVENT TRIGGER,PUBLICATIONandSUBSCRIPTION.[PROCEDURAL] LANGUAGE, whereisProcedural()records the spelling.Kind.isRoutine()andKind.isOwnedByRelation()describe the reference shape. The grammar andappendTo()both use them.CommentTargetKind()reads the kind words first.CommentTarget()then uses semantic lookahead on the kind to select the reference shape.ROLE,RULEandSERVER, are matched withisKeywordAhead()andContextualKeyword(), so they remain identifiers elsewhere.RoutineReference: skip the direct-argument list whenORDER BYimmediately follows(.StatementVisitorAdaptervisit foreign tables and the tables that own triggers, policies and rules, throughgetReferencedRelation(). Custom deparsers can rewrite these names. Routines, roles, databases and other catalog objects are never reported as tables.Feature.commentOn...per new kind, as in feat: support additional PostgreSQL COMMENT targets #2639. All of them are enabled in the PostgreSQL feature set.PROCEDURE/ROUTINEneed PostgreSQL 11, but they stay in the base set, asexecuteCallalready does.OPERATOR [CLASS|FAMILY],TEXT SEARCH ...,CONVERSION,LARGE OBJECTandTRANSFORM.Validation
CommentTargetTestgoes from 74 to 240 andCommentValidatorTestfrom 10 to 32. They cover:Dialect.POSTGRESQLand without a dialect;*andORDER BY;PROCEDURAL;TRIGGER t ON DOMAIN d,PROCEDURE p(*),AGGREGATE aandCAST (integer);Kindmaps to a validation feature.spotlessApply check: 10,543 tests, 10,518 passed, 25 skipped, zero failures/errors. The grammar conflict check, Checkstyle, PMD and SpotBugs pass.master(bdf8ac31) on a corpus of 635 MySQL 8.4 and PostgreSQL 18 DDL/DCL statements, each accepted by the server, plus variants and keyword cases, with and without a dialect:COMMENT ON TRIGGER/POLICY/EXTENSION/DATABASE/ROLEnow parse in both the PostgreSQL dialect and the default mode.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.