diff options
author | Robert Haas <rhaas@postgresql.org> | 2024-05-21 12:54:09 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2024-05-21 12:54:09 -0400 |
commit | c37267162e889fe783786b9e28d1b65b82365a00 (patch) | |
tree | 0cbb5e2dbf8351f919cdd355a9f0a198c0db5b75 /src/test | |
parent | 12933dc6048902ba891f9572cab96981f50ef669 (diff) | |
download | postgresql-REL_17_BETA1.tar.gz postgresql-REL_17_BETA1.zip |
Fix generate_union_paths for non-sortable types.REL_17_BETA1
The previous logic would fail to set groupList when
grouping_is_sortable() returned false, which could cause queries
to return wrong answers when some columns were not sortable.
David Rowley, reviewed by Heikki Linnakangas and Álvaro Herrera.
Reported by Hubert "depesz" Lubaczewski.
Discussion: http://postgr.es/m/Zktzf926vslR35Fv@depesz.com
Discussion: http://postgr.es/m/CAApHDvra=c8_zZT0J-TftByWN2Y+OJfnjNJFg4Dfdi2s+QzmqA@mail.gmail.com
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/union.out | 13 | ||||
-rw-r--r-- | src/test/regress/sql/union.sql | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/test/regress/expected/union.out b/src/test/regress/expected/union.out index 26b718e9033..0fd0e1c38b3 100644 --- a/src/test/regress/expected/union.out +++ b/src/test/regress/expected/union.out @@ -815,6 +815,19 @@ select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (value (1,3) (1 row) +-- non-sortable type +-- Ensure we get a HashAggregate plan. Keep enable_hashagg=off to ensure +-- there's no chance of a sort. +explain (costs off) select '123'::xid union select '123'::xid; + QUERY PLAN +--------------------------- + HashAggregate + Group Key: ('123'::xid) + -> Append + -> Result + -> Result +(5 rows) + reset enable_hashagg; -- -- Mixed types diff --git a/src/test/regress/sql/union.sql b/src/test/regress/sql/union.sql index 8afc580c632..f8826514e42 100644 --- a/src/test/regress/sql/union.sql +++ b/src/test/regress/sql/union.sql @@ -244,6 +244,12 @@ explain (costs off) select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x); select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x); +-- non-sortable type + +-- Ensure we get a HashAggregate plan. Keep enable_hashagg=off to ensure +-- there's no chance of a sort. +explain (costs off) select '123'::xid union select '123'::xid; + reset enable_hashagg; -- |