pgsql: Fix issue with code manually adjusting a TupleTableSlot

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix issue with code manually adjusting a TupleTableSlot
Date: 2026-10-29 20:50:41
Message-ID: E1xMX57-00000001IyU-2za2@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix issue with code manually adjusting a TupleTableSlot

c456e3911 changed how tuple deforming populates the slot's tts_isnull
array. This is now done 8 columns at a time instead of 1 column at a
time. That code also now deforms the tuple's entire NULL bitmap on each
incremental deform, where previously only the tts_isnull elements for
newly deformed attributes got set. This caused problems for grouping
sets queries.

In prepare_projection_slot() when grouped_cols was non-empty, the code
would manually put "true" into the grouped column's tts_isnull element to
represent the NULL for grouping sets which don't include that column.
This was incompatible with the post-c456e3911 complete fresh of previously
deformed tts_isnull elements, as if any further attributes needed to be
deformed after the NULLs were manually placed, the deforming code would
overwrite those NULLs.

Here we fix this by changing the slot_getsomeattrs() call to always
deform everything we need for this tuple. That means there will be no
additional tuple deforms for this tuple.

Bug: #19783
Reported-by: Alperen Keles <alpkeles99(at)gmail(dot)com>
Author: David Rowley <dgrowleyml(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://postgr.es/m/19783-070e4bf0c73c1076@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/04e0891fe0b8790b3c414bb5782b69d6491ff20b

Modified Files
--------------
src/backend/executor/nodeAgg.c | 32 +++++++++++++++++++++++++++---
src/test/regress/expected/groupingsets.out | 14 +++++++++++++
src/test/regress/sql/groupingsets.sql | 9 +++++++++
3 files changed, 52 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-29 21:46:30 pgsql: Fix poorly-formatted comment.
Previous Message David Rowley 2026-10-29 20:50:15 pgsql: Fix issue with code manually adjusting a TupleTableSlot