Skip to content

Commit 634a981

Browse files
committed
sql: disallow set-returning PL/pgSQL functions in mixed version state
This commit adds a version check during routine creation for set-returning PL/pgSQL function. Fixes #144914 Release note (bug fix): Fixed a bug in alpha and beta versions of 25.2 that allowed a set-returning PL/pgSQL function to be created before the version change was finalized.
1 parent 45057e1 commit 634a981

File tree

11 files changed

+52
-18
lines changed

11 files changed

+52
-18
lines changed

pkg/ccl/logictestccl/testdata/logic_test/plpgsql_srf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# LogicTest: !local-mixed-24.3 !local-mixed-25.1
2+
13
statement ok
24
CREATE TABLE xy (x INT, y INT);
35
INSERT INTO xy VALUES (1, 2), (3, 4), (5, 6);

pkg/ccl/logictestccl/tests/local-mixed-24.3/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 = 33,
12+
shard_count = 32,
1313
tags = ["cpu:1"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/local-mixed-24.3/generated_test.go

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

pkg/ccl/logictestccl/tests/local-mixed-25.1/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 = 33,
12+
shard_count = 32,
1313
tags = ["cpu:1"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/local-mixed-25.1/generated_test.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# LogicTest: cockroach-go-testserver-configs
2+
3+
statement error pgcode 0A000 pq: unimplemented: set-returning PL/pgSQL functions are not yet supported
4+
CREATE FUNCTION f() RETURNS SETOF INT LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEXT 1; END $$;
5+
6+
upgrade 0
7+
8+
statement error pgcode 0A000 pq: unimplemented: PL/pgSQL set-returning functions are only supported in v25.2 and later
9+
CREATE FUNCTION f() RETURNS SETOF INT LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEXT 1; END $$;
10+
11+
upgrade 1
12+
13+
upgrade 2
14+
15+
statement ok
16+
SET CLUSTER SETTING version = crdb_internal.node_executable_version();
17+
18+
query B retry
19+
SELECT crdb_internal.is_at_least_version('25.1-02')
20+
----
21+
true
22+
23+
statement ok
24+
CREATE FUNCTION f() RETURNS SETOF INT LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEXT 1; END $$;

pkg/sql/logictest/tests/cockroach-go-testserver-24.3/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ go_test(
1111
"//pkg/sql/logictest:testdata", # keep
1212
],
1313
exec_properties = {"test.Pool": "heavy"},
14-
shard_count = 9,
14+
shard_count = 10,
1515
tags = ["cpu:3"],
1616
deps = [
1717
"//pkg/base",

pkg/sql/logictest/tests/cockroach-go-testserver-24.3/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/sql/logictest/tests/cockroach-go-testserver-25.1/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ go_test(
1111
"//pkg/sql/logictest:testdata", # keep
1212
],
1313
exec_properties = {"test.Pool": "heavy"},
14-
shard_count = 9,
14+
shard_count = 10,
1515
tags = ["cpu:3"],
1616
deps = [
1717
"//pkg/base",

pkg/sql/logictest/tests/cockroach-go-testserver-25.1/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.

0 commit comments

Comments
 (0)