From 2ffb87e93fc4075d9d10dbf637c92fb596c39978 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Mon, 13 Jan 2025 10:35:17 -0800 Subject: [PATCH v13 2/2] Rename RBTXN_XXX constants for better consistency. Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch-through: --- src/backend/replication/logical/proto.c | 2 +- .../replication/logical/reorderbuffer.c | 24 +++++++++---------- src/backend/replication/logical/snapbuild.c | 2 +- src/include/replication/reorderbuffer.h | 6 ++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index bef350714db..628228e1228 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -163,7 +163,7 @@ logicalrep_write_prepare_common(StringInfo out, LogicalRepMsgType type, * which case we expect to have a valid GID. */ Assert(txn->gid != NULL); - Assert(rbtxn_prepared(txn)); + Assert(rbtxn_is_prepared_txn(txn)); Assert(TransactionIdIsValid(txn->xid)); /* send the flags field */ diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 39110a2fc70..07203529c1d 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -1793,7 +1793,7 @@ ReorderBufferCheckAndTruncateAbortedTXN(ReorderBuffer *rb, ReorderBufferTXN *txn * and toast reconstruction data. The full cleanup will happen as part of * decoding ABORT record of this transaction. */ - ReorderBufferTruncateTXN(rb, txn, rbtxn_prepared(txn)); + ReorderBufferTruncateTXN(rb, txn, rbtxn_is_prepared_txn(txn)); ReorderBufferToastReset(rb, txn); /* All changes should be discarded */ @@ -1968,7 +1968,7 @@ ReorderBufferStreamCommit(ReorderBuffer *rb, ReorderBufferTXN *txn) ReorderBufferStreamTXN(rb, txn); - if (rbtxn_prepared(txn)) + if (rbtxn_is_prepared_txn(txn)) { /* * Note, we send stream prepare even if a concurrent abort is @@ -2150,7 +2150,7 @@ ReorderBufferResetTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, ReorderBufferChange *specinsert) { /* Discard the changes that we just streamed */ - ReorderBufferTruncateTXN(rb, txn, rbtxn_prepared(txn)); + ReorderBufferTruncateTXN(rb, txn, rbtxn_is_prepared_txn(txn)); /* Free all resources allocated for toast reconstruction */ ReorderBufferToastReset(rb, txn); @@ -2238,7 +2238,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, */ if (!streaming) { - if (rbtxn_prepared(txn)) + if (rbtxn_is_prepared_txn(txn)) rb->begin_prepare(rb, txn); else rb->begin(rb, txn); @@ -2280,7 +2280,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, * required for the cases when we decode the changes before the * COMMIT record is processed. */ - if (streaming || rbtxn_prepared(change->txn)) + if (streaming || rbtxn_is_prepared_txn(change->txn)) { curtxn = change->txn; SetupCheckXidLive(curtxn->xid); @@ -2625,7 +2625,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, * Call either PREPARE (for two-phase transactions) or COMMIT (for * regular ones). */ - if (rbtxn_prepared(txn)) + if (rbtxn_is_prepared_txn(txn)) { rb->prepare(rb, txn, commit_lsn); txn->txn_flags |= RBTXN_SENT_PREPARE; @@ -2679,12 +2679,12 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, * For 4, as the entire txn has been decoded, we can fully clean up * the TXN reorder buffer. */ - if (streaming || rbtxn_prepared(txn)) + if (streaming || rbtxn_is_prepared_txn(txn)) { if (streaming) ReorderBufferMaybeMarkTXNStreamed(rb, txn); - ReorderBufferTruncateTXN(rb, txn, rbtxn_prepared(txn)); + ReorderBufferTruncateTXN(rb, txn, rbtxn_is_prepared_txn(txn)); /* Reset the CheckXidAlive */ CheckXidAlive = InvalidTransactionId; } @@ -2728,7 +2728,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, * during a two-phase commit. */ if (errdata->sqlerrcode == ERRCODE_TRANSACTION_ROLLBACK && - (stream_started || rbtxn_prepared(txn))) + (stream_started || rbtxn_is_prepared_txn(txn))) { /* curtxn must be set for streaming or prepared transactions */ Assert(curtxn); @@ -2815,7 +2815,7 @@ ReorderBufferReplay(ReorderBufferTXN *txn, * Removing this txn before a commit might result in the computation * of an incorrect restart_lsn. See SnapBuildProcessRunningXacts. */ - if (!rbtxn_prepared(txn)) + if (!rbtxn_is_prepared_txn(txn)) ReorderBufferCleanupTXN(rb, txn); return; } @@ -2914,7 +2914,7 @@ ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, if (txn == NULL) return; - txn->txn_flags |= RBTXN_PREPARE; + txn->txn_flags |= RBTXN_IS_PREPARED_TXN; txn->gid = pstrdup(gid); /* The prepare info must have been updated in txn by now. */ @@ -2975,7 +2975,7 @@ ReorderBufferFinishPrepared(ReorderBuffer *rb, TransactionId xid, */ if ((txn->final_lsn < two_phase_at) && is_commit) { - txn->txn_flags |= RBTXN_PREPARE; + txn->txn_flags |= RBTXN_IS_PREPARED_TXN; /* * The prepare info must have been updated in txn even if we skip diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index bbedd3de318..9f33e51f21d 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -761,7 +761,7 @@ SnapBuildDistributeNewCatalogSnapshot(SnapBuild *builder, XLogRecPtr lsn) * We don't need to add snapshot to prepared transactions as they * should not see the new catalog contents. */ - if (rbtxn_prepared(txn) || rbtxn_skip_prepared(txn)) + if (rbtxn_is_prepared_txn(txn) || rbtxn_skip_prepared(txn)) continue; elog(DEBUG2, "adding a new snapshot to %u at %X/%X", diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index 0ce688ef909..36d4a752bcb 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -170,7 +170,7 @@ typedef struct ReorderBufferChange #define RBTXN_IS_SERIALIZED_CLEAR 0x0008 #define RBTXN_IS_STREAMED 0x0010 #define RBTXN_HAS_PARTIAL_CHANGE 0x0020 -#define RBTXN_PREPARE 0x0040 +#define RBTXN_IS_PREPARED_TXN 0x0040 #define RBTXN_SKIPPED_PREPARE 0x0080 #define RBTXN_HAS_STREAMABLE_CHANGE 0x0100 #define RBTXN_SENT_PREPARE 0x0200 @@ -234,9 +234,9 @@ typedef struct ReorderBufferChange * committed. To check whether a prepare or a stream_prepare has already * been sent for this transaction, we need to use rbtxn_sent_prepare(). */ -#define rbtxn_prepared(txn) \ +#define rbtxn_is_prepared_txn(txn) \ ( \ - ((txn)->txn_flags & RBTXN_PREPARE) != 0 \ + ((txn)->txn_flags & RBTXN_IS_PREPARED_TXN) != 0 \ ) /* Has a prepare or stream_prepare already been sent? */ -- 2.43.5