@@ -101,11 +101,10 @@ MakeTupleTableSlot(TupleDesc tupleDesc)
101101
102102slot = palloc0 (sz );
103103slot -> type = T_TupleTableSlot ;
104- slot -> tts_isempty = true ;
105- slot -> tts_shouldFree = false;
106- slot -> tts_shouldFreeMin = false ;
104+ slot -> tts_flags |= TTS_FLAG_EMPTY ;
105+ if ( tupleDesc != NULL )
106+ slot -> tts_flags |= TTS_FLAG_FIXED ;
107107slot -> tts_tuple = NULL ;
108- slot -> tts_fixedTupleDescriptor = tupleDesc != NULL ;
109108slot -> tts_tupleDescriptor = tupleDesc ;
110109slot -> tts_mcxt = CurrentMemoryContext ;
111110slot -> tts_buffer = InvalidBuffer ;
@@ -176,7 +175,7 @@ ExecResetTupleTable(List *tupleTable,/* tuple table */
176175/* If shouldFree, release memory occupied by the slot itself */
177176if (shouldFree )
178177{
179- if (!slot -> tts_fixedTupleDescriptor )
178+ if (!TTS_FIXED ( slot ) )
180179{
181180if (slot -> tts_values )
182181pfree (slot -> tts_values );
@@ -224,7 +223,7 @@ ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
224223ExecClearTuple (slot );
225224if (slot -> tts_tupleDescriptor )
226225ReleaseTupleDesc (slot -> tts_tupleDescriptor );
227- if (!slot -> tts_fixedTupleDescriptor )
226+ if (!TTS_FIXED ( slot ) )
228227{
229228if (slot -> tts_values )
230229pfree (slot -> tts_values );
254253ExecSetSlotDescriptor (TupleTableSlot * slot ,/* slot to change */
255254TupleDesc tupdesc )/* new tuple descriptor */
256255{
257- Assert (!slot -> tts_fixedTupleDescriptor );
256+ Assert (!TTS_FIXED ( slot ) );
258257
259258/* For safety, make sure slot is empty before changing it */
260259ExecClearTuple (slot );
@@ -325,17 +324,23 @@ ExecStoreHeapTuple(HeapTuple tuple,
325324/*
326325 * Free any old physical tuple belonging to the slot.
327326 */
328- if (slot -> tts_shouldFree )
327+ if (TTS_SHOULDFREE (slot ))
328+ {
329329heap_freetuple (slot -> tts_tuple );
330- if (slot -> tts_shouldFreeMin )
330+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
331+ }
332+ if (TTS_SHOULDFREEMIN (slot ))
333+ {
331334heap_free_minimal_tuple (slot -> tts_mintuple );
335+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
336+ }
332337
333338/*
334339 * Store the new tuple into the specified slot.
335340 */
336- slot -> tts_isempty = false ;
337- slot -> tts_shouldFree = shouldFree ;
338- slot -> tts_shouldFreeMin = false ;
341+ slot -> tts_flags &= ~ TTS_FLAG_EMPTY ;
342+ if ( shouldFree )
343+ slot -> tts_flags |= TTS_FLAG_SHOULDFREE ;
339344slot -> tts_tuple = tuple ;
340345slot -> tts_mintuple = NULL ;
341346
@@ -382,17 +387,21 @@ ExecStoreBufferHeapTuple(HeapTuple tuple,
382387/*
383388 * Free any old physical tuple belonging to the slot.
384389 */
385- if (slot -> tts_shouldFree )
390+ if (TTS_SHOULDFREE (slot ))
391+ {
386392heap_freetuple (slot -> tts_tuple );
387- if (slot -> tts_shouldFreeMin )
393+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
394+ }
395+ if (TTS_SHOULDFREEMIN (slot ))
396+ {
388397heap_free_minimal_tuple (slot -> tts_mintuple );
398+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
399+ }
389400
390401/*
391402 * Store the new tuple into the specified slot.
392403 */
393- slot -> tts_isempty = false;
394- slot -> tts_shouldFree = false;
395- slot -> tts_shouldFreeMin = false;
404+ slot -> tts_flags &= ~TTS_FLAG_EMPTY ;
396405slot -> tts_tuple = tuple ;
397406slot -> tts_mintuple = NULL ;
398407
@@ -442,10 +451,16 @@ ExecStoreMinimalTuple(MinimalTuple mtup,
442451/*
443452 * Free any old physical tuple belonging to the slot.
444453 */
445- if (slot -> tts_shouldFree )
454+ if (TTS_SHOULDFREE (slot ))
455+ {
446456heap_freetuple (slot -> tts_tuple );
447- if (slot -> tts_shouldFreeMin )
457+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
458+ }
459+ if (TTS_SHOULDFREEMIN (slot ))
460+ {
448461heap_free_minimal_tuple (slot -> tts_mintuple );
462+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
463+ }
449464
450465/*
451466 * Drop the pin on the referenced buffer, if there is one.
@@ -458,9 +473,9 @@ ExecStoreMinimalTuple(MinimalTuple mtup,
458473/*
459474 * Store the new tuple into the specified slot.
460475 */
461- slot -> tts_isempty = false ;
462- slot -> tts_shouldFree = false;
463- slot -> tts_shouldFreeMin = shouldFree ;
476+ slot -> tts_flags &= ~ TTS_FLAG_EMPTY ;
477+ if ( shouldFree )
478+ slot -> tts_flags |= TTS_FLAG_SHOULDFREEMIN ;
464479slot -> tts_tuple = & slot -> tts_minhdr ;
465480slot -> tts_mintuple = mtup ;
466481
@@ -493,15 +508,19 @@ ExecClearTuple(TupleTableSlot *slot)/* slot in which to store tuple */
493508/*
494509 * Free the old physical tuple if necessary.
495510 */
496- if (slot -> tts_shouldFree )
511+ if (TTS_SHOULDFREE (slot ))
512+ {
497513heap_freetuple (slot -> tts_tuple );
498- if (slot -> tts_shouldFreeMin )
514+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
515+ }
516+ if (TTS_SHOULDFREEMIN (slot ))
517+ {
499518heap_free_minimal_tuple (slot -> tts_mintuple );
519+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
520+ }
500521
501522slot -> tts_tuple = NULL ;
502523slot -> tts_mintuple = NULL ;
503- slot -> tts_shouldFree = false;
504- slot -> tts_shouldFreeMin = false;
505524
506525/*
507526 * Drop the pin on the referenced buffer, if there is one.
@@ -514,7 +533,7 @@ ExecClearTuple(TupleTableSlot *slot)/* slot in which to store tuple */
514533/*
515534 * Mark it empty.
516535 */
517- slot -> tts_isempty = true ;
536+ slot -> tts_flags |= TTS_FLAG_EMPTY ;
518537slot -> tts_nvalid = 0 ;
519538
520539return slot ;
@@ -539,9 +558,9 @@ ExecStoreVirtualTuple(TupleTableSlot *slot)
539558 */
540559Assert (slot != NULL );
541560Assert (slot -> tts_tupleDescriptor != NULL );
542- Assert (slot -> tts_isempty );
561+ Assert (TTS_EMPTY ( slot ) );
543562
544- slot -> tts_isempty = false ;
563+ slot -> tts_flags &= ~ TTS_FLAG_EMPTY ;
545564slot -> tts_nvalid = slot -> tts_tupleDescriptor -> natts ;
546565
547566return slot ;
@@ -595,7 +614,7 @@ ExecCopySlotTuple(TupleTableSlot *slot)
595614 * sanity checks
596615 */
597616Assert (slot != NULL );
598- Assert (!slot -> tts_isempty );
617+ Assert (!TTS_EMPTY ( slot ) );
599618
600619/*
601620 * If we have a physical tuple (either format) then just copy it.
@@ -627,7 +646,7 @@ ExecCopySlotMinimalTuple(TupleTableSlot *slot)
627646 * sanity checks
628647 */
629648Assert (slot != NULL );
630- Assert (!slot -> tts_isempty );
649+ Assert (!TTS_EMPTY ( slot ) );
631650
632651/*
633652 * If we have a physical tuple then just copy it. Prefer to copy
@@ -675,7 +694,7 @@ ExecFetchSlotTuple(TupleTableSlot *slot)
675694 * sanity checks
676695 */
677696Assert (slot != NULL );
678- Assert (!slot -> tts_isempty );
697+ Assert (!TTS_EMPTY ( slot ) );
679698
680699/*
681700 * If we have a regular physical tuple then just return it.
@@ -724,7 +743,8 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
724743 * sanity checks
725744 */
726745Assert (slot != NULL );
727- Assert (!slot -> tts_isempty );
746+ Assert (!TTS_EMPTY (slot ));
747+
728748
729749/*
730750 * If we have a minimal physical tuple (local or not) then just return it.
@@ -741,7 +761,7 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
741761 */
742762oldContext = MemoryContextSwitchTo (slot -> tts_mcxt );
743763slot -> tts_mintuple = ExecCopySlotMinimalTuple (slot );
744- slot -> tts_shouldFreeMin = true ;
764+ slot -> tts_flags |= TTS_FLAG_SHOULDFREEMIN ;
745765MemoryContextSwitchTo (oldContext );
746766
747767/*
@@ -797,13 +817,13 @@ ExecMaterializeSlot(TupleTableSlot *slot)
797817 * sanity checks
798818 */
799819Assert (slot != NULL );
800- Assert (!slot -> tts_isempty );
820+ Assert (!TTS_EMPTY ( slot ) );
801821
802822/*
803823 * If we have a regular physical tuple, and it's locally palloc'd, we have
804824 * nothing to do.
805825 */
806- if (slot -> tts_tuple && slot -> tts_shouldFree )
826+ if (slot -> tts_tuple && TTS_SHOULDFREE ( slot ) )
807827return slot -> tts_tuple ;
808828
809829/*
@@ -815,7 +835,7 @@ ExecMaterializeSlot(TupleTableSlot *slot)
815835 */
816836oldContext = MemoryContextSwitchTo (slot -> tts_mcxt );
817837slot -> tts_tuple = ExecCopySlotTuple (slot );
818- slot -> tts_shouldFree = true ;
838+ slot -> tts_flags |= TTS_FLAG_SHOULDFREE ;
819839MemoryContextSwitchTo (oldContext );
820840
821841/*
@@ -842,7 +862,7 @@ ExecMaterializeSlot(TupleTableSlot *slot)
842862 * storage, we must not pfree it now, since callers might have already
843863 * fetched datum pointers referencing it.)
844864 */
845- if (!slot -> tts_shouldFreeMin )
865+ if (!TTS_SHOULDFREEMIN ( slot ) )
846866slot -> tts_mintuple = NULL ;
847867
848868return slot -> tts_tuple ;