Skip to content

Commit 06a1863

Browse files
committed
plpgsql: add support for set-returning functions
This commit adds support for set-returning PL/pgSQL functions. Unlike SQL SRFs, PL/pgSQL SRFs add to the result set at arbitrary points during execution using `RETURN NEXT` (scalar) and `RETURN QUERY` (relational) statements. We support this feature by allocating a `RoutineResultBufferID` that allows the sub-routines that implement the PL/pgSQL routine body to access the SRF's result buffer directly during execution. Fixes #105240 Release note (sql change): Set-returning PL/pgSQL functions are now supported. A PL/pgSQL SRF can be created by declaring the return type as `SETOF <type>` or `TABLE`.
1 parent 3aa0b3a commit 06a1863

File tree

27 files changed

+1060
-60
lines changed

27 files changed

+1060
-60
lines changed

pkg/ccl/logictestccl/testdata/logic_test/plpgsql_srf

Lines changed: 591 additions & 0 deletions
Large diffs are not rendered by default.

pkg/ccl/logictestccl/testdata/logic_test/plpgsql_unsupported

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ CREATE OR REPLACE PROCEDURE foo() AS $$
1010
END
1111
$$ LANGUAGE PLpgSQL;
1212

13-
statement error pq: unimplemented: set-returning PL/pgSQL functions
14-
CREATE OR REPLACE FUNCTION bar() RETURNS SETOF INT LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEXT 100; END $$;
15-
16-
statement error pq: unimplemented: set-returning PL/pgSQL functions
17-
CREATE OR REPLACE FUNCTION bar() RETURNS TABLE (x INT) LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEXT 100; END $$;
18-
1913
subtest error_detail
2014

2115
# Regression test for #123672 - annotate "unsupported" errors with the

pkg/ccl/logictestccl/tests/3node-tenant/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist-disk/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 32,
15+
shard_count = 33,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist-disk/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist-vec-off/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 32,
15+
shard_count = 33,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist-vec-off/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/fakedist/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ go_test(
1212
"//build/toolchains:is_heavy": {"test.Pool": "heavy"},
1313
"//conditions:default": {"test.Pool": "large"},
1414
}),
15-
shard_count = 33,
15+
shard_count = 34,
1616
tags = ["cpu:2"],
1717
deps = [
1818
"//pkg/base",

pkg/ccl/logictestccl/tests/fakedist/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ccl/logictestccl/tests/local-legacy-schema-changer/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 31,
12+
shard_count = 32,
1313
tags = ["cpu:1"],
1414
deps = [
1515
"//pkg/base",

0 commit comments

Comments
 (0)