@@ -498,13 +498,13 @@ ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change,
498
498
case REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT :
499
499
if (change -> data .tp .newtuple )
500
500
{
501
- ReorderBufferReturnTupleBuf (rb , change -> data .tp .newtuple );
501
+ ReorderBufferReturnTupleBuf (change -> data .tp .newtuple );
502
502
change -> data .tp .newtuple = NULL ;
503
503
}
504
504
505
505
if (change -> data .tp .oldtuple )
506
506
{
507
- ReorderBufferReturnTupleBuf (rb , change -> data .tp .oldtuple );
507
+ ReorderBufferReturnTupleBuf (change -> data .tp .oldtuple );
508
508
change -> data .tp .oldtuple = NULL ;
509
509
}
510
510
break ;
@@ -547,32 +547,29 @@ ReorderBufferReturnChange(ReorderBuffer *rb, ReorderBufferChange *change,
547
547
}
548
548
549
549
/*
550
- * Get a fresh ReorderBufferTupleBuf fitting at least a tuple of size
551
- * tuple_len (excluding header overhead).
550
+ * Get a fresh HeapTuple fitting a tuple of size tuple_len (excluding header
551
+ * overhead).
552
552
*/
553
- ReorderBufferTupleBuf *
553
+ HeapTuple
554
554
ReorderBufferGetTupleBuf (ReorderBuffer * rb , Size tuple_len )
555
555
{
556
- ReorderBufferTupleBuf * tuple ;
556
+ HeapTuple tuple ;
557
557
Size alloc_len ;
558
558
559
559
alloc_len = tuple_len + SizeofHeapTupleHeader ;
560
560
561
- tuple = (ReorderBufferTupleBuf * )
562
- MemoryContextAlloc (rb -> tup_context ,
563
- sizeof (ReorderBufferTupleBuf ) +
564
- MAXIMUM_ALIGNOF + alloc_len );
565
- tuple -> alloc_tuple_size = alloc_len ;
566
- tuple -> tuple .t_data = ReorderBufferTupleBufData (tuple );
561
+ tuple = (HeapTuple ) MemoryContextAlloc (rb -> tup_context ,
562
+ HEAPTUPLESIZE + alloc_len );
563
+ tuple -> t_data = (HeapTupleHeader ) ((char * ) tuple + HEAPTUPLESIZE );
567
564
568
565
return tuple ;
569
566
}
570
567
571
568
/*
572
- * Free a ReorderBufferTupleBuf .
569
+ * Free a HeapTuple returned by ReorderBufferGetTupleBuf() .
573
570
*/
574
571
void
575
- ReorderBufferReturnTupleBuf (ReorderBuffer * rb , ReorderBufferTupleBuf * tuple )
572
+ ReorderBufferReturnTupleBuf (HeapTuple tuple )
576
573
{
577
574
pfree (tuple );
578
575
}
@@ -3759,8 +3756,8 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
3759
3756
case REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT :
3760
3757
{
3761
3758
char * data ;
3762
- ReorderBufferTupleBuf * oldtup ,
3763
- * newtup ;
3759
+ HeapTuple oldtup ,
3760
+ newtup ;
3764
3761
Size oldlen = 0 ;
3765
3762
Size newlen = 0 ;
3766
3763
@@ -3770,14 +3767,14 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
3770
3767
if (oldtup )
3771
3768
{
3772
3769
sz += sizeof (HeapTupleData );
3773
- oldlen = oldtup -> tuple . t_len ;
3770
+ oldlen = oldtup -> t_len ;
3774
3771
sz += oldlen ;
3775
3772
}
3776
3773
3777
3774
if (newtup )
3778
3775
{
3779
3776
sz += sizeof (HeapTupleData );
3780
- newlen = newtup -> tuple . t_len ;
3777
+ newlen = newtup -> t_len ;
3781
3778
sz += newlen ;
3782
3779
}
3783
3780
@@ -3790,19 +3787,19 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
3790
3787
3791
3788
if (oldlen )
3792
3789
{
3793
- memcpy (data , & oldtup -> tuple , sizeof (HeapTupleData ));
3790
+ memcpy (data , oldtup , sizeof (HeapTupleData ));
3794
3791
data += sizeof (HeapTupleData );
3795
3792
3796
- memcpy (data , oldtup -> tuple . t_data , oldlen );
3793
+ memcpy (data , oldtup -> t_data , oldlen );
3797
3794
data += oldlen ;
3798
3795
}
3799
3796
3800
3797
if (newlen )
3801
3798
{
3802
- memcpy (data , & newtup -> tuple , sizeof (HeapTupleData ));
3799
+ memcpy (data , newtup , sizeof (HeapTupleData ));
3803
3800
data += sizeof (HeapTupleData );
3804
3801
3805
- memcpy (data , newtup -> tuple . t_data , newlen );
3802
+ memcpy (data , newtup -> t_data , newlen );
3806
3803
data += newlen ;
3807
3804
}
3808
3805
break ;
@@ -4118,8 +4115,8 @@ ReorderBufferChangeSize(ReorderBufferChange *change)
4118
4115
case REORDER_BUFFER_CHANGE_DELETE :
4119
4116
case REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT :
4120
4117
{
4121
- ReorderBufferTupleBuf * oldtup ,
4122
- * newtup ;
4118
+ HeapTuple oldtup ,
4119
+ newtup ;
4123
4120
Size oldlen = 0 ;
4124
4121
Size newlen = 0 ;
4125
4122
@@ -4129,14 +4126,14 @@ ReorderBufferChangeSize(ReorderBufferChange *change)
4129
4126
if (oldtup )
4130
4127
{
4131
4128
sz += sizeof (HeapTupleData );
4132
- oldlen = oldtup -> tuple . t_len ;
4129
+ oldlen = oldtup -> t_len ;
4133
4130
sz += oldlen ;
4134
4131
}
4135
4132
4136
4133
if (newtup )
4137
4134
{
4138
4135
sz += sizeof (HeapTupleData );
4139
- newlen = newtup -> tuple . t_len ;
4136
+ newlen = newtup -> t_len ;
4140
4137
sz += newlen ;
4141
4138
}
4142
4139
@@ -4365,16 +4362,16 @@ ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
4365
4362
ReorderBufferGetTupleBuf (rb , tuplelen - SizeofHeapTupleHeader );
4366
4363
4367
4364
/* restore ->tuple */
4368
- memcpy (& change -> data .tp .oldtuple -> tuple , data ,
4365
+ memcpy (change -> data .tp .oldtuple , data ,
4369
4366
sizeof (HeapTupleData ));
4370
4367
data += sizeof (HeapTupleData );
4371
4368
4372
4369
/* reset t_data pointer into the new tuplebuf */
4373
- change -> data .tp .oldtuple -> tuple . t_data =
4374
- ReorderBufferTupleBufData ( change -> data .tp .oldtuple );
4370
+ change -> data .tp .oldtuple -> t_data =
4371
+ ( HeapTupleHeader ) (( char * ) change -> data .tp .oldtuple + HEAPTUPLESIZE );
4375
4372
4376
4373
/* restore tuple data itself */
4377
- memcpy (change -> data .tp .oldtuple -> tuple . t_data , data , tuplelen );
4374
+ memcpy (change -> data .tp .oldtuple -> t_data , data , tuplelen );
4378
4375
data += tuplelen ;
4379
4376
}
4380
4377
@@ -4390,16 +4387,16 @@ ReorderBufferRestoreChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
4390
4387
ReorderBufferGetTupleBuf (rb , tuplelen - SizeofHeapTupleHeader );
4391
4388
4392
4389
/* restore ->tuple */
4393
- memcpy (& change -> data .tp .newtuple -> tuple , data ,
4390
+ memcpy (change -> data .tp .newtuple , data ,
4394
4391
sizeof (HeapTupleData ));
4395
4392
data += sizeof (HeapTupleData );
4396
4393
4397
4394
/* reset t_data pointer into the new tuplebuf */
4398
- change -> data .tp .newtuple -> tuple . t_data =
4399
- ReorderBufferTupleBufData ( change -> data .tp .newtuple );
4395
+ change -> data .tp .newtuple -> t_data =
4396
+ ( HeapTupleHeader ) (( char * ) change -> data .tp .newtuple + HEAPTUPLESIZE );
4400
4397
4401
4398
/* restore tuple data itself */
4402
- memcpy (change -> data .tp .newtuple -> tuple . t_data , data , tuplelen );
4399
+ memcpy (change -> data .tp .newtuple -> t_data , data , tuplelen );
4403
4400
data += tuplelen ;
4404
4401
}
4405
4402
@@ -4646,7 +4643,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
4646
4643
Relation relation , ReorderBufferChange * change )
4647
4644
{
4648
4645
ReorderBufferToastEnt * ent ;
4649
- ReorderBufferTupleBuf * newtup ;
4646
+ HeapTuple newtup ;
4650
4647
bool found ;
4651
4648
int32 chunksize ;
4652
4649
bool isnull ;
@@ -4661,9 +4658,9 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
4661
4658
Assert (IsToastRelation (relation ));
4662
4659
4663
4660
newtup = change -> data .tp .newtuple ;
4664
- chunk_id = DatumGetObjectId (fastgetattr (& newtup -> tuple , 1 , desc , & isnull ));
4661
+ chunk_id = DatumGetObjectId (fastgetattr (newtup , 1 , desc , & isnull ));
4665
4662
Assert (!isnull );
4666
- chunk_seq = DatumGetInt32 (fastgetattr (& newtup -> tuple , 2 , desc , & isnull ));
4663
+ chunk_seq = DatumGetInt32 (fastgetattr (newtup , 2 , desc , & isnull ));
4667
4664
Assert (!isnull );
4668
4665
4669
4666
ent = (ReorderBufferToastEnt * )
@@ -4686,7 +4683,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
4686
4683
elog (ERROR , "got sequence entry %d for toast chunk %u instead of seq %d" ,
4687
4684
chunk_seq , chunk_id , ent -> last_chunk_seq + 1 );
4688
4685
4689
- chunk = DatumGetPointer (fastgetattr (& newtup -> tuple , 3 , desc , & isnull ));
4686
+ chunk = DatumGetPointer (fastgetattr (newtup , 3 , desc , & isnull ));
4690
4687
Assert (!isnull );
4691
4688
4692
4689
/* calculate size so we can allocate the right size at once later */
@@ -4737,7 +4734,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
4737
4734
Relation toast_rel ;
4738
4735
TupleDesc toast_desc ;
4739
4736
MemoryContext oldcontext ;
4740
- ReorderBufferTupleBuf * newtup ;
4737
+ HeapTuple newtup ;
4741
4738
Size old_size ;
4742
4739
4743
4740
/* no toast tuples changed */
@@ -4777,7 +4774,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
4777
4774
4778
4775
newtup = change -> data .tp .newtuple ;
4779
4776
4780
- heap_deform_tuple (& newtup -> tuple , desc , attrs , isnull );
4777
+ heap_deform_tuple (newtup , desc , attrs , isnull );
4781
4778
4782
4779
for (natt = 0 ; natt < desc -> natts ; natt ++ )
4783
4780
{
@@ -4842,12 +4839,12 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
4842
4839
{
4843
4840
bool cisnull ;
4844
4841
ReorderBufferChange * cchange ;
4845
- ReorderBufferTupleBuf * ctup ;
4842
+ HeapTuple ctup ;
4846
4843
Pointer chunk ;
4847
4844
4848
4845
cchange = dlist_container (ReorderBufferChange , node , it .cur );
4849
4846
ctup = cchange -> data .tp .newtuple ;
4850
- chunk = DatumGetPointer (fastgetattr (& ctup -> tuple , 3 , toast_desc , & cisnull ));
4847
+ chunk = DatumGetPointer (fastgetattr (ctup , 3 , toast_desc , & cisnull ));
4851
4848
4852
4849
Assert (!cisnull );
4853
4850
Assert (!VARATT_IS_EXTERNAL (chunk ));
@@ -4882,11 +4879,11 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
4882
4879
* the tuplebuf because attrs[] will point back into the current content.
4883
4880
*/
4884
4881
tmphtup = heap_form_tuple (desc , attrs , isnull );
4885
- Assert (newtup -> tuple . t_len <= MaxHeapTupleSize );
4886
- Assert (ReorderBufferTupleBufData ( newtup ) == newtup -> tuple . t_data );
4882
+ Assert (newtup -> t_len <= MaxHeapTupleSize );
4883
+ Assert (newtup -> t_data == ( HeapTupleHeader ) (( char * ) newtup + HEAPTUPLESIZE ) );
4887
4884
4888
- memcpy (newtup -> tuple . t_data , tmphtup -> t_data , tmphtup -> t_len );
4889
- newtup -> tuple . t_len = tmphtup -> t_len ;
4885
+ memcpy (newtup -> t_data , tmphtup -> t_data , tmphtup -> t_len );
4886
+ newtup -> t_len = tmphtup -> t_len ;
4890
4887
4891
4888
/*
4892
4889
* free resources we won't further need, more persistent stuff will be
0 commit comments