-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Labels
A-sql-routineUDFs and Stored ProceduresUDFs and Stored ProceduresA-sql-udfC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Description
When a set-returning UDF is specified directly in the SELECT list rather than as a data source, we apply a transformation to the last body statement so that multiple columns are wrapped into a single tuple column. This step loses the ordering if one was specified by the user, and so results can be returned in a non-deterministic order. Here's a logic test that demonstrates this behavior when run under the fakedist-vec-off configuration:
statement ok
CREATE TABLE ab (
a INT PRIMARY KEY,
b INT
)
statement ok
INSERT INTO ab SELECT i, i*10 FROM generate_series(1, 4) g(i)
statement ok
CREATE FUNCTION all_ab() RETURNS SETOF ab LANGUAGE SQL AS $$
SELECT a, b FROM ab ORDER BY a
$$
query II nosort
SELECT * FROM all_ab()
----
1 10
2 20
3 30
4 40
query T nosort
SELECT all_ab()
----
(1,10)
(2,20)
(3,30)
(4,40)
Jira issue: CRDB-49208
Metadata
Metadata
Assignees
Labels
A-sql-routineUDFs and Stored ProceduresUDFs and Stored ProceduresA-sql-udfC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Type
Projects
Status
Backlog