From 316fc9ac7512c406ad8a83b3307d1ebff3966de7 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 22 Sep 2025 14:47:48 +0200 Subject: [PATCH 02/23] C11 anonymous unions [reorderbuffer xact_time] --- contrib/test_decoding/test_decoding.c | 12 ++++++------ src/backend/replication/logical/proto.c | 14 +++++++------- src/backend/replication/logical/reorderbuffer.c | 14 +++++++------- src/backend/replication/pgoutput/pgoutput.c | 2 +- src/include/replication/reorderbuffer.h | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index f671a7d4b31..36e77c69e1c 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -340,7 +340,7 @@ pg_decode_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.commit_time)); + timestamptz_to_str(txn->commit_time)); OutputPluginWrite(ctx, true); } @@ -391,7 +391,7 @@ pg_decode_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.prepare_time)); + timestamptz_to_str(txn->prepare_time)); OutputPluginWrite(ctx, true); } @@ -413,7 +413,7 @@ pg_decode_commit_prepared_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.commit_time)); + timestamptz_to_str(txn->commit_time)); OutputPluginWrite(ctx, true); } @@ -437,7 +437,7 @@ pg_decode_rollback_prepared_txn(LogicalDecodingContext *ctx, if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.commit_time)); + timestamptz_to_str(txn->commit_time)); OutputPluginWrite(ctx, true); } @@ -874,7 +874,7 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx, if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.prepare_time)); + timestamptz_to_str(txn->prepare_time)); OutputPluginWrite(ctx, true); } @@ -903,7 +903,7 @@ pg_decode_stream_commit(LogicalDecodingContext *ctx, if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", - timestamptz_to_str(txn->xact_time.commit_time)); + timestamptz_to_str(txn->commit_time)); OutputPluginWrite(ctx, true); } diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index 1b3d9eb49dd..2436a263dc2 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -52,7 +52,7 @@ logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn) /* fixed fields */ pq_sendint64(out, txn->final_lsn); - pq_sendint64(out, txn->xact_time.commit_time); + pq_sendint64(out, txn->commit_time); pq_sendint32(out, txn->xid); } @@ -88,7 +88,7 @@ logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn, /* send fields */ pq_sendint64(out, commit_lsn); pq_sendint64(out, txn->end_lsn); - pq_sendint64(out, txn->xact_time.commit_time); + pq_sendint64(out, txn->commit_time); } /* @@ -120,7 +120,7 @@ logicalrep_write_begin_prepare(StringInfo out, ReorderBufferTXN *txn) /* fixed fields */ pq_sendint64(out, txn->final_lsn); pq_sendint64(out, txn->end_lsn); - pq_sendint64(out, txn->xact_time.prepare_time); + pq_sendint64(out, txn->prepare_time); pq_sendint32(out, txn->xid); /* send gid */ @@ -173,7 +173,7 @@ logicalrep_write_prepare_common(StringInfo out, LogicalRepMsgType type, /* send fields */ pq_sendint64(out, prepare_lsn); pq_sendint64(out, txn->end_lsn); - pq_sendint64(out, txn->xact_time.prepare_time); + pq_sendint64(out, txn->prepare_time); pq_sendint32(out, txn->xid); /* send gid */ @@ -253,7 +253,7 @@ logicalrep_write_commit_prepared(StringInfo out, ReorderBufferTXN *txn, /* send fields */ pq_sendint64(out, commit_lsn); pq_sendint64(out, txn->end_lsn); - pq_sendint64(out, txn->xact_time.commit_time); + pq_sendint64(out, txn->commit_time); pq_sendint32(out, txn->xid); /* send gid */ @@ -311,7 +311,7 @@ logicalrep_write_rollback_prepared(StringInfo out, ReorderBufferTXN *txn, pq_sendint64(out, prepare_end_lsn); pq_sendint64(out, txn->end_lsn); pq_sendint64(out, prepare_time); - pq_sendint64(out, txn->xact_time.commit_time); + pq_sendint64(out, txn->commit_time); pq_sendint32(out, txn->xid); /* send gid */ @@ -1119,7 +1119,7 @@ logicalrep_write_stream_commit(StringInfo out, ReorderBufferTXN *txn, /* send fields */ pq_sendint64(out, commit_lsn); pq_sendint64(out, txn->end_lsn); - pq_sendint64(out, txn->xact_time.commit_time); + pq_sendint64(out, txn->commit_time); } /* diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 4736f993c37..a5e165fb123 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2830,7 +2830,7 @@ ReorderBufferReplay(ReorderBufferTXN *txn, txn->final_lsn = commit_lsn; txn->end_lsn = end_lsn; - txn->xact_time.commit_time = commit_time; + txn->commit_time = commit_time; txn->origin_id = origin_id; txn->origin_lsn = origin_lsn; @@ -2922,7 +2922,7 @@ ReorderBufferRememberPrepareInfo(ReorderBuffer *rb, TransactionId xid, */ txn->final_lsn = prepare_lsn; txn->end_lsn = end_lsn; - txn->xact_time.prepare_time = prepare_time; + txn->prepare_time = prepare_time; txn->origin_id = origin_id; txn->origin_lsn = origin_lsn; @@ -2979,7 +2979,7 @@ ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, txn->gid = pstrdup(gid); ReorderBufferReplay(txn, rb, xid, txn->final_lsn, txn->end_lsn, - txn->xact_time.prepare_time, txn->origin_id, txn->origin_lsn); + txn->prepare_time, txn->origin_id, txn->origin_lsn); /* * Send a prepare if not already done so. This might occur if we have @@ -3018,7 +3018,7 @@ ReorderBufferFinishPrepared(ReorderBuffer *rb, TransactionId xid, * be later used for rollback. */ prepare_end_lsn = txn->end_lsn; - prepare_time = txn->xact_time.prepare_time; + prepare_time = txn->prepare_time; /* add the gid in the txn */ txn->gid = pstrdup(gid); @@ -3050,12 +3050,12 @@ ReorderBufferFinishPrepared(ReorderBuffer *rb, TransactionId xid, * prepared after the restart. */ ReorderBufferReplay(txn, rb, xid, txn->final_lsn, txn->end_lsn, - txn->xact_time.prepare_time, txn->origin_id, txn->origin_lsn); + txn->prepare_time, txn->origin_id, txn->origin_lsn); } txn->final_lsn = commit_lsn; txn->end_lsn = end_lsn; - txn->xact_time.commit_time = commit_time; + txn->commit_time = commit_time; txn->origin_id = origin_id; txn->origin_lsn = origin_lsn; @@ -3095,7 +3095,7 @@ ReorderBufferAbort(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn, if (txn == NULL) return; - txn->xact_time.abort_time = abort_time; + txn->abort_time = abort_time; /* For streamed transactions notify the remote node about the abort. */ if (rbtxn_is_streamed(txn)) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 80540c017bd..92eb17049c3 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1888,7 +1888,7 @@ pgoutput_stream_abort(struct LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); logicalrep_write_stream_abort(ctx->out, toptxn->xid, txn->xid, abort_lsn, - txn->xact_time.abort_time, write_abort_info); + txn->abort_time, write_abort_info); OutputPluginWrite(ctx, true); diff --git a/src/include/replication/reorderbuffer.h b/src/include/replication/reorderbuffer.h index fa0745552f8..91dc7e5e448 100644 --- a/src/include/replication/reorderbuffer.h +++ b/src/include/replication/reorderbuffer.h @@ -359,7 +359,7 @@ typedef struct ReorderBufferTXN TimestampTz commit_time; TimestampTz prepare_time; TimestampTz abort_time; - } xact_time; + }; /* * The base snapshot is used to decode all changes until either this -- 2.51.0