Commit c70f9e89 authored by Tom Lane's avatar Tom Lane

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".
parent bf007a27
...@@ -1258,12 +1258,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, ...@@ -1258,12 +1258,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
TimestampTz commit_time) TimestampTz commit_time)
{ {
ReorderBufferTXN *txn; ReorderBufferTXN *txn;
ReorderBufferIterTXNState *volatile iterstate = NULL; volatile Snapshot snapshot_now;
ReorderBufferChange *change;
volatile CommandId command_id = FirstCommandId; volatile CommandId command_id = FirstCommandId;
volatile Snapshot snapshot_now = NULL; bool using_subtxn;
volatile bool using_subtxn = false; ReorderBufferIterTXNState *volatile iterstate = NULL;
txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr, txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
false); false);
...@@ -1301,20 +1299,22 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, ...@@ -1301,20 +1299,22 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
/* setup the initial snapshot */ /* setup the initial snapshot */
SetupHistoricSnapshot(snapshot_now, txn->tuplecid_hash); SetupHistoricSnapshot(snapshot_now, txn->tuplecid_hash);
PG_TRY();
{
/* /*
* Decoding needs access to syscaches et al., which in turn use * Decoding needs access to syscaches et al., which in turn use
* heavyweight locks and such. Thus we need to have enough state * heavyweight locks and such. Thus we need to have enough state around to
* around to keep track of those. The easiest way is to simply use a * keep track of those. The easiest way is to simply use a transaction
* transaction internally. That also allows us to easily enforce that * internally. That also allows us to easily enforce that nothing writes
* nothing writes to the database by checking for xid assignments. * to the database by checking for xid assignments.
* *
* When we're called via the SQL SRF there's already a transaction * When we're called via the SQL SRF there's already a transaction
* started, so start an explicit subtransaction there. * started, so start an explicit subtransaction there.
*/ */
using_subtxn = IsTransactionOrTransactionBlock(); using_subtxn = IsTransactionOrTransactionBlock();
PG_TRY();
{
ReorderBufferChange *change;
if (using_subtxn) if (using_subtxn)
BeginInternalSubTransaction("replay"); BeginInternalSubTransaction("replay");
else else
...@@ -1323,7 +1323,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, ...@@ -1323,7 +1323,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
rb->begin(rb, txn); rb->begin(rb, txn);
iterstate = ReorderBufferIterTXNInit(rb, txn); iterstate = ReorderBufferIterTXNInit(rb, txn);
while ((change = ReorderBufferIterTXNNext(rb, iterstate))) while ((change = ReorderBufferIterTXNNext(rb, iterstate)) != NULL)
{ {
Relation relation = NULL; Relation relation = NULL;
Oid reloid; Oid reloid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment