Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc70f9e8

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 removeall question of whether it needs "volatile", and remove uselessearly initializations of "snapshow_now" and "using_subtxn".
1 parentbf007a2 commitc70f9e8

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
@@ -1258,12 +1258,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
12581258
TimestampTzcommit_time)
12591259
{
12601260
ReorderBufferTXN*txn;
1261-
ReorderBufferIterTXNState*volatileiterstate=NULL;
1262-
ReorderBufferChange*change;
1263-
1261+
volatileSnapshotsnapshot_now;
12641262
volatileCommandIdcommand_id=FirstCommandId;
1265-
volatileSnapshotsnapshot_now=NULL;
1266-
volatileboolusing_subtxn= false;
1263+
boolusing_subtxn;
1264+
ReorderBufferIterTXNState*volatileiterstate=NULL;
12671265

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

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

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

13251325
iterstate=ReorderBufferIterTXNInit(rb,txn);
1326-
while ((change=ReorderBufferIterTXNNext(rb,iterstate)))
1326+
while ((change=ReorderBufferIterTXNNext(rb,iterstate))!=NULL)
13271327
{
13281328
Relationrelation=NULL;
13291329
Oidreloid;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp