Skip to content

Commit ed69864

Browse files
committed
Small cleanups in fast default code.
Problems identified by Andres Freund and Haribabu Kommi
1 parent 94173d3 commit ed69864

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
127127
if (slot->tts_tupleDescriptor->constr)
128128
attrmiss = slot->tts_tupleDescriptor->constr->missing;
129129

130-
131130
if (!attrmiss)
132131
{
133132
/* no missing values array at all, so just fill everything in as NULL */
@@ -139,9 +138,9 @@ slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
139138
else
140139
{
141140
/* if there is a missing values array we must process them one by one */
142-
for (missattnum = lastAttNum - 1;
143-
missattnum >= startAttNum;
144-
missattnum--)
141+
for (missattnum = startAttNum;
142+
missattnum < lastAttNum;
143+
missattnum++)
145144
{
146145
slot->tts_values[missattnum] = attrmiss[missattnum].ammissing;
147146
slot->tts_isnull[missattnum] =
@@ -1636,6 +1635,8 @@ slot_getallattrs(TupleTableSlot *slot)
16361635

16371636
slot_deform_tuple(slot, attnum);
16381637

1638+
attnum = slot->tts_nvalid;
1639+
16391640
/*
16401641
* If tuple doesn't have all the atts indicated by tupleDesc, read the
16411642
* rest as NULLS or missing values.
@@ -1681,8 +1682,10 @@ slot_getsomeattrs(TupleTableSlot *slot, int attnum)
16811682

16821683
slot_deform_tuple(slot, attno);
16831684

1685+
attno = slot->tts_nvalid;
1686+
16841687
/*
1685-
* If tuple doesn't have all the atts indicated by tupleDesc, read the
1688+
* If tuple doesn't have all the atts indicated by attnum, read the
16861689
* rest as NULLs or missing values
16871690
*/
16881691
if (attno < attnum)

src/backend/executor/execTuples.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,7 @@ ExecCopySlotMinimalTuple(TupleTableSlot *slot)
626626
return heap_copy_minimal_tuple(slot->tts_mintuple);
627627
if (slot->tts_tuple)
628628
{
629-
if (TTS_HAS_PHYSICAL_TUPLE(slot) &&
630-
HeapTupleHeaderGetNatts(slot->tts_tuple->t_data)
629+
if (HeapTupleHeaderGetNatts(slot->tts_tuple->t_data)
631630
< slot->tts_tupleDescriptor->natts)
632631
return minimal_expand_tuple(slot->tts_tuple,
633632
slot->tts_tupleDescriptor);
@@ -675,18 +674,15 @@ ExecFetchSlotTuple(TupleTableSlot *slot)
675674
if (HeapTupleHeaderGetNatts(slot->tts_tuple->t_data) <
676675
slot->tts_tupleDescriptor->natts)
677676
{
677+
HeapTuple tuple;
678678
MemoryContext oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
679679

680-
slot->tts_tuple = heap_expand_tuple(slot->tts_tuple,
681-
slot->tts_tupleDescriptor);
682-
slot->tts_shouldFree = true;
680+
tuple = heap_expand_tuple(slot->tts_tuple,
681+
slot->tts_tupleDescriptor);
683682
MemoryContextSwitchTo(oldContext);
684-
return slot->tts_tuple;
685-
}
686-
else
687-
{
688-
return slot->tts_tuple;
683+
slot = ExecStoreTuple(tuple, slot, InvalidBuffer, true);
689684
}
685+
return slot->tts_tuple;
690686
}
691687

692688
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy