PostgreSQL: COMMENT ON FUNCTION/PROCEDURE/AGGREGATE accepts argmode/argname/VARIADIC#28
Merged
fmguerreiro merged 1 commit intomainfrom Apr 25, 2026
Merged
Conversation
…rgname/VARIADIC Postgres permits argmode (IN/OUT/INOUT/VARIADIC) and argname tokens ahead of each argument type in COMMENT ON FUNCTION / PROCEDURE / AGGREGATE; they are ignored for identity resolution but appear in real-world dumps and consumer schema files. The previous parser used bare parse_data_type for the argument list, which hard-failed on those shapes. Switch the function-like arms of parse_comment to parse_function_arg and project to data_type, since Statement::Comment.arguments stores a plain Vec<DataType> and the modes/names are intentionally discarded for identity matching. Add tests covering argname, IN/OUT/INOUT, VARIADIC, and AGGREGATE.
This was referenced Apr 25, 2026
fmguerreiro
added a commit
that referenced
this pull request
Apr 26, 2026
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.
Bug
Parser::parse_commentparses the argument list forCOMMENT ON FUNCTION/PROCEDURE/AGGREGATEusing bareparse_data_type. PostgreSQL permits an argmode (IN/OUT/INOUT/VARIADIC) and an argname before the type — they are ignored for identity resolution, but they appear in real-worldpg_dumpoutput and in consumer-authored schema files. With the bareparse_data_typereader, all of these hard-fail today:Fix
Swap
parse_data_typeforparse_function_argin the FUNCTION / PROCEDURE / AGGREGATE arms ofparse_comment.parse_function_argalready consumes[mode] [name] type [DEFAULT expr].Statement::Comment.argumentsisOption<Vec<DataType>>, so we project with.into_iter().map(|a| a.data_type).collect()— the mode/name are intentionally discarded since they are not part of the function identity forCOMMENT ON. Round-trip canonicalises to the bare-type form, matching the existing serializer.No other call sites of
parse_data_typeare touched.Tests
Added to
tests/sqlparser_postgres.rs:parse_comment_on_function_with_argname—add(a INTEGER, b INTEGER)round-trips to bare typesparse_comment_on_function_with_argmode—IN/OUT/INOUTmodesparse_comment_on_function_with_variadic—VARIADIC arr TEXT[]parse_comment_on_aggregate_with_argname_and_variadic— same shapes forCOMMENT ON AGGREGATEDownstream
Unblocks pgmold's
COMMENT ONAST migration, which currently rejects valid Postgres dumps containing these shapes.Verification
Locally green:
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningscargo test --all-featurescargo check --no-default-features --target thumbv6m-none-eabi(cd sqlparser_bench && cargo clippy --all-targets --all-features -- -D warnings)