Restrict Datum sort optimization to byval types only
authorDavid Rowley <[email protected]>
Wed, 28 Sep 2022 22:43:00 +0000 (11:43 +1300)
committerDavid Rowley <[email protected]>
Wed, 28 Sep 2022 22:43:00 +0000 (11:43 +1300)
commit3a5817695a8360011864c1834f8a90ffdfc7f840
tree0aa8cbca23376359819144a1e988f3777737f291
parent2a66b9bfb74e522d64c066dabe4fddde0fe7425c
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.
src/backend/executor/nodeSort.c