Skip to content

Commit cc11647

Browse files
committed
Add proper regression test for the recent SRFs-in-pathkeys problem.
Remove the test case added by commit fac1b47, which never actually worked to expose the problem it claimed to test. Replace it with a case that does expose the problem, and also covers the SRF-not- at-the-top deficiency repaired in 1aa8dad. Richard Guo, with some editorialization by me Discussion: https://postgr.es/m/17564-c7472c2f90ef2da3@postgresql.org
1 parent f8f2020 commit cc11647

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

src/test/regress/expected/incremental_sort.out

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,15 +1672,3 @@ order by 1, 2;
16721672
-> Function Scan on generate_series
16731673
(7 rows)
16741674

1675-
-- Disallow pushing down sort when pathkey is an SRF.
1676-
explain (costs off) select unique1 from tenk1 order by unnest('{1,2}'::int[]);
1677-
QUERY PLAN
1678-
-------------------------------------------------------------------------
1679-
Sort
1680-
Sort Key: (unnest('{1,2}'::integer[]))
1681-
-> Gather
1682-
Workers Planned: 2
1683-
-> ProjectSet
1684-
-> Parallel Index Only Scan using tenk1_unique1 on tenk1
1685-
(6 rows)
1686-

src/test/regress/expected/select_parallel.out

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,30 @@ SELECT generate_series(1, two), array(select generate_series(1, two))
11491149
-> Result
11501150
(16 rows)
11511151

1152+
-- must disallow pushing sort below gather when pathkey contains an SRF
1153+
EXPLAIN (VERBOSE, COSTS OFF)
1154+
SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey
1155+
FROM tenk1 t1 JOIN tenk1 t2 ON TRUE
1156+
ORDER BY pathkey;
1157+
QUERY PLAN
1158+
-----------------------------------------------------------------------------------------------------
1159+
Sort
1160+
Output: (((unnest('{}'::integer[])) + 1))
1161+
Sort Key: (((unnest('{}'::integer[])) + 1))
1162+
-> Result
1163+
Output: ((unnest('{}'::integer[])) + 1)
1164+
-> ProjectSet
1165+
Output: unnest('{}'::integer[])
1166+
-> Nested Loop
1167+
-> Gather
1168+
Workers Planned: 4
1169+
-> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t1
1170+
-> Materialize
1171+
-> Gather
1172+
Workers Planned: 4
1173+
-> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t2
1174+
(15 rows)
1175+
11521176
-- test passing expanded-value representations to workers
11531177
CREATE FUNCTION make_some_array(int,int) returns int[] as
11541178
$$declare x int[];

src/test/regress/sql/incremental_sort.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,3 @@ from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub;
281281
explain (costs off) select sub.unique1, stringu1 || random()::text
282282
from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub
283283
order by 1, 2;
284-
-- Disallow pushing down sort when pathkey is an SRF.
285-
explain (costs off) select unique1 from tenk1 order by unnest('{1,2}'::int[]);

src/test/regress/sql/select_parallel.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ EXPLAIN (VERBOSE, COSTS OFF)
433433
SELECT generate_series(1, two), array(select generate_series(1, two))
434434
FROM tenk1 ORDER BY tenthous;
435435

436+
-- must disallow pushing sort below gather when pathkey contains an SRF
437+
EXPLAIN (VERBOSE, COSTS OFF)
438+
SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey
439+
FROM tenk1 t1 JOIN tenk1 t2 ON TRUE
440+
ORDER BY pathkey;
441+
436442
-- test passing expanded-value representations to workers
437443
CREATE FUNCTION make_some_array(int,int) returns int[] as
438444
$$declare x int[];

0 commit comments

Comments
 (0)