Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a58176

Browse files
committed
Restrict Datum sort optimization to byval types only
91e9e89 modified nodeSort.c so that it used datum sorts when thetargetlist of the outer node contained only a single column. That commitfailed to recognise that the Datum returned by tuplesort_getdatum() mustbe pfree'd when the type is a byref type. Ronan Dunklau did originallypropose the patch with that restriction, but that, probably through my ownfault, got lost during further development work.Due to the timing of this report (PG15 RC1 is almost out the door), let'sjust restrict the datum sort optimization to apply for byval types only.We might want to look harder into making this work for byref types inPG16.Reported-by: Önder KalacıDiagnosis-by: Tom LaneDiscussion:https://postgr.es/m/CACawEhVxe0ufR26UcqtU7GYGRuubq3p6ZWPGXL4cxy_uexpAAQ@mail.gmail.comBackpatch-through: 15, where91e9e89 was introduced.
1 parent2a66b9b commit3a58176

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎src/backend/executor/nodeSort.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ SortState *
220220
ExecInitSort(Sort*node,EState*estate,inteflags)
221221
{
222222
SortState*sortstate;
223+
TupleDescouterTupDesc;
223224

224225
SO1_printf("ExecInitSort: %s\n",
225226
"initializing sort node");
@@ -274,11 +275,13 @@ ExecInitSort(Sort *node, EState *estate, int eflags)
274275
ExecInitResultTupleSlotTL(&sortstate->ss.ps,&TTSOpsMinimalTuple);
275276
sortstate->ss.ps.ps_ProjInfo=NULL;
276277

278+
outerTupDesc=ExecGetResultType(outerPlanState(sortstate));
279+
277280
/*
278-
* We perform a Datum sort when we're sorting just a single column,
281+
* We perform a Datum sort when we're sorting just a singlebyvalcolumn,
279282
* otherwise we perform a tuple sort.
280283
*/
281-
if (ExecGetResultType(outerPlanState(sortstate))->natts==1)
284+
if (outerTupDesc->natts==1&&TupleDescAttr(outerTupDesc,0)->attbyval)
282285
sortstate->datumSort= true;
283286
else
284287
sortstate->datumSort= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp