@@ -101,11 +101,10 @@ MakeTupleTableSlot(TupleDesc tupleDesc)
101
101
102
102
slot = palloc0 (sz );
103
103
slot -> 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 ;
107
107
slot -> tts_tuple = NULL ;
108
- slot -> tts_fixedTupleDescriptor = tupleDesc != NULL ;
109
108
slot -> tts_tupleDescriptor = tupleDesc ;
110
109
slot -> tts_mcxt = CurrentMemoryContext ;
111
110
slot -> tts_buffer = InvalidBuffer ;
@@ -176,7 +175,7 @@ ExecResetTupleTable(List *tupleTable, /* tuple table */
176
175
/* If shouldFree, release memory occupied by the slot itself */
177
176
if (shouldFree )
178
177
{
179
- if (!slot -> tts_fixedTupleDescriptor )
178
+ if (!TTS_FIXED ( slot ) )
180
179
{
181
180
if (slot -> tts_values )
182
181
pfree (slot -> tts_values );
@@ -224,7 +223,7 @@ ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
224
223
ExecClearTuple (slot );
225
224
if (slot -> tts_tupleDescriptor )
226
225
ReleaseTupleDesc (slot -> tts_tupleDescriptor );
227
- if (!slot -> tts_fixedTupleDescriptor )
226
+ if (!TTS_FIXED ( slot ) )
228
227
{
229
228
if (slot -> tts_values )
230
229
pfree (slot -> tts_values );
254
253
ExecSetSlotDescriptor (TupleTableSlot * slot , /* slot to change */
255
254
TupleDesc tupdesc ) /* new tuple descriptor */
256
255
{
257
- Assert (!slot -> tts_fixedTupleDescriptor );
256
+ Assert (!TTS_FIXED ( slot ) );
258
257
259
258
/* For safety, make sure slot is empty before changing it */
260
259
ExecClearTuple (slot );
@@ -325,17 +324,23 @@ ExecStoreHeapTuple(HeapTuple tuple,
325
324
/*
326
325
* Free any old physical tuple belonging to the slot.
327
326
*/
328
- if (slot -> tts_shouldFree )
327
+ if (TTS_SHOULDFREE (slot ))
328
+ {
329
329
heap_freetuple (slot -> tts_tuple );
330
- if (slot -> tts_shouldFreeMin )
330
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
331
+ }
332
+ if (TTS_SHOULDFREEMIN (slot ))
333
+ {
331
334
heap_free_minimal_tuple (slot -> tts_mintuple );
335
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
336
+ }
332
337
333
338
/*
334
339
* Store the new tuple into the specified slot.
335
340
*/
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 ;
339
344
slot -> tts_tuple = tuple ;
340
345
slot -> tts_mintuple = NULL ;
341
346
@@ -382,17 +387,21 @@ ExecStoreBufferHeapTuple(HeapTuple tuple,
382
387
/*
383
388
* Free any old physical tuple belonging to the slot.
384
389
*/
385
- if (slot -> tts_shouldFree )
390
+ if (TTS_SHOULDFREE (slot ))
391
+ {
386
392
heap_freetuple (slot -> tts_tuple );
387
- if (slot -> tts_shouldFreeMin )
393
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
394
+ }
395
+ if (TTS_SHOULDFREEMIN (slot ))
396
+ {
388
397
heap_free_minimal_tuple (slot -> tts_mintuple );
398
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
399
+ }
389
400
390
401
/*
391
402
* Store the new tuple into the specified slot.
392
403
*/
393
- slot -> tts_isempty = false;
394
- slot -> tts_shouldFree = false;
395
- slot -> tts_shouldFreeMin = false;
404
+ slot -> tts_flags &= ~TTS_FLAG_EMPTY ;
396
405
slot -> tts_tuple = tuple ;
397
406
slot -> tts_mintuple = NULL ;
398
407
@@ -442,10 +451,16 @@ ExecStoreMinimalTuple(MinimalTuple mtup,
442
451
/*
443
452
* Free any old physical tuple belonging to the slot.
444
453
*/
445
- if (slot -> tts_shouldFree )
454
+ if (TTS_SHOULDFREE (slot ))
455
+ {
446
456
heap_freetuple (slot -> tts_tuple );
447
- if (slot -> tts_shouldFreeMin )
457
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
458
+ }
459
+ if (TTS_SHOULDFREEMIN (slot ))
460
+ {
448
461
heap_free_minimal_tuple (slot -> tts_mintuple );
462
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
463
+ }
449
464
450
465
/*
451
466
* Drop the pin on the referenced buffer, if there is one.
@@ -458,9 +473,9 @@ ExecStoreMinimalTuple(MinimalTuple mtup,
458
473
/*
459
474
* Store the new tuple into the specified slot.
460
475
*/
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 ;
464
479
slot -> tts_tuple = & slot -> tts_minhdr ;
465
480
slot -> tts_mintuple = mtup ;
466
481
@@ -493,15 +508,19 @@ ExecClearTuple(TupleTableSlot *slot) /* slot in which to store tuple */
493
508
/*
494
509
* Free the old physical tuple if necessary.
495
510
*/
496
- if (slot -> tts_shouldFree )
511
+ if (TTS_SHOULDFREE (slot ))
512
+ {
497
513
heap_freetuple (slot -> tts_tuple );
498
- if (slot -> tts_shouldFreeMin )
514
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREE ;
515
+ }
516
+ if (TTS_SHOULDFREEMIN (slot ))
517
+ {
499
518
heap_free_minimal_tuple (slot -> tts_mintuple );
519
+ slot -> tts_flags &= ~TTS_FLAG_SHOULDFREEMIN ;
520
+ }
500
521
501
522
slot -> tts_tuple = NULL ;
502
523
slot -> tts_mintuple = NULL ;
503
- slot -> tts_shouldFree = false;
504
- slot -> tts_shouldFreeMin = false;
505
524
506
525
/*
507
526
* Drop the pin on the referenced buffer, if there is one.
@@ -514,7 +533,7 @@ ExecClearTuple(TupleTableSlot *slot) /* slot in which to store tuple */
514
533
/*
515
534
* Mark it empty.
516
535
*/
517
- slot -> tts_isempty = true ;
536
+ slot -> tts_flags |= TTS_FLAG_EMPTY ;
518
537
slot -> tts_nvalid = 0 ;
519
538
520
539
return slot ;
@@ -539,9 +558,9 @@ ExecStoreVirtualTuple(TupleTableSlot *slot)
539
558
*/
540
559
Assert (slot != NULL );
541
560
Assert (slot -> tts_tupleDescriptor != NULL );
542
- Assert (slot -> tts_isempty );
561
+ Assert (TTS_EMPTY ( slot ) );
543
562
544
- slot -> tts_isempty = false ;
563
+ slot -> tts_flags &= ~ TTS_FLAG_EMPTY ;
545
564
slot -> tts_nvalid = slot -> tts_tupleDescriptor -> natts ;
546
565
547
566
return slot ;
@@ -595,7 +614,7 @@ ExecCopySlotTuple(TupleTableSlot *slot)
595
614
* sanity checks
596
615
*/
597
616
Assert (slot != NULL );
598
- Assert (!slot -> tts_isempty );
617
+ Assert (!TTS_EMPTY ( slot ) );
599
618
600
619
/*
601
620
* If we have a physical tuple (either format) then just copy it.
@@ -627,7 +646,7 @@ ExecCopySlotMinimalTuple(TupleTableSlot *slot)
627
646
* sanity checks
628
647
*/
629
648
Assert (slot != NULL );
630
- Assert (!slot -> tts_isempty );
649
+ Assert (!TTS_EMPTY ( slot ) );
631
650
632
651
/*
633
652
* If we have a physical tuple then just copy it. Prefer to copy
@@ -675,7 +694,7 @@ ExecFetchSlotTuple(TupleTableSlot *slot)
675
694
* sanity checks
676
695
*/
677
696
Assert (slot != NULL );
678
- Assert (!slot -> tts_isempty );
697
+ Assert (!TTS_EMPTY ( slot ) );
679
698
680
699
/*
681
700
* If we have a regular physical tuple then just return it.
@@ -724,7 +743,8 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
724
743
* sanity checks
725
744
*/
726
745
Assert (slot != NULL );
727
- Assert (!slot -> tts_isempty );
746
+ Assert (!TTS_EMPTY (slot ));
747
+
728
748
729
749
/*
730
750
* If we have a minimal physical tuple (local or not) then just return it.
@@ -741,7 +761,7 @@ ExecFetchSlotMinimalTuple(TupleTableSlot *slot)
741
761
*/
742
762
oldContext = MemoryContextSwitchTo (slot -> tts_mcxt );
743
763
slot -> tts_mintuple = ExecCopySlotMinimalTuple (slot );
744
- slot -> tts_shouldFreeMin = true ;
764
+ slot -> tts_flags |= TTS_FLAG_SHOULDFREEMIN ;
745
765
MemoryContextSwitchTo (oldContext );
746
766
747
767
/*
@@ -797,13 +817,13 @@ ExecMaterializeSlot(TupleTableSlot *slot)
797
817
* sanity checks
798
818
*/
799
819
Assert (slot != NULL );
800
- Assert (!slot -> tts_isempty );
820
+ Assert (!TTS_EMPTY ( slot ) );
801
821
802
822
/*
803
823
* If we have a regular physical tuple, and it's locally palloc'd, we have
804
824
* nothing to do.
805
825
*/
806
- if (slot -> tts_tuple && slot -> tts_shouldFree )
826
+ if (slot -> tts_tuple && TTS_SHOULDFREE ( slot ) )
807
827
return slot -> tts_tuple ;
808
828
809
829
/*
@@ -815,7 +835,7 @@ ExecMaterializeSlot(TupleTableSlot *slot)
815
835
*/
816
836
oldContext = MemoryContextSwitchTo (slot -> tts_mcxt );
817
837
slot -> tts_tuple = ExecCopySlotTuple (slot );
818
- slot -> tts_shouldFree = true ;
838
+ slot -> tts_flags |= TTS_FLAG_SHOULDFREE ;
819
839
MemoryContextSwitchTo (oldContext );
820
840
821
841
/*
@@ -842,7 +862,7 @@ ExecMaterializeSlot(TupleTableSlot *slot)
842
862
* storage, we must not pfree it now, since callers might have already
843
863
* fetched datum pointers referencing it.)
844
864
*/
845
- if (!slot -> tts_shouldFreeMin )
865
+ if (!TTS_SHOULDFREEMIN ( slot ) )
846
866
slot -> tts_mintuple = NULL ;
847
867
848
868
return slot -> tts_tuple ;
0 commit comments