| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix tuplesort memory accounting for datum sorts on byref types |
| Date: | 2026-10-05 12:21:46 |
| Message-ID: | E1xDhhS-00000000PiJ-19rj@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix tuplesort memory accounting for datum sorts on byref types
6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for
non-bounded sorts in order to save memory and increase performance.
That commit didn't get the memory accounting correct for datum sorts and
mistakenly passed 0 bytes to tuplesort_puttuple_common(). That was
correct for byval types, but failed to take into account palloc'd memory
for byref types.
Fix by using datumGetSize() when using the bump allocator and by using
GetMemoryChunkSpace() when not.
Backpatch to v17, where 6ed83d5fa was added.
Author: Mario Karuza <mkaruza(dot)pg(at)icloud(dot)com>
Reviewed-by: David Rowley <dgrowleyml(at)gmail(dot)com>
Reviewed-by: Joao Detomini <joao(dot)detomini(at)enterprisedb(dot)com>
Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com
Backpatch-through: 17
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/a2148471b0db8fb44c43d5a2933d99c82f3aa0c8
Modified Files
--------------
src/backend/utils/sort/tuplesortvariants.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-10-05 12:22:16 | pgsql: Fix tuplesort memory accounting for datum sorts on byref types |
| Previous Message | David Rowley | 2026-10-05 12:21:17 | pgsql: Fix tuplesort memory accounting for datum sorts on byref types |