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>
…ts and large objects Extend CommentTarget with the PostgreSQL COMMENT ON kinds that still failed: OPERATOR with its operand types (NONE for a missing operand), OPERATOR CLASS and OPERATOR FAMILY with their access method, LARGE OBJECT with its OID, TEXT SEARCH CONFIGURATION, DICTIONARY, PARSER and TEMPLATE, CONVERSION, and TRANSFORM FOR type LANGUAGE lang. COMMENT ON OPERATOR reuses the operator reference shared with exclusion constraints and ALTER EXTENSION. That production now accepts the JSON, pattern, bitwise and geometric operators, and joins operator parts that the lexer splits but that touch each other, such as <<= or -|-. The new kind words stay non-reserved. 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.
Builds on #2816, which extends
CommentTarget; please review that first.Purpose
Parse the PostgreSQL
COMMENT ONtargets that still fail after #2816:OPERATOR, including prefix operators such as- (NONE, integer)and schema-qualified operators such asapp.+;OPERATOR CLASSandOPERATOR FAMILYwithUSING access_method;LARGE OBJECT oid;TEXT SEARCH CONFIGURATION,DICTIONARY,PARSERandTEMPLATE;CONVERSIONandTRANSFORM FOR type LANGUAGE lang.These statements fail in every configuration, for example
COMMENT ON OPERATOR - (NONE, integer) IS 'x'withEncountered: <S_IDENTIFIER> / "OPERATOR". pg_dump writes aCOMMENT ONfor every commented object, so a dump with commented operators, text search objects or large objects stops at these lines. With this change, every object kind in the PostgreSQL 18COMMENT ONsynopsis parses.Current design (As-is)
CommentTarget.Kindhas the 29 kinds from feat: support additional PostgreSQL COMMENT targets #2639 and Extend PostgreSQL COMMENT ON targets #2816.CommentTargetKind()reads the kind words, andCommentTarget()uses the kind to choose the reference shape.Kindvalue and no grammar alternative.PostgreSqlOperatorReference()reads[schema.]opfor exclusion constraints (WITH OPERATOR(...)) andALTER EXTENSION ... OPERATOR. It accepts 23 single tokens. JSON operators such as->>or#>,^, and operators that the lexer splits into several tokens, such as<<=or-|-, fail.Target design (To-be)
CommentTarget.Kindvalues, appended at the end of the enum, with typed fields:OPERATOR:getOperator()is theExclusionOperatorreturned by the shared operator reference (getSchemaName(), operator symbol ingetName());getLeftOperandType()andgetRightOperandType()areColDataTypes, and null stands forNONE.OPERATOR_CLASSandOPERATOR_FAMILY:getName()andgetAccessMethod().Kind.isOwnedByAccessMethod()identifies them, asisOwnedByRelation()does for constraints.LARGE_OBJECT:getLargeObjectOid()(Long). The grammar accepts an unsigned 32-bit integer.TRANSFORM:getTransformType()andgetLanguage().TEXT_SEARCH_CONFIGURATION,TEXT_SEARCH_DICTIONARY,TEXT_SEARCH_PARSER,TEXT_SEARCH_TEMPLATEandCONVERSION: a possibly schema-qualifiedgetName(). Each text search object type has its own kind, as inExtensionObject.Kind.appendTo()renders every kind. Rendering of the existing kinds does not change.CommentTargetKind()reads the new kind words withisKeywordAhead()/ContextualKeyword()and the existingTEXT,SEARCHandPARSERtokens. There are no new tokens, and the words remain identifiers.OPERATOR class.+is still an operator in schemaclass.CommentTarget()has one alternative per new shape. The operand types reuseExtensionOperatorType(). At least one operand type is required, as in PostgreSQL'soper_argtypes.PostgreSqlOperatorReference()now reads the operator throughPostgreSqlOperatorName():<<=,-|-,|>>,@-@or~>=~are one operator;< =and+ -are rejected.ALTER EXTENSIONshare this production and accept the same operators.##withoutDialect.POSTGRESQL, because the lexer reads it as an identifier, and catalog-qualified operators (db.schema.op).Feature.commentOn...capability per new kind (10), all enabled in the PostgreSQL feature set.ALTER EXTENSIONno longer accept an operator with inner whitespace, such asOPERATOR(pg_catalog.< >). PostgreSQL reads it as two operators and rejects it.Validation
CommentTargetTestgoes from 240 to 417,CommentValidatorTestfrom 32 to 42, and the exclusion operator and type DDL tests gain 2 each. They cover:Dialect.POSTGRESQLand without a dialect;NONEon either side;(NONE, NONE),(integer),< =,+ -,=>,OPERATOR(pg_catalog.+),OPERATOR CLASS opswithoutUSING,LARGE OBJECT -1,LARGE OBJECT 4294967296andTRANSFORM int LANGUAGE sql;ALTER EXTENSION.spotlessApply check: 10,741 tests, 10,716 passed, 25 skipped, zero failures/errors. The grammar conflict check, Checkstyle, PMD and SpotBugs pass.master(bdf8ac31), the only changes are the Extend PostgreSQL COMMENT ON targets #2816 fixes; there are no regressions.COMMENT ONstatements checked on PostgreSQL 18.3, the 11 operator, operator class/family, large object, text search, conversion and transform statements now parse withDialect.POSTGRESQLand without a dialect. No other result changes. The remaining failures,U&'...'strings (Parse PostgreSQL Unicode escape string constants #2820) andCREATE EVENT TRIGGER(Parse PostgreSQL event triggers, REINDEX, SECURITY LABEL and schema elements #2818), are outside this change.COMMENT ONsynopsis parses and round-trips with and without a dialect.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).pg_description) is byte-identical on both servers.U&'...'strings.Integration validation
Applied this PR together with the other comment PRs (#2820, #2821, #2824, #2823), the DDL/DCL PRs #2806–#2819 and #2778 on
master(bdf8ac31), with the stacked PRs on top of their bases (#2814 → #2821, #2816 → #2822, #2806 → #2824 and #2811 → #2812 → #2823).master. Between the branches, conflicts are limited to adjacent additions (README/index rows, usage sections, imports, test methods, visitor and feature lists, an enum line and an alias guard).spotlessApply check: 11,877 tests, 11,852 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes.master: 206) and 363 of 364 PostgreSQL statements (master: 328), the same as Share MySQL account names across CREATE USER and DEFINER #2806–Render single spaces in ALTER visibility, FORCE and row level security actions #2819 together. There are no regressions.master: 67) and for 118 of 119 PostgreSQL statements (master: 76). The exception is aCREATE AGGREGATEsetup statement. Every table, column, index, partition, routine, event, user andCOMMENT ONcomment literal is aStringValue, exceptCOMMENT = _utf8mb4'x', which MySQL rejects.