Skip to content

PostgreSQL RETURNS SETOF Support in CREATE FUNCTION#2258

Closed
LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
LucaCappelletti94:postgres-regression-13
Closed

PostgreSQL RETURNS SETOF Support in CREATE FUNCTION#2258
LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
LucaCappelletti94:postgres-regression-13

Conversation

@LucaCappelletti94
Copy link
Contributor

PostgreSQL allows function declarations like RETURNS SETOF UUID, but previously failed to parse that form and produced: Expected: end of statement, found: UUID

Now statements like:

  • CREATE FUNCTION any_ids() RETURNS SETOF UUID ...
  • CREATE FUNCTION ids_for_user(p_user_id UUID) RETURNS SETOF UUID ...
  • CREATE FUNCTION ids_from_array() RETURNS SETOF UUID ...

parse successfully under PostgreSqlDialect.

Add a dedicated SETOF data type wrapper in the AST, teach the PostgreSQL CREATE FUNCTION parser to wrap return types after RETURNS SETOF, and register SETOF in the keyword table so parsing no longer relies on raw NoKeyword text matching.
Cover SETOF UUID function declarations for no-arg, parameterized, and array/unnest bodies, and assert return_type/language/behavior in the parsed AST.
@LucaCappelletti94 LucaCappelletti94 marked this pull request as ready for review March 1, 2026 16:55
@iffyio
Copy link
Contributor

iffyio commented Mar 2, 2026

a note, there's an ongoing PR related to this feature #2217

@LucaCappelletti94
Copy link
Contributor Author

Closing as there already PR #2217 covering the same set of functionalities

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.

2 participants