pgsql: Restrict Datum sort optimization to byval types only

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Restrict Datum sort optimization to byval types only
Date: 2022-09-28 22:43:24
Message-ID: E1odfm0-0003GK-8G@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Restrict Datum sort optimization to byval types only

91e9e89dc modified nodeSort.c so that it used datum sorts when the
targetlist of the outer node contained only a single column. That commit
failed to recognise that the Datum returned by tuplesort_getdatum() must
be pfree'd when the type is a byref type. Ronan Dunklau did originally
propose the patch with that restriction, but that, probably through my own
fault, got lost during further development work.

Due to the timing of this report (PG15 RC1 is almost out the door), let's
just restrict the datum sort optimization to apply for byval types only.
We might want to look harder into making this work for byref types in
PG16.

Reported-by: Önder Kalacı
Diagnosis-by: Tom Lane
Discussion: https://postgr.es/m/CACawEhVxe0ufR26UcqtU7GYGRuubq3p6ZWPGXL4cxy_uexpAAQ@mail.gmail.com
Backpatch-through: 15, where 91e9e89dc was introduced.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3a5817695a8360011864c1834f8a90ffdfc7f840

Modified Files
--------------
src/backend/executor/nodeSort.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2022-09-28 22:44:06 pgsql: Restrict Datum sort optimization to byval types only
Previous Message Bruce Momjian 2022-09-28 17:15:07 pgsql: doc: clarify internal behavior of RECURSIVE CTE queries