Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f86a895

Browse files
committed
Further cleanup of ReorderBufferCommit().
On closer inspection, we can remove the "volatile" qualifier on "using_subtxn" so long as we initialize that before the PG_TRY block, which there's no particularly good reason not to do. Also, push the "change" variable inside the PG_TRY so as to remove all question of whether it needs "volatile", and remove useless early initializations of "snapshow_now" and "using_subtxn".
1 parent 138a5c4 commit f86a895

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/backend/replication/logical/reorderbuffer.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,12 +1259,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
12591259
TimestampTz commit_time)
12601260
{
12611261
ReorderBufferTXN *txn;
1262-
ReorderBufferIterTXNState *volatile iterstate = NULL;
1263-
ReorderBufferChange *change;
1264-
1262+
volatile Snapshot snapshot_now;
12651263
volatile CommandId command_id = FirstCommandId;
1266-
volatile Snapshot snapshot_now = NULL;
1267-
volatile bool using_subtxn = false;
1264+
bool using_subtxn;
1265+
ReorderBufferIterTXNState *volatile iterstate = NULL;
12681266

12691267
txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
12701268
false);
@@ -1302,19 +1300,21 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
13021300
/* setup the initial snapshot */
13031301
SetupHistoricSnapshot(snapshot_now, txn->tuplecid_hash);
13041302

1303+
/*
1304+
* Decoding needs access to syscaches et al., which in turn use
1305+
* heavyweight locks and such. Thus we need to have enough state around to
1306+
* keep track of those. The easiest way is to simply use a transaction
1307+
* internally. That also allows us to easily enforce that nothing writes
1308+
* to the database by checking for xid assignments.
1309+
*
1310+
* When we're called via the SQL SRF there's already a transaction
1311+
* started, so start an explicit subtransaction there.
1312+
*/
1313+
using_subtxn = IsTransactionOrTransactionBlock();
1314+
13051315
PG_TRY();
13061316
{
1307-
/*
1308-
* Decoding needs access to syscaches et al., which in turn use
1309-
* heavyweight locks and such. Thus we need to have enough state
1310-
* around to keep track of those. The easiest way is to simply use a
1311-
* transaction internally. That also allows us to easily enforce that
1312-
* nothing writes to the database by checking for xid assignments.
1313-
*
1314-
* When we're called via the SQL SRF there's already a transaction
1315-
* started, so start an explicit subtransaction there.
1316-
*/
1317-
using_subtxn = IsTransactionOrTransactionBlock();
1317+
ReorderBufferChange *change;
13181318

13191319
if (using_subtxn)
13201320
BeginInternalSubTransaction("replay");
@@ -1324,7 +1324,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
13241324
rb->begin(rb, txn);
13251325

13261326
iterstate = ReorderBufferIterTXNInit(rb, txn);
1327-
while ((change = ReorderBufferIterTXNNext(rb, iterstate)))
1327+
while ((change = ReorderBufferIterTXNNext(rb, iterstate)) != NULL)
13281328
{
13291329
Relation relation = NULL;
13301330
Oid reloid;

0 commit comments

Comments
 (0)