diff options
| author | Tomas Vondra | 2020-12-21 17:58:32 +0000 |
|---|---|---|
| committer | Tomas Vondra | 2020-12-21 18:36:22 +0000 |
| commit | fac1b470a9f7e846534620b78ea4cf122ed432b2 (patch) | |
| tree | 1f744e28fef69e808d099b04d4abc6d2779f7285 /src/test | |
| parent | ff5d5611c01f60525c30b2c3ebc16d05edb7956d (diff) | |
Disallow SRFs when considering sorts below Gather Merge
While we do allow SRFs in ORDER BY, scan/join processing should not
consider such cases - such sorts should only happen via final Sort atop
a ProjectSet. So make sure we don't try adding such sorts below Gather
Merge, just like we do for expressions that are volatile and/or not
parallel safe.
Backpatch to PostgreSQL 13, where this code was introduced as part of
the Incremental Sort patch.
Author: James Coleman
Reviewed-by: Tomas Vondra
Backpatch-through: 13
Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs=hC0mSksZC=H5M8LSchj5e5OxpTAg@mail.gmail.com
Discussion: https://postgr.es/m/295524.1606246314%40sss.pgh.pa.us
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/incremental_sort.out | 12 | ||||
| -rw-r--r-- | src/test/regress/sql/incremental_sort.sql | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/test/regress/expected/incremental_sort.out b/src/test/regress/expected/incremental_sort.out index d316a7c4b90..a8cbfd9f5f9 100644 --- a/src/test/regress/expected/incremental_sort.out +++ b/src/test/regress/expected/incremental_sort.out @@ -1620,3 +1620,15 @@ 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/sql/incremental_sort.sql b/src/test/regress/sql/incremental_sort.sql index ff3af0fd165..62a037b0cfb 100644 --- a/src/test/regress/sql/incremental_sort.sql +++ b/src/test/regress/sql/incremental_sort.sql @@ -267,3 +267,5 @@ 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[]); |
