@@ -2621,6 +2621,9 @@ heap_page_xid_min_max(Page page, bool multi,
2621
2621
if (!HeapTupleHeaderXminFrozen (htup ) &&
2622
2622
TransactionIdIsNormal (htup -> t_choice .t_heap .t_xmin ))
2623
2623
{
2624
+ Assert (htup -> t_choice .t_heap .t_xmin >= FirstNormalTransactionId );
2625
+ Assert (htup -> t_choice .t_heap .t_xmin <= MaxShortTransactionId );
2626
+
2624
2627
if (!found )
2625
2628
{
2626
2629
* min = * max = htup -> t_choice .t_heap .t_xmin ;
@@ -2636,6 +2639,9 @@ heap_page_xid_min_max(Page page, bool multi,
2636
2639
if (TransactionIdIsNormal (htup -> t_choice .t_heap .t_xmax ) &&
2637
2640
!(htup -> t_infomask & HEAP_XMAX_IS_MULTI ))
2638
2641
{
2642
+ Assert (htup -> t_choice .t_heap .t_xmax >= FirstNormalTransactionId );
2643
+ Assert (htup -> t_choice .t_heap .t_xmax <= MaxShortTransactionId );
2644
+
2639
2645
if (!found )
2640
2646
{
2641
2647
* min = * max = htup -> t_choice .t_heap .t_xmax ;
@@ -2653,6 +2659,9 @@ heap_page_xid_min_max(Page page, bool multi,
2653
2659
if (TransactionIdIsNormal (htup -> t_choice .t_heap .t_xmax ) &&
2654
2660
(htup -> t_infomask & HEAP_XMAX_IS_MULTI ))
2655
2661
{
2662
+ Assert (htup -> t_choice .t_heap .t_xmax >= FirstNormalTransactionId );
2663
+ Assert (htup -> t_choice .t_heap .t_xmax <= MaxShortTransactionId );
2664
+
2656
2665
if (!found )
2657
2666
{
2658
2667
* min = * max = htup -> t_choice .t_heap .t_xmax ;
@@ -2896,11 +2905,15 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
2896
2905
2897
2906
delta = (int64 ) (xid - FirstNormalTransactionId ) - (int64 ) base ;
2898
2907
2908
+ Assert (xid >= base + delta + FirstNormalTransactionId );
2909
+ Assert (xid <= base + delta + MaxShortTransactionId );
2910
+
2899
2911
heap_page_shift_base (relation , buffer , page , multi , delta );
2900
2912
MarkBufferDirty (buffer );
2901
2913
2902
2914
base = multi ? pageSpecial -> pd_multi_base : pageSpecial -> pd_xid_base ;
2903
- Assert (xid >= base + FirstNormalTransactionId && xid <= base + MaxShortTransactionId );
2915
+ Assert (xid >= base + FirstNormalTransactionId );
2916
+ Assert (xid <= base + MaxShortTransactionId );
2904
2917
return false;
2905
2918
}
2906
2919
@@ -2912,12 +2925,17 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
2912
2925
2913
2926
if (requiredDelta <= freeDelta )
2914
2927
{
2915
- heap_page_shift_base (relation , buffer ,
2916
- page , multi , - (freeDelta + requiredDelta ) / 2 );
2928
+ int64 delta = - (freeDelta + requiredDelta ) / 2 ;
2929
+
2930
+ Assert (xid >= base + delta + FirstNormalTransactionId );
2931
+ Assert (xid <= base + delta + MaxShortTransactionId );
2932
+
2933
+ heap_page_shift_base (relation , buffer , page , multi , delta );
2917
2934
MarkBufferDirty (buffer );
2918
2935
2919
2936
base = multi ? pageSpecial -> pd_multi_base : pageSpecial -> pd_xid_base ;
2920
- Assert (xid >= base + FirstNormalTransactionId && xid <= base + MaxShortTransactionId );
2937
+ Assert (xid >= base + FirstNormalTransactionId );
2938
+ Assert (xid <= base + MaxShortTransactionId );
2921
2939
return true;
2922
2940
}
2923
2941
}
@@ -2926,14 +2944,21 @@ heap_page_prepare_for_xid(Relation relation, Buffer buffer,
2926
2944
int64 freeDelta = min - FirstNormalTransactionId ,
2927
2945
requiredDelta = xid - (base + MaxShortTransactionId );
2928
2946
2947
+ Assert (xid > base + MaxShortTransactionId );
2948
+
2929
2949
if (requiredDelta <= freeDelta )
2930
2950
{
2931
- heap_page_shift_base (relation , buffer ,
2932
- page , multi , (freeDelta + requiredDelta ) / 2 );
2951
+ int64 delta = (freeDelta + requiredDelta ) / 2 ;
2952
+
2953
+ Assert (xid >= base + delta + FirstNormalTransactionId );
2954
+ Assert (xid <= base + delta + MaxShortTransactionId );
2955
+
2956
+ heap_page_shift_base (relation , buffer , page , multi , delta );
2933
2957
MarkBufferDirty (buffer );
2934
2958
2935
2959
base = multi ? pageSpecial -> pd_multi_base : pageSpecial -> pd_xid_base ;
2936
- Assert (xid >= base + FirstNormalTransactionId && xid <= base + MaxShortTransactionId );
2960
+ Assert (xid >= base + FirstNormalTransactionId );
2961
+ Assert (xid <= base + MaxShortTransactionId );
2937
2962
return true;
2938
2963
}
2939
2964
}
0 commit comments