@@ -717,10 +717,7 @@ ReorderBufferProcessPartialChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
717
717
return ;
718
718
719
719
/* Get the top transaction. */
720
- if (txn -> toptxn != NULL )
721
- toptxn = txn -> toptxn ;
722
- else
723
- toptxn = txn ;
720
+ toptxn = rbtxn_get_toptxn (txn );
724
721
725
722
/*
726
723
* Indicate a partial change for toast inserts. The change will be
@@ -809,13 +806,7 @@ ReorderBufferQueueChange(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn,
809
806
change -> action == REORDER_BUFFER_CHANGE_TRUNCATE ||
810
807
change -> action == REORDER_BUFFER_CHANGE_MESSAGE )
811
808
{
812
- ReorderBufferTXN * toptxn ;
813
-
814
- /* get the top transaction */
815
- if (txn -> toptxn != NULL )
816
- toptxn = txn -> toptxn ;
817
- else
818
- toptxn = txn ;
809
+ ReorderBufferTXN * toptxn = rbtxn_get_toptxn (txn );
819
810
820
811
toptxn -> txn_flags |= RBTXN_HAS_STREAMABLE_CHANGE ;
821
812
}
@@ -1655,9 +1646,9 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
1655
1646
/*
1656
1647
* Mark the transaction as streamed.
1657
1648
*
1658
- * The toplevel transaction, identified by (toptxn==NULL), is marked as
1659
- * streamed always, even if it does not contain any changes (that is, when
1660
- * all the changes are in subtransactions).
1649
+ * The top-level transaction, is marked as streamed always, even if it
1650
+ * does not contain any changes (that is, when all the changes are in
1651
+ * subtransactions).
1661
1652
*
1662
1653
* For subtransactions, we only mark them as streamed when there are
1663
1654
* changes in them.
@@ -1667,7 +1658,7 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
1667
1658
* about the toplevel xact (we send the XID in all messages), but we never
1668
1659
* stream XIDs of empty subxacts.
1669
1660
*/
1670
- if ((!txn_prepared ) && ((! txn -> toptxn ) || (txn -> nentries_mem != 0 )))
1661
+ if ((!txn_prepared ) && (rbtxn_is_toptxn ( txn ) || (txn -> nentries_mem != 0 )))
1671
1662
txn -> txn_flags |= RBTXN_IS_STREAMED ;
1672
1663
1673
1664
if (txn_prepared )
@@ -3207,10 +3198,7 @@ ReorderBufferChangeMemoryUpdate(ReorderBuffer *rb,
3207
3198
* Update the total size in top level as well. This is later used to
3208
3199
* compute the decoding stats.
3209
3200
*/
3210
- if (txn -> toptxn != NULL )
3211
- toptxn = txn -> toptxn ;
3212
- else
3213
- toptxn = txn ;
3201
+ toptxn = rbtxn_get_toptxn (txn );
3214
3202
3215
3203
if (addition )
3216
3204
{
@@ -3295,8 +3283,7 @@ ReorderBufferAddInvalidations(ReorderBuffer *rb, TransactionId xid,
3295
3283
* so that we can execute them all together. See comments atop this
3296
3284
* function.
3297
3285
*/
3298
- if (txn -> toptxn )
3299
- txn = txn -> toptxn ;
3286
+ txn = rbtxn_get_toptxn (txn );
3300
3287
3301
3288
Assert (nmsgs > 0 );
3302
3289
@@ -3354,7 +3341,6 @@ ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid,
3354
3341
XLogRecPtr lsn )
3355
3342
{
3356
3343
ReorderBufferTXN * txn ;
3357
- ReorderBufferTXN * toptxn ;
3358
3344
3359
3345
txn = ReorderBufferTXNByXid (rb , xid , true, NULL , lsn , true);
3360
3346
@@ -3370,11 +3356,15 @@ ReorderBufferXidSetCatalogChanges(ReorderBuffer *rb, TransactionId xid,
3370
3356
* conveniently check just top-level transaction and decide whether to
3371
3357
* build the hash table or not.
3372
3358
*/
3373
- toptxn = txn -> toptxn ;
3374
- if (toptxn != NULL && !rbtxn_has_catalog_changes (toptxn ))
3359
+ if (rbtxn_is_subtxn (txn ))
3375
3360
{
3376
- toptxn -> txn_flags |= RBTXN_HAS_CATALOG_CHANGES ;
3377
- dclist_push_tail (& rb -> catchange_txns , & toptxn -> catchange_node );
3361
+ ReorderBufferTXN * toptxn = rbtxn_get_toptxn (txn );
3362
+
3363
+ if (!rbtxn_has_catalog_changes (toptxn ))
3364
+ {
3365
+ toptxn -> txn_flags |= RBTXN_HAS_CATALOG_CHANGES ;
3366
+ dclist_push_tail (& rb -> catchange_txns , & toptxn -> catchange_node );
3367
+ }
3378
3368
}
3379
3369
}
3380
3370
@@ -3619,7 +3609,7 @@ ReorderBufferCheckMemoryLimit(ReorderBuffer *rb)
3619
3609
(txn = ReorderBufferLargestStreamableTopTXN (rb )) != NULL )
3620
3610
{
3621
3611
/* we know there has to be one, because the size is not zero */
3622
- Assert (txn && ! txn -> toptxn );
3612
+ Assert (txn && rbtxn_is_toptxn ( txn ) );
3623
3613
Assert (txn -> total_size > 0 );
3624
3614
Assert (rb -> size >= txn -> total_size );
3625
3615
@@ -4007,7 +3997,7 @@ ReorderBufferStreamTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
4007
3997
bool txn_is_streamed ;
4008
3998
4009
3999
/* We can never reach here for a subtransaction. */
4010
- Assert (txn -> toptxn == NULL );
4000
+ Assert (rbtxn_is_toptxn ( txn ) );
4011
4001
4012
4002
/*
4013
4003
* We can't make any assumptions about base snapshot here, similar to what
0 commit comments