From 586dd48ddd49bd66e532c8c109b51cc637fe396b Mon Sep 17 00:00:00 2001 From: Maxim Orlov Date: Fri, 11 Mar 2022 11:36:06 +0300 Subject: [PATCH v19 1/5] Use XID_FMT macro to format XIDs Replaces the %u formatting string for XIDs with XID_FMT macro. This simplifyes the change of the XID type and/or it's formatting. Also, this is one step forawrd to 64-bit XIDs. Author: Alexander Korotkov Author: Teodor Sigaev Author: Nikita Glukhov Author: Maxim Orlov Author: Pavel Borisov Author: Yura Sokolov Author: Aleksander Alekseev Reviewed-by: Aleksander Alekseev Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com --- contrib/amcheck/verify_heapam.c | 46 ++++++++--------- contrib/pageinspect/btreefuncs.c | 4 +- contrib/pgrowlocks/pgrowlocks.c | 6 +-- contrib/test_decoding/test_decoding.c | 24 ++++----- src/backend/access/heap/heapam.c | 24 ++++----- src/backend/access/heap/heapam_handler.c | 2 +- src/backend/access/heap/vacuumlazy.c | 6 +-- src/backend/access/rmgrdesc/clogdesc.c | 2 +- src/backend/access/rmgrdesc/committsdesc.c | 2 +- src/backend/access/rmgrdesc/gistdesc.c | 6 +-- src/backend/access/rmgrdesc/hashdesc.c | 2 +- src/backend/access/rmgrdesc/heapdesc.c | 18 +++---- src/backend/access/rmgrdesc/mxactdesc.c | 6 +-- src/backend/access/rmgrdesc/nbtdesc.c | 6 +-- src/backend/access/rmgrdesc/spgdesc.c | 2 +- src/backend/access/rmgrdesc/standbydesc.c | 6 +-- src/backend/access/rmgrdesc/xactdesc.c | 10 ++-- src/backend/access/rmgrdesc/xlogdesc.c | 8 +-- src/backend/access/transam/commit_ts.c | 2 +- src/backend/access/transam/multixact.c | 51 ++++++++++--------- src/backend/access/transam/slru.c | 16 +++--- src/backend/access/transam/subtrans.c | 2 +- src/backend/access/transam/transam.c | 4 +- src/backend/access/transam/twophase.c | 22 ++++---- src/backend/access/transam/xact.c | 8 +-- src/backend/access/transam/xlogrecovery.c | 20 ++++---- src/backend/replication/logical/logical.c | 2 +- .../replication/logical/reorderbuffer.c | 12 ++--- src/backend/replication/logical/snapbuild.c | 18 +++---- src/backend/replication/logical/worker.c | 18 +++---- src/backend/replication/walreceiver.c | 2 +- src/backend/replication/walsender.c | 2 +- src/backend/storage/ipc/procarray.c | 18 +++---- src/backend/storage/ipc/standby.c | 8 +-- src/backend/storage/lmgr/predicate.c | 6 +-- src/backend/utils/adt/lockfuncs.c | 2 +- src/backend/utils/error/csvlog.c | 4 +- src/backend/utils/error/elog.c | 6 +-- src/backend/utils/error/jsonlog.c | 4 +- src/backend/utils/time/snapmgr.c | 18 +++---- src/bin/pg_controldata/pg_controldata.c | 16 +++--- src/bin/pg_dump/pg_dump.c | 6 +-- src/bin/pg_resetwal/pg_resetwal.c | 4 +- src/bin/pg_upgrade/pg_upgrade.c | 18 +++---- src/bin/pg_waldump/pg_waldump.c | 3 +- src/include/c.h | 3 ++ 46 files changed, 239 insertions(+), 236 deletions(-) diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index e5f7355dcb8..59c27902ef0 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -743,21 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx) break; case XID_IN_FUTURE: report_corruption(ctx, - psprintf("xmin %u equals or exceeds next valid transaction ID %u:%u", + psprintf("xmin " XID_FMT " equals or exceeds next valid transaction ID %u:" XID_FMT, xmin, EpochFromFullTransactionId(ctx->next_fxid), XidFromFullTransactionId(ctx->next_fxid))); return false; case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("xmin %u precedes oldest valid transaction ID %u:%u", + psprintf("xmin " XID_FMT " precedes oldest valid transaction ID %u:" XID_FMT, xmin, EpochFromFullTransactionId(ctx->oldest_fxid), XidFromFullTransactionId(ctx->oldest_fxid))); return false; case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("xmin %u precedes relation freeze threshold %u:%u", + psprintf("xmin " XID_FMT " precedes relation freeze threshold %u:" XID_FMT, xmin, EpochFromFullTransactionId(ctx->relfrozenfxid), XidFromFullTransactionId(ctx->relfrozenfxid))); @@ -784,21 +784,21 @@ check_tuple_visibility(HeapCheckContext *ctx) return false; case XID_IN_FUTURE: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple equals or exceeds next valid transaction ID %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved off tuple equals or exceeds next valid transaction ID %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->next_fxid), XidFromFullTransactionId(ctx->next_fxid))); return false; case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes relation freeze threshold %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved off tuple precedes relation freeze threshold %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->relfrozenfxid), XidFromFullTransactionId(ctx->relfrozenfxid))); return false; case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple precedes oldest valid transaction ID %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved off tuple precedes oldest valid transaction ID %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->oldest_fxid), XidFromFullTransactionId(ctx->oldest_fxid))); @@ -811,12 +811,12 @@ check_tuple_visibility(HeapCheckContext *ctx) { case XID_IS_CURRENT_XID: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple matches our current transaction ID", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved off tuple matches our current transaction ID", xvac)); return false; case XID_IN_PROGRESS: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved off tuple appears to be in progress", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved off tuple appears to be in progress", xvac)); return false; @@ -853,21 +853,21 @@ check_tuple_visibility(HeapCheckContext *ctx) return false; case XID_IN_FUTURE: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple equals or exceeds next valid transaction ID %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved in tuple equals or exceeds next valid transaction ID %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->next_fxid), XidFromFullTransactionId(ctx->next_fxid))); return false; case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes relation freeze threshold %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved in tuple precedes relation freeze threshold %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->relfrozenfxid), XidFromFullTransactionId(ctx->relfrozenfxid))); return false; case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple precedes oldest valid transaction ID %u:%u", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved in tuple precedes oldest valid transaction ID %u:" XID_FMT, xvac, EpochFromFullTransactionId(ctx->oldest_fxid), XidFromFullTransactionId(ctx->oldest_fxid))); @@ -880,12 +880,12 @@ check_tuple_visibility(HeapCheckContext *ctx) { case XID_IS_CURRENT_XID: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple matches our current transaction ID", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved in tuple matches our current transaction ID", xvac)); return false; case XID_IN_PROGRESS: report_corruption(ctx, - psprintf("old-style VACUUM FULL transaction ID %u for moved in tuple appears to be in progress", + psprintf("old-style VACUUM FULL transaction ID " XID_FMT " for moved in tuple appears to be in progress", xvac)); return false; @@ -956,17 +956,17 @@ check_tuple_visibility(HeapCheckContext *ctx) return true; case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("multitransaction ID %u precedes relation minimum multitransaction ID threshold %u", + psprintf("multitransaction ID " XID_FMT " precedes relation minimum multitransaction ID threshold " XID_FMT, xmax, ctx->relminmxid)); return true; case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u", + psprintf("multitransaction ID " XID_FMT " precedes oldest valid multitransaction ID threshold " XID_FMT, xmax, ctx->oldest_mxact)); return true; case XID_IN_FUTURE: report_corruption(ctx, - psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u", + psprintf("multitransaction ID " XID_FMT " equals or exceeds next valid multitransaction ID " XID_FMT, xmax, ctx->next_mxact)); return true; @@ -1014,21 +1014,21 @@ check_tuple_visibility(HeapCheckContext *ctx) return true; case XID_IN_FUTURE: report_corruption(ctx, - psprintf("update xid %u equals or exceeds next valid transaction ID %u:%u", + psprintf("update xid " XID_FMT " equals or exceeds next valid transaction ID %u:" XID_FMT, xmax, EpochFromFullTransactionId(ctx->next_fxid), XidFromFullTransactionId(ctx->next_fxid))); return true; case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("update xid %u precedes relation freeze threshold %u:%u", + psprintf("update xid " XID_FMT " precedes relation freeze threshold %u:" XID_FMT, xmax, EpochFromFullTransactionId(ctx->relfrozenfxid), XidFromFullTransactionId(ctx->relfrozenfxid))); return true; case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("update xid %u precedes oldest valid transaction ID %u:%u", + psprintf("update xid " XID_FMT " precedes oldest valid transaction ID %u:" XID_FMT, xmax, EpochFromFullTransactionId(ctx->oldest_fxid), XidFromFullTransactionId(ctx->oldest_fxid))); @@ -1076,23 +1076,21 @@ check_tuple_visibility(HeapCheckContext *ctx) { case XID_IN_FUTURE: report_corruption(ctx, - psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u", + psprintf("xmax " XID_FMT " equals or exceeds next valid transaction ID %u:" XID_FMT, xmax, EpochFromFullTransactionId(ctx->next_fxid), XidFromFullTransactionId(ctx->next_fxid))); return false; /* corrupt */ case XID_PRECEDES_RELMIN: report_corruption(ctx, - psprintf("xmax %u precedes relation freeze threshold %u:%u", + psprintf("xmax " XID_FMT " precedes relation freeze threshold " XID_FMT, xmax, - EpochFromFullTransactionId(ctx->relfrozenfxid), XidFromFullTransactionId(ctx->relfrozenfxid))); return false; /* corrupt */ case XID_PRECEDES_CLUSTERMIN: report_corruption(ctx, - psprintf("xmax %u precedes oldest valid transaction ID %u:%u", + psprintf("xmax " XID_FMT " precedes oldest valid transaction ID " XID_FMT, xmax, - EpochFromFullTransactionId(ctx->oldest_fxid), XidFromFullTransactionId(ctx->oldest_fxid))); return false; /* corrupt */ case XID_BOUNDS_OK: diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c index 03debe336ba..e257dfa0ac9 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -125,12 +125,12 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat) { FullTransactionId safexid = BTPageGetDeleteXid(page); - elog(DEBUG2, "deleted page from block %u has safexid %u:%u", + elog(DEBUG2, "deleted page from block %u has safexid %u:" XID_FMT, blkno, EpochFromFullTransactionId(safexid), XidFromFullTransactionId(safexid)); } else - elog(DEBUG2, "deleted page from block %u has safexid %u", + elog(DEBUG2, "deleted page from block %u has safexid " XID_FMT, blkno, opaque->btpo_level); /* Don't interpret BTDeletedPageData as index tuples */ diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c index 713a165203e..80e5b01846f 100644 --- a/contrib/pgrowlocks/pgrowlocks.c +++ b/contrib/pgrowlocks/pgrowlocks.c @@ -142,7 +142,7 @@ pgrowlocks(PG_FUNCTION_ARGS) PointerGetDatum(&tuple->t_self)); values[Atnum_xmax] = palloc(NCHARS * sizeof(char)); - snprintf(values[Atnum_xmax], NCHARS, "%u", xmax); + snprintf(values[Atnum_xmax], NCHARS, XID_FMT, xmax); if (infomask & HEAP_XMAX_IS_MULTI) { MultiXactMember *members; @@ -183,7 +183,7 @@ pgrowlocks(PG_FUNCTION_ARGS) strcat(values[Atnum_modes], ","); strcat(values[Atnum_pids], ","); } - snprintf(buf, NCHARS, "%u", members[j].xid); + snprintf(buf, NCHARS, XID_FMT, members[j].xid); strcat(values[Atnum_xids], buf); switch (members[j].status) { @@ -224,7 +224,7 @@ pgrowlocks(PG_FUNCTION_ARGS) values[Atnum_ismulti] = pstrdup("false"); values[Atnum_xids] = palloc(NCHARS * sizeof(char)); - snprintf(values[Atnum_xids], NCHARS, "{%u}", xmax); + snprintf(values[Atnum_xids], NCHARS, "{" XID_FMT "}", xmax); values[Atnum_modes] = palloc(NCHARS); if (infomask & HEAP_XMAX_LOCK_ONLY) diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index ea22649e41d..523ed6ef64b 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -333,7 +333,7 @@ pg_output_begin(LogicalDecodingContext *ctx, TestDecodingData *data, ReorderBuff { OutputPluginPrepareWrite(ctx, last_write); if (data->include_xids) - appendStringInfo(ctx->out, "BEGIN %u", txn->xid); + appendStringInfo(ctx->out, "BEGIN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "BEGIN"); OutputPluginWrite(ctx, last_write); @@ -356,7 +356,7 @@ pg_decode_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "COMMIT %u", txn->xid); + appendStringInfo(ctx->out, "COMMIT " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "COMMIT"); @@ -401,7 +401,7 @@ pg_decode_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, quote_literal_cstr(txn->gid)); if (data->include_xids) - appendStringInfo(ctx->out, ", txid %u", txn->xid); + appendStringInfo(ctx->out, ", txid " XID_FMT, txn->xid); if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", @@ -423,7 +423,7 @@ pg_decode_commit_prepared_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn quote_literal_cstr(txn->gid)); if (data->include_xids) - appendStringInfo(ctx->out, ", txid %u", txn->xid); + appendStringInfo(ctx->out, ", txid " XID_FMT, txn->xid); if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", @@ -447,7 +447,7 @@ pg_decode_rollback_prepared_txn(LogicalDecodingContext *ctx, quote_literal_cstr(txn->gid)); if (data->include_xids) - appendStringInfo(ctx->out, ", txid %u", txn->xid); + appendStringInfo(ctx->out, ", txid " XID_FMT, txn->xid); if (data->include_timestamp) appendStringInfo(ctx->out, " (at %s)", @@ -828,7 +828,7 @@ pg_output_stream_start(LogicalDecodingContext *ctx, TestDecodingData *data, Reor { OutputPluginPrepareWrite(ctx, last_write); if (data->include_xids) - appendStringInfo(ctx->out, "opening a streamed block for transaction TXN %u", txn->xid); + appendStringInfo(ctx->out, "opening a streamed block for transaction TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "opening a streamed block for transaction"); OutputPluginWrite(ctx, last_write); @@ -846,7 +846,7 @@ pg_decode_stream_stop(LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "closing a streamed block for transaction TXN %u", txn->xid); + appendStringInfo(ctx->out, "closing a streamed block for transaction TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "closing a streamed block for transaction"); OutputPluginWrite(ctx, true); @@ -880,7 +880,7 @@ pg_decode_stream_abort(LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "aborting streamed (sub)transaction TXN %u", txn->xid); + appendStringInfo(ctx->out, "aborting streamed (sub)transaction TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "aborting streamed (sub)transaction"); OutputPluginWrite(ctx, true); @@ -900,7 +900,7 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u", + appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid " XID_FMT, quote_literal_cstr(txn->gid), txn->xid); else appendStringInfo(ctx->out, "preparing streamed transaction %s", @@ -931,7 +931,7 @@ pg_decode_stream_commit(LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "committing streamed transaction TXN %u", txn->xid); + appendStringInfo(ctx->out, "committing streamed transaction TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "committing streamed transaction"); @@ -965,7 +965,7 @@ pg_decode_stream_change(LogicalDecodingContext *ctx, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "streaming change for TXN %u", txn->xid); + appendStringInfo(ctx->out, "streaming change for TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "streaming change for transaction"); OutputPluginWrite(ctx, true); @@ -1050,7 +1050,7 @@ pg_decode_stream_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, OutputPluginPrepareWrite(ctx, true); if (data->include_xids) - appendStringInfo(ctx->out, "streaming truncate for TXN %u", txn->xid); + appendStringInfo(ctx->out, "streaming truncate for TXN " XID_FMT, txn->xid); else appendStringInfoString(ctx->out, "streaming truncate for transaction"); OutputPluginWrite(ctx, true); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 3746336a09d..47fddd2b107 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -5198,7 +5198,7 @@ l5: * TransactionIdIsInProgress() should have returned false. We * assume it's no longer locked in this case. */ - elog(WARNING, "LOCK_ONLY found for Xid in progress %u", xmax); + elog(WARNING, "LOCK_ONLY found for Xid in progress " XID_FMT, xmax); old_infomask |= HEAP_XMAX_INVALID; old_infomask &= ~HEAP_XMAX_LOCK_ONLY; goto l5; @@ -6173,7 +6173,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, else if (MultiXactIdPrecedes(multi, relminmxid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found multixact %u from before relminmxid %u", + errmsg_internal("found multixact " XID_FMT " from before relminmxid " XID_FMT, multi, relminmxid))); else if (MultiXactIdPrecedes(multi, cutoff_multi)) { @@ -6187,7 +6187,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("multixact %u from before cutoff %u found to be still running", + errmsg_internal("multixact " XID_FMT " from before cutoff " XID_FMT " found to be still running", multi, cutoff_multi))); if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask)) @@ -6206,7 +6206,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, if (TransactionIdPrecedes(xid, relfrozenxid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found update xid %u from before relfrozenxid %u", + errmsg_internal("found update xid " XID_FMT " from before relfrozenxid " XID_FMT, xid, relfrozenxid))); /* @@ -6218,7 +6218,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, if (TransactionIdDidCommit(xid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("cannot freeze committed update xid %u", xid))); + errmsg_internal("cannot freeze committed update xid " XID_FMT, xid))); *flags |= FRM_INVALIDATE_XMAX; xid = InvalidTransactionId; /* not strictly necessary */ } @@ -6294,7 +6294,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, if (TransactionIdPrecedes(xid, relfrozenxid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found update xid %u from before relfrozenxid %u", + errmsg_internal("found update xid " XID_FMT " from before relfrozenxid " XID_FMT, xid, relfrozenxid))); /* @@ -6344,7 +6344,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, TransactionIdPrecedes(update_xid, cutoff_xid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found update xid %u from before xid cutoff %u", + errmsg_internal("found update xid " XID_FMT " from before xid cutoff " XID_FMT, update_xid, cutoff_xid))); /* @@ -6474,7 +6474,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, if (TransactionIdPrecedes(xid, relfrozenxid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found xmin %u from before relfrozenxid %u", + errmsg_internal("found xmin " XID_FMT " from before relfrozenxid " XID_FMT, xid, relfrozenxid))); xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid); @@ -6483,7 +6483,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, if (!TransactionIdDidCommit(xid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("uncommitted xmin %u from before xid cutoff %u needs to be frozen", + errmsg_internal("uncommitted xmin " XID_FMT " from before xid cutoff " XID_FMT " needs to be frozen", xid, cutoff_xid))); frz->t_infomask |= HEAP_XMIN_FROZEN; @@ -6555,7 +6555,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, if (TransactionIdPrecedes(xid, relfrozenxid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found xmax %u from before relfrozenxid %u", + errmsg_internal("found xmax " XID_FMT " from before relfrozenxid " XID_FMT, xid, relfrozenxid))); if (TransactionIdPrecedes(xid, cutoff_xid)) @@ -6570,7 +6570,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, TransactionIdDidCommit(xid)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("cannot freeze committed xmax %u", + errmsg_internal("cannot freeze committed xmax " XID_FMT, xid))); freeze_xmax = true; } @@ -6586,7 +6586,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, else ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("found xmax %u (infomask 0x%04x) not frozen, not multi, not normal", + errmsg_internal("found xmax " XID_FMT " (infomask 0x%04x) not frozen, not multi, not normal", xid, tuple->t_infomask))); if (freeze_xmax) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 39ef8a0b77d..c9613f51c34 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -424,7 +424,7 @@ tuple_lock_retry: if (TransactionIdIsValid(SnapshotDirty.xmin)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_internal("t_xmin %u is uncommitted in tuple (%u,%u) to be updated in table \"%s\"", + errmsg_internal("t_xmin " XID_FMT " is uncommitted in tuple (%u,%u) to be updated in table \"%s\"", SnapshotDirty.xmin, ItemPointerGetBlockNumber(&tuple->t_self), ItemPointerGetOffsetNumber(&tuple->t_self), diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 87ab7775aee..1c4df68f64b 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -690,20 +690,20 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, vacrel->missed_dead_pages); diff = (int32) (ReadNextTransactionId() - OldestXmin); appendStringInfo(&buf, - _("removable cutoff: %u, older by %d xids when operation ended\n"), + _("removable cutoff: " XID_FMT ", older by %d xids when operation ended\n"), OldestXmin, diff); if (frozenxid_updated) { diff = (int32) (FreezeLimit - vacrel->relfrozenxid); appendStringInfo(&buf, - _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"), + _("new relfrozenxid: " XID_FMT ", which is %d xids ahead of previous value\n"), FreezeLimit, diff); } if (minmulti_updated) { diff = (int32) (MultiXactCutoff - vacrel->relminmxid); appendStringInfo(&buf, - _("new relminmxid: %u, which is %d mxids ahead of previous value\n"), + _("new relminmxid: " XID_FMT ", which is %d mxids ahead of previous value\n"), MultiXactCutoff, diff); } if (orig_rel_pages > 0) diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c index 87513732be6..4b7cc4d574f 100644 --- a/src/backend/access/rmgrdesc/clogdesc.c +++ b/src/backend/access/rmgrdesc/clogdesc.c @@ -35,7 +35,7 @@ clog_desc(StringInfo buf, XLogReaderState *record) xl_clog_truncate xlrec; memcpy(&xlrec, rec, sizeof(xl_clog_truncate)); - appendStringInfo(buf, "page %d; oldestXact %u", + appendStringInfo(buf, "page %d; oldestXact " XID_FMT, xlrec.pageno, xlrec.oldestXact); } } diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c index 3a65538bb0a..94633cadac8 100644 --- a/src/backend/access/rmgrdesc/committsdesc.c +++ b/src/backend/access/rmgrdesc/committsdesc.c @@ -35,7 +35,7 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record) { xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec; - appendStringInfo(buf, "pageno %d, oldestXid %u", + appendStringInfo(buf, "pageno %d, oldestXid " XID_FMT, trunc->pageno, trunc->oldestXid); } } diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c index 9cab4fa1580..d39059c6f4e 100644 --- a/src/backend/access/rmgrdesc/gistdesc.c +++ b/src/backend/access/rmgrdesc/gistdesc.c @@ -26,7 +26,7 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec) static void out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec) { - appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%u", + appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:" XID_FMT, xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode, xlrec->block, EpochFromFullTransactionId(xlrec->latestRemovedFullXid), @@ -36,7 +36,7 @@ out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec) static void out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec) { - appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u", + appendStringInfo(buf, "delete: latestRemovedXid " XID_FMT ", nitems: %u", xlrec->latestRemovedXid, xlrec->ntodelete); } @@ -51,7 +51,7 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec) static void out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec) { - appendStringInfo(buf, "deleteXid %u:%u; downlink %u", + appendStringInfo(buf, "deleteXid %u:" XID_FMT "; downlink %u", EpochFromFullTransactionId(xlrec->deleteXid), XidFromFullTransactionId(xlrec->deleteXid), xlrec->downlinkOffset); diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c index ef443bdb16c..d9f0c40fbfe 100644 --- a/src/backend/access/rmgrdesc/hashdesc.c +++ b/src/backend/access/rmgrdesc/hashdesc.c @@ -113,7 +113,7 @@ hash_desc(StringInfo buf, XLogReaderState *record) { xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec; - appendStringInfo(buf, "ntuples %d, latestRemovedXid %u", + appendStringInfo(buf, "ntuples %d, latestRemovedXid " XID_FMT, xlrec->ntuples, xlrec->latestRemovedXid); break; diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c index 6238085d65e..ef3cc7f0c87 100644 --- a/src/backend/access/rmgrdesc/heapdesc.c +++ b/src/backend/access/rmgrdesc/heapdesc.c @@ -58,12 +58,12 @@ heap_desc(StringInfo buf, XLogReaderState *record) { xl_heap_update *xlrec = (xl_heap_update *) rec; - appendStringInfo(buf, "off %u xmax %u flags 0x%02X ", + appendStringInfo(buf, "off %u xmax " XID_FMT " flags 0x%02X ", xlrec->old_offnum, xlrec->old_xmax, xlrec->flags); out_infobits(buf, xlrec->old_infobits_set); - appendStringInfo(buf, "; new off %u xmax %u", + appendStringInfo(buf, "; new off %u xmax " XID_FMT, xlrec->new_offnum, xlrec->new_xmax); } @@ -71,12 +71,12 @@ heap_desc(StringInfo buf, XLogReaderState *record) { xl_heap_update *xlrec = (xl_heap_update *) rec; - appendStringInfo(buf, "off %u xmax %u flags 0x%02X ", + appendStringInfo(buf, "off %u xmax " XID_FMT " flags 0x%02X ", xlrec->old_offnum, xlrec->old_xmax, xlrec->flags); out_infobits(buf, xlrec->old_infobits_set); - appendStringInfo(buf, "; new off %u xmax %u", + appendStringInfo(buf, "; new off %u xmax " XID_FMT, xlrec->new_offnum, xlrec->new_xmax); } @@ -103,7 +103,7 @@ heap_desc(StringInfo buf, XLogReaderState *record) { xl_heap_lock *xlrec = (xl_heap_lock *) rec; - appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ", + appendStringInfo(buf, "off %u: xid " XID_FMT ": flags 0x%02X ", xlrec->offnum, xlrec->locking_xid, xlrec->flags); out_infobits(buf, xlrec->infobits_set); } @@ -125,7 +125,7 @@ heap2_desc(StringInfo buf, XLogReaderState *record) { xl_heap_prune *xlrec = (xl_heap_prune *) rec; - appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u", + appendStringInfo(buf, "latestRemovedXid " XID_FMT " nredirected %u ndead %u", xlrec->latestRemovedXid, xlrec->nredirected, xlrec->ndead); @@ -140,14 +140,14 @@ heap2_desc(StringInfo buf, XLogReaderState *record) { xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec; - appendStringInfo(buf, "cutoff xid %u ntuples %u", + appendStringInfo(buf, "cutoff xid " XID_FMT " ntuples %u", xlrec->cutoff_xid, xlrec->ntuples); } else if (info == XLOG_HEAP2_VISIBLE) { xl_heap_visible *xlrec = (xl_heap_visible *) rec; - appendStringInfo(buf, "cutoff xid %u flags 0x%02X", + appendStringInfo(buf, "cutoff xid " XID_FMT " flags 0x%02X", xlrec->cutoff_xid, xlrec->flags); } else if (info == XLOG_HEAP2_MULTI_INSERT) @@ -161,7 +161,7 @@ heap2_desc(StringInfo buf, XLogReaderState *record) { xl_heap_lock_updated *xlrec = (xl_heap_lock_updated *) rec; - appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ", + appendStringInfo(buf, "off %u: xmax " XID_FMT ": flags 0x%02X ", xlrec->offnum, xlrec->xmax, xlrec->flags); out_infobits(buf, xlrec->infobits_set); } diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c index 7076be2b3f2..c53671fe61a 100644 --- a/src/backend/access/rmgrdesc/mxactdesc.c +++ b/src/backend/access/rmgrdesc/mxactdesc.c @@ -19,7 +19,7 @@ static void out_member(StringInfo buf, MultiXactMember *member) { - appendStringInfo(buf, "%u ", member->xid); + appendStringInfo(buf, XID_FMT " ", member->xid); switch (member->status) { case MultiXactStatusForKeyShare: @@ -65,7 +65,7 @@ multixact_desc(StringInfo buf, XLogReaderState *record) xl_multixact_create *xlrec = (xl_multixact_create *) rec; int i; - appendStringInfo(buf, "%u offset %u nmembers %d: ", xlrec->mid, + appendStringInfo(buf, XID_FMT " offset %u nmembers %d: ", xlrec->mid, xlrec->moff, xlrec->nmembers); for (i = 0; i < xlrec->nmembers; i++) out_member(buf, &xlrec->members[i]); @@ -74,7 +74,7 @@ multixact_desc(StringInfo buf, XLogReaderState *record) { xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec; - appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)", + appendStringInfo(buf, "offsets [" XID_FMT ", " XID_FMT "), members [%u, %u)", xlrec->startTruncOff, xlrec->endTruncOff, xlrec->startTruncMemb, xlrec->endTruncMemb); } diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c index dfbbf4ebaf8..2fce072294e 100644 --- a/src/backend/access/rmgrdesc/nbtdesc.c +++ b/src/backend/access/rmgrdesc/nbtdesc.c @@ -63,7 +63,7 @@ btree_desc(StringInfo buf, XLogReaderState *record) { xl_btree_delete *xlrec = (xl_btree_delete *) rec; - appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u", + appendStringInfo(buf, "latestRemovedXid " XID_FMT "; ndeleted %u; nupdated %u", xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated); break; } @@ -80,7 +80,7 @@ btree_desc(StringInfo buf, XLogReaderState *record) { xl_btree_unlink_page *xlrec = (xl_btree_unlink_page *) rec; - appendStringInfo(buf, "left %u; right %u; level %u; safexid %u:%u; ", + appendStringInfo(buf, "left %u; right %u; level %u; safexid %u:" XID_FMT "; ", xlrec->leftsib, xlrec->rightsib, xlrec->level, EpochFromFullTransactionId(xlrec->safexid), XidFromFullTransactionId(xlrec->safexid)); @@ -100,7 +100,7 @@ btree_desc(StringInfo buf, XLogReaderState *record) { xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec; - appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%u", + appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:" XID_FMT, xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode, EpochFromFullTransactionId(xlrec->latestRemovedFullXid), diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c index d5d921a42a1..a094ac738b4 100644 --- a/src/backend/access/rmgrdesc/spgdesc.c +++ b/src/backend/access/rmgrdesc/spgdesc.c @@ -118,7 +118,7 @@ spg_desc(StringInfo buf, XLogReaderState *record) { spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec; - appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, newestredirectxid: %u", + appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, newestredirectxid: " XID_FMT, xlrec->nToPlaceholder, xlrec->firstPlaceholder, xlrec->newestRedirectXid); diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c index 2dba39e349c..57fa4b729ed 100644 --- a/src/backend/access/rmgrdesc/standbydesc.c +++ b/src/backend/access/rmgrdesc/standbydesc.c @@ -21,7 +21,7 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec) { int i; - appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u", + appendStringInfo(buf, "nextXid " XID_FMT " latestCompletedXid " XID_FMT " oldestRunningXid " XID_FMT, xlrec->nextXid, xlrec->latestCompletedXid, xlrec->oldestRunningXid); @@ -29,7 +29,7 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec) { appendStringInfo(buf, "; %d xacts:", xlrec->xcnt); for (i = 0; i < xlrec->xcnt; i++) - appendStringInfo(buf, " %u", xlrec->xids[i]); + appendStringInfo(buf, " " XID_FMT, xlrec->xids[i]); } if (xlrec->subxid_overflow) @@ -48,7 +48,7 @@ standby_desc(StringInfo buf, XLogReaderState *record) int i; for (i = 0; i < xlrec->nlocks; i++) - appendStringInfo(buf, "xid %u db %u rel %u ", + appendStringInfo(buf, "xid " XID_FMT " db %u rel %u ", xlrec->locks[i].xid, xlrec->locks[i].dbOid, xlrec->locks[i].relOid); } diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c index 025d556f6ce..0e9b8a36770 100644 --- a/src/backend/access/rmgrdesc/xactdesc.c +++ b/src/backend/access/rmgrdesc/xactdesc.c @@ -276,7 +276,7 @@ xact_desc_subxacts(StringInfo buf, int nsubxacts, TransactionId *subxacts) { appendStringInfoString(buf, "; subxacts:"); for (i = 0; i < nsubxacts; i++) - appendStringInfo(buf, " %u", subxacts[i]); + appendStringInfo(buf, " " XID_FMT, subxacts[i]); } } @@ -289,7 +289,7 @@ xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId /* If this is a prepared xact, show the xid of the original xact */ if (TransactionIdIsValid(parsed.twophase_xid)) - appendStringInfo(buf, "%u: ", parsed.twophase_xid); + appendStringInfo(buf, XID_FMT ": ", parsed.twophase_xid); appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time)); @@ -324,7 +324,7 @@ xact_desc_abort(StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId or /* If this is a prepared xact, show the xid of the original xact */ if (TransactionIdIsValid(parsed.twophase_xid)) - appendStringInfo(buf, "%u: ", parsed.twophase_xid); + appendStringInfo(buf, XID_FMT ": ", parsed.twophase_xid); appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time)); @@ -377,7 +377,7 @@ xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec) appendStringInfoString(buf, "subxacts:"); for (i = 0; i < xlrec->nsubxacts; i++) - appendStringInfo(buf, " %u", xlrec->xsub[i]); + appendStringInfo(buf, " " XID_FMT, xlrec->xsub[i]); } void @@ -416,7 +416,7 @@ xact_desc(StringInfo buf, XLogReaderState *record) * interested in the top-level xid that issued the record and which * xids are being reported here. */ - appendStringInfo(buf, "xtop %u: ", xlrec->xtop); + appendStringInfo(buf, "xtop " XID_FMT ": ", xlrec->xtop); xact_desc_assignment(buf, xlrec); } else if (info == XLOG_XACT_INVALIDATIONS) diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c index e7452af6790..82ffc2eaabf 100644 --- a/src/backend/access/rmgrdesc/xlogdesc.c +++ b/src/backend/access/rmgrdesc/xlogdesc.c @@ -45,10 +45,10 @@ xlog_desc(StringInfo buf, XLogReaderState *record) CheckPoint *checkpoint = (CheckPoint *) rec; appendStringInfo(buf, "redo %X/%X; " - "tli %u; prev tli %u; fpw %s; xid %u:%u; oid %u; multi %u; offset %u; " - "oldest xid %u in DB %u; oldest multi %u in DB %u; " - "oldest/newest commit timestamp xid: %u/%u; " - "oldest running xid %u; %s", + "tli %u; prev tli %u; fpw %s; xid %u:" XID_FMT "; oid %u; multi " XID_FMT "; offset %u; " + "oldest xid " XID_FMT " in DB %u; oldest multi " XID_FMT " in DB %u; " + "oldest/newest commit timestamp xid: " XID_FMT "/" XID_FMT "; " + "oldest running xid " XID_FMT "; %s", LSN_FORMAT_ARGS(checkpoint->redo), checkpoint->ThisTimeLineID, checkpoint->PrevTimeLineID, diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c index 20950eb1e4a..bc75f7e77a0 100644 --- a/src/backend/access/transam/commit_ts.c +++ b/src/backend/access/transam/commit_ts.c @@ -279,7 +279,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts, if (!TransactionIdIsValid(xid)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("cannot retrieve commit timestamp for transaction %u", xid))); + errmsg("cannot retrieve commit timestamp for transaction " XID_FMT, xid))); else if (!TransactionIdIsNormal(xid)) { /* frozen and bootstrap xids are always committed far in the past */ diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 6a70d497380..cb4ed41d5ee 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -451,7 +451,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status) /* MultiXactIdSetOldestMember() must have been called already. */ Assert(MultiXactIdIsValid(OldestMemberMXactId[MyBackendId])); - debug_elog5(DEBUG2, "Expand: received multi %u, xid %u status %s", + debug_elog5(DEBUG2, "Expand: received multi " XID_FMT ", xid " XID_FMT " status %s", multi, xid, mxstatus_to_string(status)); /* @@ -476,7 +476,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status) member.status = status; newMulti = MultiXactIdCreateFromMembers(1, &member); - debug_elog4(DEBUG2, "Expand: %u has no members, create singleton %u", + debug_elog4(DEBUG2, "Expand: " XID_FMT " has no members, create singleton " XID_FMT, multi, newMulti); return newMulti; } @@ -490,7 +490,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status) if (TransactionIdEquals(members[i].xid, xid) && (members[i].status == status)) { - debug_elog4(DEBUG2, "Expand: %u is already a member of %u", + debug_elog4(DEBUG2, "Expand: " XID_FMT " is already a member of " XID_FMT, xid, multi); pfree(members); return multi; @@ -526,12 +526,13 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status) newMembers[j].xid = xid; newMembers[j++].status = status; + newMulti = MultiXactIdCreateFromMembers(j, newMembers); pfree(members); pfree(newMembers); - debug_elog3(DEBUG2, "Expand: returning new multi %u", newMulti); + debug_elog3(DEBUG2, "Expand: returning new multi " XID_FMT, newMulti); return newMulti; } @@ -554,7 +555,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly) int nmembers; int i; - debug_elog3(DEBUG2, "IsRunning %u?", multi); + debug_elog3(DEBUG2, "IsRunning " XID_FMT "?", multi); /* * "false" here means we assume our callers have checked that the given @@ -594,7 +595,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly) { if (TransactionIdIsInProgress(members[i].xid)) { - debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running", + debug_elog4(DEBUG2, "IsRunning: member %d (" XID_FMT ") is running", i, members[i].xid); pfree(members); return true; @@ -603,7 +604,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly) pfree(members); - debug_elog3(DEBUG2, "IsRunning: %u is not running", multi); + debug_elog3(DEBUG2, "IsRunning: " XID_FMT " is not running", multi); return false; } @@ -657,7 +658,7 @@ MultiXactIdSetOldestMember(void) LWLockRelease(MultiXactGenLock); - debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u", + debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = " XID_FMT, MyBackendId, nextMXact); } } @@ -722,7 +723,7 @@ MultiXactIdSetOldestVisible(void) LWLockRelease(MultiXactGenLock); - debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u", + debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = " XID_FMT, MyBackendId, oldestMXact); } } @@ -1200,7 +1201,7 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset) LWLockRelease(MultiXactGenLock); - debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset); + debug_elog4(DEBUG2, "GetNew: returning " XID_FMT " offset %u", result, *offset); return result; } @@ -1250,7 +1251,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members, MultiXactOffset nextOffset; MultiXactMember *ptr; - debug_elog3(DEBUG2, "GetMembers: asked for %u", multi); + debug_elog3(DEBUG2, "GetMembers: asked for " XID_FMT, multi); if (!MultiXactIdIsValid(multi) || from_pgupgrade) { @@ -1529,7 +1530,7 @@ mXactCacheGetBySet(int nmembers, MultiXactMember *members) */ if (memcmp(members, entry->members, nmembers * sizeof(MultiXactMember)) == 0) { - debug_elog3(DEBUG2, "CacheGet: found %u", entry->multi); + debug_elog3(DEBUG2, "CacheGet: found " XID_FMT, entry->multi); dlist_move_head(&MXactCache, iter.cur); return entry->multi; } @@ -1552,7 +1553,7 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members) { dlist_iter iter; - debug_elog3(DEBUG2, "CacheGet: looking for %u", multi); + debug_elog3(DEBUG2, "CacheGet: looking for " XID_FMT, multi); dlist_foreach(iter, &MXactCache) { @@ -1633,7 +1634,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members) MXactCacheMembers--; entry = dlist_container(mXactCacheEnt, node, node); - debug_elog3(DEBUG2, "CachePut: pruning cached multi %u", + debug_elog3(DEBUG2, "CachePut: pruning cached multi " XID_FMT, entry->multi); pfree(entry); @@ -1675,11 +1676,11 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members) initStringInfo(&buf); - appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid, + appendStringInfo(&buf, XID_FMT " %d[" XID_FMT " (%s)", multi, nmembers, members[0].xid, mxstatus_to_string(members[0].status)); for (i = 1; i < nmembers; i++) - appendStringInfo(&buf, ", %u (%s)", members[i].xid, + appendStringInfo(&buf, ", " XID_FMT " (%s)", members[i].xid, mxstatus_to_string(members[i].status)); appendStringInfoChar(&buf, ']'); @@ -2156,7 +2157,7 @@ MultiXactGetCheckptMulti(bool is_shutdown, LWLockRelease(MultiXactGenLock); debug_elog6(DEBUG2, - "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u", + "MultiXact: checkpoint is nextMulti " XID_FMT ", nextOffset %u, oldestMulti " XID_FMT " in DB %u", *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB); } @@ -2191,7 +2192,7 @@ void MultiXactSetNextMXact(MultiXactId nextMulti, MultiXactOffset nextMultiOffset) { - debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u", + debug_elog4(DEBUG2, "MultiXact: setting next multi to " XID_FMT " offset %u", nextMulti, nextMultiOffset); LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE); MultiXactState->nextMXact = nextMulti; @@ -2377,7 +2378,7 @@ MultiXactAdvanceNextMXact(MultiXactId minMulti, LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE); if (MultiXactIdPrecedes(MultiXactState->nextMXact, minMulti)) { - debug_elog3(DEBUG2, "MultiXact: setting next multi to %u", minMulti); + debug_elog3(DEBUG2, "MultiXact: setting next multi to " XID_FMT, minMulti); MultiXactState->nextMXact = minMulti; } if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset)) @@ -3040,7 +3041,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB) else if (!find_multixact_start(oldestMulti, &oldestOffset)) { ereport(LOG, - (errmsg("oldest MultiXact %u not found, earliest MultiXact %u, skipping truncation", + (errmsg("oldest MultiXact " XID_FMT " not found, earliest MultiXact " XID_FMT ", skipping truncation", oldestMulti, earliest))); LWLockRelease(MultiXactTruncationLock); return; @@ -3058,14 +3059,14 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB) else if (!find_multixact_start(newOldestMulti, &newOldestOffset)) { ereport(LOG, - (errmsg("cannot truncate up to MultiXact %u because it does not exist on disk, skipping truncation", + (errmsg("cannot truncate up to MultiXact " XID_FMT " because it does not exist on disk, skipping truncation", newOldestMulti))); LWLockRelease(MultiXactTruncationLock); return; } elog(DEBUG1, "performing multixact truncation: " - "offsets [%u, %u), offsets segments [%x, %x), " + "offsets [" XID_FMT ", " XID_FMT "), offsets segments [%x, %x), " "members [%u, %u), members segments [%x, %x)", oldestMulti, newOldestMulti, MultiXactIdToOffsetSegment(oldestMulti), @@ -3321,7 +3322,7 @@ multixact_redo(XLogReaderState *record) SizeOfMultiXactTruncate); elog(DEBUG1, "replaying multixact truncation: " - "offsets [%u, %u), offsets segments [%x, %x), " + "offsets [" XID_FMT ", " XID_FMT "), offsets segments [%x, %x), " "members [%u, %u), members segments [%x, %x)", xlrec.startTruncOff, xlrec.endTruncOff, MultiXactIdToOffsetSegment(xlrec.startTruncOff), @@ -3372,7 +3373,7 @@ pg_get_multixact_members(PG_FUNCTION_ARGS) if (mxid < FirstMultiXactId) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid MultiXactId: %u", mxid))); + errmsg("invalid MultiXactId: " XID_FMT, mxid))); if (SRF_IS_FIRSTCALL()) { @@ -3408,7 +3409,7 @@ pg_get_multixact_members(PG_FUNCTION_ARGS) HeapTuple tuple; char *values[2]; - values[0] = psprintf("%u", multi->members[multi->iter].xid); + values[0] = psprintf(XID_FMT, multi->members[multi->iter].xid); values[1] = mxstatus_to_string(multi->members[multi->iter].status); tuple = BuildTupleFromCStrings(funccxt->attinmeta, values); diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c index 30a476ed5dc..dc036e80f81 100644 --- a/src/backend/access/transam/slru.c +++ b/src/backend/access/transam/slru.c @@ -942,13 +942,13 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) case SLRU_OPEN_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not open file \"%s\": %m.", path))); break; case SLRU_SEEK_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not seek in file \"%s\" to offset %u: %m.", path, offset))); break; @@ -956,38 +956,38 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) if (errno) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not read from file \"%s\" at offset %u: %m.", path, offset))); else ereport(ERROR, - (errmsg("could not access status of transaction %u", xid), + (errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset))); break; case SLRU_WRITE_FAILED: if (errno) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not write to file \"%s\" at offset %u: %m.", path, offset))); else ereport(ERROR, - (errmsg("could not access status of transaction %u", xid), + (errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.", path, offset))); break; case SLRU_FSYNC_FAILED: ereport(data_sync_elevel(ERROR), (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not fsync file \"%s\": %m.", path))); break; case SLRU_CLOSE_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction " XID_FMT, xid), errdetail("Could not close file \"%s\": %m.", path))); break; diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index 66d35481552..967e4f62471 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -168,7 +168,7 @@ SubTransGetTopmostTransaction(TransactionId xid) * structure that could lead to an infinite loop, so exit. */ if (!TransactionIdPrecedes(parentXid, previousXid)) - elog(ERROR, "pg_subtrans contains invalid entry: xid %u points to parent xid %u", + elog(ERROR, "pg_subtrans contains invalid entry: xid " XID_FMT " points to parent xid " XID_FMT, previousXid, parentXid); } diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index dbc5f884e88..cb55b1fdf2e 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -157,7 +157,7 @@ TransactionIdDidCommit(TransactionId transactionId) parentXid = SubTransGetParent(transactionId); if (!TransactionIdIsValid(parentXid)) { - elog(WARNING, "no pg_subtrans entry for subcommitted XID %u", + elog(WARNING, "no pg_subtrans entry for subcommitted XID " XID_FMT, transactionId); return false; } @@ -206,7 +206,7 @@ TransactionIdDidAbort(TransactionId transactionId) if (!TransactionIdIsValid(parentXid)) { /* see notes in TransactionIdDidCommit */ - elog(WARNING, "no pg_subtrans entry for subcommitted XID %u", + elog(WARNING, "no pg_subtrans entry for subcommitted XID " XID_FMT, transactionId); return true; } diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 874c8ed1256..16f68f4de79 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -849,7 +849,7 @@ TwoPhaseGetGXact(TransactionId xid, bool lock_held) LWLockRelease(TwoPhaseStateLock); if (result == NULL) /* should not happen */ - elog(ERROR, "failed to find GlobalTransaction for xid %u", xid); + elog(ERROR, "failed to find GlobalTransaction for xid " XID_FMT, xid); cached_xid = xid; cached_gxact = result; @@ -2054,7 +2054,7 @@ RecoverPreparedTransactions(void) continue; ereport(LOG, - (errmsg("recovering prepared transaction %u from shared memory", xid))); + (errmsg("recovering prepared transaction " XID_FMT " from shared memory", xid))); hdr = (TwoPhaseFileHeader *) buf; Assert(TransactionIdEquals(hdr->xid, xid)); @@ -2145,14 +2145,14 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (fromdisk) { ereport(WARNING, - (errmsg("removing stale two-phase state file for transaction %u", + (errmsg("removing stale two-phase state file for transaction " XID_FMT, xid))); RemoveTwoPhaseFile(xid, true); } else { ereport(WARNING, - (errmsg("removing stale two-phase state from memory for transaction %u", + (errmsg("removing stale two-phase state from memory for transaction " XID_FMT, xid))); PrepareRedoRemove(xid, true); } @@ -2165,14 +2165,14 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (fromdisk) { ereport(WARNING, - (errmsg("removing future two-phase state file for transaction %u", + (errmsg("removing future two-phase state file for transaction " XID_FMT, xid))); RemoveTwoPhaseFile(xid, true); } else { ereport(WARNING, - (errmsg("removing future two-phase state from memory for transaction %u", + (errmsg("removing future two-phase state from memory for transaction " XID_FMT, xid))); PrepareRedoRemove(xid, true); } @@ -2197,12 +2197,12 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (fromdisk) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("corrupted two-phase state file for transaction %u", + errmsg("corrupted two-phase state file for transaction " XID_FMT, xid))); else ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("corrupted two-phase state in memory for transaction %u", + errmsg("corrupted two-phase state in memory for transaction " XID_FMT, xid))); } @@ -2358,7 +2358,7 @@ RecordTransactionAbortPrepared(TransactionId xid, * RecordTransactionCommitPrepared ... */ if (TransactionIdDidCommit(xid)) - elog(PANIC, "cannot abort transaction %u, it was already committed", + elog(PANIC, "cannot abort transaction " XID_FMT ", it was already committed", xid); START_CRIT_SECTION(); @@ -2465,7 +2465,7 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, false /* backward */ , false /* WAL */ ); } - elog(DEBUG2, "added 2PC data in shared memory for transaction %u", gxact->xid); + elog(DEBUG2, "added 2PC data in shared memory for transaction " XID_FMT, gxact->xid); } /* @@ -2508,7 +2508,7 @@ PrepareRedoRemove(TransactionId xid, bool giveWarning) /* * And now we can clean up any files we may have left. */ - elog(DEBUG2, "removing 2PC data for transaction %u", xid); + elog(DEBUG2, "removing 2PC data for transaction " XID_FMT, xid); if (gxact->ondisk) RemoveTwoPhaseFile(xid, giveWarning); RemoveGXact(gxact); diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 8964ddf3ebf..bd29dc7c669 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -1727,7 +1727,7 @@ RecordTransactionAbort(bool isSubXact) * Check that we haven't aborted halfway through RecordTransactionCommit. */ if (TransactionIdDidCommit(xid)) - elog(PANIC, "cannot abort transaction %u, it was already committed", + elog(PANIC, "cannot abort transaction " XID_FMT ", it was already committed", xid); /* Fetch the data we need for the abort record */ @@ -5434,16 +5434,16 @@ ShowTransactionStateRec(const char *str, TransactionState s) { int i; - appendStringInfo(&buf, ", children: %u", s->childXids[0]); + appendStringInfo(&buf, ", children: " XID_FMT, s->childXids[0]); for (i = 1; i < s->nChildXids; i++) - appendStringInfo(&buf, " %u", s->childXids[i]); + appendStringInfo(&buf, " " XID_FMT, s->childXids[i]); } if (s->parent) ShowTransactionStateRec(str, s->parent); ereport(DEBUG5, - (errmsg_internal("%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s", + (errmsg_internal("%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: " XID_FMT "/" XID_FMT "/%u%s%s", str, s->nestingLevel, PointerIsValid(s->name) ? s->name : "unnamed", BlockStateAsString(s->blockState), diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index f9f212680b0..f58dcf65bcb 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -518,7 +518,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, (errmsg("entering standby mode"))); else if (recoveryTarget == RECOVERY_TARGET_XID) ereport(LOG, - (errmsg("starting point-in-time recovery to XID %u", + (errmsg("starting point-in-time recovery to XID " XID_FMT, recoveryTargetXid))); else if (recoveryTarget == RECOVERY_TARGET_TIME) ereport(LOG, @@ -798,16 +798,16 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, U64FromFullTransactionId(checkPoint.nextXid), checkPoint.nextOid))); ereport(DEBUG1, - (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u", + (errmsg_internal("next MultiXactId: " XID_FMT "; next MultiXactOffset: " XID_FMT, checkPoint.nextMulti, checkPoint.nextMultiOffset))); ereport(DEBUG1, - (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u", + (errmsg_internal("oldest unfrozen transaction ID: " XID_FMT ", in database %u", checkPoint.oldestXid, checkPoint.oldestXidDB))); ereport(DEBUG1, - (errmsg_internal("oldest MultiXactId: %u, in database %u", + (errmsg_internal("oldest MultiXactId: " XID_FMT ", in database %u", checkPoint.oldestMulti, checkPoint.oldestMultiDB))); ereport(DEBUG1, - (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u", + (errmsg_internal("commit timestamp Xid oldest/newest: " XID_FMT "/" XID_FMT, checkPoint.oldestCommitTsXid, checkPoint.newestCommitTsXid))); if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid))) @@ -2490,14 +2490,14 @@ recoveryStopsBefore(XLogReaderState *record) if (isCommit) { ereport(LOG, - (errmsg("recovery stopping before commit of transaction %u, time %s", + (errmsg("recovery stopping before commit of transaction " XID_FMT ", time %s", recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } else { ereport(LOG, - (errmsg("recovery stopping before abort of transaction %u, time %s", + (errmsg("recovery stopping before abort of transaction " XID_FMT ", time %s", recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } @@ -2635,7 +2635,7 @@ recoveryStopsAfter(XLogReaderState *record) xact_info == XLOG_XACT_COMMIT_PREPARED) { ereport(LOG, - (errmsg("recovery stopping after commit of transaction %u, time %s", + (errmsg("recovery stopping after commit of transaction " XID_FMT ", time %s", recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } @@ -2643,7 +2643,7 @@ recoveryStopsAfter(XLogReaderState *record) xact_info == XLOG_XACT_ABORT_PREPARED) { ereport(LOG, - (errmsg("recovery stopping after abort of transaction %u, time %s", + (errmsg("recovery stopping after abort of transaction " XID_FMT ", time %s", recoveryStopXid, timestamptz_to_str(recoveryStopTime)))); } @@ -2679,7 +2679,7 @@ getRecoveryStopReason(void) if (recoveryTarget == RECOVERY_TARGET_XID) snprintf(reason, sizeof(reason), - "%s transaction %u", + "%s transaction " XID_FMT, recoveryStopAfter ? "after" : "before", recoveryStopXid); else if (recoveryTarget == RECOVERY_TARGET_TIME) diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 934aa13f2d3..d3323bf3150 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -1702,7 +1702,7 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin) SpinLockRelease(&slot->mutex); if (got_new_xmin) - elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin, + elog(DEBUG1, "got new catalog xmin " XID_FMT " at %X/%X", xmin, LSN_FORMAT_ARGS(current_lsn)); /* candidate already valid with the current flush position, apply */ diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index c2d9be81fae..56cc0e56005 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2774,7 +2774,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, /* this is just a sanity check against bad output plugin behaviour */ if (GetCurrentTransactionIdIfAny() != InvalidTransactionId) - elog(ERROR, "output plugin used XID %u", + elog(ERROR, "output plugin used XID " XID_FMT, GetCurrentTransactionId()); /* @@ -3213,7 +3213,7 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid) if (TransactionIdPrecedes(txn->xid, oldestRunningXid)) { - elog(DEBUG2, "aborting old transaction %u", txn->xid); + elog(DEBUG2, "aborting old transaction " XID_FMT, txn->xid); /* remove potential on-disk data, and deallocate this tx */ ReorderBufferCleanupTXN(rb, txn); @@ -3855,7 +3855,7 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn) Size spilled = 0; Size size = txn->size; - elog(DEBUG2, "spill %u changes in XID %u to disk", + elog(DEBUG2, "spill %u changes in XID " XID_FMT " to disk", (uint32) txn->nentries_mem, txn->xid); /* do the same to all child TXs */ @@ -4165,7 +4165,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, errno = save_errno ? save_errno : ENOSPC; ereport(ERROR, (errcode_for_file_access(), - errmsg("could not write to data file for XID %u: %m", + errmsg("could not write to data file for XID " XID_FMT ": %m", txn->xid))); } pgstat_report_wait_end(); @@ -4848,7 +4848,7 @@ ReorderBufferSerializedPath(char *path, ReplicationSlot *slot, TransactionId xid XLogSegNoOffsetToRecPtr(segno, 0, wal_segment_size, recptr); - snprintf(path, MAXPGPATH, "pg_replslot/%s/xid-%u-lsn-%X-%X.spill", + snprintf(path, MAXPGPATH, "pg_replslot/%s/xid-" XID_FMT "-lsn-%X-%X.spill", NameStr(MyReplicationSlot->data.name), xid, LSN_FORMAT_ARGS(recptr)); } @@ -5479,7 +5479,7 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot) { RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file); - elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname, + elog(DEBUG1, "applying mapping: \"%s\" in " XID_FMT, f->fname, snapshot->subxip[0]); ApplyLogicalMappingFile(tuplecid_data, relid, f->fname); pfree(f); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 83fca8a77d9..e383e558f89 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -847,7 +847,7 @@ SnapBuildDistributeNewCatalogSnapshot(SnapBuild *builder, XLogRecPtr lsn) if (rbtxn_prepared(txn) || rbtxn_skip_prepared(txn)) continue; - elog(DEBUG2, "adding a new snapshot to %u at %X/%X", + elog(DEBUG2, "adding a new snapshot to " XID_FMT " at %X/%X", txn->xid, LSN_FORMAT_ARGS(lsn)); /* @@ -922,7 +922,7 @@ SnapBuildPurgeCommittedTxn(SnapBuild *builder) memcpy(builder->committed.xip, workspace, surviving_xids * sizeof(TransactionId)); - elog(DEBUG3, "purged committed transactions from %u to %u, xmin: %u, xmax: %u", + elog(DEBUG3, "purged committed transactions from %u to %u, xmin: " XID_FMT ", xmax: " XID_FMT, (uint32) builder->committed.xcnt, (uint32) surviving_xids, builder->xmin, builder->xmax); builder->committed.xcnt = surviving_xids; @@ -988,7 +988,7 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, sub_needs_timetravel = true; needs_snapshot = true; - elog(DEBUG1, "found subtransaction %u:%u with catalog changes", + elog(DEBUG1, "found subtransaction " XID_FMT ":" XID_FMT " with catalog changes", xid, subxid); SnapBuildAddCommittedTxn(builder, subxid); @@ -1014,7 +1014,7 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, /* if top-level modified catalog, it'll need a snapshot */ if (ReorderBufferXidHasCatalogChanges(builder->reorder, xid)) { - elog(DEBUG2, "found top level transaction %u, with catalog changes", + elog(DEBUG2, "found top level transaction " XID_FMT ", with catalog changes", xid); needs_snapshot = true; needs_timetravel = true; @@ -1027,7 +1027,7 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, } else if (needs_timetravel) { - elog(DEBUG2, "forced transaction %u to do timetravel", xid); + elog(DEBUG2, "forced transaction " XID_FMT " to do timetravel", xid); SnapBuildAddCommittedTxn(builder, xid); } @@ -1149,7 +1149,7 @@ SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xact xmin = ReorderBufferGetOldestXmin(builder->reorder); if (xmin == InvalidTransactionId) xmin = running->oldestRunningXid; - elog(DEBUG3, "xmin: %u, xmax: %u, oldest running: %u, oldest xmin: %u", + elog(DEBUG3, "xmin: " XID_FMT ", xmax: " XID_FMT ", oldest running: " XID_FMT ", oldest xmin: " XID_FMT, builder->xmin, builder->xmax, running->oldestRunningXid, xmin); LogicalIncreaseXminForSlot(lsn, xmin); @@ -1239,7 +1239,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn ereport(DEBUG1, (errmsg_internal("skipping snapshot at %X/%X while building logical decoding snapshot, xmin horizon too low", LSN_FORMAT_ARGS(lsn)), - errdetail_internal("initial xmin horizon of %u vs the snapshot's %u", + errdetail_internal("initial xmin horizon of " XID_FMT " vs the snapshot's " XID_FMT, builder->initial_xmin_horizon, running->oldestRunningXid))); @@ -1322,7 +1322,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn ereport(LOG, (errmsg("logical decoding found initial starting point at %X/%X", LSN_FORMAT_ARGS(lsn)), - errdetail("Waiting for transactions (approximately %d) older than %u to end.", + errdetail("Waiting for transactions (approximately %d) older than " XID_FMT " to end.", running->xcnt, running->nextXid))); SnapBuildWaitSnapshot(running, running->nextXid); @@ -1346,7 +1346,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn ereport(LOG, (errmsg("logical decoding found initial consistent point at %X/%X", LSN_FORMAT_ARGS(lsn)), - errdetail("Waiting for transactions (approximately %d) older than %u to end.", + errdetail("Waiting for transactions (approximately %d) older than " XID_FMT " to end.", running->xcnt, running->nextXid))); SnapBuildWaitSnapshot(running, running->nextXid); diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index a1fe81b34f3..68d310a112d 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1050,7 +1050,7 @@ apply_handle_stream_prepare(StringInfo s) logicalrep_read_stream_prepare(s, &prepare_data); set_apply_error_context_xact(prepare_data.xid, prepare_data.prepare_lsn); - elog(DEBUG1, "received prepare for streamed transaction %u", prepare_data.xid); + elog(DEBUG1, "received prepare for streamed transaction " XID_FMT, prepare_data.xid); /* Replay all the spooled operations. */ apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn); @@ -1432,7 +1432,7 @@ apply_handle_stream_commit(StringInfo s) xid = logicalrep_read_stream_commit(s, &commit_data); set_apply_error_context_xact(xid, commit_data.commit_lsn); - elog(DEBUG1, "received commit for streamed transaction %u", xid); + elog(DEBUG1, "received commit for streamed transaction " XID_FMT, xid); apply_spooled_messages(xid, commit_data.commit_lsn); @@ -3204,14 +3204,14 @@ subxact_info_add(TransactionId xid) static inline void subxact_filename(char *path, Oid subid, TransactionId xid) { - snprintf(path, MAXPGPATH, "%u-%u.subxacts", subid, xid); + snprintf(path, MAXPGPATH, "%u-" XID_FMT ".subxacts", subid, xid); } /* format filename for file containing serialized changes */ static inline void changes_filename(char *path, Oid subid, TransactionId xid) { - snprintf(path, MAXPGPATH, "%u-%u.changes", subid, xid); + snprintf(path, MAXPGPATH, "%u-" XID_FMT ".changes", subid, xid); } /* @@ -3373,7 +3373,7 @@ TwoPhaseTransactionGid(Oid subid, TransactionId xid, char *gid, int szgid) (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg_internal("invalid two-phase transaction ID"))); - snprintf(gid, szgid, "pg_gid_%u_%u", subid, xid); + snprintf(gid, szgid, "pg_gid_%u_" XID_FMT, subid, xid); } /* @@ -3756,19 +3756,19 @@ apply_error_callback(void *arg) errarg->origin_name, logicalrep_message_type(errarg->command)); else if (XLogRecPtrIsInvalid(errarg->finish_lsn)) - errcontext("processing remote data for replication origin \"%s\" during \"%s\" in transaction %u", + errcontext("processing remote data for replication origin \"%s\" during \"%s\" in transaction " XID_FMT, errarg->origin_name, logicalrep_message_type(errarg->command), errarg->remote_xid); else - errcontext("processing remote data for replication origin \"%s\" during \"%s\" in transaction %u finished at %X/%X", + errcontext("processing remote data for replication origin \"%s\" during \"%s\" in transaction " XID_FMT " finished at %X/%X", errarg->origin_name, logicalrep_message_type(errarg->command), errarg->remote_xid, LSN_FORMAT_ARGS(errarg->finish_lsn)); } else if (errarg->remote_attnum < 0) - errcontext("processing remote data for replication origin \"%s\" during \"%s\" for replication target relation \"%s.%s\" in transaction %u finished at %X/%X", + errcontext("processing remote data for replication origin \"%s\" during \"%s\" for replication target relation \"%s.%s\" in transaction " XID_FMT " finished at %X/%X", errarg->origin_name, logicalrep_message_type(errarg->command), errarg->rel->remoterel.nspname, @@ -3776,7 +3776,7 @@ apply_error_callback(void *arg) errarg->remote_xid, LSN_FORMAT_ARGS(errarg->finish_lsn)); else - errcontext("processing remote data for replication origin \"%s\" during \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %u finished at %X/%X", + errcontext("processing remote data for replication origin \"%s\" during \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction " XID_FMT " finished at %X/%X", errarg->origin_name, logicalrep_message_type(errarg->command), errarg->rel->remoterel.nspname, diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index ceaff097b97..7d747f4d386 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -1216,7 +1216,7 @@ XLogWalRcvSendHSFeedback(bool immed) if (nextXid < catalog_xmin) catalog_xmin_epoch--; - elog(DEBUG2, "sending hot standby feedback xmin %u epoch %u catalog_xmin %u catalog_xmin_epoch %u", + elog(DEBUG2, "sending hot standby feedback xmin " XID_FMT " epoch %u catalog_xmin " XID_FMT " catalog_xmin_epoch %u", xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch); /* Construct the message and send it. */ diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 2d0292a092e..1693cd9eddb 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -2214,7 +2214,7 @@ ProcessStandbyHSFeedbackMessage(void) /* Copy because timestamptz_to_str returns a static buffer */ replyTimeStr = pstrdup(timestamptz_to_str(replyTime)); - elog(DEBUG2, "hot standby feedback xmin %u epoch %u, catalog_xmin %u epoch %u reply_time %s", + elog(DEBUG2, "hot standby feedback xmin " XID_FMT " epoch %u, catalog_xmin " XID_FMT " epoch %u reply_time %s", feedbackXmin, feedbackEpoch, feedbackCatalogXmin, diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 13d192ec2b4..814c3d7d7ae 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -1105,7 +1105,7 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running) else elog(trace_recovery(DEBUG1), "recovery snapshot waiting for non-overflowed snapshot or " - "until oldest active xid on standby is at least %u (now %u)", + "until oldest active xid on standby is at least " XID_FMT " (now " XID_FMT ")", standbySnapshotPendingXmin, running->oldestRunningXid); return; @@ -1191,7 +1191,7 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running) if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i])) { elog(DEBUG1, - "found duplicated transaction %u for KnownAssignedXids insertion", + "found duplicated transaction " XID_FMT " for KnownAssignedXids insertion", xids[i]); continue; } @@ -1276,7 +1276,7 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running) else elog(trace_recovery(DEBUG1), "recovery snapshot waiting for non-overflowed snapshot or " - "until oldest active xid on standby is at least %u (now %u)", + "until oldest active xid on standby is at least " XID_FMT " (now " XID_FMT ")", standbySnapshotPendingXmin, running->oldestRunningXid); } @@ -3992,7 +3992,7 @@ XidCacheRemoveRunningXids(TransactionId xid, * debug warning. */ if (j < 0 && !MyProc->subxidStatus.overflowed) - elog(WARNING, "did not find subXID %u in MyProc", anxid); + elog(WARNING, "did not find subXID " XID_FMT " in MyProc", anxid); } for (j = MyProc->subxidStatus.count - 1; j >= 0; j--) @@ -4008,7 +4008,7 @@ XidCacheRemoveRunningXids(TransactionId xid, } /* Ordinarily we should have found it, unless the cache has overflowed */ if (j < 0 && !MyProc->subxidStatus.overflowed) - elog(WARNING, "did not find subXID %u in MyProc", xid); + elog(WARNING, "did not find subXID " XID_FMT " in MyProc", xid); /* Also advance global latestCompletedXid while holding the lock */ MaintainLatestCompletedXid(latestXid); @@ -4385,7 +4385,7 @@ RecordKnownAssignedTransactionIds(TransactionId xid) Assert(TransactionIdIsValid(xid)); Assert(TransactionIdIsValid(latestObservedXid)); - elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u", + elog(trace_recovery(DEBUG4), "record known xact " XID_FMT " latestObservedXid " XID_FMT, xid, latestObservedXid); /* @@ -4896,7 +4896,7 @@ KnownAssignedXidsRemove(TransactionId xid) { Assert(TransactionIdIsValid(xid)); - elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid); + elog(trace_recovery(DEBUG4), "remove KnownAssignedXid " XID_FMT, xid); /* * Note: we cannot consider it an error to remove an XID that's not @@ -4956,7 +4956,7 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid) return; } - elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid); + elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to " XID_FMT, removeXid); /* * Mark entries invalid starting at the tail. Since array is sorted, we @@ -5144,7 +5144,7 @@ KnownAssignedXidsDisplay(int trace_level) if (KnownAssignedXidsValid[i]) { nxids++; - appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]); + appendStringInfo(&buf, "[%d]=" XID_FMT " ", i, KnownAssignedXids[i]); } } diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c index 27361ac8610..785447f8c77 100644 --- a/src/backend/storage/ipc/standby.c +++ b/src/backend/storage/ipc/standby.c @@ -995,13 +995,13 @@ StandbyReleaseLockList(List *locks) LOCKTAG locktag; elog(trace_recovery(DEBUG4), - "releasing recovery lock: xid %u db %u rel %u", + "releasing recovery lock: xid " XID_FMT " db %u rel %u", lock->xid, lock->dbOid, lock->relOid); SET_LOCKTAG_RELATION(locktag, lock->dbOid, lock->relOid); if (!LockRelease(&locktag, AccessExclusiveLock, true)) { elog(LOG, - "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u", + "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid " XID_FMT " database %u relation %u", lock->xid, lock->dbOid, lock->relOid); Assert(false); } @@ -1306,7 +1306,7 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts) if (CurrRunningXacts->subxid_overflow) elog(trace_recovery(DEBUG2), - "snapshot of %u running transactions overflowed (lsn %X/%X oldest xid %u latest complete %u next xid %u)", + "snapshot of %u running transactions overflowed (lsn %X/%X oldest xid " XID_FMT " latest complete " XID_FMT " next xid " XID_FMT ")", CurrRunningXacts->xcnt, LSN_FORMAT_ARGS(recptr), CurrRunningXacts->oldestRunningXid, @@ -1314,7 +1314,7 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts) CurrRunningXacts->nextXid); else elog(trace_recovery(DEBUG2), - "snapshot of %u+%u running transaction ids (lsn %X/%X oldest xid %u latest complete %u next xid %u)", + "snapshot of %u+%u running transaction ids (lsn %X/%X oldest xid " XID_FMT " latest complete " XID_FMT " next xid " XID_FMT ")", CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt, LSN_FORMAT_ARGS(recptr), CurrRunningXacts->oldestRunningXid, diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index e337aad5b24..6f25112bbb3 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -4168,7 +4168,7 @@ CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot s ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to read/write dependencies among transactions"), - errdetail_internal("Reason code: Canceled on conflict out to old pivot %u.", xid), + errdetail_internal("Reason code: Canceled on conflict out to old pivot " XID_FMT ".", xid), errhint("The transaction might succeed if retried."))); if (SxactHasSummaryConflictIn(MySerializableXact) @@ -4176,7 +4176,7 @@ CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot s ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to read/write dependencies among transactions"), - errdetail_internal("Reason code: Canceled on identification as a pivot, with conflict out to old committed transaction %u.", xid), + errdetail_internal("Reason code: Canceled on identification as a pivot, with conflict out to old committed transaction " XID_FMT ".", xid), errhint("The transaction might succeed if retried."))); MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT; @@ -4806,7 +4806,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader, ereport(ERROR, (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), errmsg("could not serialize access due to read/write dependencies among transactions"), - errdetail_internal("Reason code: Canceled on conflict out to pivot %u, during read.", writer->topXid), + errdetail_internal("Reason code: Canceled on conflict out to pivot " XID_FMT ", during read.", writer->topXid), errhint("The transaction might succeed if retried."))); } writer->flags |= SXACT_FLAG_DOOMED; diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index 944cd6df03f..6a8e462a6c2 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -79,7 +79,7 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid) */ char vxidstr[32]; - snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid); + snprintf(vxidstr, sizeof(vxidstr), "%d/" XID_FMT, bid, lxid); return CStringGetTextDatum(vxidstr); } diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c index 89f78b447d9..8bf5213d7e1 100644 --- a/src/backend/utils/error/csvlog.c +++ b/src/backend/utils/error/csvlog.c @@ -153,11 +153,11 @@ write_csvlog(ErrorData *edata) /* Virtual transaction id */ /* keep VXID format in sync with lockfuncs.c */ if (MyProc != NULL && MyProc->backendId != InvalidBackendId) - appendStringInfo(&buf, "%d/%u", MyProc->backendId, MyProc->lxid); + appendStringInfo(&buf, "%d/" XID_FMT, MyProc->backendId, MyProc->lxid); appendStringInfoChar(&buf, ','); /* Transaction id */ - appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny()); + appendStringInfo(&buf, XID_FMT, GetTopTransactionIdIfAny()); appendStringInfoChar(&buf, ','); /* Error severity */ diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 7402696986b..d5104819503 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2754,12 +2754,12 @@ log_line_prefix(StringInfo buf, ErrorData *edata) { char strfbuf[128]; - snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u", + snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/" XID_FMT, MyProc->backendId, MyProc->lxid); appendStringInfo(buf, "%*s", padding, strfbuf); } else - appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid); + appendStringInfo(buf, "%d/" XID_FMT, MyProc->backendId, MyProc->lxid); } else if (padding != 0) appendStringInfoSpaces(buf, @@ -2769,7 +2769,7 @@ log_line_prefix(StringInfo buf, ErrorData *edata) if (padding != 0) appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny()); else - appendStringInfo(buf, "%u", GetTopTransactionIdIfAny()); + appendStringInfo(buf, XID_FMT, GetTopTransactionIdIfAny()); break; case 'e': if (padding != 0) diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c index 843641c865f..7ef41813d00 100644 --- a/src/backend/utils/error/jsonlog.c +++ b/src/backend/utils/error/jsonlog.c @@ -198,11 +198,11 @@ write_jsonlog(ErrorData *edata) /* Virtual transaction id */ /* keep VXID format in sync with lockfuncs.c */ if (MyProc != NULL && MyProc->backendId != InvalidBackendId) - appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%u", MyProc->backendId, + appendJSONKeyValueFmt(&buf, "vxid", true, "%d/" XID_FMT, MyProc->backendId, MyProc->lxid); /* Transaction id */ - appendJSONKeyValueFmt(&buf, "txid", false, "%u", + appendJSONKeyValueFmt(&buf, "txid", false, XID_FMT, GetTopTransactionIdIfAny()); /* Error severity */ diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index a0be0c411a3..17a2a9d3914 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -1202,14 +1202,14 @@ ExportSnapshot(Snapshot snapshot) */ initStringInfo(&buf); - appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid); + appendStringInfo(&buf, "vxid:%d/" XID_FMT "\n", MyProc->backendId, MyProc->lxid); appendStringInfo(&buf, "pid:%d\n", MyProcPid); appendStringInfo(&buf, "dbid:%u\n", MyDatabaseId); appendStringInfo(&buf, "iso:%d\n", XactIsoLevel); appendStringInfo(&buf, "ro:%d\n", XactReadOnly); - appendStringInfo(&buf, "xmin:%u\n", snapshot->xmin); - appendStringInfo(&buf, "xmax:%u\n", snapshot->xmax); + appendStringInfo(&buf, "xmin:" XID_FMT "\n", snapshot->xmin); + appendStringInfo(&buf, "xmax:" XID_FMT "\n", snapshot->xmax); /* * We must include our own top transaction ID in the top-xid data, since @@ -1226,9 +1226,9 @@ ExportSnapshot(Snapshot snapshot) TransactionIdPrecedes(topXid, snapshot->xmax)) ? 1 : 0; appendStringInfo(&buf, "xcnt:%d\n", snapshot->xcnt + addTopXid); for (i = 0; i < snapshot->xcnt; i++) - appendStringInfo(&buf, "xip:%u\n", snapshot->xip[i]); + appendStringInfo(&buf, "xip:" XID_FMT "\n", snapshot->xip[i]); if (addTopXid) - appendStringInfo(&buf, "xip:%u\n", topXid); + appendStringInfo(&buf, "xip:" XID_FMT "\n", topXid); /* * Similarly, we add our subcommitted child XIDs to the subxid data. Here, @@ -1242,9 +1242,9 @@ ExportSnapshot(Snapshot snapshot) appendStringInfoString(&buf, "sof:0\n"); appendStringInfo(&buf, "sxcnt:%d\n", snapshot->subxcnt + nchildren); for (i = 0; i < snapshot->subxcnt; i++) - appendStringInfo(&buf, "sxp:%u\n", snapshot->subxip[i]); + appendStringInfo(&buf, "sxp:" XID_FMT "\n", snapshot->subxip[i]); for (i = 0; i < nchildren; i++) - appendStringInfo(&buf, "sxp:%u\n", children[i]); + appendStringInfo(&buf, "sxp:" XID_FMT "\n", children[i]); } appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery); @@ -1347,7 +1347,7 @@ parseXidFromText(const char *prefix, char **s, const char *filename) (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid snapshot data in file \"%s\"", filename))); ptr += prefixlen; - if (sscanf(ptr, "%u", &val) != 1) + if (sscanf(ptr, XID_FMT, &val) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid snapshot data in file \"%s\"", filename))); @@ -1372,7 +1372,7 @@ parseVxidFromText(const char *prefix, char **s, const char *filename, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid snapshot data in file \"%s\"", filename))); ptr += prefixlen; - if (sscanf(ptr, "%d/%u", &vxid->backendId, &vxid->localTransactionId) != 2) + if (sscanf(ptr, "%d/" XID_FMT, &vxid->backendId, &vxid->localTransactionId) != 2) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid snapshot data in file \"%s\"", filename))); diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index f911f98d946..bd9c4bfe9c1 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -247,28 +247,28 @@ main(int argc, char *argv[]) ControlFile->checkPointCopy.PrevTimeLineID); printf(_("Latest checkpoint's full_page_writes: %s\n"), ControlFile->checkPointCopy.fullPageWrites ? _("on") : _("off")); - printf(_("Latest checkpoint's NextXID: %u:%u\n"), + printf(_("Latest checkpoint's NextXID: %u:" XID_FMT "\n"), EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid), XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)); printf(_("Latest checkpoint's NextOID: %u\n"), ControlFile->checkPointCopy.nextOid); - printf(_("Latest checkpoint's NextMultiXactId: %u\n"), + printf(_("Latest checkpoint's NextMultiXactId: " XID_FMT "\n"), ControlFile->checkPointCopy.nextMulti); - printf(_("Latest checkpoint's NextMultiOffset: %u\n"), + printf(_("Latest checkpoint's NextMultiOffset: " XID_FMT "\n"), ControlFile->checkPointCopy.nextMultiOffset); - printf(_("Latest checkpoint's oldestXID: %u\n"), + printf(_("Latest checkpoint's oldestXID: " XID_FMT "\n"), ControlFile->checkPointCopy.oldestXid); printf(_("Latest checkpoint's oldestXID's DB: %u\n"), ControlFile->checkPointCopy.oldestXidDB); - printf(_("Latest checkpoint's oldestActiveXID: %u\n"), + printf(_("Latest checkpoint's oldestActiveXID: " XID_FMT "\n"), ControlFile->checkPointCopy.oldestActiveXid); - printf(_("Latest checkpoint's oldestMultiXid: %u\n"), + printf(_("Latest checkpoint's oldestMultiXid: " XID_FMT "\n"), ControlFile->checkPointCopy.oldestMulti); printf(_("Latest checkpoint's oldestMulti's DB: %u\n"), ControlFile->checkPointCopy.oldestMultiDB); - printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"), + printf(_("Latest checkpoint's oldestCommitTsXid:" XID_FMT "\n"), ControlFile->checkPointCopy.oldestCommitTsXid); - printf(_("Latest checkpoint's newestCommitTsXid:%u\n"), + printf(_("Latest checkpoint's newestCommitTsXid:" XID_FMT "\n"), ControlFile->checkPointCopy.newestCommitTsXid); printf(_("Time of latest checkpoint: %s\n"), ckpttime_str); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 4dd24b8c89f..0e83f3b94fe 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -3037,7 +3037,7 @@ dumpDatabase(Archive *fout) { appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n"); appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n" - "SET datfrozenxid = '%u', datminmxid = '%u'\n" + "SET datfrozenxid = '" XID_FMT "', datminmxid = '" XID_FMT "'\n" "WHERE datname = ", frozenxid, minmxid); appendStringLiteralAH(creaQry, datname, fout); @@ -15441,7 +15441,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) { appendPQExpBufferStr(q, "\n-- For binary upgrade, set heap's relfrozenxid and relminmxid\n"); appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n" - "SET relfrozenxid = '%u', relminmxid = '%u'\n" + "SET relfrozenxid = '" XID_FMT "', relminmxid = '" XID_FMT "'\n" "WHERE oid = ", tbinfo->frozenxid, tbinfo->minmxid); appendStringLiteralAH(q, qualrelname, fout); @@ -15455,7 +15455,7 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) */ appendPQExpBufferStr(q, "\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n"); appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n" - "SET relfrozenxid = '%u', relminmxid = '%u'\n" + "SET relfrozenxid = '" XID_FMT "', relminmxid = '" XID_FMT "'\n" "WHERE oid = '%u';\n", tbinfo->toast_frozenxid, tbinfo->toast_minmxid, tbinfo->toast_oid); diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 1eb4509fcac..c2ee94d3d5c 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -182,7 +182,7 @@ main(int argc, char *argv[]) } if (!TransactionIdIsNormal(set_oldest_xid)) { - pg_log_error("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId); + pg_log_error("oldest transaction ID (-u) must be greater than or equal to " XID_FMT, FirstNormalTransactionId); exit(1); } break; @@ -198,7 +198,7 @@ main(int argc, char *argv[]) } if (!TransactionIdIsNormal(set_xid)) { - pg_log_error("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId); + pg_log_error("transaction ID (-x) must be greater than or equal to " XID_FMT, FirstNormalTransactionId); exit(1); } break; diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index ecb3e1f6474..bb83fcdf972 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -538,7 +538,7 @@ copy_xact_xlog_xid(void) prep_status("Setting oldest XID for new cluster"); exec_prog(UTILITY_LOG_FILE, NULL, true, true, - "\"%s/pg_resetwal\" -f -u %u \"%s\"", + "\"%s/pg_resetwal\" -f -u " XID_FMT " \"%s\"", new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid, new_cluster.pgdata); check_ok(); @@ -546,7 +546,7 @@ copy_xact_xlog_xid(void) /* set the next transaction id and epoch of the new cluster */ prep_status("Setting next transaction ID and epoch for new cluster"); exec_prog(UTILITY_LOG_FILE, NULL, true, true, - "\"%s/pg_resetwal\" -f -x %u \"%s\"", + "\"%s/pg_resetwal\" -f -x " XID_FMT " \"%s\"", new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata); exec_prog(UTILITY_LOG_FILE, NULL, true, true, @@ -555,7 +555,7 @@ copy_xact_xlog_xid(void) new_cluster.pgdata); /* must reset commit timestamp limits also */ exec_prog(UTILITY_LOG_FILE, NULL, true, true, - "\"%s/pg_resetwal\" -f -c %u,%u \"%s\"", + "\"%s/pg_resetwal\" -f -c " XID_FMT "," XID_FMT " \"%s\"", new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, old_cluster.controldata.chkpnt_nxtxid, @@ -581,7 +581,7 @@ copy_xact_xlog_xid(void) * counters here and the oldest multi present on system. */ exec_prog(UTILITY_LOG_FILE, NULL, true, true, - "\"%s/pg_resetwal\" -O %u -m %u,%u \"%s\"", + "\"%s/pg_resetwal\" -O " XID_FMT " -m " XID_FMT "," XID_FMT " \"%s\"", new_cluster.bindir, old_cluster.controldata.chkpnt_nxtmxoff, old_cluster.controldata.chkpnt_nxtmulti, @@ -609,7 +609,7 @@ copy_xact_xlog_xid(void) * next=MaxMultiXactId, but multixact.c can cope with that just fine. */ exec_prog(UTILITY_LOG_FILE, NULL, true, true, - "\"%s/pg_resetwal\" -m %u,%u \"%s\"", + "\"%s/pg_resetwal\" -m " XID_FMT "," XID_FMT " \"%s\"", new_cluster.bindir, old_cluster.controldata.chkpnt_nxtmulti + 1, old_cluster.controldata.chkpnt_nxtmulti, @@ -671,13 +671,13 @@ set_frozenxids(bool minmxid_only) /* set pg_database.datfrozenxid */ PQclear(executeQueryOrDie(conn_template1, "UPDATE pg_catalog.pg_database " - "SET datfrozenxid = '%u'", + "SET datfrozenxid = '" XID_FMT "'", old_cluster.controldata.chkpnt_nxtxid)); /* set pg_database.datminmxid */ PQclear(executeQueryOrDie(conn_template1, "UPDATE pg_catalog.pg_database " - "SET datminmxid = '%u'", + "SET datminmxid = '" XID_FMT "'", old_cluster.controldata.chkpnt_nxtmulti)); /* get database names */ @@ -712,7 +712,7 @@ set_frozenxids(bool minmxid_only) /* set pg_class.relfrozenxid */ PQclear(executeQueryOrDie(conn, "UPDATE pg_catalog.pg_class " - "SET relfrozenxid = '%u' " + "SET relfrozenxid = '" XID_FMT "' " /* only heap, materialized view, and TOAST are vacuumed */ "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ", " @@ -723,7 +723,7 @@ set_frozenxids(bool minmxid_only) /* set pg_class.relminmxid */ PQclear(executeQueryOrDie(conn, "UPDATE pg_catalog.pg_class " - "SET relminmxid = '%u' " + "SET relminmxid = '" XID_FMT "' " /* only heap, materialized view, and TOAST are vacuumed */ "WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ", " diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index f128050b4ea..5db29c00f78 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -487,6 +487,7 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record) XLogDumpRecordLen(record, &rec_len, &fpi_len); + /* Use XID_FMT instad of %10u here? */ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ", desc->rm_name, rec_len, XLogRecGetTotalLen(record), @@ -949,7 +950,7 @@ main(int argc, char **argv) } break; case 'x': - if (sscanf(optarg, "%u", &config.filter_by_xid) != 1) + if (sscanf(optarg, XID_FMT, &config.filter_by_xid) != 1) { pg_log_error("could not parse \"%s\" as a transaction ID", optarg); diff --git a/src/include/c.h b/src/include/c.h index 4f16e589b3e..812e0e50162 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -593,6 +593,9 @@ typedef uint32 SubTransactionId; #define InvalidSubTransactionId ((SubTransactionId) 0) #define TopSubTransactionId ((SubTransactionId) 1) +/* Format string used for XIDs. */ +#define XID_FMT "%u" + /* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */ typedef TransactionId MultiXactId; -- 2.35.1