if (slot->tts_tupleDescriptor->constr)
attrmiss = slot->tts_tupleDescriptor->constr->missing;
-
if (!attrmiss)
{
/* no missing values array at all, so just fill everything in as NULL */
else
{
/* if there is a missing values array we must process them one by one */
- for (missattnum = lastAttNum - 1;
- missattnum >= startAttNum;
- missattnum--)
+ for (missattnum = startAttNum;
+ missattnum < lastAttNum;
+ missattnum++)
{
slot->tts_values[missattnum] = attrmiss[missattnum].ammissing;
slot->tts_isnull[missattnum] =
slot_deform_tuple(slot, attnum);
+ attnum = slot->tts_nvalid;
+
/*
* If tuple doesn't have all the atts indicated by tupleDesc, read the
* rest as NULLS or missing values.
slot_deform_tuple(slot, attno);
+ attno = slot->tts_nvalid;
+
/*
- * If tuple doesn't have all the atts indicated by tupleDesc, read the
+ * If tuple doesn't have all the atts indicated by attnum, read the
* rest as NULLs or missing values
*/
if (attno < attnum)
return heap_copy_minimal_tuple(slot->tts_mintuple);
if (slot->tts_tuple)
{
- if (TTS_HAS_PHYSICAL_TUPLE(slot) &&
- HeapTupleHeaderGetNatts(slot->tts_tuple->t_data)
+ if (HeapTupleHeaderGetNatts(slot->tts_tuple->t_data)
< slot->tts_tupleDescriptor->natts)
return minimal_expand_tuple(slot->tts_tuple,
slot->tts_tupleDescriptor);
if (HeapTupleHeaderGetNatts(slot->tts_tuple->t_data) <
slot->tts_tupleDescriptor->natts)
{
+ HeapTuple tuple;
MemoryContext oldContext = MemoryContextSwitchTo(slot->tts_mcxt);
- slot->tts_tuple = heap_expand_tuple(slot->tts_tuple,
- slot->tts_tupleDescriptor);
- slot->tts_shouldFree = true;
+ tuple = heap_expand_tuple(slot->tts_tuple,
+ slot->tts_tupleDescriptor);
MemoryContextSwitchTo(oldContext);
- return slot->tts_tuple;
- }
- else
- {
- return slot->tts_tuple;
+ slot = ExecStoreTuple(tuple, slot, InvalidBuffer, true);
}
+ return slot->tts_tuple;
}
/*