postgresql/src
David Rowley ae69c4fcf1 Fix use of incorrect TupleTableSlot in DISTINCT aggregates
1349d2790 added code to allow DISTINCT and ORDER BY aggregates to work
more efficiently by using presorted input.  That commit added some code
that made use of the AggState's tmpcontext and adjusted the
ecxt_outertuple and ecxt_innertuple slots before checking if the current
row is distinct from the previously seen row.  That code forgot to set the
TupleTableSlots back to what they were originally, which could result in
errors such as:

ERROR:  attribute 1 of type record has wrong type

This only affects aggregate functions which have multiple arguments when
DISTINCT is used.  For example: string_agg(DISTINCT col, ', ')

Thanks to Tom Lane for identifying the breaking commit.

Bug: #18264
Reported-by: Vojtěch Beneš
Discussion: https://postgr.es/m/18264-e363593d7e9feb7d@postgresql.org
Backpatch-through: 16, where 1349d2790 was added
2024-01-04 20:38:25 +13:00
..
backend Fix use of incorrect TupleTableSlot in DISTINCT aggregates 2024-01-04 20:38:25 +13:00
bin Track conflict_reason in pg_replication_slots. 2024-01-04 08:26:25 +05:30
common Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe_utils Update copyright for 2024 2024-01-03 20:49:05 -05:00
include Track conflict_reason in pg_replication_slots. 2024-01-04 08:26:25 +05:30
interfaces Update copyright for 2024 2024-01-03 20:49:05 -05:00
makefiles Update copyright for 2024 2024-01-03 20:49:05 -05:00
pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
port Update copyright for 2024 2024-01-03 20:49:05 -05:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Fix use of incorrect TupleTableSlot in DISTINCT aggregates 2024-01-04 20:38:25 +13:00
timezone Update copyright for 2024 2024-01-03 20:49:05 -05:00
tools Update copyright for 2024 2024-01-03 20:49:05 -05:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Initialize data directories with --lc-messages=C for tests. 2023-12-21 15:10:13 -08:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00