diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-08-04 11:11:22 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-08-04 11:11:22 -0400 |
commit | 1a9ac84923b8530ca18d497b3ccc40965c01b66b (patch) | |
tree | f9f2601790939967b863743f325d53d1038788f1 /src | |
parent | 120e159b7d93fa36b94ded8a51fe4e619e1261ca (diff) | |
download | postgresql-1a9ac84923b8530ca18d497b3ccc40965c01b66b.tar.gz postgresql-1a9ac84923b8530ca18d497b3ccc40965c01b66b.zip |
Add proper regression test for the recent SRFs-in-pathkeys problem.
Remove the test case added by commit fac1b470a, 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 1aa8dad41.
Richard Guo, with some editorialization by me
Discussion: https://postgr.es/m/17564-c7472c2f90ef2da3@postgresql.org
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/expected/incremental_sort.out | 12 | ||||
-rw-r--r-- | src/test/regress/expected/select_parallel.out | 24 | ||||
-rw-r--r-- | src/test/regress/sql/incremental_sort.sql | 2 | ||||
-rw-r--r-- | src/test/regress/sql/select_parallel.sql | 6 |
4 files changed, 30 insertions, 14 deletions
diff --git a/src/test/regress/expected/incremental_sort.out b/src/test/regress/expected/incremental_sort.out index 545e301e482..a0b27477faf 100644 --- a/src/test/regress/expected/incremental_sort.out +++ b/src/test/regress/expected/incremental_sort.out @@ -1674,15 +1674,3 @@ order by 1, 2; -> Function Scan on generate_series (7 rows) --- Disallow pushing down sort when pathkey is an SRF. -explain (costs off) select unique1 from tenk1 order by unnest('{1,2}'::int[]); - QUERY PLAN -------------------------------------------------------------------------- - Sort - Sort Key: (unnest('{1,2}'::integer[])) - -> Gather - Workers Planned: 2 - -> ProjectSet - -> Parallel Index Only Scan using tenk1_unique1 on tenk1 -(6 rows) - diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 4ea1aa7dfd4..91f74fe47a3 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -1149,6 +1149,30 @@ SELECT generate_series(1, two), array(select generate_series(1, two)) -> Result (16 rows) +-- must disallow pushing sort below gather when pathkey contains an SRF +EXPLAIN (VERBOSE, COSTS OFF) +SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey + FROM tenk1 t1 JOIN tenk1 t2 ON TRUE + ORDER BY pathkey; + QUERY PLAN +----------------------------------------------------------------------------------------------------- + Sort + Output: (((unnest('{}'::integer[])) + 1)) + Sort Key: (((unnest('{}'::integer[])) + 1)) + -> Result + Output: ((unnest('{}'::integer[])) + 1) + -> ProjectSet + Output: unnest('{}'::integer[]) + -> Nested Loop + -> Gather + Workers Planned: 4 + -> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t1 + -> Materialize + -> Gather + Workers Planned: 4 + -> Parallel Index Only Scan using tenk1_hundred on public.tenk1 t2 +(15 rows) + -- test passing expanded-value representations to workers CREATE FUNCTION make_some_array(int,int) returns int[] as $$declare x int[]; diff --git a/src/test/regress/sql/incremental_sort.sql b/src/test/regress/sql/incremental_sort.sql index d8768a6b54d..284a354dbb7 100644 --- a/src/test/regress/sql/incremental_sort.sql +++ b/src/test/regress/sql/incremental_sort.sql @@ -281,5 +281,3 @@ from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub; explain (costs off) select sub.unique1, stringu1 || random()::text from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub order by 1, 2; --- Disallow pushing down sort when pathkey is an SRF. -explain (costs off) select unique1 from tenk1 order by unnest('{1,2}'::int[]); diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql index f9247312484..62fb68c7a04 100644 --- a/src/test/regress/sql/select_parallel.sql +++ b/src/test/regress/sql/select_parallel.sql @@ -433,6 +433,12 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, two), array(select generate_series(1, two)) FROM tenk1 ORDER BY tenthous; +-- must disallow pushing sort below gather when pathkey contains an SRF +EXPLAIN (VERBOSE, COSTS OFF) +SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey + FROM tenk1 t1 JOIN tenk1 t2 ON TRUE + ORDER BY pathkey; + -- test passing expanded-value representations to workers CREATE FUNCTION make_some_array(int,int) returns int[] as $$declare x int[]; |