TimestampTz commit_time)
{
ReorderBufferTXN *txn;
- ReorderBufferIterTXNState *volatile iterstate = NULL;
- ReorderBufferChange *change;
-
+ volatile Snapshot snapshot_now;
volatile CommandId command_id = FirstCommandId;
- volatile Snapshot snapshot_now = NULL;
- volatile bool using_subtxn = false;
+ bool using_subtxn;
+ ReorderBufferIterTXNState *volatile iterstate = NULL;
txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr,
false);
/* setup the initial snapshot */
SetupHistoricSnapshot(snapshot_now, txn->tuplecid_hash);
+ /*
+ * Decoding needs access to syscaches et al., which in turn use
+ * heavyweight locks and such. Thus we need to have enough state around to
+ * keep track of those. The easiest way is to simply use a transaction
+ * internally. That also allows us to easily enforce that nothing writes
+ * to the database by checking for xid assignments.
+ *
+ * When we're called via the SQL SRF there's already a transaction
+ * started, so start an explicit subtransaction there.
+ */
+ using_subtxn = IsTransactionOrTransactionBlock();
+
PG_TRY();
{
- /*
- * Decoding needs access to syscaches et al., which in turn use
- * heavyweight locks and such. Thus we need to have enough state
- * around to keep track of those. The easiest way is to simply use a
- * transaction internally. That also allows us to easily enforce that
- * nothing writes to the database by checking for xid assignments.
- *
- * When we're called via the SQL SRF there's already a transaction
- * started, so start an explicit subtransaction there.
- */
- using_subtxn = IsTransactionOrTransactionBlock();
+ ReorderBufferChange *change;
if (using_subtxn)
BeginInternalSubTransaction("replay");
rb->begin(rb, txn);
iterstate = ReorderBufferIterTXNInit(rb, txn);
- while ((change = ReorderBufferIterTXNNext(rb, iterstate)))
+ while ((change = ReorderBufferIterTXNNext(rb, iterstate)) != NULL)
{
Relation relation = NULL;
Oid reloid;