Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8d38cca

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 da4ed75 commit 8d38cca

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
@@ -1151,6 +1151,30 @@ SELECT generate_series(1, two), array(select generate_series(1, two))
11511151
-> Result
11521152
(16 rows)
11531153

1154+
-- must disallow pushing sort below gather when pathkey contains an SRF
1155+
EXPLAIN (VERBOSE, COSTS OFF)
1156+
SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey
1157+
FROM tenk1 t1 JOIN tenk1 t2 ON TRUE
1158+
ORDER BY pathkey;
1159+
QUERY PLAN
1160+
-----------------------------------------------------------------------------------------------------
1161+
Sort
1162+
Output: (((unnest('{}'::integer[])) + 1))
1163+
Sort Key: (((unnest('{}'::integer[])) + 1))
1164+
-> Result
1165+
Output: ((unnest('{}'::integer[])) + 1)
1166+
-> ProjectSet
1167+
Output: unnest('{}'::integer[])
1168+
-> Nested Loop
1169+
-> Gather
1170+
Workers Planned: 4
1171+
-> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t1
1172+
-> Materialize
1173+
-> Gather
1174+
Workers Planned: 4
1175+
-> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t2
1176+
(15 rows)
1177+
11541178
-- test passing expanded-value representations to workers
11551179
CREATE FUNCTION make_some_array(int,int) returns int[] as
11561180
$$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
@@ -435,6 +435,12 @@ EXPLAIN (VERBOSE, COSTS OFF)
435435
SELECT generate_series(1, two), array(select generate_series(1, two))
436436
FROM tenk1 ORDER BY tenthous;
437437

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

0 commit comments

Comments
 (0)