Skip to content

Add SETOF support for PostgreSQL function return types#2217

Open
fmguerreiro wants to merge 1 commit intoapache:mainfrom
fmguerreiro:setof-support
Open

Add SETOF support for PostgreSQL function return types#2217
fmguerreiro wants to merge 1 commit intoapache:mainfrom
fmguerreiro:setof-support

Conversation

@fmguerreiro
Copy link
Contributor

@fmguerreiro fmguerreiro commented Feb 13, 2026

PostgreSQL functions can return sets via RETURNS SETOF <type>. This is currently not supported by the parser, which fails when encountering SETOF after RETURNS.

Changes

  • Add SETOF keyword
  • Add DataType::SetOf(Box<DataType>) variant
  • Handle SETOF in parse_data_type_helper() so any DataType::SetOf round-trips through Display → parse
  • Tests for SETOF with TEXT, INTEGER, RECORD, and schema-qualified custom types

Example

CREATE FUNCTION get_users() RETURNS SETOF TEXT LANGUAGE sql AS 'SELECT name FROM users';
CREATE FUNCTION get_all() RETURNS SETOF my_schema."MyType" LANGUAGE sql AS 'SELECT * FROM t';

Reference

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.

1 participant