pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix use of incorrect TupleTableSlot in DISTINCT aggregates 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix use of incorrect TupleTableSlot in DISTINCT aggregates @ 2024-01-04 07:39 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: David Rowley @ 2024-01-04 07:39 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ae69c4fcf1337af399a788ab8d96af540bd1cd8e Modified Files -------------- src/backend/executor/execExprInterp.c | 20 +++++++++++++++++--- src/test/regress/expected/aggregates.out | 13 +++++++++++++ src/test/regress/sql/aggregates.sql | 9 +++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix use of incorrect TupleTableSlot in DISTINCT aggregates @ 2024-01-04 07:40 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: David Rowley @ 2024-01-04 07:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6298673f4b91b8b5815855785cc30f0ac390988e Modified Files -------------- src/backend/executor/execExprInterp.c | 20 +++++++++++++++++--- src/test/regress/expected/aggregates.out | 13 +++++++++++++ src/test/regress/sql/aggregates.sql | 9 +++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-01-04 07:40 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-01-04 07:39 pgsql: Fix use of incorrect TupleTableSlot in DISTINCT aggregates David Rowley <drowley@postgresql.org> 2024-01-04 07:40 pgsql: Fix use of incorrect TupleTableSlot in DISTINCT aggregates David Rowley <drowley@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox