XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
Hi hackers,
This thread is a fork of [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com, created per request by several people in
the discussion. It includes two patches from the patchset that we
believe can be delivered in PG15. The rest of the patches are
targeting PG >= 16 and can be discussed further in [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com.
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.
Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.
v19-0002 refactors SLRU and the dependent code so that `pageno`s
become int64's. This is a requirement for the rest of the patches.
The patches were in pretty good shape last time I checked several days
ago, I even suggested changing their status to "Ready for Committer".
Let's see what cfbot will tell us.
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Aleksander Alekseev
Attachments:
v19-0001-Use-XID_FMT-macro-to-format-XIDs.patchapplication/octet-stream; name=v19-0001-Use-XID_FMT-macro-to-format-XIDs.patchDownload
From 586dd48ddd49bd66e532c8c109b51cc637fe396b Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
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 <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
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
v19-0002-Use-64-bit-pages-in-SLRU.patchapplication/octet-stream; name=v19-0002-Use-64-bit-pages-in-SLRU.patchDownload
From fcae8a95530e2c0b14e04c2f7554375a9fffaea0 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v19 2/5] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 108 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 16 +--
src/backend/storage/lmgr/predicate.c | 4 +-
src/backend/utils/adt/numutils.c | 22 ++++
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++---
src/include/utils/builtins.h | 1 +
11 files changed, 109 insertions(+), 90 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index bc75f7e77a0..e6cedb86068 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index cb4ed41d5ee..239487bcede 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2879,7 +2879,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3130,7 +3130,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3150,7 +3150,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index dc036e80f81..01978fa180b 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (int64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,7 +951,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction " XID_FMT, xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
+ errdetail("Could not seek in file \"%s\" to offset " UINT64_FORMAT ": %m.",
path, offset)));
break;
case SLRU_READ_FAILED:
@@ -957,24 +959,24 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction " XID_FMT, xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
+ errdetail("Could not read from file \"%s\" at offset " UINT64_FORMAT ": %m.",
path, offset)));
else
ereport(ERROR,
(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)));
+ errdetail("Could not read from file \"%s\" at offset " UINT64_FORMAT ": 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 " XID_FMT, xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
+ errdetail("Could not write to file \"%s\" at offset " UINT64_FORMAT ": %m.",
path, offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction " XID_FMT, xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
+ errdetail("Could not write to file \"%s\" at offset " UINT64_FORMAT ": wrote too few bytes.",
path, offset)));
break;
case SLRU_FSYNC_FAILED:
@@ -1013,7 +1015,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1026,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1070,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1160,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1225,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1303,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1326,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1499,9 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1514,9 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1529,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1557,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1567,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = pg_strtouint64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1598,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 967e4f62471..4cb02517e29 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..4b22140459d 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) MAXALIGN(len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -444,7 +444,7 @@ bool Trace_notify = false;
/* local function prototypes */
static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -497,16 +497,10 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 6f25112bbb3..7bac5cfa60e 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c
index cc3f95d3990..0da1b4e214a 100644
--- a/src/backend/utils/adt/numutils.c
+++ b/src/backend/utils/adt/numutils.c
@@ -602,3 +602,25 @@ pg_ultostr(char *str, uint32 value)
return str + len;
}
+
+/*
+ * pg_strtouint64
+ * Converts 'str' into an unsigned 64-bit integer.
+ *
+ * This has the identical API to strtoul(3), except that it will handle
+ * 64-bit ints even where "long" is narrower than that.
+ *
+ * For the moment it seems sufficient to assume that the platform has
+ * such a function somewhere; let's not roll our own.
+ */
+uint64
+pg_strtouint64(const char *str, char **endptr, int base)
+{
+#ifdef _MSC_VER /* MSVC only */
+ return _strtoui64(str, endptr, base);
+#elif defined(HAVE_STRTOULL) && SIZEOF_LONG < 8
+ return strtoull(str, endptr, base);
+#else
+ return strtoul(str, endptr, base);
+#endif
+}
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 666e5454969..4b89f36d64a 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -53,6 +53,7 @@ extern int pg_ltoa(int32 l, char *a);
extern int pg_lltoa(int64 ll, char *a);
extern char *pg_ultostr_zeropad(char *str, uint32 value, int32 minwidth);
extern char *pg_ultostr(char *str, uint32 value);
+extern uint64 pg_strtouint64(const char *s, char **endptr, int base);
/* oid.c */
extern oidvector *buildoidvector(const Oid *oids, int n);
--
2.35.1
Hi, Aleksander!
On Thu, Mar 17, 2022 at 4:12 PM Aleksander Alekseev
<aleksander@timescale.com> wrote:
This thread is a fork of [1], created per request by several people in
the discussion. It includes two patches from the patchset that we
believe can be delivered in PG15. The rest of the patches are
targeting PG >= 16 and can be discussed further in [1].
Thank you for putting this into a separate thread.
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.
I'm not a localization expert. Could you clarify what localization
messages should look like if we switch to XID_FMT? And will we have
to change them if change the definition of XID_FMT?
------
Regards,
Alexander Korotkov
On 17.03.22 14:12, Aleksander Alekseev wrote:
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.
This is not a question of simplification. Translatable messages with
embedded macros won't work. This patch isn't going to be acceptable.
On Thu, Mar 17, 2022 at 4:23 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:
On 17.03.22 14:12, Aleksander Alekseev wrote:
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.This is not a question of simplification. Translatable messages with
embedded macros won't work. This patch isn't going to be acceptable.
I've suspected this, but wasn't sure. Thank you for clarification.
------
Regards,
Alexander Korotkov
On Thu, 17 Mar 2022 at 21:31, Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Thu, Mar 17, 2022 at 4:23 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:On 17.03.22 14:12, Aleksander Alekseev wrote:
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.This is not a question of simplification. Translatable messages with
embedded macros won't work. This patch isn't going to be acceptable.I've suspected this, but wasn't sure. Thank you for clarification.
Maybe, we should format it to string before for localization messages,
like the following code snippet comes from pg_backup_tar.c.
However, I do not think it is a good way.
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->fileLen);
fatal("actual file length (%s) does not match expected (%s)",
buf1, buf2);
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
Japin Li <japinli@hotmail.com> writes:
Maybe, we should format it to string before for localization messages,
like the following code snippet comes from pg_backup_tar.c.
However, I do not think it is a good way.
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->fileLen);
fatal("actual file length (%s) does not match expected (%s)",
buf1, buf2);
That used to be our standard practice before we switched to always
relying on our own snprintf.c. Now, we know that "%lld" with an
explicit cast to long long will work, so that's the preferred method
for printing 64-bit values in localizable strings. Not all of the old
code has been updated, though.
regards, tom lane
On Thu, 17 Mar 2022 at 21:31, Alexander Korotkov <aekorotkov@gmail.com>
wrote:On Thu, Mar 17, 2022 at 4:23 PM Peter Eisentraut
<peter.eisentraut@enterprisedb.com> wrote:On 17.03.22 14:12, Aleksander Alekseev wrote:
v19-0001 changes the format string for XIDs from %u to XID_FMT. This
refactoring allows us to switch to UINT64_FORMAT by changing one
#define in the future patches.Kyotaro suggested using `errmsg("blah blah %lld ..", (long long)
xid)` instead in order to simplify localization of the error messages.
Personally I don't have a strong opinion here. Either approach will
work and will affect the error messages eventually. Please let us know
what you think.This is not a question of simplification. Translatable messages with
embedded macros won't work. This patch isn't going to be acceptable.I've suspected this, but wasn't sure. Thank you for clarification.
Hi, hackers!
The need to support localization is very much understood by us. We'll
deliver a patchset soon with localization based on %lld/%llu format and
explicit casts to unsigned/signed long long.
Alexander Alexeev could you wait a little bit and give us time to deliver
v20 patch which will address localization (I propose concurrent work should
stop until that to avoid conflicts)
Advice and discussion help us a lot.
Thanks!
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Hi!
Here is the v20 patch. 0001 and 0002 are proposed into PG15 as
discussed above.
The whole set of patches is added into [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com to be committed into PG16.
In this version we've made a major revision related to printf/elog format
compatible with localization
as was proposed above.
We also think of adding 0003 patch related to 64 bit GUC's into this
thread. Suppose it also may be delivered
into PG15.
Aleksander Alekseev, we've done this major revision mentioned above and you
are free to continue working on this patch set.
Reviews and proposals are very welcome!
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Maxim Orlov.
Attachments:
v20-0001-Use-XID_FMT-macro-to-format-XIDs.patchapplication/octet-stream; name=v20-0001-Use-XID_FMT-macro-to-format-XIDs.patchDownload
From 5264a7bd3996c6087b18dd5f7e2a462dfa5d3de7 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v20 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 <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 8 +-
contrib/pgrowlocks/pgrowlocks.c | 6 +-
contrib/test_decoding/test_decoding.c | 26 ++--
src/backend/access/heap/heapam.c | 44 +++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 12 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 36 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 8 +-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 14 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 77 +++++------
src/backend/access/transam/slru.c | 16 +--
src/backend/access/transam/subtrans.c | 4 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 36 +++---
src/backend/access/transam/xact.c | 14 +-
src/backend/access/transam/xlogrecovery.c | 42 +++---
src/backend/replication/logical/logical.c | 2 +-
.../replication/logical/reorderbuffer.c | 22 ++--
src/backend/replication/logical/snapbuild.c | 34 ++---
src/backend/replication/logical/worker.c | 26 ++--
src/backend/replication/walreceiver.c | 4 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 30 ++---
src/backend/storage/ipc/standby.c | 24 ++--
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 | 8 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 18 +--
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 14 +-
src/bin/pg_resetwal/pg_resetwal.c | 4 +-
src/bin/pg_upgrade/pg_upgrade.c | 44 +++----
src/bin/pg_waldump/pg_waldump.c | 6 +-
src/include/c.h | 5 +
46 files changed, 427 insertions(+), 423 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..3fb11ba1e4c 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_TYPE) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (XID_TYPE) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (XID_TYPE) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (XID_TYPE) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (XID_TYPE) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (XID_TYPE) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (XID_TYPE) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (XID_TYPE) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,19 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (XID_TYPE) xmax, (XID_TYPE) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (XID_TYPE) xmax, (XID_TYPE) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (XID_TYPE) xmax,
+ (XID_TYPE) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_TYPE) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (XID_TYPE) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (XID_TYPE) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1076,22 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_TYPE) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
+ (XID_TYPE) xmax,
+ (XID_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
+ (XID_TYPE) xmax,
+ (XID_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..12f844c8f84 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,13 +125,13 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (XID_TYPE) XidFromFullTransactionId(safexid));
}
else
- elog(DEBUG2, "deleted page from block %u has safexid %u",
- blkno, opaque->btpo_level);
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (XID_TYPE) opaque->btpo_level);
/* Don't interpret BTDeletedPageData as index tuples */
maxoff = InvalidOffsetNumber;
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..8baaf431f4a 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, "%llu", (XID_TYPE) 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, "%llu", (XID_TYPE) 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, "{%llu}", (XID_TYPE) 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..2ff15f2cc20 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +900,8 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid), (XID_TYPE) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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..0f82253c20e 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 %llu", (XID_TYPE) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6173,8 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (XID_TYPE) multi, (XID_TYPE) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6187,8 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (XID_TYPE) multi, (XID_TYPE) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6206,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (XID_TYPE) xid, (XID_TYPE) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -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 %llu", (XID_TYPE) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6294,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (XID_TYPE) xid, (XID_TYPE) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6344,8 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (XID_TYPE) update_xid, (XID_TYPE) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6474,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (XID_TYPE) xid, (XID_TYPE) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6483,8 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (XID_TYPE) xid, (XID_TYPE) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6555,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (XID_TYPE) xid, (XID_TYPE) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6570,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (XID_TYPE) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6586,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (XID_TYPE) 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..93f3352e815 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (XID_TYPE) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..e9b97dc5199 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (XID_TYPE) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (XID_TYPE) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (XID_TYPE) 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..255de5e62fc 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (XID_TYPE) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..fa60666a7d9 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (XID_TYPE) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..b8bc063c3ff 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (XID_TYPE) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (XID_TYPE) xlrec->latestRemovedXid, xlrec->ntodelete);
}
@@ -51,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (XID_TYPE) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..ecf165c872d 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (XID_TYPE) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..2868c3ed054 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (XID_TYPE) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (XID_TYPE) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (XID_TYPE) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (XID_TYPE) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,8 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (XID_TYPE) xlrec->locking_xid, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (XID_TYPE) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +140,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (XID_TYPE) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (XID_TYPE) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +161,8 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (XID_TYPE) xlrec->xmax, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..706af4ad6db 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, "%llu ", (XID_TYPE) 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, "%llu offset %u nmembers %d: ", (XID_TYPE) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +74,8 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (XID_TYPE) xlrec->startTruncOff, (XID_TYPE) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..c6299f5799f 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (XID_TYPE) xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +80,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (XID_TYPE) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (XID_TYPE) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..ee0bd5f4f18 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (XID_TYPE) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..90c3f9f7ed6 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (XID_TYPE) xlrec->nextXid,
+ (XID_TYPE) xlrec->latestCompletedXid,
+ (XID_TYPE) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (XID_TYPE) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,8 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (XID_TYPE) xlrec->locks[i].xid, xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..74ae5f316f9 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, " %llu", (XID_TYPE) 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, "%llu: ", (XID_TYPE) 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, "%llu: ", (XID_TYPE) 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, " %llu", (XID_TYPE) 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 %llu: ", (XID_TYPE) 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..2dd8273c86a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (XID_TYPE) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (XID_TYPE) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (XID_TYPE) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (XID_TYPE) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (XID_TYPE) checkpoint->oldestCommitTsXid,
+ (XID_TYPE) checkpoint->newestCommitTsXid,
+ (XID_TYPE) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..d5038e8b8ba 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 %llu", (XID_TYPE) 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..c5d12b78c39 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,8 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (XID_TYPE) multi, (XID_TYPE) xid, mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (XID_TYPE) multi, (XID_TYPE) newMulti);
return newMulti;
}
@@ -490,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (XID_TYPE) xid, (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu?", (XID_TYPE) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +595,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running",
+ i, (XID_TYPE) 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: %llu is not running", (XID_TYPE) multi);
return false;
}
@@ -657,8 +658,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (XID_TYPE) nextMXact);
}
}
@@ -722,8 +723,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (XID_TYPE) 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 %llu offset %u", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1634,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (XID_TYPE) 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, "%llu %d[%llu (%s)", (XID_TYPE) multi, nmembers, (XID_TYPE) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)", (XID_TYPE) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2157,8 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu" " in DB %u",
+ (XID_TYPE) *nextMulti, *nextMultiOffset, (XID_TYPE) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2192,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (XID_TYPE) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -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 %llu", (XID_TYPE) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -3040,8 +3041,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (XID_TYPE) oldestMulti, (XID_TYPE) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3059,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (XID_TYPE) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (XID_TYPE) oldestMulti, (XID_TYPE) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3322,9 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (XID_TYPE) xlrec.startTruncOff, (XID_TYPE) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -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: %llu", (XID_TYPE) 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("%llu", (XID_TYPE) 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..df50128c576 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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..2044c51128b 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,8 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (XID_TYPE) previousXid, (XID_TYPE) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..a3c8070aa97 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (XID_TYPE) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (XID_TYPE) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..3681b3c4d2b 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 %llu", (XID_TYPE) 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 %llu from shared memory", (XID_TYPE) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2145,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (XID_TYPE) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (XID_TYPE) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2165,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (XID_TYPE) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (XID_TYPE) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2197,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (XID_TYPE) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (XID_TYPE) xid)));
}
/*
@@ -2358,8 +2358,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (XID_TYPE) 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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..c1d9f719291 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (XID_TYPE) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,22 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu", (XID_TYPE) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu", (XID_TYPE) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (XID_TYPE) XidFromFullTransactionId(s->fullTransactionId),
+ (XID_TYPE) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index f9f212680b0..6d20e45cd0b 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (XID_TYPE) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,18 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (XID_TYPE) checkPoint.nextMulti, (XID_TYPE) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (XID_TYPE) checkPoint.oldestXid, checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (XID_TYPE) checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (XID_TYPE) checkPoint.oldestCommitTsXid,
+ (XID_TYPE) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2490,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (XID_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (XID_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2635,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (XID_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (XID_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2679,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (XID_TYPE) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..2c02edcb23e 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 %llu at %X/%X", (XID_TYPE) 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..f7778502478 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (XID_TYPE) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -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 %llu", (XID_TYPE) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3855,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (XID_TYPE) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4165,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (XID_TYPE) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4848,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (XID_TYPE) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5479,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (XID_TYPE) 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..61f2e88099e 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (XID_TYPE) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (XID_TYPE) builder->xmin, (XID_TYPE) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (XID_TYPE) xid, (XID_TYPE) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (XID_TYPE) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -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 %llu to do timetravel", (XID_TYPE) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1149,8 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (XID_TYPE) builder->xmin, (XID_TYPE) builder->xmax, (XID_TYPE) running->oldestRunningXid, (XID_TYPE) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1239,8 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (XID_TYPE) builder->initial_xmin_horizon, (XID_TYPE) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1322,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (XID_TYPE) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1346,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (XID_TYPE) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 03e069c7cdd..b6c7e00cd62 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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-%llu.subxacts", subid, (XID_TYPE) 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-%llu.changes", subid, (XID_TYPE) 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_%llu", subid, (XID_TYPE) xid);
}
/*
@@ -3756,33 +3756,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (XID_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (XID_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (XID_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (XID_TYPE) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..306ec8be816 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,8 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (XID_TYPE) xmin, xmin_epoch, (XID_TYPE) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..1ef5bb100a3 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (XID_TYPE) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (XID_TYPE) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..1d56827af27 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (XID_TYPE) standbySnapshotPendingXmin,
+ (XID_TYPE) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (XID_TYPE) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (XID_TYPE) standbySnapshotPendingXmin,
+ (XID_TYPE) 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 %llu in MyProc", (XID_TYPE) 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 %llu in MyProc", (XID_TYPE) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4385,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (XID_TYPE) xid, (XID_TYPE) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4896,7 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu", (XID_TYPE) 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 %llu", (XID_TYPE) 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]=%llu ", i, (XID_TYPE) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..2cb52a06dbe 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (XID_TYPE) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (XID_TYPE) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (XID_TYPE) CurrRunningXacts->oldestRunningXid,
+ (XID_TYPE) CurrRunningXacts->latestCompletedXid,
+ (XID_TYPE) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (XID_TYPE) CurrRunningXacts->oldestRunningXid,
+ (XID_TYPE) CurrRunningXacts->latestCompletedXid,
+ (XID_TYPE) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..e27d38a5f12 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 %llu.", (XID_TYPE) 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 %llu.", (XID_TYPE) 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 %llu, during read.", (XID_TYPE) 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..a6e79813ce5 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/%llu", bid, (XID_TYPE) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..d4ea25e735e 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/%llu", MyProc->backendId, (XID_TYPE) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (XID_TYPE) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..a828a65338f 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",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId, (XID_TYPE) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId, (XID_TYPE) 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, "%llu", (XID_TYPE) 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..645edbfbc00 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (XID_TYPE) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (XID_TYPE) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..30b2fe531d1 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/%llu\n", MyProc->backendId, (XID_TYPE) 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:%llu\n", (XID_TYPE) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (XID_TYPE) 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:%llu\n", (XID_TYPE) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (XID_TYPE) 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:%llu\n", (XID_TYPE) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n", (XID_TYPE) 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, XID32_SCANF_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/" XID32_SCANF_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..58b3246e8af 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (XID_TYPE) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (XID_TYPE) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 725cd2e4ebc..bcd84e5f917 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,9 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (XID_TYPE) frozenxid, (XID_TYPE) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15467,9 +15467,9 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (XID_TYPE) tbinfo->frozenxid, (XID_TYPE) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15481,10 +15481,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (XID_TYPE) tbinfo->toast_frozenxid,
+ (XID_TYPE) 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..88a1f935749 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 %llu", (XID_TYPE) 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 %llu", (XID_TYPE) FirstNormalTransactionId);
exit(1);
}
break;
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..407e9e64c28 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,16 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir, (XID_TYPE) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir, (XID_TYPE) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +555,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtxid,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +581,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmxoff,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmulti,
+ (XID_TYPE) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +609,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +671,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +712,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (XID_TYPE) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index f128050b4ea..070b24f67f5 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -487,10 +487,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (XID_TYPE) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
@@ -949,7 +949,7 @@ main(int argc, char **argv)
}
break;
case 'x':
- if (sscanf(optarg, "%u", &config.filter_by_xid) != 1)
+ if (sscanf(optarg, XID32_SCANF_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..5b85465414f 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -593,6 +593,11 @@ typedef uint32 SubTransactionId;
#define InvalidSubTransactionId ((SubTransactionId) 0)
#define TopSubTransactionId ((SubTransactionId) 1)
+/* printf/elog format compatible with 32 and 64 bit xid. */
+typedef unsigned long long XID_TYPE;
+/* Temp define while internal xid is 32 bit. */
+#define XID32_SCANF_FMT "%u"
+
/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
typedef TransactionId MultiXactId;
--
2.35.1
v20-0002-Use-64-bit-pages-in-SLRU.patchapplication/octet-stream; name=v20-0002-Use-64-bit-pages-in-SLRU.patchDownload
From 2af22999a7cceccfb8b381d5ade647e22a243bb1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v20 2/5] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 117 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++--
src/backend/storage/lmgr/predicate.c | 4 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 94 insertions(+), 97 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index d5038e8b8ba..af2610244ce 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index c5d12b78c39..05262262e72 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2879,7 +2879,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3130,7 +3130,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3150,7 +3150,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index df50128c576..a008670561f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (int64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +951,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_TYPE) xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_TYPE) xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %llu", (XID_TYPE) xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_TYPE) xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %llu", (XID_TYPE) xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1016,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1027,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1071,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1161,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1304,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1327,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1500,9 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1515,9 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1530,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1558,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1568,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1599,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 2044c51128b..6b78a2c3096 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..61042c34d58 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e27d38a5f12..e389ef667a7 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
At Thu, 17 Mar 2022 19:25:00 +0300, Maxim Orlov <orlovmg@gmail.com> wrote in
Hi!
Here is the v20 patch. 0001 and 0002 are proposed into PG15 as
discussed above.
The whole set of patches is added into [1] to be committed into PG16.In this version we've made a major revision related to printf/elog format
compatible with localization
as was proposed above.We also think of adding 0003 patch related to 64 bit GUC's into this
thread. Suppose it also may be delivered
into PG15.Aleksander Alekseev, we've done this major revision mentioned above and you
are free to continue working on this patch set.Reviews and proposals are very welcome!
(I'm afraid that this thread is not for the discussion of the patch?:)
[1]
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
+/* printf/elog format compatible with 32 and 64 bit xid. */
+typedef unsigned long long XID_TYPE;
...
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (XID_TYPE) multi, (XID_TYPE) relminmxid)));
"(XID_TYPE) x" is actually equivalent to "(long long) x" here, but the
point here is "%llu in format string accepts (long long)" so we should
use literally (or bare) (long long) and the maybe-all precedents does
that.
And.. You looks like applying the change to some inappropriate places?
- elog(DEBUG2, "deleted page from block %u has safexid %u",
- blkno, opaque->btpo_level);
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (XID_TYPE) opaque->btpo_level);
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
At Fri, 18 Mar 2022 10:20:08 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in
"(XID_TYPE) x" is actually equivalent to "(long long) x" here, but the
point here is "%llu in format string accepts (long long)" so we should
Of course it's the typo of
"%llu in format string accepts (*unsigned* long long)".
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
At Thu, 17 Mar 2022 19:25:00 +0300, Maxim Orlov <orlovmg@gmail.com> wrote in
+/* printf/elog format compatible with 32 and 64 bit xid. */ +typedef unsigned long long XID_TYPE; ... + errmsg_internal("found multixact %llu from before relminmxid %llu", + (XID_TYPE) multi, (XID_TYPE) relminmxid)));
"(XID_TYPE) x" is actually equivalent to "(long long) x" here, but the
point here is "%llu in format string accepts (long long)" so we should
use literally (or bare) (long long) and the maybe-all precedents does
that.
Yes. Please do NOT do it like that. Write (long long), not something
else, to cast a value to match an "ll" format specifier. Otherwise
you're just making readers wonder whether your code is correct.
regards, tom lane
Hi hackers,
Aleksander Alekseev, we've done this major revision mentioned above and
you are free to continue working on this patch set.
Reviews and proposals are very welcome!
Many thanks!
Here is an new version with the following changes compared to v20:
- Commit messages and links to the discussions were updated;
- XID_TYPE name seemed to be slightly misleading. I changed it to
XID_FMT_TYPE. Not 100% sure if we really need this typedef though. If not,
XID_FMT_TYPE is easy to replace in the .patch files. Same for
XID32_SCANF_FMT definition;
- I noticed that pg_resetwal.c continues to use %u to format XIDs. Fixed;
- Since v20-0001 modifies gettext() arguments, I'm pretty sure the
corresponding .po files should be modified as well. I addressed this in a
separate patch in order to simplify the review;
To me personally v21 looks almost OK. The comments in c.h should be
rewritten depending on whether we choose to keep XID_FMT_TYPE and/or
XID32_SCANF_FMT. The patchset passes all the tests.
(As a side note, it looks like cfbot was slightly confused by forking the
thread and modifying the CF entry. It couldn't find v20. If somebody knows
how to fix this, please help.)
--
Best regards,
Aleksander Alekseev
Attachments:
v21-0001-Use-llu-to-format-XIDs.patchapplication/octet-stream; name=v21-0001-Use-llu-to-format-XIDs.patchDownload
From 9d47697edfb657641abaf2a2e206e584bd523004 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v21 1/3] Use %llu to format XIDs
Replaces the %u formatting string for XIDs with %llu. This is one step toward
64-bit XIDs. This patch doesn't modify corresponding .po files, it is done in
the following one.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 8 +-
contrib/pgrowlocks/pgrowlocks.c | 6 +-
contrib/test_decoding/test_decoding.c | 26 ++--
src/backend/access/heap/heapam.c | 44 +++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 12 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 36 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 8 +-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 14 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 77 +++++------
src/backend/access/transam/slru.c | 16 +--
src/backend/access/transam/subtrans.c | 4 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 36 +++---
src/backend/access/transam/xact.c | 14 +-
src/backend/access/transam/xlogrecovery.c | 42 +++---
src/backend/replication/logical/logical.c | 2 +-
.../replication/logical/reorderbuffer.c | 22 ++--
src/backend/replication/logical/snapbuild.c | 34 ++---
src/backend/replication/logical/worker.c | 26 ++--
src/backend/replication/walreceiver.c | 4 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 30 ++---
src/backend/storage/ipc/standby.c | 24 ++--
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 | 8 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 18 +--
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 14 +-
src/bin/pg_resetwal/pg_resetwal.c | 60 ++++-----
src/bin/pg_upgrade/pg_upgrade.c | 44 +++----
src/bin/pg_waldump/pg_waldump.c | 6 +-
src/include/c.h | 5 +
46 files changed, 455 insertions(+), 451 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb..b9dad69c57 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (XID_FMT_TYPE) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_FMT_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_FMT_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (XID_FMT_TYPE) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (XID_FMT_TYPE) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_FMT_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_FMT_TYPE) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (XID_FMT_TYPE) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (XID_FMT_TYPE) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,19 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (XID_FMT_TYPE) xmax, (XID_FMT_TYPE) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (XID_FMT_TYPE) xmax, (XID_FMT_TYPE) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (XID_FMT_TYPE) xmax,
+ (XID_FMT_TYPE) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (XID_FMT_TYPE) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1076,22 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (XID_FMT_TYPE) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
+ (XID_FMT_TYPE) xmax,
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
+ (XID_FMT_TYPE) xmax,
+ (XID_FMT_TYPE) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664..44a9ffe98b 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,13 +125,13 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (XID_FMT_TYPE) XidFromFullTransactionId(safexid));
}
else
- elog(DEBUG2, "deleted page from block %u has safexid %u",
- blkno, opaque->btpo_level);
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (XID_FMT_TYPE) opaque->btpo_level);
/* Don't interpret BTDeletedPageData as index tuples */
maxoff = InvalidOffsetNumber;
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203..02efe78917 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, "%llu", (XID_FMT_TYPE) 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, "%llu", (XID_FMT_TYPE) 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, "{%llu}", (XID_FMT_TYPE) 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 ea22649e41..e8a9185e3b 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +900,8 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid), (XID_FMT_TYPE) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 3746336a09..ab6d2fbfa2 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 %llu", (XID_FMT_TYPE) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6173,8 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (XID_FMT_TYPE) multi, (XID_FMT_TYPE) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6187,8 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (XID_FMT_TYPE) multi, (XID_FMT_TYPE) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6206,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -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 %llu", (XID_FMT_TYPE) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6294,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6344,8 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (XID_FMT_TYPE) update_xid, (XID_FMT_TYPE) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6474,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6483,8 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6555,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6570,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (XID_FMT_TYPE) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6586,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (XID_FMT_TYPE) 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 39ef8a0b77..6a155ab55b 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (XID_FMT_TYPE) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775ae..d5d397da17 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (XID_FMT_TYPE) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (XID_FMT_TYPE) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (XID_FMT_TYPE) MultiXactCutoff, diff);
}
if (orig_rel_pages > 0)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..513be0044f 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (XID_FMT_TYPE) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..6aab3f416c 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (XID_FMT_TYPE) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa158..c677f9a14a 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (XID_FMT_TYPE) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (XID_FMT_TYPE) xlrec->latestRemovedXid, xlrec->ntodelete);
}
@@ -51,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (XID_FMT_TYPE) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..5c713c2639 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (XID_FMT_TYPE) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65..5ddeed260a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (XID_FMT_TYPE) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (XID_FMT_TYPE) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (XID_FMT_TYPE) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (XID_FMT_TYPE) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,8 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (XID_FMT_TYPE) xlrec->locking_xid, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (XID_FMT_TYPE) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +140,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (XID_FMT_TYPE) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (XID_FMT_TYPE) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +161,8 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (XID_FMT_TYPE) xlrec->xmax, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..79f4ebec36 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, "%llu ", (XID_FMT_TYPE) 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, "%llu offset %u nmembers %d: ", (XID_FMT_TYPE) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +74,8 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (XID_FMT_TYPE) xlrec->startTruncOff, (XID_FMT_TYPE) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf..4da37a366d 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (XID_FMT_TYPE) xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +80,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (XID_FMT_TYPE) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (XID_FMT_TYPE) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..472ea3df7f 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (XID_FMT_TYPE) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..b7b49bcf7b 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (XID_FMT_TYPE) xlrec->nextXid,
+ (XID_FMT_TYPE) xlrec->latestCompletedXid,
+ (XID_FMT_TYPE) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (XID_FMT_TYPE) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,8 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (XID_FMT_TYPE) xlrec->locks[i].xid, xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6c..770ffba938 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, " %llu", (XID_FMT_TYPE) 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, "%llu: ", (XID_FMT_TYPE) 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, "%llu: ", (XID_FMT_TYPE) 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, " %llu", (XID_FMT_TYPE) 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 %llu: ", (XID_FMT_TYPE) 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 e7452af679..d32507d4e7 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (XID_FMT_TYPE) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (XID_FMT_TYPE) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (XID_FMT_TYPE) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (XID_FMT_TYPE) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (XID_FMT_TYPE) checkpoint->oldestCommitTsXid,
+ (XID_FMT_TYPE) checkpoint->newestCommitTsXid,
+ (XID_FMT_TYPE) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4..2946816521 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 %llu", (XID_FMT_TYPE) 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 6a70d49738..bdaeef1eda 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,8 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (XID_FMT_TYPE) multi, (XID_FMT_TYPE) xid, mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (XID_FMT_TYPE) multi, (XID_FMT_TYPE) newMulti);
return newMulti;
}
@@ -490,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu?", (XID_FMT_TYPE) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +595,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running",
+ i, (XID_FMT_TYPE) 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: %llu is not running", (XID_FMT_TYPE) multi);
return false;
}
@@ -657,8 +658,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (XID_FMT_TYPE) nextMXact);
}
}
@@ -722,8 +723,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (XID_FMT_TYPE) 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 %llu offset %u", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1634,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (XID_FMT_TYPE) 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, "%llu %d[%llu (%s)", (XID_FMT_TYPE) multi, nmembers, (XID_FMT_TYPE) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)", (XID_FMT_TYPE) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2157,8 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu" " in DB %u",
+ (XID_FMT_TYPE) *nextMulti, *nextMultiOffset, (XID_FMT_TYPE) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2192,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (XID_FMT_TYPE) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -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 %llu", (XID_FMT_TYPE) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -3040,8 +3041,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (XID_FMT_TYPE) oldestMulti, (XID_FMT_TYPE) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3059,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (XID_FMT_TYPE) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (XID_FMT_TYPE) oldestMulti, (XID_FMT_TYPE) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3322,9 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (XID_FMT_TYPE) xlrec.startTruncOff, (XID_FMT_TYPE) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -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: %llu", (XID_FMT_TYPE) 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("%llu", (XID_FMT_TYPE) 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 30a476ed5d..42e0e8fca5 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 66d3548155..61f688416a 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,8 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (XID_FMT_TYPE) previousXid, (XID_FMT_TYPE) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e8..d810f71d2f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (XID_FMT_TYPE) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (XID_FMT_TYPE) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed125..59336f6658 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 %llu", (XID_FMT_TYPE) 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 %llu from shared memory", (XID_FMT_TYPE) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2145,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (XID_FMT_TYPE) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (XID_FMT_TYPE) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2165,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (XID_FMT_TYPE) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (XID_FMT_TYPE) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2197,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (XID_FMT_TYPE) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (XID_FMT_TYPE) xid)));
}
/*
@@ -2358,8 +2358,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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 8964ddf3eb..2c9df7603a 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (XID_FMT_TYPE) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,22 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu", (XID_FMT_TYPE) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu", (XID_FMT_TYPE) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (XID_FMT_TYPE) XidFromFullTransactionId(s->fullTransactionId),
+ (XID_FMT_TYPE) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 9feea3e6ec..f49e943280 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (XID_FMT_TYPE) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,18 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (XID_FMT_TYPE) checkPoint.nextMulti, (XID_FMT_TYPE) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (XID_FMT_TYPE) checkPoint.oldestXid, checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (XID_FMT_TYPE) checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (XID_FMT_TYPE) checkPoint.oldestCommitTsXid,
+ (XID_FMT_TYPE) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2490,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (XID_FMT_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (XID_FMT_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2635,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (XID_FMT_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (XID_FMT_TYPE) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2679,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (XID_FMT_TYPE) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d..b6425c9e97 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 %llu at %X/%X", (XID_FMT_TYPE) 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 c2d9be81fa..4523610d48 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (XID_FMT_TYPE) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -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 %llu", (XID_FMT_TYPE) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3855,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (XID_FMT_TYPE) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4165,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (XID_FMT_TYPE) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4848,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (XID_FMT_TYPE) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5479,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (XID_FMT_TYPE) 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 83fca8a77d..d577f99ace 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (XID_FMT_TYPE) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (XID_FMT_TYPE) builder->xmin, (XID_FMT_TYPE) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (XID_FMT_TYPE) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -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 %llu to do timetravel", (XID_FMT_TYPE) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1149,8 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (XID_FMT_TYPE) builder->xmin, (XID_FMT_TYPE) builder->xmax, (XID_FMT_TYPE) running->oldestRunningXid, (XID_FMT_TYPE) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1239,8 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (XID_FMT_TYPE) builder->initial_xmin_horizon, (XID_FMT_TYPE) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1322,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (XID_FMT_TYPE) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1346,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (XID_FMT_TYPE) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 03e069c7cd..d07ebd16e9 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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-%llu.subxacts", subid, (XID_FMT_TYPE) 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-%llu.changes", subid, (XID_FMT_TYPE) 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_%llu", subid, (XID_FMT_TYPE) xid);
}
/*
@@ -3756,33 +3756,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (XID_FMT_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (XID_FMT_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (XID_FMT_TYPE) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (XID_FMT_TYPE) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b9..cf618d485a 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,8 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (XID_FMT_TYPE) xmin, xmin_epoch, (XID_FMT_TYPE) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092..827edbfbf6 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (XID_FMT_TYPE) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (XID_FMT_TYPE) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b..6ff7c09c0a 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (XID_FMT_TYPE) standbySnapshotPendingXmin,
+ (XID_FMT_TYPE) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (XID_FMT_TYPE) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (XID_FMT_TYPE) standbySnapshotPendingXmin,
+ (XID_FMT_TYPE) 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 %llu in MyProc", (XID_FMT_TYPE) 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 %llu in MyProc", (XID_FMT_TYPE) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4385,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (XID_FMT_TYPE) xid, (XID_FMT_TYPE) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4896,7 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) 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]=%llu ", i, (XID_FMT_TYPE) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac861..bcfcebe858 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (XID_FMT_TYPE) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (XID_FMT_TYPE) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (XID_FMT_TYPE) CurrRunningXacts->oldestRunningXid,
+ (XID_FMT_TYPE) CurrRunningXacts->latestCompletedXid,
+ (XID_FMT_TYPE) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (XID_FMT_TYPE) CurrRunningXacts->oldestRunningXid,
+ (XID_FMT_TYPE) CurrRunningXacts->latestCompletedXid,
+ (XID_FMT_TYPE) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b2..987e17dcf6 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 %llu.", (XID_FMT_TYPE) 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 %llu.", (XID_FMT_TYPE) 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 %llu, during read.", (XID_FMT_TYPE) 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 944cd6df03..250dd12cbb 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/%llu", bid, (XID_FMT_TYPE) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d..8652780b4f 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/%llu", MyProc->backendId, (XID_FMT_TYPE) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (XID_FMT_TYPE) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..765c2743c5 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",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId, (XID_FMT_TYPE) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId, (XID_FMT_TYPE) 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, "%llu", (XID_FMT_TYPE) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 843641c865..9432e46d5b 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (XID_FMT_TYPE) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (XID_FMT_TYPE) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a..497dc8ce59 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/%llu\n", MyProc->backendId, (XID_FMT_TYPE) 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:%llu\n", (XID_FMT_TYPE) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (XID_FMT_TYPE) 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:%llu\n", (XID_FMT_TYPE) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (XID_FMT_TYPE) 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:%llu\n", (XID_FMT_TYPE) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n", (XID_FMT_TYPE) 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, XID32_SCANF_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/" XID32_SCANF_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 f911f98d94..2ad3738e6c 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (XID_FMT_TYPE) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (XID_FMT_TYPE) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 725cd2e4eb..d2c522afa6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,9 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (XID_FMT_TYPE) frozenxid, (XID_FMT_TYPE) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15467,9 +15467,9 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (XID_FMT_TYPE) tbinfo->frozenxid, (XID_FMT_TYPE) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15481,10 +15481,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (XID_FMT_TYPE) tbinfo->toast_frozenxid,
+ (XID_FMT_TYPE) 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 1eb4509fca..ca8998c864 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 %llu", (XID_FMT_TYPE) 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 %llu", (XID_FMT_TYPE) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +772,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (XID_FMT_TYPE)XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,10 +841,10 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
@@ -863,10 +863,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (XID_FMT_TYPE)XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +879,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (XID_FMT_TYPE)ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f647..ba822735c0 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,16 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir, (XID_FMT_TYPE) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir, (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +555,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtxid,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +581,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmxoff,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmulti,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +609,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +671,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +712,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (XID_FMT_TYPE) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index fc081adfb8..d8438c20b0 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -486,10 +486,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (XID_FMT_TYPE) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
@@ -948,7 +948,7 @@ main(int argc, char **argv)
}
break;
case 'x':
- if (sscanf(optarg, "%u", &config.filter_by_xid) != 1)
+ if (sscanf(optarg, XID32_SCANF_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 4f16e589b3..a636725aa9 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -593,6 +593,11 @@ typedef uint32 SubTransactionId;
#define InvalidSubTransactionId ((SubTransactionId) 0)
#define TopSubTransactionId ((SubTransactionId) 1)
+/* printf/elog format compatible with 32 and 64 bit xid. */
+typedef unsigned long long XID_FMT_TYPE;
+/* Temp define while internal xid is 32 bit. */
+#define XID32_SCANF_FMT "%u"
+
/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
typedef TransactionId MultiXactId;
--
2.35.1
v21-0002-Update-XID-formatting-in-the-.po-files.patchapplication/octet-stream; name=v21-0002-Update-XID-formatting-in-the-.po-files.patchDownload
From 432d9ef5f2e1c1f77f92881005e980266224de68 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Fri, 18 Mar 2022 13:08:34 +0300
Subject: [PATCH v21 2/3] Update XID formatting in the .po files
This patch updates the XIDs formatting in the .po files. Previously the
formatting was changed from %u to %llu. This is one step toward 64-bit XIDs.
Author: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/bin/pg_controldata/po/cs.po | 28 ++++++++--------
src/bin/pg_controldata/po/de.po | 28 ++++++++--------
src/bin/pg_controldata/po/el.po | 28 ++++++++--------
src/bin/pg_controldata/po/es.po | 28 ++++++++--------
src/bin/pg_controldata/po/fr.po | 28 ++++++++--------
src/bin/pg_controldata/po/it.po | 28 ++++++++--------
src/bin/pg_controldata/po/ja.po | 28 ++++++++--------
src/bin/pg_controldata/po/ko.po | 28 ++++++++--------
src/bin/pg_controldata/po/pl.po | 28 ++++++++--------
src/bin/pg_controldata/po/pt_BR.po | 28 ++++++++--------
src/bin/pg_controldata/po/ru.po | 28 ++++++++--------
src/bin/pg_controldata/po/sv.po | 28 ++++++++--------
src/bin/pg_controldata/po/tr.po | 28 ++++++++--------
src/bin/pg_controldata/po/uk.po | 28 ++++++++--------
src/bin/pg_controldata/po/vi.po | 28 ++++++++--------
src/bin/pg_controldata/po/zh_CN.po | 28 ++++++++--------
src/bin/pg_resetwal/po/cs.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/de.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/es.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/fr.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/it.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ja.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ko.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/pl.po | 48 +++++++++++++--------------
src/bin/pg_resetwal/po/pt_BR.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ru.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/sv.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/tr.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/uk.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/zh_CN.po | 52 +++++++++++++++---------------
30 files changed, 586 insertions(+), 586 deletions(-)
diff --git a/src/bin/pg_controldata/po/cs.po b/src/bin/pg_controldata/po/cs.po
index 4774832b80..5c61c0bde0 100644
--- a/src/bin/pg_controldata/po/cs.po
+++ b/src/bin/pg_controldata/po/cs.po
@@ -311,8 +311,8 @@ msgstr "zapnuto"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID posledního checkpointu: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID posledního checkpointu: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -321,8 +321,8 @@ msgstr "Poslední umístění NextOID checkpointu: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId posledního checkpointu: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId posledního checkpointu: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -331,8 +331,8 @@ msgstr "NextMultiOffset posledního checkpointu: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID posledního checkpointu: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -341,13 +341,13 @@ msgstr "DB k oldestXID posledního checkpointu: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID posledního checkpointu: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid posledního checkpointu: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -356,13 +356,13 @@ msgstr "DB k oldestMulti posledního checkpointu: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid posledního checkpointu: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid posledního checkpointu: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/de.po b/src/bin/pg_controldata/po/de.po
index 4a8785d336..913f7db1d8 100644
--- a/src/bin/pg_controldata/po/de.po
+++ b/src/bin/pg_controldata/po/de.po
@@ -298,8 +298,8 @@ msgstr "an"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID des letzten Checkpoints: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID des letzten Checkpoints: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -308,8 +308,8 @@ msgstr "NextOID des letzten Checkpoints: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId des letzten Checkpoints: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -318,8 +318,8 @@ msgstr "NextMultiOffset des letzten Checkpoints: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID des letzten Checkpoints: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -328,13 +328,13 @@ msgstr "DB der oldestXID des letzten Checkpoints: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID des letzten Checkpoints: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -343,13 +343,13 @@ msgstr "DB des oldestMulti des letzten Checkpoints: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/el.po b/src/bin/pg_controldata/po/el.po
index 12bbb0556b..8ea7c92605 100644
--- a/src/bin/pg_controldata/po/el.po
+++ b/src/bin/pg_controldata/po/el.po
@@ -307,8 +307,8 @@ msgstr "ανοικτό"
#: pg_controldata.c:250
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Πιο πρόσφατο NextXID του σημείου ελέγχου: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Πιο πρόσφατο NextXID του σημείου ελέγχου: %u:%llu\n"
#: pg_controldata.c:253
#, c-format
@@ -317,8 +317,8 @@ msgstr "Πιο πρόσφατο NextOID του σημείου ελέγχου:
#: pg_controldata.c:255
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Πιο πρόσφατο NextMultiXactId του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Πιο πρόσφατο NextMultiXactId του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:257
#, c-format
@@ -327,8 +327,8 @@ msgstr "Πιο πρόσφατο NextMultiOffset του σημείου ελέγχ
#: pg_controldata.c:259
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Πιο πρόσφατο oldestXID του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Πιο πρόσφατο oldestXID του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:261
#, c-format
@@ -337,13 +337,13 @@ msgstr "Πιο πρόσφατο oldestXID’s DB του σημείου ελέγ
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Πιο πρόσφατο oldestActiveXID του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Πιο πρόσφατο oldestActiveXID του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Πιο πρόσφατο oldestMultiXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Πιο πρόσφατο oldestMultiXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:267
#, c-format
@@ -352,13 +352,13 @@ msgstr "Πιο πρόσφατο oldestMulti’s DB του σημείου ελέ
#: pg_controldata.c:269
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Πιο πρόσφατο oldestCommitTsXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Πιο πρόσφατο oldestCommitTsXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Πιο πρόσφατο newestCommitTsXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Πιο πρόσφατο newestCommitTsXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:273
#, c-format
diff --git a/src/bin/pg_controldata/po/es.po b/src/bin/pg_controldata/po/es.po
index 2764c38466..dc7e439776 100644
--- a/src/bin/pg_controldata/po/es.po
+++ b/src/bin/pg_controldata/po/es.po
@@ -301,8 +301,8 @@ msgstr "activado"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID de último checkpoint: %u/%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID de último checkpoint: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -311,8 +311,8 @@ msgstr "NextOID de último checkpoint: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId de último checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId de último checkpoint: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -321,8 +321,8 @@ msgstr "NextMultiOffset de último checkpoint: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID del último checkpoint: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -331,13 +331,13 @@ msgstr "DB del oldestXID del último checkpoint: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID del último checkpoint: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid del último checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -346,13 +346,13 @@ msgstr "DB del oldestMultiXid del últ. checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid del último checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid del último checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/fr.po b/src/bin/pg_controldata/po/fr.po
index bd3b6d68c2..78105d841d 100644
--- a/src/bin/pg_controldata/po/fr.po
+++ b/src/bin/pg_controldata/po/fr.po
@@ -304,8 +304,8 @@ msgstr "activé"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Dernier NextXID du point de contrôle : %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Dernier NextXID du point de contrôle : %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -314,8 +314,8 @@ msgstr "Dernier NextOID du point de contrôle : %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Dernier NextMultiXactId du point de contrôle : %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Dernier NextMultiXactId du point de contrôle : %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -324,8 +324,8 @@ msgstr "Dernier NextMultiOffset du point de contrôle : %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Dernier oldestXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Dernier oldestXID du point de contrôle : %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -334,13 +334,13 @@ msgstr "Dernier oldestXID du point de contrôle de la base : %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Dernier oldestActiveXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Dernier oldestActiveXID du point de contrôle : %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Dernier oldestMultiXid du point de restauration : %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Dernier oldestMultiXid du point de restauration : %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -349,13 +349,13 @@ msgstr "Dernier oldestMulti du point de restauration de base : %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Dernier oldestCommitTsXid du point de restauration : %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Dernier oldestCommitTsXid du point de restauration : %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Dernier newestCommitTsXid du point de restauration : %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Dernier newestCommitTsXid du point de restauration : %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/it.po b/src/bin/pg_controldata/po/it.po
index e1697bb668..fc97f4c580 100644
--- a/src/bin/pg_controldata/po/it.po
+++ b/src/bin/pg_controldata/po/it.po
@@ -285,8 +285,8 @@ msgstr "attivato"
#: pg_controldata.c:258
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID dell'ultimo checkpoint: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID dell'ultimo checkpoint: %u:%llu\n"
#: pg_controldata.c:261
#, c-format
@@ -295,8 +295,8 @@ msgstr "NextOID dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:265
#, c-format
@@ -305,8 +305,8 @@ msgstr "NextMultiOffset dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -315,13 +315,13 @@ msgstr "DB dell'oldestXID dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
@@ -330,13 +330,13 @@ msgstr "DB dell'oldestMulti dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:277
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:281
#, c-format
diff --git a/src/bin/pg_controldata/po/ja.po b/src/bin/pg_controldata/po/ja.po
index a98a05fbf1..0a2990ac1b 100644
--- a/src/bin/pg_controldata/po/ja.po
+++ b/src/bin/pg_controldata/po/ja.po
@@ -301,8 +301,8 @@ msgstr "オン"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最終チェックポイントのNextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最終チェックポイントのNextXID: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -311,8 +311,8 @@ msgstr "最終チェックポイントのNextOID: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最終チェックポイントのNextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最終チェックポイントのNextMultiXactId: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -321,8 +321,8 @@ msgstr "最終チェックポイントのNextMultiOffset: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最終チェックポイントのoldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最終チェックポイントのoldestXID: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -331,13 +331,13 @@ msgstr "最終チェックポイントのoldestXIDのDB: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最終チェックポイントのoldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最終チェックポイントのoldestActiveXID: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最終チェックポイントのoldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最終チェックポイントのoldestMultiXid: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -346,13 +346,13 @@ msgstr "最終チェックポイントのoldestMultiのDB: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのoldestCommitTsXid: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのoldestCommitTsXid: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのnewestCommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのnewestCommitTsXid: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/ko.po b/src/bin/pg_controldata/po/ko.po
index 962b36ece7..7f3055c7d6 100644
--- a/src/bin/pg_controldata/po/ko.po
+++ b/src/bin/pg_controldata/po/ko.po
@@ -290,8 +290,8 @@ msgstr "on"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "마지막 체크포인트 NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "마지막 체크포인트 NextXID: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -300,8 +300,8 @@ msgstr "마지막 체크포인트 NextOID: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "마지막 체크포인트 NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "마지막 체크포인트 NextMultiXactId: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -310,8 +310,8 @@ msgstr "마지막 체크포인트 NextMultiOffset: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "마지막 체크포인트 제일오래된XID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "마지막 체크포인트 제일오래된XID: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -320,13 +320,13 @@ msgstr "마지막 체크포인트 제일오래된XID의 DB: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "마지막 체크포인트 제일오래된ActiveXID:%u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "마지막 체크포인트 제일오래된ActiveXID: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "마지막 체크포인트 제일오래된MultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "마지막 체크포인트 제일오래된MultiXid: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -335,13 +335,13 @@ msgstr "마지막 체크포인트 제일오래된멀티Xid DB:%u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 제일오래된CommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 제일오래된CommitTsXid:%llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 최신CommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 최신CommitTsXid: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/pl.po b/src/bin/pg_controldata/po/pl.po
index 7f52886303..59615b663a 100644
--- a/src/bin/pg_controldata/po/pl.po
+++ b/src/bin/pg_controldata/po/pl.po
@@ -244,8 +244,8 @@ msgstr "włączone"
#: pg_controldata.c:228
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %u:%llu\n"
#: pg_controldata.c:231
#, c-format
@@ -254,8 +254,8 @@ msgstr "NextOID najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:233
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:235
#, c-format
@@ -264,8 +264,8 @@ msgstr "NextMultiOffset najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:237
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:239
#, c-format
@@ -274,13 +274,13 @@ msgstr "DB oldestXID'u najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:241
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:243
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:245
#, c-format
@@ -289,13 +289,13 @@ msgstr "DB oldestMulti'u najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:247
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:249
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:251
#, c-format
diff --git a/src/bin/pg_controldata/po/pt_BR.po b/src/bin/pg_controldata/po/pt_BR.po
index f40e348ab9..e35f61b902 100644
--- a/src/bin/pg_controldata/po/pt_BR.po
+++ b/src/bin/pg_controldata/po/pt_BR.po
@@ -244,8 +244,8 @@ msgstr "habilitado"
#: pg_controldata.c:217
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID do último ponto de controle: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID do último ponto de controle: %u:%llu\n"
#: pg_controldata.c:220
#, c-format
@@ -254,8 +254,8 @@ msgstr "NextOID do último ponto de controle: %u\n"
#: pg_controldata.c:222
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId do último ponto de controle: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId do último ponto de controle: %llu\n"
#: pg_controldata.c:224
#, c-format
@@ -264,8 +264,8 @@ msgstr "NextMultiOffset do último ponto de controle: %u\n"
#: pg_controldata.c:226
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID do último ponto de controle: %llu\n"
#: pg_controldata.c:228
#, c-format
@@ -274,13 +274,13 @@ msgstr "BD do oldestXID do último ponto de controle: %u\n"
#: pg_controldata.c:230
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID do último ponto de controle: %llu\n"
#: pg_controldata.c:232
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid do último ponto de controle: %llu\n"
#: pg_controldata.c:234
#, c-format
@@ -289,13 +289,13 @@ msgstr "BD do oldestMulti do último ponto de controle: %u\n"
#: pg_controldata.c:236
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid do último ponto de controle: %llu\n"
#: pg_controldata.c:238
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid do último ponto de controle: %llu\n"
#: pg_controldata.c:240
#, c-format
diff --git a/src/bin/pg_controldata/po/ru.po b/src/bin/pg_controldata/po/ru.po
index 39343c05a1..fe9b6ff5f6 100644
--- a/src/bin/pg_controldata/po/ru.po
+++ b/src/bin/pg_controldata/po/ru.po
@@ -317,8 +317,8 @@ msgstr "вкл."
# skip-rule: capital-letter-first
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID последней конт. точки: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID последней конт. точки: %u:%llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:255
@@ -329,8 +329,8 @@ msgstr "NextOID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId послед. конт. точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId послед. конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:259
@@ -341,8 +341,8 @@ msgstr "NextMultiOffset послед. конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID последней конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:263
@@ -353,14 +353,14 @@ msgstr "БД с oldestXID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID последней к. т.: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid последней конт. точки: %llu\n"
# skip-rule: double-space, capital-letter-first
#: pg_controldata.c:269
@@ -371,14 +371,14 @@ msgstr "БД с oldestMulti последней к. т.: %u\n"
# skip-rule: double-space, capital-letter-first
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid последней к. т.: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid последней к. т.: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/sv.po b/src/bin/pg_controldata/po/sv.po
index 3526df1a9c..f9d5bf2416 100644
--- a/src/bin/pg_controldata/po/sv.po
+++ b/src/bin/pg_controldata/po/sv.po
@@ -304,8 +304,8 @@ msgstr "på"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID vid senaste checkpoint: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID vid senaste checkpoint: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -314,8 +314,8 @@ msgstr "NextOID vid senaste checkpoint: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId vid senaste checkpoint: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -324,8 +324,8 @@ msgstr "NextMultiOffset vid senaste checkpoint: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID vid senaste checkpoint: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -334,13 +334,13 @@ msgstr "DB för oldestXID vid senaste checkpoint: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID vid senaste checkpoint: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -349,13 +349,13 @@ msgstr "DB för oldestMulti vid senaste checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/tr.po b/src/bin/pg_controldata/po/tr.po
index 528889f280..c9f0d21a39 100644
--- a/src/bin/pg_controldata/po/tr.po
+++ b/src/bin/pg_controldata/po/tr.po
@@ -298,8 +298,8 @@ msgstr "açık"
#: pg_controldata.c:258
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "En son checkpoint'in NextXID'si: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "En son checkpoint'in NextXID'si: %u:%llu\n"
#: pg_controldata.c:261
#, c-format
@@ -308,8 +308,8 @@ msgstr "En son checkpoint'in NextOID'si: %u\n"
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "En son checkpoint'in NextMultiXactId'si: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "En son checkpoint'in NextMultiXactId'si: %llu\n"
#: pg_controldata.c:265
#, c-format
@@ -318,8 +318,8 @@ msgstr "En son checkpoint'in NextMultiOffset'i: %u\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "En son checkpoint'in oldestXID'si: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "En son checkpoint'in oldestXID'si: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -328,13 +328,13 @@ msgstr "En son checkpoint'in oldestXID'sini DB'si: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "En son checkpoint'in odestActiveXID'si: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "En son checkpoint'in odestActiveXID'si: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "En son checkpoint'in oldestMultiXid'si: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "En son checkpoint'in oldestMultiXid'si: %llu\n"
#: pg_controldata.c:275
#, c-format
@@ -343,13 +343,13 @@ msgstr "En son checkpoint'in oldestMulti'sinin DB'si: %u\n"
#: pg_controldata.c:277
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "En son checkpoint'in oldestCommitTsXid'si: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "En son checkpoint'in oldestCommitTsXid'si: %llu\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "En son checkpoint'in newestCommitTsXid'si: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "En son checkpoint'in newestCommitTsXid'si: %llu\n"
#: pg_controldata.c:281
#, c-format
diff --git a/src/bin/pg_controldata/po/uk.po b/src/bin/pg_controldata/po/uk.po
index 23c5dfb714..4666d291e5 100644
--- a/src/bin/pg_controldata/po/uk.po
+++ b/src/bin/pg_controldata/po/uk.po
@@ -265,8 +265,8 @@ msgstr "увімк"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Останній NextXID контрольної точки: %u%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Останній NextXID контрольної точки: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -275,8 +275,8 @@ msgstr "Останній NextOID контрольної точки: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Останній NextMultiXactId контрольної точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Останній NextMultiXactId контрольної точки: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -285,8 +285,8 @@ msgstr "Останній NextMultiOffset контрольної точки: %u\n
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Останній oldestXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Останній oldestXID контрольної точки: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -295,13 +295,13 @@ msgstr "Остання DB останнього oldestXID контрольної
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Останній oldestActiveXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Останній oldestActiveXID контрольної точки: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Останній oldestMultiXid контрольної точки: %u \n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Останній oldestMultiXid контрольної точки: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -310,13 +310,13 @@ msgstr "Остання DB останньої oldestMulti контрольної
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Останній oldestCommitTsXid контрольної точки:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Останній oldestCommitTsXid контрольної точки:%llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Останній newestCommitTsXid контрольної точки: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Останній newestCommitTsXid контрольної точки: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/vi.po b/src/bin/pg_controldata/po/vi.po
index 019b7b05d8..4a530768c2 100644
--- a/src/bin/pg_controldata/po/vi.po
+++ b/src/bin/pg_controldata/po/vi.po
@@ -262,8 +262,8 @@ msgstr "on"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID của checkpoint gần nhất: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID của checkpoint gần nhất: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -272,8 +272,8 @@ msgstr "NextOID của checkpoint gần nhất: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -282,8 +282,8 @@ msgstr "NextMultiOffset của checkpoint gần nhất: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "OldestXID của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "OldestXID của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -292,13 +292,13 @@ msgstr "OldestXID DB của checkpoint gần nhất: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "OldestActiveXID của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "OldestActiveXID của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "OldestMultiXid của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "OldestMultiXid của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -307,13 +307,13 @@ msgstr "OldestMulti DB của checkpoint gần nhất: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "OldestCommitTsXid DB của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "OldestCommitTsXid DB của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "NewestCommitTsXid của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "NewestCommitTsXid của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/zh_CN.po b/src/bin/pg_controldata/po/zh_CN.po
index 259996bfc0..caf24e1850 100644
--- a/src/bin/pg_controldata/po/zh_CN.po
+++ b/src/bin/pg_controldata/po/zh_CN.po
@@ -286,8 +286,8 @@ msgstr "开启"
#: pg_controldata.c:260
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最新检查点的NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最新检查点的NextXID: %u:%llu\n"
#: pg_controldata.c:263
#, c-format
@@ -296,8 +296,8 @@ msgstr "最新检查点的 NextOID: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最新检查点的NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最新检查点的NextMultiXactId: %llu\n"
#: pg_controldata.c:267
#, c-format
@@ -306,8 +306,8 @@ msgstr "最新检查点的NextMultiOffsetD: %u\n"
#: pg_controldata.c:269
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最新检查点的oldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最新检查点的oldestXID: %llu\n"
#: pg_controldata.c:271
#, c-format
@@ -316,13 +316,13 @@ msgstr "最新检查点的oldestXID所在的数据库:%u\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最新检查点的oldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最新检查点的oldestActiveXID: %llu\n"
#: pg_controldata.c:275
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最新检查点的oldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最新检查点的oldestMultiXid: %llu\n"
#: pg_controldata.c:277
#, c-format
@@ -331,13 +331,13 @@ msgstr "最新检查点的oldestMulti所在的数据库:%u\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最新检查点的oldestCommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最新检查点的oldestCommitTsXid:%llu\n"
#: pg_controldata.c:281
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最新检查点的newestCommitTsXid:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最新检查点的newestCommitTsXid:%llu\n"
#: pg_controldata.c:283
#, c-format
diff --git a/src/bin/pg_resetwal/po/cs.po b/src/bin/pg_resetwal/po/cs.po
index f1ec4d9da1..fd540ff3c8 100644
--- a/src/bin/pg_resetwal/po/cs.po
+++ b/src/bin/pg_resetwal/po/cs.po
@@ -307,8 +307,8 @@ msgstr "zapnuto"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID posledního checkpointu: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID posledního checkpointu: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -317,8 +317,8 @@ msgstr "Poslední umístění NextOID checkpointu: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId posledního checkpointu: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId posledního checkpointu: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -327,8 +327,8 @@ msgstr "NextMultiOffset posledního checkpointu: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID posledního checkpointu: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -337,13 +337,13 @@ msgstr "DB k oldestXID posledního checkpointu: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID posledního checkpointu: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -352,13 +352,13 @@ msgstr "DB k oldestMulti posledního checkpointu: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -452,13 +452,13 @@ msgstr "První log segment po resetu: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -477,13 +477,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -497,13 +497,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/de.po b/src/bin/pg_resetwal/po/de.po
index 433f4008fa..256b12cdef 100644
--- a/src/bin/pg_resetwal/po/de.po
+++ b/src/bin/pg_resetwal/po/de.po
@@ -305,8 +305,8 @@ msgstr "an"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID des letzten Checkpoints: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID des letzten Checkpoints: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -315,8 +315,8 @@ msgstr "NextOID des letzten Checkpoints: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -325,8 +325,8 @@ msgstr "NextMultiOffset des letzten Checkpoints: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -335,13 +335,13 @@ msgstr "DB der oldestXID des letzten Checkpoints: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -350,13 +350,13 @@ msgstr "DB des oldestMulti des letzten Checkpoints: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -450,13 +450,13 @@ msgstr "Erstes Logdateisegment nach Zurücksetzen: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -475,13 +475,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -495,13 +495,13 @@ msgstr "NextXID-Epoche: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/es.po b/src/bin/pg_resetwal/po/es.po
index 4403bc0908..eccdc309fd 100644
--- a/src/bin/pg_resetwal/po/es.po
+++ b/src/bin/pg_resetwal/po/es.po
@@ -309,8 +309,8 @@ msgstr "activado"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID del checkpoint más reciente: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID del checkpoint más reciente: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -319,8 +319,8 @@ msgstr "NextOID del checkpoint más reciente: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -329,8 +329,8 @@ msgstr "NextMultiOffset del checkpoint más reciente: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -339,13 +339,13 @@ msgstr "BD del oldestXID del checkpoint más reciente: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -354,13 +354,13 @@ msgstr "BD del oldestMultiXid del checkpt. más reciente: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid del último checkpoint: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid del último checkpoint: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Primer segmento de log después de reiniciar: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "Epoch del NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/fr.po b/src/bin/pg_resetwal/po/fr.po
index 4ebf78caa8..f9e3a8d600 100644
--- a/src/bin/pg_resetwal/po/fr.po
+++ b/src/bin/pg_resetwal/po/fr.po
@@ -309,8 +309,8 @@ msgstr "activé"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Dernier NextXID du point de contrôle : %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Dernier NextXID du point de contrôle : %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -319,8 +319,8 @@ msgstr "Dernier NextOID du point de contrôle : %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Dernier NextMultiXactId du point de contrôle : %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Dernier NextMultiXactId du point de contrôle : %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -329,8 +329,8 @@ msgstr "Dernier NextMultiOffset du point de contrôle : %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Dernier oldestXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Dernier oldestXID du point de contrôle : %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -339,13 +339,13 @@ msgstr "Dernier oldestXID du point de contrôle de la base : %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Dernier oldestActiveXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Dernier oldestActiveXID du point de contrôle : %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Dernier oldestMultiXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Dernier oldestMultiXID du point de contrôle : %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -354,13 +354,13 @@ msgstr "Dernier oldestMulti du point de contrôle de la base : %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Dernier oldestCommitTsXid du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Dernier oldestCommitTsXid du point de contrôle : %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Dernier newestCommitTsXid du point de contrôle : %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Dernier newestCommitTsXid du point de contrôle : %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Premier segment du journal après réinitialisation : %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "NextXID Epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/it.po b/src/bin/pg_resetwal/po/it.po
index 9fc4479060..281187c367 100644
--- a/src/bin/pg_resetwal/po/it.po
+++ b/src/bin/pg_resetwal/po/it.po
@@ -263,8 +263,8 @@ msgstr "attivato"
#: pg_resetxlog.c:649
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID dell'ultimo checkpoint: %u.%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID dell'ultimo checkpoint: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -273,8 +273,8 @@ msgstr "NextOID dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -283,8 +283,8 @@ msgstr "NextMultiOffset dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -293,13 +293,13 @@ msgstr "DB dell'oldestXID dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:664
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:666
#, c-format
@@ -308,13 +308,13 @@ msgstr "DB dell'oldestMulti dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -417,13 +417,13 @@ msgstr "Primo segmento di log dopo il reset: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -442,13 +442,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -462,13 +462,13 @@ msgstr "Epoca del NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/ja.po b/src/bin/pg_resetwal/po/ja.po
index b14af6e21d..e548930691 100644
--- a/src/bin/pg_resetwal/po/ja.po
+++ b/src/bin/pg_resetwal/po/ja.po
@@ -303,8 +303,8 @@ msgstr "オン"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最終チェックポイントのNextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最終チェックポイントのNextXID: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -313,8 +313,8 @@ msgstr "最終チェックポイントのNextOID: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最終チェックポイントのNextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最終チェックポイントのNextMultiXactId: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -323,8 +323,8 @@ msgstr "最終チェックポイントのNextMultiOffset: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最終チェックポイントのoldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最終チェックポイントのoldestXID: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -333,13 +333,13 @@ msgstr "最終チェックポイントのoldestXIDのDB: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最終チェックポイントのoldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最終チェックポイントのoldestActiveXID: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最終チェックポイントのoldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最終チェックポイントのoldestMultiXid: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -348,13 +348,13 @@ msgstr "最終チェックポイントのoldestMultiのDB: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのoldestCommitTsXid: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのoldestCommitTsXid: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのnewestCommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのnewestCommitTsXid: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -448,13 +448,13 @@ msgstr "リセット後最初のログセグメント: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -473,13 +473,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -493,13 +493,13 @@ msgstr "NextXID基点: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/ko.po b/src/bin/pg_resetwal/po/ko.po
index 03e30bc6d8..7686261876 100644
--- a/src/bin/pg_resetwal/po/ko.po
+++ b/src/bin/pg_resetwal/po/ko.po
@@ -308,8 +308,8 @@ msgstr "on"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "마지막 체크포인트 NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "마지막 체크포인트 NextXID: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -318,8 +318,8 @@ msgstr "마지막 체크포인트 NextOID: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "마지막 체크포인트 NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "마지막 체크포인트 NextMultiXactId: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -328,8 +328,8 @@ msgstr "마지막 체크포인트 NextMultiOffset: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 XID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 XID: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -338,13 +338,13 @@ msgstr "마지막 체크포인트 제일 오래된 XID의 DB:%u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 ActiveXID:%u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 ActiveXID:%llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 MultiXid:%u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 MultiXid:%llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -353,13 +353,13 @@ msgstr "마지막 체크포인트 제일 오래된 MultiXid의 DB:%u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 제일 오래된 CommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 제일 오래된 CommitTsXid:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 최신 CommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 최신 CommitTsXid: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -453,13 +453,13 @@ msgstr "리셋 뒤 첫 로그 세그먼트: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -478,13 +478,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -498,13 +498,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "제일 오래된 CommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "제일 오래된 CommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "최근 CommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "최근 CommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/pl.po b/src/bin/pg_resetwal/po/pl.po
index d87214bc53..e06b5cfe20 100644
--- a/src/bin/pg_resetwal/po/pl.po
+++ b/src/bin/pg_resetwal/po/pl.po
@@ -248,8 +248,8 @@ msgstr "włączone"
#: pg_resetxlog.c:649
#, c-format
#| msgid "Latest checkpoint's NextXID: %u/%u\n"
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -258,8 +258,8 @@ msgstr "NextOID najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -268,8 +268,8 @@ msgstr "NextMultiOffset najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -278,8 +278,8 @@ msgstr "DB oldestXID'u najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:664
#, c-format
@@ -293,13 +293,13 @@ msgstr "DB oldestMulti'u najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -402,13 +402,13 @@ msgstr "Pierwszy segment dziennika po resecie: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -427,13 +427,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -447,13 +447,13 @@ msgstr "Epoka NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/pt_BR.po b/src/bin/pg_resetwal/po/pt_BR.po
index 491e8b67d8..d5a3aba77f 100644
--- a/src/bin/pg_resetwal/po/pt_BR.po
+++ b/src/bin/pg_resetwal/po/pt_BR.po
@@ -246,8 +246,8 @@ msgstr "habilitado"
#: pg_resetxlog.c:649
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID do último ponto de controle: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID do último ponto de controle: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -256,8 +256,8 @@ msgstr "NextOID do último ponto de controle: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId do último ponto de controle: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId do último ponto de controle: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -266,8 +266,8 @@ msgstr "NextMultiOffset do último ponto de controle: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID do último ponto de controle: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -276,13 +276,13 @@ msgstr "BD do oldestXID do último ponto de controle: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID do último ponto de controle: %llu\n"
#: pg_resetxlog.c:664
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:666
#, c-format
@@ -291,13 +291,13 @@ msgstr "BD do oldestMulti do último ponto de controle: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -400,13 +400,13 @@ msgstr "Primeiro segmento do arquivo de log após reinício: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -425,13 +425,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -445,13 +445,13 @@ msgstr "época do NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/ru.po b/src/bin/pg_resetwal/po/ru.po
index d0f196d807..62aa0afe4e 100644
--- a/src/bin/pg_resetwal/po/ru.po
+++ b/src/bin/pg_resetwal/po/ru.po
@@ -329,8 +329,8 @@ msgstr "вкл."
# skip-rule: capital-letter-first
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID последней конт. точки: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID последней конт. точки: %u:%llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:761
@@ -341,8 +341,8 @@ msgstr "NextOID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId послед. конт. точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId послед. конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:765
@@ -353,8 +353,8 @@ msgstr "NextMultiOffset послед. конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID последней конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:769
@@ -365,14 +365,14 @@ msgstr "БД с oldestXID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID последней к. т.: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid последней конт. точки: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:775
@@ -383,14 +383,14 @@ msgstr "БД с oldestMulti последней к. т.: %u\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid последней к. т.: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid последней к. т.: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -485,13 +485,13 @@ msgstr "Первый сегмент журнала после сброса: %s\
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -510,13 +510,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -530,13 +530,13 @@ msgstr "Эпоха NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/sv.po b/src/bin/pg_resetwal/po/sv.po
index 74d07a3638..a4cc42a88e 100644
--- a/src/bin/pg_resetwal/po/sv.po
+++ b/src/bin/pg_resetwal/po/sv.po
@@ -306,8 +306,8 @@ msgstr "på"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID vid senaste kontrollpunkt: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID vid senaste kontrollpunkt: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -316,8 +316,8 @@ msgstr "NextOID vid senaste kontrollpunkt: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -326,8 +326,8 @@ msgstr "NextMultiOffset vid senaste kontrollpunkt: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -337,13 +337,13 @@ msgstr "DB för oldestXID vid senaste kontrollpunkt: %u\n"
# FIXME: too wide
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -352,13 +352,13 @@ msgstr "DB för oldestMulti vid senaste kontrollpkt: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid vid senaste kontrollpunkt:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid vid senaste kontrollpunkt:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid vid senaste kontrollpunkt:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid vid senaste kontrollpunkt:%llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Första loggsegment efter återställning: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "Epoch för NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/tr.po b/src/bin/pg_resetwal/po/tr.po
index 48b1497c55..0ab0634a0d 100644
--- a/src/bin/pg_resetwal/po/tr.po
+++ b/src/bin/pg_resetwal/po/tr.po
@@ -300,8 +300,8 @@ msgstr "açık"
#: pg_resetwal.c:775
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Son checkpoint'in NextXID değeri: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Son checkpoint'in NextXID değeri: %u:%llu\n"
#: pg_resetwal.c:778
#, c-format
@@ -310,8 +310,8 @@ msgstr "Son checkpoint''in NextOID değeri: %u\n"
#: pg_resetwal.c:780
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Son checkpoint''in NextMultiXactId değeri: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Son checkpoint''in NextMultiXactId değeri: %llu\n"
#: pg_resetwal.c:782
#, c-format
@@ -320,8 +320,8 @@ msgstr "Son checkpoint''in NextMultiOffset değeri: %u\n"
#: pg_resetwal.c:784
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Son checkpoint'in oldestXID değeri: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Son checkpoint'in oldestXID değeri: %llu\n"
#: pg_resetwal.c:786
#, c-format
@@ -330,13 +330,13 @@ msgstr "Son checkpoint'in oldestXID değeri'nin DB'si: %u\n"
#: pg_resetwal.c:788
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Son checkpoint'in oldestActiveXID değeri: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Son checkpoint'in oldestActiveXID değeri: %llu\n"
#: pg_resetwal.c:790
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Son checkpoint'in oldestMultiXid değeri: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Son checkpoint'in oldestMultiXid değeri: %llu\n"
#: pg_resetwal.c:792
#, c-format
@@ -345,13 +345,13 @@ msgstr "Son checkpoint'in oldestMulti'sinin VT'si: %u\n"
#: pg_resetwal.c:794
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Son checkpoint'in oldestCommitTsXid değeri: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Son checkpoint'in oldestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:796
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Son checkpoint''in newestCommitTsXid değeri: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Son checkpoint''in newestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:798
#, c-format
@@ -450,13 +450,13 @@ msgstr "Sıfırlamadan sonraki ilk kayıt segmenti: %s\n"
#: pg_resetwal.c:846
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId değeri: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId değeri: %llu\n"
#: pg_resetwal.c:848
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid değeri: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid değeri: %llu\n"
#: pg_resetwal.c:850
#, c-format
@@ -475,13 +475,13 @@ msgstr "NextOID değeri: %u\n"
#: pg_resetwal.c:868
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID değeri: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID değeri: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID değeri: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID değeri: %llu\n"
#: pg_resetwal.c:872
#, c-format
@@ -495,13 +495,13 @@ msgstr "NextXID devri: %u\n"
#: pg_resetwal.c:884
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid değeri: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:889
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid değeri: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:975 pg_resetwal.c:1043 pg_resetwal.c:1090
#, c-format
diff --git a/src/bin/pg_resetwal/po/uk.po b/src/bin/pg_resetwal/po/uk.po
index b6c024e7aa..67e6ddccb0 100644
--- a/src/bin/pg_resetwal/po/uk.po
+++ b/src/bin/pg_resetwal/po/uk.po
@@ -291,8 +291,8 @@ msgstr "увімк"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Останній NextXID контрольної точки: %u%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Останній NextXID контрольної точки: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -301,8 +301,8 @@ msgstr "Останній NextOID контрольної точки: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Останній NextMultiXactId контрольної точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Останній NextMultiXactId контрольної точки: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -311,8 +311,8 @@ msgstr "Останній NextMultiOffset контрольної точки: %u\n
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Останній oldestXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Останній oldestXID контрольної точки: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -321,13 +321,13 @@ msgstr "Остання DB останнього oldestXID контрольної
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Останній oldestActiveXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Останній oldestActiveXID контрольної точки: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Останній oldestMultiXid контрольної точки: %u \n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Останній oldestMultiXid контрольної точки: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -336,13 +336,13 @@ msgstr "Остання DB останньої oldestMulti контрольної
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Останній oldestCommitTsXid контрольної точки:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Останній oldestCommitTsXid контрольної точки:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Останній newestCommitTsXid контрольної точки: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Останній newestCommitTsXid контрольної точки: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -430,13 +430,13 @@ msgstr "Перший сегмент журналу після скидання:
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -455,13 +455,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -475,13 +475,13 @@ msgstr "Епоха NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/zh_CN.po b/src/bin/pg_resetwal/po/zh_CN.po
index f5cec00c61..5b40210cb8 100644
--- a/src/bin/pg_resetwal/po/zh_CN.po
+++ b/src/bin/pg_resetwal/po/zh_CN.po
@@ -298,8 +298,8 @@ msgstr "开启"
#: pg_resetwal.c:775
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最新检查点的NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最新检查点的NextXID: %u:%llu\n"
#: pg_resetwal.c:778
#, c-format
@@ -308,8 +308,8 @@ msgstr "最新检查点的 NextOID: %u\n"
#: pg_resetwal.c:780
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最新检查点的NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最新检查点的NextMultiXactId: %llu\n"
#: pg_resetwal.c:782
#, c-format
@@ -318,8 +318,8 @@ msgstr "最新检查点的NextMultiOffsetD: %u\n"
#: pg_resetwal.c:784
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最新检查点的oldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最新检查点的oldestXID: %llu\n"
#: pg_resetwal.c:786
#, c-format
@@ -328,13 +328,13 @@ msgstr "最新检查点的oldestXID所在的数据库:%u\n"
#: pg_resetwal.c:788
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最新检查点的oldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最新检查点的oldestActiveXID: %llu\n"
#: pg_resetwal.c:790
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最新检查点的oldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最新检查点的oldestMultiXid: %llu\n"
#: pg_resetwal.c:792
#, c-format
@@ -343,13 +343,13 @@ msgstr "最新检查点的oldestMulti所在的数据库:%u\n"
#: pg_resetwal.c:794
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最新检查点的oldestCommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最新检查点的oldestCommitTsXid:%llu\n"
#: pg_resetwal.c:796
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最新检查点的newestCommitTsXid:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最新检查点的newestCommitTsXid:%llu\n"
#: pg_resetwal.c:798
#, c-format
@@ -447,13 +447,13 @@ msgstr "First log segment after reset: %s\n"
#: pg_resetwal.c:846
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:848
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:850
#, c-format
@@ -472,13 +472,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:868
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:872
#, c-format
@@ -492,13 +492,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:884
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:889
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:975 pg_resetwal.c:1043 pg_resetwal.c:1090
#, c-format
--
2.35.1
v21-0003-Use-64-bit-pages-in-SLRU.patchapplication/octet-stream; name=v21-0003-Use-64-bit-pages-in-SLRU.patchDownload
From d5bd6ce5cbd07d4e1a7d15cfeb4a6ae9e3fce512 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v21 3/3] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 117 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++--
src/backend/storage/lmgr/predicate.c | 4 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 94 insertions(+), 97 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 2946816521..2343639756 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index bdaeef1eda..e357e9674c 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2879,7 +2879,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3130,7 +3130,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3150,7 +3150,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 42e0e8fca5..457b5988ef 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (int64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +951,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_FMT_TYPE) xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_FMT_TYPE) xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %llu", (XID_FMT_TYPE) xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %llu", (XID_FMT_TYPE) xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %llu", (XID_FMT_TYPE) xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1016,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1027,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1071,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1161,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1304,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1327,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1500,9 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1515,9 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1530,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1558,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1568,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1599,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 61f688416a..001d1445f8 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44..61042c34d5 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 987e17dcf6..00d01b2e16 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877..7805ad1be7 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
Hi hackers,
Here is an new version with the following changes compared to v20:
[...]
To me personally v21 looks almost OK.
For some reason I didn't receive the recent e-mails from Tom and Kyotaro.
I've just discovered them accidentally by reading the thread through the
web interface. These comments were not addressed in v21.
--
Best regards,
Aleksander Alekseev
To me personally v21 looks almost OK.
For some reason I didn't receive the recent e-mails from Tom and Kyotaro.
I've just discovered them accidentally by reading the thread through the
web interface. These comments were not addressed in v21.
Aleksander, as of now we're preparing a new version that addresses a thing
mentioned by Tom&Kyotaro. We'll try to add what you've done in v21, but
please check. We're going to send a patch very soon, most probably today in
several hours.
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Hi!
Here is v22. It addresses things mentioned by Tom and Kyotaro. Also added
Aleksander's changes from v21.
--
Best regards,
Maxim Orlov.
Attachments:
v22-0003-Use-64-bit-pages-in-SLRU.patchapplication/octet-stream; name=v22-0003-Use-64-bit-pages-in-SLRU.patchDownload
From 51908585d45091f8d6078d9e770b10aba40124bd Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v22 3/6] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 141 +++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++-
src/backend/storage/lmgr/predicate.c | 4 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 110 insertions(+), 105 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index f20484c4261..530b77e5528 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index b5880b3650b..764b2261aeb 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2879,7 +2879,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3130,7 +3130,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3150,7 +3150,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index d98348523f5..16ca020f7aa 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (int64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -942,52 +944,61 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
case SLRU_OPEN_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %llu", (unsigned long long) xid),
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) 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 %llu", (unsigned long long) xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %llu", (unsigned long long) xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %llu", (unsigned long long) xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %llu", (unsigned long long) xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %llu", (unsigned long long) xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
(errcode_for_file_access(),
- errmsg("could not access status of transaction %llu", (unsigned long long) xid),
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) 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 %llu", (unsigned long long) xid),
+ errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not close file \"%s\": %m.",
path)));
break;
@@ -1013,7 +1024,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1035,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1079,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1169,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1234,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1312,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1335,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1508,9 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1523,9 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1576,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1607,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 4665feb3430..2a03de967c5 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..61042c34d58 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index c19e5d527b9..20aab29e754 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
v22-0002-Update-XID-formatting-in-the-.po-files.patchapplication/octet-stream; name=v22-0002-Update-XID-formatting-in-the-.po-files.patchDownload
From 44ff595d04790950a45aa77a703be43d0582f279 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 18 Mar 2022 18:04:40 +0300
Subject: [PATCH v22 2/6] Update XID formatting in the .po files
This patch updates the XIDs formatting in the .po files. Previously the
formatting was changed from %u to %llu. This is one step toward 64-bit XIDs.
Author: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/bin/pg_controldata/po/cs.po | 28 ++++++++--------
src/bin/pg_controldata/po/de.po | 28 ++++++++--------
src/bin/pg_controldata/po/el.po | 28 ++++++++--------
src/bin/pg_controldata/po/es.po | 28 ++++++++--------
src/bin/pg_controldata/po/fr.po | 28 ++++++++--------
src/bin/pg_controldata/po/it.po | 28 ++++++++--------
src/bin/pg_controldata/po/ja.po | 28 ++++++++--------
src/bin/pg_controldata/po/ko.po | 28 ++++++++--------
src/bin/pg_controldata/po/pl.po | 28 ++++++++--------
src/bin/pg_controldata/po/pt_BR.po | 28 ++++++++--------
src/bin/pg_controldata/po/ru.po | 28 ++++++++--------
src/bin/pg_controldata/po/sv.po | 28 ++++++++--------
src/bin/pg_controldata/po/tr.po | 28 ++++++++--------
src/bin/pg_controldata/po/uk.po | 28 ++++++++--------
src/bin/pg_controldata/po/vi.po | 28 ++++++++--------
src/bin/pg_controldata/po/zh_CN.po | 28 ++++++++--------
src/bin/pg_resetwal/po/cs.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/de.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/es.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/fr.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/it.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ja.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ko.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/pl.po | 48 +++++++++++++--------------
src/bin/pg_resetwal/po/pt_BR.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/ru.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/sv.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/tr.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/uk.po | 52 +++++++++++++++---------------
src/bin/pg_resetwal/po/zh_CN.po | 52 +++++++++++++++---------------
30 files changed, 586 insertions(+), 586 deletions(-)
diff --git a/src/bin/pg_controldata/po/cs.po b/src/bin/pg_controldata/po/cs.po
index 4774832b805..5c61c0bde04 100644
--- a/src/bin/pg_controldata/po/cs.po
+++ b/src/bin/pg_controldata/po/cs.po
@@ -311,8 +311,8 @@ msgstr "zapnuto"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID posledního checkpointu: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID posledního checkpointu: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -321,8 +321,8 @@ msgstr "Poslední umístění NextOID checkpointu: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId posledního checkpointu: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId posledního checkpointu: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -331,8 +331,8 @@ msgstr "NextMultiOffset posledního checkpointu: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID posledního checkpointu: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -341,13 +341,13 @@ msgstr "DB k oldestXID posledního checkpointu: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID posledního checkpointu: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid posledního checkpointu: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -356,13 +356,13 @@ msgstr "DB k oldestMulti posledního checkpointu: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid posledního checkpointu: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid posledního checkpointu: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/de.po b/src/bin/pg_controldata/po/de.po
index 4a8785d3362..913f7db1d8b 100644
--- a/src/bin/pg_controldata/po/de.po
+++ b/src/bin/pg_controldata/po/de.po
@@ -298,8 +298,8 @@ msgstr "an"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID des letzten Checkpoints: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID des letzten Checkpoints: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -308,8 +308,8 @@ msgstr "NextOID des letzten Checkpoints: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId des letzten Checkpoints: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -318,8 +318,8 @@ msgstr "NextMultiOffset des letzten Checkpoints: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID des letzten Checkpoints: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -328,13 +328,13 @@ msgstr "DB der oldestXID des letzten Checkpoints: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID des letzten Checkpoints: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -343,13 +343,13 @@ msgstr "DB des oldestMulti des letzten Checkpoints: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/el.po b/src/bin/pg_controldata/po/el.po
index 12bbb0556b4..8ea7c926057 100644
--- a/src/bin/pg_controldata/po/el.po
+++ b/src/bin/pg_controldata/po/el.po
@@ -307,8 +307,8 @@ msgstr "ανοικτό"
#: pg_controldata.c:250
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Πιο πρόσφατο NextXID του σημείου ελέγχου: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Πιο πρόσφατο NextXID του σημείου ελέγχου: %u:%llu\n"
#: pg_controldata.c:253
#, c-format
@@ -317,8 +317,8 @@ msgstr "Πιο πρόσφατο NextOID του σημείου ελέγχου:
#: pg_controldata.c:255
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Πιο πρόσφατο NextMultiXactId του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Πιο πρόσφατο NextMultiXactId του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:257
#, c-format
@@ -327,8 +327,8 @@ msgstr "Πιο πρόσφατο NextMultiOffset του σημείου ελέγχ
#: pg_controldata.c:259
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Πιο πρόσφατο oldestXID του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Πιο πρόσφατο oldestXID του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:261
#, c-format
@@ -337,13 +337,13 @@ msgstr "Πιο πρόσφατο oldestXID’s DB του σημείου ελέγ
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Πιο πρόσφατο oldestActiveXID του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Πιο πρόσφατο oldestActiveXID του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Πιο πρόσφατο oldestMultiXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Πιο πρόσφατο oldestMultiXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:267
#, c-format
@@ -352,13 +352,13 @@ msgstr "Πιο πρόσφατο oldestMulti’s DB του σημείου ελέ
#: pg_controldata.c:269
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Πιο πρόσφατο oldestCommitTsXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Πιο πρόσφατο oldestCommitTsXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Πιο πρόσφατο newestCommitTsXid του σημείου ελέγχου: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Πιο πρόσφατο newestCommitTsXid του σημείου ελέγχου: %llu\n"
#: pg_controldata.c:273
#, c-format
diff --git a/src/bin/pg_controldata/po/es.po b/src/bin/pg_controldata/po/es.po
index 2764c38466f..dc7e4397769 100644
--- a/src/bin/pg_controldata/po/es.po
+++ b/src/bin/pg_controldata/po/es.po
@@ -301,8 +301,8 @@ msgstr "activado"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID de último checkpoint: %u/%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID de último checkpoint: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -311,8 +311,8 @@ msgstr "NextOID de último checkpoint: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId de último checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId de último checkpoint: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -321,8 +321,8 @@ msgstr "NextMultiOffset de último checkpoint: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID del último checkpoint: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -331,13 +331,13 @@ msgstr "DB del oldestXID del último checkpoint: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID del último checkpoint: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid del último checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -346,13 +346,13 @@ msgstr "DB del oldestMultiXid del últ. checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid del último checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid del último checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/fr.po b/src/bin/pg_controldata/po/fr.po
index bd3b6d68c28..78105d841dd 100644
--- a/src/bin/pg_controldata/po/fr.po
+++ b/src/bin/pg_controldata/po/fr.po
@@ -304,8 +304,8 @@ msgstr "activé"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Dernier NextXID du point de contrôle : %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Dernier NextXID du point de contrôle : %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -314,8 +314,8 @@ msgstr "Dernier NextOID du point de contrôle : %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Dernier NextMultiXactId du point de contrôle : %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Dernier NextMultiXactId du point de contrôle : %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -324,8 +324,8 @@ msgstr "Dernier NextMultiOffset du point de contrôle : %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Dernier oldestXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Dernier oldestXID du point de contrôle : %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -334,13 +334,13 @@ msgstr "Dernier oldestXID du point de contrôle de la base : %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Dernier oldestActiveXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Dernier oldestActiveXID du point de contrôle : %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Dernier oldestMultiXid du point de restauration : %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Dernier oldestMultiXid du point de restauration : %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -349,13 +349,13 @@ msgstr "Dernier oldestMulti du point de restauration de base : %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Dernier oldestCommitTsXid du point de restauration : %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Dernier oldestCommitTsXid du point de restauration : %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Dernier newestCommitTsXid du point de restauration : %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Dernier newestCommitTsXid du point de restauration : %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/it.po b/src/bin/pg_controldata/po/it.po
index e1697bb6689..fc97f4c580a 100644
--- a/src/bin/pg_controldata/po/it.po
+++ b/src/bin/pg_controldata/po/it.po
@@ -285,8 +285,8 @@ msgstr "attivato"
#: pg_controldata.c:258
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID dell'ultimo checkpoint: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID dell'ultimo checkpoint: %u:%llu\n"
#: pg_controldata.c:261
#, c-format
@@ -295,8 +295,8 @@ msgstr "NextOID dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:265
#, c-format
@@ -305,8 +305,8 @@ msgstr "NextMultiOffset dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -315,13 +315,13 @@ msgstr "DB dell'oldestXID dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXID dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
@@ -330,13 +330,13 @@ msgstr "DB dell'oldestMulti dell'ultimo checkpoint: %u\n"
#: pg_controldata.c:277
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_controldata.c:281
#, c-format
diff --git a/src/bin/pg_controldata/po/ja.po b/src/bin/pg_controldata/po/ja.po
index a98a05fbf1b..0a2990ac1b5 100644
--- a/src/bin/pg_controldata/po/ja.po
+++ b/src/bin/pg_controldata/po/ja.po
@@ -301,8 +301,8 @@ msgstr "オン"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最終チェックポイントのNextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最終チェックポイントのNextXID: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -311,8 +311,8 @@ msgstr "最終チェックポイントのNextOID: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最終チェックポイントのNextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最終チェックポイントのNextMultiXactId: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -321,8 +321,8 @@ msgstr "最終チェックポイントのNextMultiOffset: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最終チェックポイントのoldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最終チェックポイントのoldestXID: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -331,13 +331,13 @@ msgstr "最終チェックポイントのoldestXIDのDB: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最終チェックポイントのoldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最終チェックポイントのoldestActiveXID: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最終チェックポイントのoldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最終チェックポイントのoldestMultiXid: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -346,13 +346,13 @@ msgstr "最終チェックポイントのoldestMultiのDB: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのoldestCommitTsXid: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのoldestCommitTsXid: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのnewestCommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのnewestCommitTsXid: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/ko.po b/src/bin/pg_controldata/po/ko.po
index 962b36ece72..7f3055c7d65 100644
--- a/src/bin/pg_controldata/po/ko.po
+++ b/src/bin/pg_controldata/po/ko.po
@@ -290,8 +290,8 @@ msgstr "on"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "마지막 체크포인트 NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "마지막 체크포인트 NextXID: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -300,8 +300,8 @@ msgstr "마지막 체크포인트 NextOID: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "마지막 체크포인트 NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "마지막 체크포인트 NextMultiXactId: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -310,8 +310,8 @@ msgstr "마지막 체크포인트 NextMultiOffset: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "마지막 체크포인트 제일오래된XID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "마지막 체크포인트 제일오래된XID: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -320,13 +320,13 @@ msgstr "마지막 체크포인트 제일오래된XID의 DB: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "마지막 체크포인트 제일오래된ActiveXID:%u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "마지막 체크포인트 제일오래된ActiveXID: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "마지막 체크포인트 제일오래된MultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "마지막 체크포인트 제일오래된MultiXid: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -335,13 +335,13 @@ msgstr "마지막 체크포인트 제일오래된멀티Xid DB:%u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 제일오래된CommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 제일오래된CommitTsXid:%llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 최신CommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 최신CommitTsXid: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/pl.po b/src/bin/pg_controldata/po/pl.po
index 7f528863032..59615b663ad 100644
--- a/src/bin/pg_controldata/po/pl.po
+++ b/src/bin/pg_controldata/po/pl.po
@@ -244,8 +244,8 @@ msgstr "włączone"
#: pg_controldata.c:228
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %u:%llu\n"
#: pg_controldata.c:231
#, c-format
@@ -254,8 +254,8 @@ msgstr "NextOID najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:233
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:235
#, c-format
@@ -264,8 +264,8 @@ msgstr "NextMultiOffset najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:237
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:239
#, c-format
@@ -274,13 +274,13 @@ msgstr "DB oldestXID'u najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:241
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:243
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:245
#, c-format
@@ -289,13 +289,13 @@ msgstr "DB oldestMulti'u najnowszego punktu kontrolnego: %u\n"
#: pg_controldata.c:247
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:249
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_controldata.c:251
#, c-format
diff --git a/src/bin/pg_controldata/po/pt_BR.po b/src/bin/pg_controldata/po/pt_BR.po
index f40e348ab93..e35f61b902c 100644
--- a/src/bin/pg_controldata/po/pt_BR.po
+++ b/src/bin/pg_controldata/po/pt_BR.po
@@ -244,8 +244,8 @@ msgstr "habilitado"
#: pg_controldata.c:217
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID do último ponto de controle: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID do último ponto de controle: %u:%llu\n"
#: pg_controldata.c:220
#, c-format
@@ -254,8 +254,8 @@ msgstr "NextOID do último ponto de controle: %u\n"
#: pg_controldata.c:222
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId do último ponto de controle: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId do último ponto de controle: %llu\n"
#: pg_controldata.c:224
#, c-format
@@ -264,8 +264,8 @@ msgstr "NextMultiOffset do último ponto de controle: %u\n"
#: pg_controldata.c:226
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID do último ponto de controle: %llu\n"
#: pg_controldata.c:228
#, c-format
@@ -274,13 +274,13 @@ msgstr "BD do oldestXID do último ponto de controle: %u\n"
#: pg_controldata.c:230
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID do último ponto de controle: %llu\n"
#: pg_controldata.c:232
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid do último ponto de controle: %llu\n"
#: pg_controldata.c:234
#, c-format
@@ -289,13 +289,13 @@ msgstr "BD do oldestMulti do último ponto de controle: %u\n"
#: pg_controldata.c:236
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid do último ponto de controle: %llu\n"
#: pg_controldata.c:238
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid do último ponto de controle: %llu\n"
#: pg_controldata.c:240
#, c-format
diff --git a/src/bin/pg_controldata/po/ru.po b/src/bin/pg_controldata/po/ru.po
index 39343c05a1a..fe9b6ff5f65 100644
--- a/src/bin/pg_controldata/po/ru.po
+++ b/src/bin/pg_controldata/po/ru.po
@@ -317,8 +317,8 @@ msgstr "вкл."
# skip-rule: capital-letter-first
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID последней конт. точки: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID последней конт. точки: %u:%llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:255
@@ -329,8 +329,8 @@ msgstr "NextOID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId послед. конт. точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId послед. конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:259
@@ -341,8 +341,8 @@ msgstr "NextMultiOffset послед. конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID последней конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:263
@@ -353,14 +353,14 @@ msgstr "БД с oldestXID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID последней к. т.: %llu\n"
# skip-rule: capital-letter-first
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid последней конт. точки: %llu\n"
# skip-rule: double-space, capital-letter-first
#: pg_controldata.c:269
@@ -371,14 +371,14 @@ msgstr "БД с oldestMulti последней к. т.: %u\n"
# skip-rule: double-space, capital-letter-first
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid последней к. т.: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid последней к. т.: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/sv.po b/src/bin/pg_controldata/po/sv.po
index 3526df1a9cc..f9d5bf24162 100644
--- a/src/bin/pg_controldata/po/sv.po
+++ b/src/bin/pg_controldata/po/sv.po
@@ -304,8 +304,8 @@ msgstr "på"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID vid senaste checkpoint: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID vid senaste checkpoint: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -314,8 +314,8 @@ msgstr "NextOID vid senaste checkpoint: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId vid senaste checkpoint: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -324,8 +324,8 @@ msgstr "NextMultiOffset vid senaste checkpoint: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID vid senaste checkpoint: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -334,13 +334,13 @@ msgstr "DB för oldestXID vid senaste checkpoint: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID vid senaste checkpoint: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -349,13 +349,13 @@ msgstr "DB för oldestMulti vid senaste checkpoint: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid vid senaste checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid vid senaste checkpoint: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/tr.po b/src/bin/pg_controldata/po/tr.po
index 528889f2803..c9f0d21a39d 100644
--- a/src/bin/pg_controldata/po/tr.po
+++ b/src/bin/pg_controldata/po/tr.po
@@ -298,8 +298,8 @@ msgstr "açık"
#: pg_controldata.c:258
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "En son checkpoint'in NextXID'si: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "En son checkpoint'in NextXID'si: %u:%llu\n"
#: pg_controldata.c:261
#, c-format
@@ -308,8 +308,8 @@ msgstr "En son checkpoint'in NextOID'si: %u\n"
#: pg_controldata.c:263
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "En son checkpoint'in NextMultiXactId'si: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "En son checkpoint'in NextMultiXactId'si: %llu\n"
#: pg_controldata.c:265
#, c-format
@@ -318,8 +318,8 @@ msgstr "En son checkpoint'in NextMultiOffset'i: %u\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "En son checkpoint'in oldestXID'si: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "En son checkpoint'in oldestXID'si: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -328,13 +328,13 @@ msgstr "En son checkpoint'in oldestXID'sini DB'si: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "En son checkpoint'in odestActiveXID'si: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "En son checkpoint'in odestActiveXID'si: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "En son checkpoint'in oldestMultiXid'si: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "En son checkpoint'in oldestMultiXid'si: %llu\n"
#: pg_controldata.c:275
#, c-format
@@ -343,13 +343,13 @@ msgstr "En son checkpoint'in oldestMulti'sinin DB'si: %u\n"
#: pg_controldata.c:277
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "En son checkpoint'in oldestCommitTsXid'si: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "En son checkpoint'in oldestCommitTsXid'si: %llu\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "En son checkpoint'in newestCommitTsXid'si: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "En son checkpoint'in newestCommitTsXid'si: %llu\n"
#: pg_controldata.c:281
#, c-format
diff --git a/src/bin/pg_controldata/po/uk.po b/src/bin/pg_controldata/po/uk.po
index 23c5dfb7148..4666d291e59 100644
--- a/src/bin/pg_controldata/po/uk.po
+++ b/src/bin/pg_controldata/po/uk.po
@@ -265,8 +265,8 @@ msgstr "увімк"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Останній NextXID контрольної точки: %u%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Останній NextXID контрольної точки: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -275,8 +275,8 @@ msgstr "Останній NextOID контрольної точки: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Останній NextMultiXactId контрольної точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Останній NextMultiXactId контрольної точки: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -285,8 +285,8 @@ msgstr "Останній NextMultiOffset контрольної точки: %u\n
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Останній oldestXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Останній oldestXID контрольної точки: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -295,13 +295,13 @@ msgstr "Остання DB останнього oldestXID контрольної
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Останній oldestActiveXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Останній oldestActiveXID контрольної точки: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Останній oldestMultiXid контрольної точки: %u \n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Останній oldestMultiXid контрольної точки: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -310,13 +310,13 @@ msgstr "Остання DB останньої oldestMulti контрольної
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Останній oldestCommitTsXid контрольної точки:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Останній oldestCommitTsXid контрольної точки:%llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Останній newestCommitTsXid контрольної точки: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Останній newestCommitTsXid контрольної точки: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/vi.po b/src/bin/pg_controldata/po/vi.po
index 019b7b05d86..4a530768c24 100644
--- a/src/bin/pg_controldata/po/vi.po
+++ b/src/bin/pg_controldata/po/vi.po
@@ -262,8 +262,8 @@ msgstr "on"
#: pg_controldata.c:252
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID của checkpoint gần nhất: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID của checkpoint gần nhất: %u:%llu\n"
#: pg_controldata.c:255
#, c-format
@@ -272,8 +272,8 @@ msgstr "NextOID của checkpoint gần nhất: %u\n"
#: pg_controldata.c:257
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:259
#, c-format
@@ -282,8 +282,8 @@ msgstr "NextMultiOffset của checkpoint gần nhất: %u\n"
#: pg_controldata.c:261
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "OldestXID của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "OldestXID của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:263
#, c-format
@@ -292,13 +292,13 @@ msgstr "OldestXID DB của checkpoint gần nhất: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "OldestActiveXID của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "OldestActiveXID của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:267
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "OldestMultiXid của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "OldestMultiXid của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:269
#, c-format
@@ -307,13 +307,13 @@ msgstr "OldestMulti DB của checkpoint gần nhất: %u\n"
#: pg_controldata.c:271
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "OldestCommitTsXid DB của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "OldestCommitTsXid DB của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "NewestCommitTsXid của checkpoint gần nhất: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "NewestCommitTsXid của checkpoint gần nhất: %llu\n"
#: pg_controldata.c:275
#, c-format
diff --git a/src/bin/pg_controldata/po/zh_CN.po b/src/bin/pg_controldata/po/zh_CN.po
index 259996bfc04..caf24e1850d 100644
--- a/src/bin/pg_controldata/po/zh_CN.po
+++ b/src/bin/pg_controldata/po/zh_CN.po
@@ -286,8 +286,8 @@ msgstr "开启"
#: pg_controldata.c:260
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最新检查点的NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最新检查点的NextXID: %u:%llu\n"
#: pg_controldata.c:263
#, c-format
@@ -296,8 +296,8 @@ msgstr "最新检查点的 NextOID: %u\n"
#: pg_controldata.c:265
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最新检查点的NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最新检查点的NextMultiXactId: %llu\n"
#: pg_controldata.c:267
#, c-format
@@ -306,8 +306,8 @@ msgstr "最新检查点的NextMultiOffsetD: %u\n"
#: pg_controldata.c:269
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最新检查点的oldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最新检查点的oldestXID: %llu\n"
#: pg_controldata.c:271
#, c-format
@@ -316,13 +316,13 @@ msgstr "最新检查点的oldestXID所在的数据库:%u\n"
#: pg_controldata.c:273
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最新检查点的oldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最新检查点的oldestActiveXID: %llu\n"
#: pg_controldata.c:275
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最新检查点的oldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最新检查点的oldestMultiXid: %llu\n"
#: pg_controldata.c:277
#, c-format
@@ -331,13 +331,13 @@ msgstr "最新检查点的oldestMulti所在的数据库:%u\n"
#: pg_controldata.c:279
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最新检查点的oldestCommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最新检查点的oldestCommitTsXid:%llu\n"
#: pg_controldata.c:281
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最新检查点的newestCommitTsXid:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最新检查点的newestCommitTsXid:%llu\n"
#: pg_controldata.c:283
#, c-format
diff --git a/src/bin/pg_resetwal/po/cs.po b/src/bin/pg_resetwal/po/cs.po
index f1ec4d9da15..fd540ff3c8d 100644
--- a/src/bin/pg_resetwal/po/cs.po
+++ b/src/bin/pg_resetwal/po/cs.po
@@ -307,8 +307,8 @@ msgstr "zapnuto"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID posledního checkpointu: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID posledního checkpointu: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -317,8 +317,8 @@ msgstr "Poslední umístění NextOID checkpointu: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId posledního checkpointu: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId posledního checkpointu: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -327,8 +327,8 @@ msgstr "NextMultiOffset posledního checkpointu: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID posledního checkpointu: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -337,13 +337,13 @@ msgstr "DB k oldestXID posledního checkpointu: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID posledního checkpointu: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -352,13 +352,13 @@ msgstr "DB k oldestMulti posledního checkpointu: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid posledního checkpointu: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid posledního checkpointu: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -452,13 +452,13 @@ msgstr "První log segment po resetu: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -477,13 +477,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -497,13 +497,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/de.po b/src/bin/pg_resetwal/po/de.po
index 433f4008fa3..256b12cdef1 100644
--- a/src/bin/pg_resetwal/po/de.po
+++ b/src/bin/pg_resetwal/po/de.po
@@ -305,8 +305,8 @@ msgstr "an"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID des letzten Checkpoints: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID des letzten Checkpoints: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -315,8 +315,8 @@ msgstr "NextOID des letzten Checkpoints: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -325,8 +325,8 @@ msgstr "NextMultiOffset des letzten Checkpoints: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -335,13 +335,13 @@ msgstr "DB der oldestXID des letzten Checkpoints: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -350,13 +350,13 @@ msgstr "DB des oldestMulti des letzten Checkpoints: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid des letzten Checkpoints: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid des letzten Checkpoints: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -450,13 +450,13 @@ msgstr "Erstes Logdateisegment nach Zurücksetzen: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -475,13 +475,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -495,13 +495,13 @@ msgstr "NextXID-Epoche: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/es.po b/src/bin/pg_resetwal/po/es.po
index 4403bc0908c..eccdc309fd3 100644
--- a/src/bin/pg_resetwal/po/es.po
+++ b/src/bin/pg_resetwal/po/es.po
@@ -309,8 +309,8 @@ msgstr "activado"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID del checkpoint más reciente: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID del checkpoint más reciente: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -319,8 +319,8 @@ msgstr "NextOID del checkpoint más reciente: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -329,8 +329,8 @@ msgstr "NextMultiOffset del checkpoint más reciente: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -339,13 +339,13 @@ msgstr "BD del oldestXID del checkpoint más reciente: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid del checkpoint más reciente: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid del checkpoint más reciente: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -354,13 +354,13 @@ msgstr "BD del oldestMultiXid del checkpt. más reciente: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid del último checkpoint: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid del último checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid del último checkpoint: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Primer segmento de log después de reiniciar: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "Epoch del NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/fr.po b/src/bin/pg_resetwal/po/fr.po
index 4ebf78caa81..f9e3a8d600b 100644
--- a/src/bin/pg_resetwal/po/fr.po
+++ b/src/bin/pg_resetwal/po/fr.po
@@ -309,8 +309,8 @@ msgstr "activé"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Dernier NextXID du point de contrôle : %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Dernier NextXID du point de contrôle : %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -319,8 +319,8 @@ msgstr "Dernier NextOID du point de contrôle : %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Dernier NextMultiXactId du point de contrôle : %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Dernier NextMultiXactId du point de contrôle : %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -329,8 +329,8 @@ msgstr "Dernier NextMultiOffset du point de contrôle : %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Dernier oldestXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Dernier oldestXID du point de contrôle : %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -339,13 +339,13 @@ msgstr "Dernier oldestXID du point de contrôle de la base : %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Dernier oldestActiveXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Dernier oldestActiveXID du point de contrôle : %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Dernier oldestMultiXID du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Dernier oldestMultiXID du point de contrôle : %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -354,13 +354,13 @@ msgstr "Dernier oldestMulti du point de contrôle de la base : %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Dernier oldestCommitTsXid du point de contrôle : %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Dernier oldestCommitTsXid du point de contrôle : %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Dernier newestCommitTsXid du point de contrôle : %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Dernier newestCommitTsXid du point de contrôle : %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Premier segment du journal après réinitialisation : %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "NextXID Epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/it.po b/src/bin/pg_resetwal/po/it.po
index 9fc4479060b..281187c3674 100644
--- a/src/bin/pg_resetwal/po/it.po
+++ b/src/bin/pg_resetwal/po/it.po
@@ -263,8 +263,8 @@ msgstr "attivato"
#: pg_resetxlog.c:649
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID dell'ultimo checkpoint: %u.%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID dell'ultimo checkpoint: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -273,8 +273,8 @@ msgstr "NextOID dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -283,8 +283,8 @@ msgstr "NextMultiOffset dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -293,13 +293,13 @@ msgstr "DB dell'oldestXID dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:664
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXID dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXID dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:666
#, c-format
@@ -308,13 +308,13 @@ msgstr "DB dell'oldestMulti dell'ultimo checkpoint: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid dell'ultimo checkpoint: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid dell'ultimo checkpoint: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -417,13 +417,13 @@ msgstr "Primo segmento di log dopo il reset: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -442,13 +442,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -462,13 +462,13 @@ msgstr "Epoca del NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/ja.po b/src/bin/pg_resetwal/po/ja.po
index b14af6e21dd..e548930691a 100644
--- a/src/bin/pg_resetwal/po/ja.po
+++ b/src/bin/pg_resetwal/po/ja.po
@@ -303,8 +303,8 @@ msgstr "オン"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最終チェックポイントのNextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最終チェックポイントのNextXID: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -313,8 +313,8 @@ msgstr "最終チェックポイントのNextOID: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最終チェックポイントのNextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最終チェックポイントのNextMultiXactId: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -323,8 +323,8 @@ msgstr "最終チェックポイントのNextMultiOffset: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最終チェックポイントのoldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最終チェックポイントのoldestXID: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -333,13 +333,13 @@ msgstr "最終チェックポイントのoldestXIDのDB: %u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最終チェックポイントのoldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最終チェックポイントのoldestActiveXID: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最終チェックポイントのoldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最終チェックポイントのoldestMultiXid: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -348,13 +348,13 @@ msgstr "最終チェックポイントのoldestMultiのDB: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのoldestCommitTsXid: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのoldestCommitTsXid: %llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最終チェックポイントのnewestCommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最終チェックポイントのnewestCommitTsXid: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -448,13 +448,13 @@ msgstr "リセット後最初のログセグメント: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -473,13 +473,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -493,13 +493,13 @@ msgstr "NextXID基点: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/ko.po b/src/bin/pg_resetwal/po/ko.po
index 03e30bc6d88..7686261876b 100644
--- a/src/bin/pg_resetwal/po/ko.po
+++ b/src/bin/pg_resetwal/po/ko.po
@@ -308,8 +308,8 @@ msgstr "on"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "마지막 체크포인트 NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "마지막 체크포인트 NextXID: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -318,8 +318,8 @@ msgstr "마지막 체크포인트 NextOID: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "마지막 체크포인트 NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "마지막 체크포인트 NextMultiXactId: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -328,8 +328,8 @@ msgstr "마지막 체크포인트 NextMultiOffset: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 XID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 XID: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -338,13 +338,13 @@ msgstr "마지막 체크포인트 제일 오래된 XID의 DB:%u\n"
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 ActiveXID:%u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 ActiveXID:%llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "마지막 체크포인트 제일 오래된 MultiXid:%u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "마지막 체크포인트 제일 오래된 MultiXid:%llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -353,13 +353,13 @@ msgstr "마지막 체크포인트 제일 오래된 MultiXid의 DB:%u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 제일 오래된 CommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 제일 오래된 CommitTsXid:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "마지막 체크포인트 최신 CommitTsXid: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "마지막 체크포인트 최신 CommitTsXid: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -453,13 +453,13 @@ msgstr "리셋 뒤 첫 로그 세그먼트: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -478,13 +478,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -498,13 +498,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "제일 오래된 CommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "제일 오래된 CommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "최근 CommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "최근 CommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/pl.po b/src/bin/pg_resetwal/po/pl.po
index d87214bc533..e06b5cfe20f 100644
--- a/src/bin/pg_resetwal/po/pl.po
+++ b/src/bin/pg_resetwal/po/pl.po
@@ -248,8 +248,8 @@ msgstr "włączone"
#: pg_resetxlog.c:649
#, c-format
#| msgid "Latest checkpoint's NextXID: %u/%u\n"
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -258,8 +258,8 @@ msgstr "NextOID najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -268,8 +268,8 @@ msgstr "NextMultiOffset najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -278,8 +278,8 @@ msgstr "DB oldestXID'u najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "NextXID najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "NextXID najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:664
#, c-format
@@ -293,13 +293,13 @@ msgstr "DB oldestMulti'u najnowszego punktu kontrolnego: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid najnowszego punktu kontrolnego: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -402,13 +402,13 @@ msgstr "Pierwszy segment dziennika po resecie: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -427,13 +427,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -447,13 +447,13 @@ msgstr "Epoka NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/pt_BR.po b/src/bin/pg_resetwal/po/pt_BR.po
index 491e8b67d8f..d5a3aba77ff 100644
--- a/src/bin/pg_resetwal/po/pt_BR.po
+++ b/src/bin/pg_resetwal/po/pt_BR.po
@@ -246,8 +246,8 @@ msgstr "habilitado"
#: pg_resetxlog.c:649
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID do último ponto de controle: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID do último ponto de controle: %u:%llu\n"
#: pg_resetxlog.c:652
#, c-format
@@ -256,8 +256,8 @@ msgstr "NextOID do último ponto de controle: %u\n"
#: pg_resetxlog.c:654
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId do último ponto de controle: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId do último ponto de controle: %llu\n"
#: pg_resetxlog.c:656
#, c-format
@@ -266,8 +266,8 @@ msgstr "NextMultiOffset do último ponto de controle: %u\n"
#: pg_resetxlog.c:658
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID do último ponto de controle: %llu\n"
#: pg_resetxlog.c:660
#, c-format
@@ -276,13 +276,13 @@ msgstr "BD do oldestXID do último ponto de controle: %u\n"
#: pg_resetxlog.c:662
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID do último ponto de controle: %llu\n"
#: pg_resetxlog.c:664
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:666
#, c-format
@@ -291,13 +291,13 @@ msgstr "BD do oldestMulti do último ponto de controle: %u\n"
#: pg_resetxlog.c:668
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:670
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid do último ponto de controle: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid do último ponto de controle: %llu\n"
#: pg_resetxlog.c:672
#, c-format
@@ -400,13 +400,13 @@ msgstr "Primeiro segmento do arquivo de log após reinício: %s\n"
#: pg_resetxlog.c:718
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetxlog.c:720
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetxlog.c:722
#, c-format
@@ -425,13 +425,13 @@ msgstr "NextOID: %u\n"
#: pg_resetxlog.c:740
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetxlog.c:742
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetxlog.c:744
#, c-format
@@ -445,13 +445,13 @@ msgstr "época do NextXID: %u\n"
#: pg_resetxlog.c:756
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetxlog.c:761
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetxlog.c:827
#, c-format
diff --git a/src/bin/pg_resetwal/po/ru.po b/src/bin/pg_resetwal/po/ru.po
index d0f196d8075..62aa0afe4e8 100644
--- a/src/bin/pg_resetwal/po/ru.po
+++ b/src/bin/pg_resetwal/po/ru.po
@@ -329,8 +329,8 @@ msgstr "вкл."
# skip-rule: capital-letter-first
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID последней конт. точки: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID последней конт. точки: %u:%llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:761
@@ -341,8 +341,8 @@ msgstr "NextOID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId послед. конт. точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId послед. конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:765
@@ -353,8 +353,8 @@ msgstr "NextMultiOffset послед. конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID последней конт. точки: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:769
@@ -365,14 +365,14 @@ msgstr "БД с oldestXID последней конт. точки: %u\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID последней к. т.: %llu\n"
# skip-rule: capital-letter-first
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid последней конт. точки: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid последней конт. точки: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:775
@@ -383,14 +383,14 @@ msgstr "БД с oldestMulti последней к. т.: %u\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid последней к. т.: %llu\n"
# skip-rule: capital-letter-first, double-space
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid последней к. т.: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid последней к. т.: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -485,13 +485,13 @@ msgstr "Первый сегмент журнала после сброса: %s\
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -510,13 +510,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -530,13 +530,13 @@ msgstr "Эпоха NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/sv.po b/src/bin/pg_resetwal/po/sv.po
index 74d07a3638c..a4cc42a88e9 100644
--- a/src/bin/pg_resetwal/po/sv.po
+++ b/src/bin/pg_resetwal/po/sv.po
@@ -306,8 +306,8 @@ msgstr "på"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "NextXID vid senaste kontrollpunkt: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "NextXID vid senaste kontrollpunkt: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -316,8 +316,8 @@ msgstr "NextOID vid senaste kontrollpunkt: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "NextMultiXactId vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -326,8 +326,8 @@ msgstr "NextMultiOffset vid senaste kontrollpunkt: %u\n"
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "oldestXID vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "oldestXID vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -337,13 +337,13 @@ msgstr "DB för oldestXID vid senaste kontrollpunkt: %u\n"
# FIXME: too wide
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "oldestActiveXID vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "oldestActiveXID vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "oldestMultiXid vid senaste kontrollpunkt: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "oldestMultiXid vid senaste kontrollpunkt: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -352,13 +352,13 @@ msgstr "DB för oldestMulti vid senaste kontrollpkt: %u\n"
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "oldestCommitTsXid vid senaste kontrollpunkt:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "oldestCommitTsXid vid senaste kontrollpunkt:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "newestCommitTsXid vid senaste kontrollpunkt:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "newestCommitTsXid vid senaste kontrollpunkt:%llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -454,13 +454,13 @@ msgstr "Första loggsegment efter återställning: %s\n"
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -479,13 +479,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -499,13 +499,13 @@ msgstr "Epoch för NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/tr.po b/src/bin/pg_resetwal/po/tr.po
index 48b1497c553..0ab0634a0d7 100644
--- a/src/bin/pg_resetwal/po/tr.po
+++ b/src/bin/pg_resetwal/po/tr.po
@@ -300,8 +300,8 @@ msgstr "açık"
#: pg_resetwal.c:775
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Son checkpoint'in NextXID değeri: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Son checkpoint'in NextXID değeri: %u:%llu\n"
#: pg_resetwal.c:778
#, c-format
@@ -310,8 +310,8 @@ msgstr "Son checkpoint''in NextOID değeri: %u\n"
#: pg_resetwal.c:780
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Son checkpoint''in NextMultiXactId değeri: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Son checkpoint''in NextMultiXactId değeri: %llu\n"
#: pg_resetwal.c:782
#, c-format
@@ -320,8 +320,8 @@ msgstr "Son checkpoint''in NextMultiOffset değeri: %u\n"
#: pg_resetwal.c:784
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Son checkpoint'in oldestXID değeri: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Son checkpoint'in oldestXID değeri: %llu\n"
#: pg_resetwal.c:786
#, c-format
@@ -330,13 +330,13 @@ msgstr "Son checkpoint'in oldestXID değeri'nin DB'si: %u\n"
#: pg_resetwal.c:788
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Son checkpoint'in oldestActiveXID değeri: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Son checkpoint'in oldestActiveXID değeri: %llu\n"
#: pg_resetwal.c:790
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Son checkpoint'in oldestMultiXid değeri: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Son checkpoint'in oldestMultiXid değeri: %llu\n"
#: pg_resetwal.c:792
#, c-format
@@ -345,13 +345,13 @@ msgstr "Son checkpoint'in oldestMulti'sinin VT'si: %u\n"
#: pg_resetwal.c:794
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Son checkpoint'in oldestCommitTsXid değeri: %u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Son checkpoint'in oldestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:796
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Son checkpoint''in newestCommitTsXid değeri: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Son checkpoint''in newestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:798
#, c-format
@@ -450,13 +450,13 @@ msgstr "Sıfırlamadan sonraki ilk kayıt segmenti: %s\n"
#: pg_resetwal.c:846
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId değeri: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId değeri: %llu\n"
#: pg_resetwal.c:848
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid değeri: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid değeri: %llu\n"
#: pg_resetwal.c:850
#, c-format
@@ -475,13 +475,13 @@ msgstr "NextOID değeri: %u\n"
#: pg_resetwal.c:868
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID değeri: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID değeri: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID değeri: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID değeri: %llu\n"
#: pg_resetwal.c:872
#, c-format
@@ -495,13 +495,13 @@ msgstr "NextXID devri: %u\n"
#: pg_resetwal.c:884
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid değeri: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:889
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid değeri: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid değeri: %llu\n"
#: pg_resetwal.c:975 pg_resetwal.c:1043 pg_resetwal.c:1090
#, c-format
diff --git a/src/bin/pg_resetwal/po/uk.po b/src/bin/pg_resetwal/po/uk.po
index b6c024e7aa0..67e6ddccb01 100644
--- a/src/bin/pg_resetwal/po/uk.po
+++ b/src/bin/pg_resetwal/po/uk.po
@@ -291,8 +291,8 @@ msgstr "увімк"
#: pg_resetwal.c:758
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "Останній NextXID контрольної точки: %u%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "Останній NextXID контрольної точки: %u:%llu\n"
#: pg_resetwal.c:761
#, c-format
@@ -301,8 +301,8 @@ msgstr "Останній NextOID контрольної точки: %u\n"
#: pg_resetwal.c:763
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "Останній NextMultiXactId контрольної точки: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "Останній NextMultiXactId контрольної точки: %llu\n"
#: pg_resetwal.c:765
#, c-format
@@ -311,8 +311,8 @@ msgstr "Останній NextMultiOffset контрольної точки: %u\n
#: pg_resetwal.c:767
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "Останній oldestXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "Останній oldestXID контрольної точки: %llu\n"
#: pg_resetwal.c:769
#, c-format
@@ -321,13 +321,13 @@ msgstr "Остання DB останнього oldestXID контрольної
#: pg_resetwal.c:771
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "Останній oldestActiveXID контрольної точки: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "Останній oldestActiveXID контрольної точки: %llu\n"
#: pg_resetwal.c:773
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "Останній oldestMultiXid контрольної точки: %u \n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "Останній oldestMultiXid контрольної точки: %llu\n"
#: pg_resetwal.c:775
#, c-format
@@ -336,13 +336,13 @@ msgstr "Остання DB останньої oldestMulti контрольної
#: pg_resetwal.c:777
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "Останній oldestCommitTsXid контрольної точки:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "Останній oldestCommitTsXid контрольної точки:%llu\n"
#: pg_resetwal.c:779
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "Останній newestCommitTsXid контрольної точки: %u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "Останній newestCommitTsXid контрольної точки: %llu\n"
#: pg_resetwal.c:781
#, c-format
@@ -430,13 +430,13 @@ msgstr "Перший сегмент журналу після скидання:
#: pg_resetwal.c:827
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:829
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:831
#, c-format
@@ -455,13 +455,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:849
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:851
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:853
#, c-format
@@ -475,13 +475,13 @@ msgstr "Епоха NextXID: %u\n"
#: pg_resetwal.c:865
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:956 pg_resetwal.c:1024 pg_resetwal.c:1071
#, c-format
diff --git a/src/bin/pg_resetwal/po/zh_CN.po b/src/bin/pg_resetwal/po/zh_CN.po
index f5cec00c612..5b40210cb80 100644
--- a/src/bin/pg_resetwal/po/zh_CN.po
+++ b/src/bin/pg_resetwal/po/zh_CN.po
@@ -298,8 +298,8 @@ msgstr "开启"
#: pg_resetwal.c:775
#, c-format
-msgid "Latest checkpoint's NextXID: %u:%u\n"
-msgstr "最新检查点的NextXID: %u:%u\n"
+msgid "Latest checkpoint's NextXID: %u:%llu\n"
+msgstr "最新检查点的NextXID: %u:%llu\n"
#: pg_resetwal.c:778
#, c-format
@@ -308,8 +308,8 @@ msgstr "最新检查点的 NextOID: %u\n"
#: pg_resetwal.c:780
#, c-format
-msgid "Latest checkpoint's NextMultiXactId: %u\n"
-msgstr "最新检查点的NextMultiXactId: %u\n"
+msgid "Latest checkpoint's NextMultiXactId: %llu\n"
+msgstr "最新检查点的NextMultiXactId: %llu\n"
#: pg_resetwal.c:782
#, c-format
@@ -318,8 +318,8 @@ msgstr "最新检查点的NextMultiOffsetD: %u\n"
#: pg_resetwal.c:784
#, c-format
-msgid "Latest checkpoint's oldestXID: %u\n"
-msgstr "最新检查点的oldestXID: %u\n"
+msgid "Latest checkpoint's oldestXID: %llu\n"
+msgstr "最新检查点的oldestXID: %llu\n"
#: pg_resetwal.c:786
#, c-format
@@ -328,13 +328,13 @@ msgstr "最新检查点的oldestXID所在的数据库:%u\n"
#: pg_resetwal.c:788
#, c-format
-msgid "Latest checkpoint's oldestActiveXID: %u\n"
-msgstr "最新检查点的oldestActiveXID: %u\n"
+msgid "Latest checkpoint's oldestActiveXID: %llu\n"
+msgstr "最新检查点的oldestActiveXID: %llu\n"
#: pg_resetwal.c:790
#, c-format
-msgid "Latest checkpoint's oldestMultiXid: %u\n"
-msgstr "最新检查点的oldestMultiXid: %u\n"
+msgid "Latest checkpoint's oldestMultiXid: %llu\n"
+msgstr "最新检查点的oldestMultiXid: %llu\n"
#: pg_resetwal.c:792
#, c-format
@@ -343,13 +343,13 @@ msgstr "最新检查点的oldestMulti所在的数据库:%u\n"
#: pg_resetwal.c:794
#, c-format
-msgid "Latest checkpoint's oldestCommitTsXid:%u\n"
-msgstr "最新检查点的oldestCommitTsXid:%u\n"
+msgid "Latest checkpoint's oldestCommitTsXid:%llu\n"
+msgstr "最新检查点的oldestCommitTsXid:%llu\n"
#: pg_resetwal.c:796
#, c-format
-msgid "Latest checkpoint's newestCommitTsXid:%u\n"
-msgstr "最新检查点的newestCommitTsXid:%u\n"
+msgid "Latest checkpoint's newestCommitTsXid:%llu\n"
+msgstr "最新检查点的newestCommitTsXid:%llu\n"
#: pg_resetwal.c:798
#, c-format
@@ -447,13 +447,13 @@ msgstr "First log segment after reset: %s\n"
#: pg_resetwal.c:846
#, c-format
-msgid "NextMultiXactId: %u\n"
-msgstr "NextMultiXactId: %u\n"
+msgid "NextMultiXactId: %llu\n"
+msgstr "NextMultiXactId: %llu\n"
#: pg_resetwal.c:848
#, c-format
-msgid "OldestMultiXid: %u\n"
-msgstr "OldestMultiXid: %u\n"
+msgid "OldestMultiXid: %llu\n"
+msgstr "OldestMultiXid: %llu\n"
#: pg_resetwal.c:850
#, c-format
@@ -472,13 +472,13 @@ msgstr "NextOID: %u\n"
#: pg_resetwal.c:868
#, c-format
-msgid "NextXID: %u\n"
-msgstr "NextXID: %u\n"
+msgid "NextXID: %llu\n"
+msgstr "NextXID: %llu\n"
#: pg_resetwal.c:870
#, c-format
-msgid "OldestXID: %u\n"
-msgstr "OldestXID: %u\n"
+msgid "OldestXID: %llu\n"
+msgstr "OldestXID: %llu\n"
#: pg_resetwal.c:872
#, c-format
@@ -492,13 +492,13 @@ msgstr "NextXID epoch: %u\n"
#: pg_resetwal.c:884
#, c-format
-msgid "oldestCommitTsXid: %u\n"
-msgstr "oldestCommitTsXid: %u\n"
+msgid "oldestCommitTsXid: %llu\n"
+msgstr "oldestCommitTsXid: %llu\n"
#: pg_resetwal.c:889
#, c-format
-msgid "newestCommitTsXid: %u\n"
-msgstr "newestCommitTsXid: %u\n"
+msgid "newestCommitTsXid: %llu\n"
+msgstr "newestCommitTsXid: %llu\n"
#: pg_resetwal.c:975 pg_resetwal.c:1043 pg_resetwal.c:1090
#, c-format
--
2.35.1
v22-0001-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v22-0001-Use-64-bit-format-to-output-XIDs.patchDownload
From 2c7f9ef823e8caa6397317e1bd5707e1f9aaa7fc Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v22 1/6] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the first part of a patchset to make XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit. This patch doesn't modify corresponding .po files, it is done in
the following one.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 120 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 6 +-
contrib/test_decoding/test_decoding.c | 26 ++--
src/backend/access/heap/heapam.c | 44 +++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 12 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 36 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 8 +-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 14 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 77 +++++------
src/backend/access/transam/slru.c | 16 +--
src/backend/access/transam/subtrans.c | 4 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 36 +++---
src/backend/access/transam/xact.c | 14 +-
src/backend/access/transam/xlogrecovery.c | 42 +++---
src/backend/replication/logical/logical.c | 2 +-
.../replication/logical/reorderbuffer.c | 22 ++--
src/backend/replication/logical/snapbuild.c | 34 ++---
src/backend/replication/logical/worker.c | 26 ++--
src/backend/replication/walreceiver.c | 4 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 30 ++---
src/backend/storage/ipc/standby.c | 24 ++--
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 | 8 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 16 +--
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 14 +-
src/bin/pg_resetwal/pg_resetwal.c | 64 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 44 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
45 files changed, 448 insertions(+), 447 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..801fb015277 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,19 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax, (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax, (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..bd2644da1a4 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, "%llu", (unsigned long long) 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, "%llu", (unsigned long long) 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, "{%llu}", (unsigned long long) 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..8e0cd48516e 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +900,8 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid), (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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..6e72cc6c741 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 %llu", (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6173,8 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi, (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6187,8 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi, (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6206,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -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 %llu", (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6294,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6344,8 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid, (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6474,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6483,8 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid, (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6555,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6570,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6586,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..6aa809e3d57 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid, xlrec->ntodelete);
}
@@ -51,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..2941f74cd28 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,8 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +140,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +161,8 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..153482718b4 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, "%llu ", (unsigned long long) 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, "%llu offset %u nmembers %d: ", (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +74,8 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff, (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..266dd95c380 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +80,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..b51e57f27cf 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,8 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid, xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..f20484c4261 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 %llu", (unsigned long long) 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..b5880b3650b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,8 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid, mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) 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 %llu", (unsigned long long) 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 %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +595,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running",
+ i, (unsigned long long) 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: %llu is not running", (unsigned long long) multi);
return false;
}
@@ -657,8 +658,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +723,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) 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 %llu offset %u", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1634,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) 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, "%llu %d[%llu (%s)", (unsigned long long) multi, nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)", (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2157,8 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu" " in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset, (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2192,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -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 %llu", (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -3040,8 +3041,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3059,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3322,9 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff, (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -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: %llu", (unsigned long long) 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("%llu", (unsigned long long) 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..d98348523f5 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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..4665feb3430 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,8 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid, (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..62486bdb6a3 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 %llu", (unsigned long long) 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 %llu from shared memory", (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2145,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2165,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2197,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2358,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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..ec004fbdf66 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,22 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu", (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu", (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 9feea3e6ec9..2a0a62318f3 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,18 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti, (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid, checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2490,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2635,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2679,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..2f30e6fe142 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 %llu at %X/%X", (unsigned long long) 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..a4d24e481b0 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -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 %llu", (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3855,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4165,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4848,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5479,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..8ea79bab427 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -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 %llu to do timetravel", (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1149,8 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax, (unsigned long long) running->oldestRunningXid, (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1239,8 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon, (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1322,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1346,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 03e069c7cdd..fcfcd3a4df8 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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-%llu.subxacts", subid, (unsigned long long) 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-%llu.changes", subid, (unsigned long long) 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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3756,33 +3756,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..438104da1de 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,8 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch, (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..2a7ed544302 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) 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 %llu in MyProc", (unsigned long long) 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 %llu in MyProc", (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4385,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4896,7 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu", (unsigned long long) 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 %llu", (unsigned long long) 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]=%llu ", i, (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..c19e5d527b9 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 %llu.", (unsigned long long) 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 %llu.", (unsigned long long) 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 %llu, during read.", (unsigned long long) 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..6905405cb24 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/%llu", bid, (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..605731cf9bd 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/%llu", MyProc->backendId, (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..4b99543b3fe 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",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId, (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId, (unsigned long long) 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, "%llu", (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..4ee21e92d59 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/%llu\n", MyProc->backendId, (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n", (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
@@ -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/" "%u", &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..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 725cd2e4ebc..6eb8620affc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,9 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid, (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15467,9 +15467,9 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid, (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15481,10 +15481,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..56ea3cb4259 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +772,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +841,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +863,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +879,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..123d346eedb 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,16 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir, (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir, (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +555,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +581,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +609,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +671,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +712,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index fc081adfb8c..8e00cc71b32 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -486,10 +486,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi,
On 2022-03-18 18:14:52 +0300, Maxim Orlov wrote:
Subject: [PATCH v22 3/6] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
I think this should explain in more detail why this move is done. Neither the
commit message nor the rest of the thread does so afaics. It's not too hard to
infer, but the central reason behind a patch shouldn't need to be inferred.
-static bool CLOGPagePrecedes(int page1, int page2); +static bool CLOGPagePrecedes(int64 page1, int64 page2);
I think all of these are actually unsigned integers. If all of this stuff gets
touched, perhaps worth moving to uint64 instead?
/messages/by-id/20220318231430.m5g56yk4ztlz2man@alap3.anarazel.de
Greetings,
Andres Freund
On 2022-03-18 18:14:52 +0300, Maxim Orlov wrote:
Subject: [PATCH v22 3/6] Use 64-bit pages in SLRU
This is one step toward 64-bit XIDs.
I think this should explain in more detail why this move is done. Neither
the
commit message nor the rest of the thread does so afaics. It's not too
hard to
infer, but the central reason behind a patch shouldn't need to be inferred.-static bool CLOGPagePrecedes(int page1, int page2); +static bool CLOGPagePrecedes(int64 page1, int64 page2);I think all of these are actually unsigned integers. If all of this stuff
gets
touched, perhaps worth moving to uint64 instead?/messages/by-id/20220318231430.m5g56yk4ztlz2man@alap3.anarazel.de
We'll try to add these and many similar changes in Slru code, thanks!
On 18.03.22 16:14, Maxim Orlov wrote:
Here is v22. It addresses things mentioned by Tom and Kyotaro. Also
added Aleksander's changes from v21.
The v22-0002-Update-XID-formatting-in-the-.po-files.patch is not
necessary. That is done by a separate procedure.
I'm wondering about things like this:
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
This %u:%u business is basically an existing workaround for the lack of
64-bit transaction identifiers. Presumably, when those are available,
all of this will be replaced by a single number display, possibly a
single %llu. So these sites you change here will have to be touched
again, and so changing this now doesn't make sense. At least that's my
guess. Maybe there needs to be a fuller explanation of how this is
meant to be transitioned.
As a more general point, I don't like plastering these bulky casts all
over the place. Casts hide problems. For example, if we currently have
elog(LOG, "xid is %u", xid);
and then xid is changed to a 64-bit type, this will give a compiler
warning until you change the format. If we add a (long long unsigned)
cast here now and then somehow forget to change the type of xid, nothing
will warn us about that. (Note that there is also third-party code
affected by this.) Besides, these casts are quite ugly anyway, and I
don't think the solution for all time should be that we have to add
these casts just to print xids.
I think there needs to be a bit more soul searching here on how to
handle that in the future and how to transition it. I don't think
targeting this patch for PG15 is useful at this point.
Hi Peter,
I think there needs to be a bit more soul searching here on how to
handle that in the future and how to transition it. I don't think
targeting this patch for PG15 is useful at this point.
The patches can be reordered so that we are still able to deliver SLRU
refactoring in PG15.
As a more general point, I don't like plastering these bulky casts all
over the place. Casts hide problems.
Regarding the casts, I don't like them either. I agree that it could
be a good idea to invest a little more time into figuring out if this
transit can be handled in a better way and deliver this change in the
next CF. However, if no one will be able to suggest a better
alternative, I think we should continue making progress here. The
32-bit XIDs are a major inconvenience for many users.
--
Best regards,
Aleksander Alekseev
I think there needs to be a bit more soul searching here on how to
handle that in the future and how to transition it. I don't think
targeting this patch for PG15 is useful at this point.The patches can be reordered so that we are still able to deliver SLRU
refactoring in PG15.
Sure.
As a more general point, I don't like plastering these bulky casts all
over the place. Casts hide problems.Regarding the casts, I don't like them either. I agree that it could
be a good idea to invest a little more time into figuring out if this
transit can be handled in a better way and deliver this change in the
next CF. However, if no one will be able to suggest a better
alternative, I think we should continue making progress here. The
32-bit XIDs are a major inconvenience for many users.
I'd like to add that the initial way of shifting to 64bit was based on
XID_FMT in a print formatting template which could be changed from 32 to 64
bit when shifting to 64-bit xids later. But this template is not
localizable so hackers recommended using %lld/%llu with (long
long)/(unsigned long long cast) which is a current best practice elsewhere
in the code (e.g. recent 1f8bc448680bf93a9). So I suppose we already have a
good enough way to stick to.
This approach in 0001 inherently processes both 32/64 bit xids and should
not change with later committing 64bit xids later (
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
)
The thing that needs to change then is suppressing output of Epoch. It
should be done when 64-xids are committed and it is done by 0006 in the
mentioned thread. Until that I've left Epoch in the output.
Big thanks for your considerations!
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Hi!
Here is v23. As was suggested by Alexander above, I've changed the order of
the patches and improved the commit message. Now, SLRU patch is the first.
Splitting 64 bit XIDs into a bunch of patches was done to simplify
reviewing and making commits in small portions. We have little overhead
here like removing Epoch later and now changes are based on the fact that
Epoch still exists.
In the SLRU patch we have changed SLRU page numbering from int to int64.
There were proposals to make use of SLRU pages numbers that are in fact
unsigned and change from int to uint64. I fully support this, but I'm not
sure this big SLRU refactoring should be done in this patchset. On the
other hand it seems logical to change everything in SLRU at once. I think I
need a second opinion in support of this change.
In general, I consider this patchset is ready to commit. It would be great
to deliver it in PG15.
--
Best regards,
Maxim Orlov.
Attachments:
v23-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v23-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 38deace75ee89f91c3b6af53aa84e46ccd08f1ea Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v23 1/2] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 117 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++--
src/backend/storage/lmgr/predicate.c | 4 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 94 insertions(+), 97 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..f70bf388cec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..252ebac58a0 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (int64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +951,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1016,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1027,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1071,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1161,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1304,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1327,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1500,9 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1515,9 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1530,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1558,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1568,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1599,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..61042c34d58 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..1a9a1b6bb74 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
v23-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v23-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 25ac3b74d1cab51e548236afadb731ef5ead3ba1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v23 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the first part of a patchset to make XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit. This patch doesn't modify corresponding .po files, it is done in
the following one.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 120 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 6 +-
contrib/test_decoding/test_decoding.c | 26 ++--
src/backend/access/heap/heapam.c | 44 +++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 12 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 36 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 8 +-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 14 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 2 +-
src/backend/access/transam/multixact.c | 77 +++++------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 4 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 36 +++---
src/backend/access/transam/xact.c | 14 +-
src/backend/access/transam/xlogrecovery.c | 42 +++---
src/backend/replication/logical/logical.c | 2 +-
.../replication/logical/reorderbuffer.c | 22 ++--
src/backend/replication/logical/snapbuild.c | 34 ++---
src/backend/replication/logical/worker.c | 26 ++--
src/backend/replication/walreceiver.c | 4 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 30 ++---
src/backend/storage/ipc/standby.c | 24 ++--
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 | 8 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 16 +--
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 14 +-
src/bin/pg_resetwal/pg_resetwal.c | 64 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 44 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
45 files changed, 456 insertions(+), 447 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..801fb015277 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,19 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax, (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax, (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..bd2644da1a4 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, "%llu", (unsigned long long) 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, "%llu", (unsigned long long) 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, "{%llu}", (unsigned long long) 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..8e0cd48516e 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +900,8 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid), (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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..6e72cc6c741 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 %llu", (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6173,8 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi, (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6187,8 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi, (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6206,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -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 %llu", (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6294,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6344,8 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid, (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6474,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6483,8 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid, (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6555,8 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid, (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6570,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6586,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..6aa809e3d57 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid, xlrec->ntodelete);
}
@@ -51,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..2941f74cd28 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,8 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +140,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +161,8 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..153482718b4 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, "%llu ", (unsigned long long) 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, "%llu offset %u nmembers %d: ", (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +74,8 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff, (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..266dd95c380 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +80,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..b51e57f27cf 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,8 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid, xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..530b77e5528 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 %llu", (unsigned long long) 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 f70bf388cec..764b2261aeb 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,8 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid, mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) 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 %llu", (unsigned long long) 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 %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +595,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running",
+ i, (unsigned long long) 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: %llu is not running", (unsigned long long) multi);
return false;
}
@@ -657,8 +658,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +723,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) 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 %llu offset %u", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1634,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) 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, "%llu %d[%llu (%s)", (unsigned long long) multi, nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)", (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2157,8 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu" " in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset, (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2192,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -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 %llu", (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -3040,8 +3041,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3059,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3322,9 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff, (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -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: %llu", (unsigned long long) 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("%llu", (unsigned long long) 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 252ebac58a0..16ca020f7aa 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -944,13 +944,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
path, (long long) offset)));
break;
@@ -958,12 +960,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
path, (long long) offset)));
break;
@@ -971,26 +975,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
path, (long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..2a03de967c5 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,8 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid, (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..62486bdb6a3 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 %llu", (unsigned long long) 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 %llu from shared memory", (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2145,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2165,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2197,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2358,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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..ec004fbdf66 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,22 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu", (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu", (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 9feea3e6ec9..2a0a62318f3 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,18 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti, (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid, checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2490,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2635,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2679,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..2f30e6fe142 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 %llu at %X/%X", (unsigned long long) 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..a4d24e481b0 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -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 %llu", (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3855,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4165,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4848,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5479,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..8ea79bab427 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -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 %llu to do timetravel", (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1149,8 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax, (unsigned long long) running->oldestRunningXid, (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1239,8 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon, (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1322,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1346,8 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt, (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 03e069c7cdd..fcfcd3a4df8 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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-%llu.subxacts", subid, (unsigned long long) 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-%llu.changes", subid, (unsigned long long) 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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3756,33 +3756,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..438104da1de 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,8 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch, (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..2a7ed544302 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) 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 %llu in MyProc", (unsigned long long) 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 %llu in MyProc", (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4385,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4896,7 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu", (unsigned long long) 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 %llu", (unsigned long long) 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]=%llu ", i, (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 1a9a1b6bb74..20aab29e754 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 %llu.", (unsigned long long) 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 %llu.", (unsigned long long) 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 %llu, during read.", (unsigned long long) 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..6905405cb24 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/%llu", bid, (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..605731cf9bd 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/%llu", MyProc->backendId, (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..4b99543b3fe 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",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId, (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId, (unsigned long long) 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, "%llu", (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..4ee21e92d59 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/%llu\n", MyProc->backendId, (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n", (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
@@ -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/" "%u", &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..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 725cd2e4ebc..6eb8620affc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,9 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid, (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15467,9 +15467,9 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid, (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15481,10 +15481,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..56ea3cb4259 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +772,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +841,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +863,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +879,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..123d346eedb 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,16 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir, (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir, (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +555,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +581,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +609,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +671,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +712,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index fc081adfb8c..8e00cc71b32 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -486,10 +486,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi hackers,
Here is v23. As was suggested by Alexander above, I've changed the order of the patches and improved the commit message. Now, SLRU patch is the first.
Many thanks!
There were proposals to make use of SLRU pages numbers that are in fact unsigned and change from int to uint64. I fully support this, but I'm not sure this big SLRU refactoring should be done in this patchset.
If it takes a lot of effort and doesn't bring us any closer to 64-bit
XIDs, I suggest not doing this in v23-0001. I can invest some time
into this refactoring in April and create a separate CF entry, if
someone will second the idea.
In general, I consider this patchset is ready to commit. It would be great to deliver it in PG15.
+1.
v23-0002 seems to have two extra sentences in the commit message that
are outdated, but this is a minor issue. The commit message should be:
"""
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. While actually XIDs are still 32 bit, this patch
completely supports both 32 and 64 bit.
"""
Since Peter expressed some concerns regarding v23-0002, maybe we
should discuss it a bit more. Although personally I doubt that we can
do much better than that, and as I recall this particular change was
explicitly requested by several people.
--
Best regards,
Aleksander Alekseev
Hi!
Here is v24. Changes are:
- correct commit messages for 0001 and 0002
- use uint64 for SLRU page numbering instead of int64 in v23
- fix code formatting and indent
- and minor fixes in slru.c
Reviews are very welcome!
--
Best regards,
Maxim Orlov.
Attachments:
v24-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v24-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patchDownload
From 646b56044a55c927f5b527e7d23aa9ec74953161 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v24 1/2] Use unsigned 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 119 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 32 +++---
src/backend/storage/lmgr/predicate.c | 10 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 104 insertions(+), 105 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..9ad71216ce3 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(uint64 page1, uint64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..ae69d3fea1e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(uint64 page1, uint64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..fd9d3d3eef8 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(uint64 page1, uint64 page2);
+static bool MultiXactMemberPagePrecedes(uint64 page1, uint64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, uint64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(uint64 page1, uint64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(uint64 page1, uint64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..72733bc2d2f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (uint64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ uint64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, uint64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, uint64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, uint64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, uint64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ uint64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, uint64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(uint64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (uint64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(uint64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, uint64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, uint64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, uint64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ uint64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, uint64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, uint64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, uint64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, uint64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +951,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %llu: %m.",
+ path, (unsigned long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %llu: %m.",
+ path, (unsigned long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %llu: read too few bytes.",
+ path, (unsigned long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %llu: %m.",
+ path, (unsigned long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %llu: wrote too few bytes.",
+ path, (unsigned long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1016,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, uint64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1027,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ uint64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ uint64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1071,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ uint64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1161,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ uint64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, uint64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1304,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, uint64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1327,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, uint64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1500,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, uint64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ uint64 cutoffPage = *(uint64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1516,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, uint64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ uint64 cutoffPage = *(uint64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1532,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, uint64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1560,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ uint64 segno;
+ uint64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1570,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1601,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..659a9d7da88 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(uint64 page1, uint64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..4e283fa9355 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ uint64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(uint64 p, uint64 q);
+static bool asyncQueuePagePrecedes(uint64 p, uint64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,17 +477,17 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(uint64 p, uint64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
* in the range 0..QUEUE_MAX_PAGE.
*/
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
+ Assert(p <= QUEUE_MAX_PAGE);
+ Assert(q <= QUEUE_MAX_PAGE);
diff = p - q;
if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(uint64 p, uint64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1331,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ uint64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1404,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ uint64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..ff9f08cde95 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(uint64 page1, uint64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ uint64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ uint64 targetPage;
int slotno;
- int firstZeroPage;
+ uint64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..b7ff036523c 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ uint64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ uint64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (uint64, uint64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, uint64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, uint64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, uint64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, uint64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, uint64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, uint64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, uint64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ uint64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, uint64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
v24-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v24-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From cd8b0c5df9d3ac9acbb2051ac27fa3df8e074543 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v24 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 20 +--
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
45 files changed, 561 insertions(+), 455 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..20a3733e7d1 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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..68a679e2e79 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -828,7 +828,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -846,7 +848,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -880,7 +884,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +906,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -931,7 +939,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -965,7 +975,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1050,7 +1061,8 @@ 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 %llu",
+ (unsigned long long) 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..9894be6c804 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..1d77fa65fb6 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..a55b69dedfe 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index ae69d3fea1e..0e510e5705e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 fd9d3d3eef8..8837e1f574a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu" " in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 72733bc2d2f..e197c76bdcc 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -944,13 +944,15 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %llu: %m.",
path, (unsigned long long) offset)));
break;
@@ -958,12 +960,14 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %llu: %m.",
path, (unsigned long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %llu: read too few bytes.",
path, (unsigned long long) offset)));
break;
@@ -971,26 +975,30 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %llu: %m.",
path, (unsigned long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %llu: wrote too few bytes.",
path, (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 659a9d7da88..d47d6e8db77 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 9feea3e6ec9..f90386fc3f3 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2493,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2638,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2682,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index ff9f08cde95..94f9405a287 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..f59da34770f 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
@@ -1372,7 +1376,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/" "%u", &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..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..4ff167f794b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index fc081adfb8c..8e00cc71b32 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -486,10 +486,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
On Wed, 23 Mar 2022 at 01:22, Maxim Orlov <orlovmg@gmail.com> wrote:
Hi!
Here is v24. Changes are:
- correct commit messages for 0001 and 0002
- use uint64 for SLRU page numbering instead of int64 in v23
- fix code formatting and indent
- and minor fixes in slru.cReviews are very welcome!
Thanks for updating the patchs. I have a little comment on 0002.
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) xid, tuple->t_infomask)));
IMO, we can remove the double quote inside the sentence.
errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
(unsigned long long) xid, tuple->t_infomask)));
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
Thanks for updating the patchs. I have a little comment on 0002.
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal", + (unsigned long long) xid, tuple->t_infomask)));
Thanks for your review! Fixed.
--
Best regards,
Maxim Orlov.
Attachments:
v25-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v25-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 40f15cbd7f620a4d761f3aaf914c41674f5e45fe Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v25 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
45 files changed, 560 insertions(+), 454 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..20a3733e7d1 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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..68a679e2e79 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) 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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -828,7 +828,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -846,7 +848,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -880,7 +884,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -900,8 +906,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -931,7 +939,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -965,7 +975,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1050,7 +1061,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..1d77fa65fb6 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..a55b69dedfe 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index ae69d3fea1e..0e510e5705e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 fd9d3d3eef8..4049e17370d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 72733bc2d2f..e197c76bdcc 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -944,13 +944,15 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %llu: %m.",
path, (unsigned long long) offset)));
break;
@@ -958,12 +960,14 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %llu: %m.",
path, (unsigned long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %llu: read too few bytes.",
path, (unsigned long long) offset)));
break;
@@ -971,26 +975,30 @@ SlruReportIOError(SlruCtl ctl, uint64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %llu: %m.",
path, (unsigned long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %llu: wrote too few bytes.",
path, (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 659a9d7da88..d47d6e8db77 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 9feea3e6ec9..f90386fc3f3 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2490,15 +2493,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2635,16 +2638,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2679,9 +2682,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index ff9f08cde95..94f9405a287 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..4ff167f794b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index fc081adfb8c..8e00cc71b32 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -486,10 +486,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
v25-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v25-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patchDownload
From 646b56044a55c927f5b527e7d23aa9ec74953161 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v25 1/2] Use unsigned 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +-
src/backend/access/transam/slru.c | 119 ++++++++++----------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 32 +++---
src/backend/storage/lmgr/predicate.c | 10 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/slru.h | 24 ++--
9 files changed, 104 insertions(+), 105 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..9ad71216ce3 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(uint64 page1, uint64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..ae69d3fea1e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(uint64 page1, uint64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..fd9d3d3eef8 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(uint64 page1, uint64 page2);
+static bool MultiXactMemberPagePrecedes(uint64 page1, uint64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, uint64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(uint64 page1, uint64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(uint64 page1, uint64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..72733bc2d2f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,11 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) & (uint64)0xFFFFFFFF))
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +77,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ uint64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +140,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, uint64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, uint64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, uint64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, uint64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ uint64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, uint64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +164,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(uint64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +227,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (uint64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(uint64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +279,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, uint64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +394,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, uint64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +494,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, uint64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +541,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ uint64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +625,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, uint64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +683,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, uint64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +755,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, uint64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +930,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, uint64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ uint64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +951,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %llu: %m.",
+ path, (unsigned long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %llu: %m.",
+ path, (unsigned long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %llu: read too few bytes.",
+ path, (unsigned long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %llu: %m.",
+ path, (unsigned long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %llu: wrote too few bytes.",
+ path, (unsigned long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1016,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, uint64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1027,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ uint64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ uint64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1071,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ uint64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1161,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ uint64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, uint64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1304,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, uint64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1327,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, uint64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1500,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, uint64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ uint64 cutoffPage = *(uint64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1516,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, uint64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ uint64 cutoffPage = *(uint64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1532,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, uint64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1560,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ uint64 segno;
+ uint64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1565,10 +1570,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtou64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
@@ -1596,7 +1601,7 @@ SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int save_errno;
int result;
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
fd = OpenTransientFile(path, O_RDWR | PG_BINARY);
if (fd < 0)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..659a9d7da88 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(uint64 page1, uint64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..4e283fa9355 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ uint64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(uint64 p, uint64 q);
+static bool asyncQueuePagePrecedes(uint64 p, uint64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,17 +477,17 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(uint64 p, uint64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
* in the range 0..QUEUE_MAX_PAGE.
*/
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
+ Assert(p <= QUEUE_MAX_PAGE);
+ Assert(q <= QUEUE_MAX_PAGE);
diff = p - q;
if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
@@ -497,14 +497,8 @@ asyncQueuePageDiff(int p, int q)
return diff;
}
-/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
- */
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(uint64 p, uint64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1331,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ uint64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1404,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ uint64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..ff9f08cde95 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(uint64 page1, uint64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(uint64 page1, uint64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ uint64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ uint64 targetPage;
int slotno;
- int firstZeroPage;
+ uint64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 406c0c9877a..7805ad1be79 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -176,7 +176,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..b7ff036523c 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ uint64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ uint64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (uint64, uint64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, uint64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, uint64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, uint64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, uint64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, uint64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, uint64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, uint64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ uint64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, uint64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
On 23.03.22 10:51, Maxim Orlov wrote:
Thanks for updating the patchs. I have a little comment on 0002.
+ errmsg_internal("found xmax %llu" " (infomask 0x%04x) not frozen, not multi, not normal", + (unsigned long long) xid, tuple->t_infomask)));Thanks for your review! Fixed.
About v25-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patch:
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(uint64 page1, uint64 page2);
You are changing the API from signed to unsigned. Is this intentional?
It is not explained anywhere. Are we sure that nothing uses, for
example, negative values as error markers?
#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+ snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \
+ (uint32) ((seg) >> 32), (uint32) ((seg) &
(uint64)0xFFFFFFFF))
What's going on here? Some explanation? Why not use something like
%llX or whatever you need?
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
[etc.]
Not clear whether segno etc. need to be changed to 64 bits, or whether
an increase of SLRU_PAGES_PER_SEGMENT should also be considered.
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
This was horrible before, but maybe we can take this opportunity now to
add a comment?
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
Maybe ftag->segno should be changed to 64 bits as well? Not clear.
There is a code comment at the definition of SLRU_PAGES_PER_SEGMENT that
has some detailed explanations of how the SLRU numbering, SLRU file
names, and transaction IDs tie together. This doesn't seem to apply
anymore after this change.
The reference page of pg_resetwal contains various pieces of information
of how to map SLRU files back to transaction IDs. Please check if that
is still all up to date.
About v25-0002-Use-64-bit-format-to-output-XIDs.patch:
I don't see the point of applying this now. It doesn't make PG15 any
better. It's just a patch part of which we might need later.
Especially the issue of how we are handwaving past the epoch-enabled
output sites disturbs me. At least those should be omitted from this
patch, since this patch makes these more wrong, not more right for the
future.
An alternative we might want to consider is that we use PRId64 as
explained here:
<https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html>.
We'd have to check whether we still support any non-GNU gettext
implementations and to what extent they support this. But I think it's
something to think about if we are going to embark on a journey of much
more int64 printf output.
Hi!
Here is the v26 patchset. Main changes:
- back to signed int in SLRU pages
- fix printing epoch and xid as single value
- SlruFileName is not changed, thus no need special procedure in pg_upgrade
- remove cast from SlruFileName
- refactoring macro SlruFileName into inline function
Reviews are very welcome!
--
Best regards,
Maxim Orlov.
Attachments:
v26-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v26-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 1c656a27ff190d7ea3bcc68308298fe224ee6ee1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v26 1/2] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +--
src/backend/access/transam/slru.c | 119 +++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 ++---
8 files changed, 102 insertions(+), 95 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..f70bf388cec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..20e0ed9d0fa 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,13 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ return snprintf(path, MAXPGPATH, "%s/%04llX", ctl->Dir, (long long) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +79,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +142,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +166,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +229,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +281,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +396,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +496,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +543,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +627,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +685,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +757,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +932,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +953,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1018,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1029,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1073,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1163,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1228,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1306,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1329,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1502,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1518,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1534,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1562,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1568,7 +1575,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
if ((len == 4 || len == 5 || len == 6) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..d6c21cd5d35 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..28cddf20dfc 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
v26-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v26-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From ce53b7c260edc01e4ff5f239df20241335b4c86e Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v26 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 137 ++++++++----------
contrib/pageinspect/btreefuncs.c | 5 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 +++--
src/backend/access/heap/heapam.c | 54 ++++---
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 15 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 ++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 15 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 23 ++-
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 +++++++------
src/backend/access/transam/slru.c | 24 ++-
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 ++---
src/backend/access/transam/xact.c | 16 +-
src/backend/access/transam/xlogrecovery.c | 45 +++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 +--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 ++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 +++--
src/backend/storage/ipc/standby.c | 24 +--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_controldata/pg_controldata.c | 33 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 67 ++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++---
src/bin/pg_waldump/pg_waldump.c | 4 +-
46 files changed, 562 insertions(+), 480 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..4a87a8fa42d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +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",
- xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +805,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +847,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +871,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +947,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1007,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1066,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..cf3f0f0b2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%u",
- blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5b..5247d36d0c1 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..05709786520 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%u; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..cd980053ab7 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,9 @@ 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 %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,10 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..1c71d61cfce 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,25 @@ 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 %llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..7bfff478eaa 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 f70bf388cec..aa7c44e51f7 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 20e0ed9d0fa..340bf8aa23c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -946,13 +946,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
path, (long long) offset)));
break;
@@ -960,12 +962,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
path, (long long) offset)));
break;
@@ -973,26 +977,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
path, (long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..9b057a6b040 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae25..4514dde25d9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20dfc..108d3a9a203 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b87580..4ab4a0a7014 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..cb815141856 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +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"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..dea9063441b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,28 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
printf(_("Latest checkpoint's full_page_writes: %s\n"),
ControlFile.checkPointCopy.fullPageWrites ? _("on") : _("off"));
- printf(_("Latest checkpoint's NextXID: %u:%u\n"),
- EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +842,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +864,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +880,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 92238f30c9e..ca0bcf01b75 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi, Peter!
Thanks for your review!
About v25-0001-Use-unsigned-64-bit-numbering-of-SLRU-pages.patch:
-static bool CLOGPagePrecedes(int page1, int page2); +static bool CLOGPagePrecedes(uint64 page1, uint64 page2);You are changing the API from signed to unsigned. Is this intentional?
It is not explained anywhere. Are we sure that nothing uses, for
example, negative values as error markers?
Initially, we've made SLRU pages to be int64, and reworked them into uint64
as per Andres Freund's proposal. It is not necessary for a 64xid patchset
though as maximum page number is at least several (>2) times less than the
maximum 64bit xid value. So we've returned them to be signed int64. I don't
see the reason why make SRLU unsigned for introducing 64bit xids.
#define SlruFileName(ctl, path, seg) \ - snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg) + snprintf(path, MAXPGPATH, "%s/%04X%08X", (ctl)->Dir, \ + (uint32) ((seg) >> 32), (uint32) ((seg) & (uint64)0xFFFFFFFF))
What's going on here? Some explanation? Why not use something like
%llX or whatever you need?
Of course, this should be simplified as %012llX and we will do this in
later stage (in 0006 patch in 64xid thread) as this should be done together
with CLOG pg_upgrade. So we've returned this to the initial state in 0001.
Thanks for the notion!
+ uint64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ uint64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
[etc.]Not clear whether segno etc. need to be changed to 64 bits, or whether
an increase of SLRU_PAGES_PER_SEGMENT should also be considered.
Yes, segno should be 64bits because even multiple of SLRU_PAGES_PER_SEGMENT
and CLOG_XACTS_PER_PAGE (and similar for commit_ts and mxact) is far less
than 2^32 and the overall length of clog/commit_ts/mxact is 64bit.
- if ((len == 4 || len == 5 || len == 6) && + if ((len == 12 || len == 13 || len == 14) &&This was horrible before, but maybe we can take this opportunity now to
add a comment?
This should also be introduced later together with SlruFileName changes. So
we've removed this change from 0001. Later in 0006 we'll add this with
comments.
- SlruFileName(ctl, path, ftag->segno);
+ SlruFileName(ctl, path, (uint64) ftag->segno);
Maybe ftag->segno should be changed to 64 bits as well? Not clear.
Same as previous.
There is a code comment at the definition of SLRU_PAGES_PER_SEGMENT that
has some detailed explanations of how the SLRU numbering, SLRU file
names, and transaction IDs tie together. This doesn't seem to apply
anymore after this change.
Same as previous.
The reference page of pg_resetwal contains various pieces of information
of how to map SLRU files back to transaction IDs. Please check if that
is still all up to date.
Same as previous.
About v25-0002-Use-64-bit-format-to-output-XIDs.patch:
I don't see the point of applying this now. It doesn't make PG15 any
better. It's just a patch part of which we might need later.
Especially the issue of how we are handwaving past the epoch-enabled
output sites disturbs me. At least those should be omitted from this
patch, since this patch makes these more wrong, not more right for the
future.
psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax, + psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu", + (unsigned long long) xmax, EpochFromFullTransactionId(ctx->next_fxid), - XidFromFullTransactionId(ctx->next_fxid))); + (unsigned long long) XidFromFullTransactionId(ctx-> next_fxid)));
This %u:%u business is basically an existing workaround for the lack of
64-bit transaction identifiers. Presumably, when those are available,
all of this will be replaced by a single number display, possibly a
single %llu. So these sites you change here will have to be touched
again, and so changing this now doesn't make sense. At least that's my
guess. Maybe there needs to be a fuller explanation of how this is
meant to be transitioned.
Fixed, thanks.
An alternative we might want to consider is that we use PRId64 as
explained here:
<
https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html>.We'd have to check whether we still support any non-GNU gettext
implementations and to what extent they support this. But I think it's
something to think about if we are going to embark on a journey of much
more int64 printf output.
There were several other ways that have met opposition above in the thread.
I guess PRId64 will also be opposed as not portable enough. Personally, I
don't see much trouble when we cast the value to be printed to more wide
value and consider this the best choice of all that was discussed. We just
stick to a portable way of printing which was recommended by Tom and in
agreement with 1f8bc448680bf93a974cb5f5
In [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com we initially proposed a 64xid patch to be committed at once. But it
appeared that a patch of this complexity can not be reviewed at once. It
was proposed in [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com that we'd better cut it into separate threads and
commit by parts, some into v15, the other into v16. So we did. In view of
this, I can not accept that 0002 patch doesn't make v15 better. I consider
it is separate enough to be committed as a base to further 64xid parts.
Anyway, big thanks for the review, which is quite useful!
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Just forgot to mention that answers in a previous message are describing
the changes that are in v26.
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Sorry, I forgot to change pg_amcheck tests to correspond to the removed
epoch from output in 0002.
Fixed in v27.
--
Best regards,
Maxim Orlov.
Attachments:
v27-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v27-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 1c656a27ff190d7ea3bcc68308298fe224ee6ee1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v27 1/2] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +--
src/backend/access/transam/slru.c | 119 +++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 ++---
8 files changed, 102 insertions(+), 95 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..f70bf388cec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..20e0ed9d0fa 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,13 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ return snprintf(path, MAXPGPATH, "%s/%04llX", ctl->Dir, (long long) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +79,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +142,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +166,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +229,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +281,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +396,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +496,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +543,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +627,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +685,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +757,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +932,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +953,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1018,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1029,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1073,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1163,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1228,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1306,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1329,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1502,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1518,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1534,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1562,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1568,7 +1575,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
if ((len == 4 || len == 5 || len == 6) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..d6c21cd5d35 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..28cddf20dfc 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
v27-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v27-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 262a7a32a619eedcc53bfda974ec25998198a547 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:06 +0300
Subject: [PATCH v27 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 137 ++++++++----------
contrib/pageinspect/btreefuncs.c | 5 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 +++--
src/backend/access/heap/heapam.c | 54 ++++---
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 15 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 ++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 15 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 23 ++-
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 +++++++------
src/backend/access/transam/slru.c | 24 ++-
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 ++---
src/backend/access/transam/xact.c | 16 +-
src/backend/access/transam/xlogrecovery.c | 45 +++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 +--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 ++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 +++--
src/backend/storage/ipc/standby.c | 24 +--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 33 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 67 ++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++---
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 484 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..4a87a8fa42d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +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",
- xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +805,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +847,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +871,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +947,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1007,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1066,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..cf3f0f0b2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%u",
- blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5b..5247d36d0c1 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..05709786520 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%u; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..cd980053ab7 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,9 @@ 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 %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,10 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..1c71d61cfce 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,25 @@ 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 %llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..7bfff478eaa 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 f70bf388cec..aa7c44e51f7 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 20e0ed9d0fa..340bf8aa23c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -946,13 +946,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
path, (long long) offset)));
break;
@@ -960,12 +962,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
path, (long long) offset)));
break;
@@ -973,26 +977,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
path, (long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..9b057a6b040 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae25..4514dde25d9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20dfc..108d3a9a203 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b87580..4ab4a0a7014 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 94d691a614d..16f9663c314 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -363,7 +363,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -374,7 +374,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -386,7 +386,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -395,7 +395,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..cb815141856 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +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"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..dea9063441b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,28 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
printf(_("Latest checkpoint's full_page_writes: %s\n"),
ControlFile.checkPointCopy.fullPageWrites ? _("on") : _("off"));
- printf(_("Latest checkpoint's NextXID: %u:%u\n"),
- EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +842,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +864,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +880,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 92238f30c9e..ca0bcf01b75 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi!
It seems that CFbot was still unhappy with pg_upgrade test due to epoch
removal from NextXid in controldata.
I've reverted this change as support for "epochless" 64-bit control data
with xids that haven't yet switched to 64-bit would otherwise need extra
temporary code to support.
I suppose this should be committed with the main 64xid (0006) patch later.
PFA v28 patch.
Thanks, you all for your attention, interest, and help with this patch!
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Attachments:
v28-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v28-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From bec2cd4689a64607f9dbf6a3af77e971eee5740d Mon Sep 17 00:00:00 2001
From: Pavel Borisov <pashkin.elfe@gmail.com>
Date: Thu, 24 Mar 2022 23:32:48 +0400
Subject: [PATCH v28 1/2] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 10 +--
src/backend/access/transam/slru.c | 119 +++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 22 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 ++---
8 files changed, 102 insertions(+), 95 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..f70bf388cec 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..20e0ed9d0fa 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -59,9 +59,13 @@
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/shmem.h"
+#include "utils/builtins.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ return snprintf(path, MAXPGPATH, "%s/%04llX", ctl->Dir, (long long) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +79,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +142,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +166,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +229,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +281,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +396,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +496,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +543,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,11 +627,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
bool result;
@@ -681,11 +685,11 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd;
@@ -753,11 +757,11 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
int fd = -1;
@@ -928,11 +932,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
- int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
- int offset = rpageno * BLCKSZ;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
SlruFileName(ctl, path, segno);
@@ -949,33 +953,34 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not seek in file \"%s\" to offset %u: %m.",
- path, offset)));
+ errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
+ path, (long long) offset)));
break;
case SLRU_READ_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: %m.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: %m.",
+ path, (long long) offset)));
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not write to file \"%s\" at offset %u: wrote too few bytes.",
- path, offset)));
+ errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
+ path, (long long) offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(data_sync_elevel(ERROR),
@@ -1013,7 +1018,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1029,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1073,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1163,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1228,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1306,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1329,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1497,9 +1502,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1518,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1534,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1562,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1568,7 +1575,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
if ((len == 4 || len == 5 || len == 6) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..d6c21cd5d35 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -186,8 +186,8 @@ typedef struct AsyncQueueEntry
char data[NAMEDATALEN + NOTIFY_PAYLOAD_MAX_LENGTH];
} AsyncQueueEntry;
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..28cddf20dfc 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.24.3 (Apple Git-128)
v28-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v28-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From d75cd72bf2ab37f7df43ab71181b6ba3e94fdf40 Mon Sep 17 00:00:00 2001
From: Pavel Borisov <pashkin.elfe@gmail.com>
Date: Thu, 24 Mar 2022 23:33:15 +0400
Subject: [PATCH v28 2/2] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 137 ++++++++----------
contrib/pageinspect/btreefuncs.c | 5 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 +++--
src/backend/access/heap/heapam.c | 54 ++++---
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 15 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 ++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 15 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 +-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 23 ++-
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 +++++++------
src/backend/access/transam/slru.c | 24 ++-
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 ++---
src/backend/access/transam/xact.c | 16 +-
src/backend/access/transam/xlogrecovery.c | 45 +++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 +--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 ++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 +++--
src/backend/storage/ipc/standby.c | 24 +--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 28 ++--
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 62 ++++----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++---
src/bin/pg_waldump/pg_waldump.c | 4 +-
46 files changed, 560 insertions(+), 475 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..4a87a8fa42d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +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",
- xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmin,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +805,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +847,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",
- xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(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",
- xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
+ (unsigned long long) xvac,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +871,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +947,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1007,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1066,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",
- xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..cf3f0f0b2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%u",
- blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5b..5247d36d0c1 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..05709786520 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,18 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%u; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..cd980053ab7 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,9 @@ 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 %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +100,10 @@ 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 %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..1c71d61cfce 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,25 @@ 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 %llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..7bfff478eaa 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 f70bf388cec..aa7c44e51f7 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 20e0ed9d0fa..340bf8aa23c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -946,13 +946,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %lld: %m.",
path, (long long) offset)));
break;
@@ -960,12 +962,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %lld: read too few bytes.",
path, (long long) offset)));
break;
@@ -973,26 +977,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: %m.",
path, (long long) offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %lld: wrote too few bytes.",
path, (long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..9b057a6b040 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae25..4514dde25d9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20dfc..108d3a9a203 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 94d691a614d..16f9663c314 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -363,7 +363,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -374,7 +374,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -386,7 +386,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -395,7 +395,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..ab7727aac2b 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -252,24 +252,24 @@ main(int argc, char *argv[])
XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..f7b22211548 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -777,24 +779,24 @@ PrintControlValues(bool guessed)
XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 92238f30c9e..ca0bcf01b75 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.24.3 (Apple Git-128)
At Fri, 25 Mar 2022 00:02:55 +0400, Pavel Borisov <pashkin.elfe@gmail.com> wrote in
Hi!
It seems that CFbot was still unhappy with pg_upgrade test due to epoch
removal from NextXid in controldata.
I've reverted this change as support for "epochless" 64-bit control data
with xids that haven't yet switched to 64-bit would otherwise need extra
temporary code to support.
I suppose this should be committed with the main 64xid (0006) patch later.PFA v28 patch.
Thanks, you all for your attention, interest, and help with this patch!
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
segpage doesn't fit mxtruncinfo.earliestExistingPage. Doesn't it need
to be int64?
+ return snprintf(path, MAXPGPATH, "%s/%04llX", ctl->Dir, (long long) segno);
We have two way to go here. One way is expanding the file name
according to the widened segno, another is keep the old format string
then cast the segno to (int). Since the objective of this patch is
widen pageno, I think, as Pavel's comment upthread, we should widen
the file format to "%s/%012llX".
As Peter suggested upthread,
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
+ int64 offset = rpageno * BLCKSZ;
rpageno is apparently over-sized. So offset is also over-sized. segno
can be up to 48 bits (maybe) so int64 is appropriate.
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
This function does the followng.
FileTag tag;
INIT_SLRUFILETAG(tag, ctl->sync_handler, segno);
tag.segno is uin32, which is too narrow here.
This is not an issue of this patch, but..
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
Why do we print int by "%u" here, even though that doesn't harm at all?
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
SlruMayDeleteSegment, called from this function, still thinks page
numbers as int.
if ((len == 4 || len == 5 || len == 6) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
(I'm not sure about "len == 5 || len == 6", though), the name of the
file is (I think) now expanded to 12 bytes. Otherwise, strtoi64 is
not needed here.
-/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+/* AsyncQueueEntry.xid requires 8-byte alignment */
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
I think we haven't expanded xid yet? (And the first member of
AsyncQueueEntry is int even after expanding xid.)
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage,
void *data)
segpage doesn't fit mxtruncinfo.earliestExistingPage. Doesn't it need
to be int64?
I think yes, fixed. Thanks!
+ return snprintf(path, MAXPGPATH, "%s/%04llX", ctl->Dir, (long long)
segno);
We have two way to go here. One way is expanding the file name
according to the widened segno, another is keep the old format string
then cast the segno to (int). Since the objective of this patch is
widen pageno, I think, as Pavel's comment upthread, we should widen
the file format to "%s/%012llX".
I did it the first way. I moved the actual change of segment file name in
the next patches that are to be committed in v16 or later.
As Peter suggested upthread,
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT; + int64 rpageno = pageno % SLRU_PAGES_PER_SEGMENT; + int64 offset = rpageno * BLCKSZ; rpageno is apparently over-sized. So offset is also over-sized. segno can be up to 48 bits (maybe) so int64 is appropriate.
Fixed. Thanks!
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll
fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll
fdata)
This function does the followng.FileTag tag;
INIT_SLRUFILETAG(tag, ctl->sync_handler, segno);
tag.segno is uin32, which is too narrow here.
Fixed. Thanks!
This is not an issue of this patch, but..
- errdetail("Could not read from file \"%s\" at offset %u: %m.",
- path, offset)));
Why do we print int by "%u" here, even though that doesn't harm at all?
Since it is not related to making XIDs 64 bit it is addressed in the
separate thread [1]/messages/by-id/CALT9ZEG1Oo9W_bME5yhsE96AYz19VOnEwHxFUNCosBJHmc0bhw@mail.gmail.com.
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void
*data) +SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage, + void *data) { - int cutoffPage = *(int *) data; + int64 cutoffPage = *(int64 *) data; SlruMayDeleteSegment, called from this function, still thinks page numbers as int.
Fixed. Thanks!
if ((len == 4 || len == 5 || len == 6) &&
strspn(clde->d_name, "0123456789ABCDEF") == len) { - segno = (int) strtol(clde->d_name, NULL, 16); + segno = strtoi64(clde->d_name, NULL, 16); (I'm not sure about "len == 5 || len == 6", though), the name of the file is (I think) now expanded to 12 bytes. Otherwise, strtoi64 is not needed here.
Same as "%s/%04llX" issues mentioned above. Moved to the next patches.
-/* Currently, no field of AsyncQueueEntry requires more than int alignment
*/ -#define QUEUEALIGN(len) INTALIGN(len) +/* AsyncQueueEntry.xid requires 8-byte alignment */ +#define QUEUEALIGN(len) TYPEALIGN(8, len) I think we haven't expanded xid yet? (And the first member of AsyncQueueEntry is int even after expanding xid.)
Same as above.
Thanks for your review!
Here is a new patchset v29.
Major changes:
- fixes from review by Kyotaro mentioned above
- 0002 is split into two patches: 0002 is change output XIDs format only,
0003 is get rid of epoch in output
- 0003 includes changes in controldata file format in order to support both
formats: old format with epoch and new as FullTransactionId
I'm not sure if it is worth it at this stage to change pg_resetwal handling
on epoch (for example, remove -e option and so on) or do it later?
Opinions are welcome!
[1]: /messages/by-id/CALT9ZEG1Oo9W_bME5yhsE96AYz19VOnEwHxFUNCosBJHmc0bhw@mail.gmail.com
/messages/by-id/CALT9ZEG1Oo9W_bME5yhsE96AYz19VOnEwHxFUNCosBJHmc0bhw@mail.gmail.com
--
Best regards,
Maxim Orlov.
Attachments:
v29-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v29-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 16bd8554072c00376aec939bd7cfdfec03c35a85 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v29 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20a3733e7d1..4a87a8fa42d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index c6d36250402..cf3f0f0b2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 1d77fa65fb6..05709786520 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -52,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index a55b69dedfe..cd980053ab7 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index efaf02fe462..1c71d61cfce 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef50..4ab4a0a7014 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 4d9cb821ce4..cb815141856 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8cb..2b1b1a3435e 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.35.1
v29-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v29-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From b85e328dec5f7aa09e6a01e150c36d040caa4be9 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v29 2/3] Use 64 bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64 bit.
While actually XIDs are still 32 bit, this patch completely supports both 32
and 64 bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..20a3733e7d1 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5b..5247d36d0c1 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..1d77fa65fb6 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..a55b69dedfe 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..7bfff478eaa 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 aa0cf37c029..b141aac8907 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 2e875825839..3b37b9b0991 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %u: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..9b057a6b040 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae25..4514dde25d9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20dfc..108d3a9a203 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b87580..88f6f33ef50 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 94d691a614d..16f9663c314 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -363,7 +363,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -374,7 +374,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -386,7 +386,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -395,7 +395,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..4ff167f794b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 92238f30c9e..ca0bcf01b75 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
v29-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v29-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 68b2c6ff8e98cd4d9f40d774060f73ff76be4c6a Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v29 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
8 files changed, 92 insertions(+), 82 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..aa0cf37c029 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2870,7 +2870,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..2e875825839 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..2f27348a9c4 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..28cddf20dfc 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.35.1
Sorry, I forgot to append a fix for FileTag in v29. Here is v30.
--
Best regards,
Maxim Orlov.
Attachments:
v30-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v30-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 28fb75f50f47e164b245780b33e89b4992794c0f Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v30 1/4] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a7048..e03c167a27d 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4a..76dfd2b13b3 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 6a70d497380..aa0cf37c029 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2870,7 +2870,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5dc..2e875825839 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d35481552..56c19021a9e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44a..2f27348a9c4 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b24..28cddf20dfc 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c8632..4f5a324da2a 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 9737e1eb67c..35fc1dff1ab 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileNode rnode;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.35.1
v30-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v30-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 370be916503bf5c0cbe5131c72b840df9b21b801 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v30 3/4] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20a3733e7d1..4a87a8fa42d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index c6d36250402..cf3f0f0b2f1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 1d77fa65fb6..05709786520 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -52,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index a55b69dedfe..cd980053ab7 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index efaf02fe462..1c71d61cfce 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef50..4ab4a0a7014 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 4d9cb821ce4..cb815141856 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8cb..2b1b1a3435e 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.35.1
v30-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v30-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From dcaa077d8f6726e7bb8562efb5f1214765dedce3 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v30 2/4] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb8..20a3733e7d1 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d9628dd664d..c6d36250402 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 713a165203e..1485a6d47d1 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5b..5247d36d0c1 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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..9f5fb28231e 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5198,7 +5198,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6173,8 +6174,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6187,8 +6189,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6206,8 +6209,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6218,7 +6222,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId; /* not strictly necessary */
}
@@ -6294,8 +6299,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6344,8 +6350,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* If we determined that it's an Xid corresponding to an update
@@ -6474,8 +6481,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6483,8 +6491,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6555,8 +6564,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6570,8 +6580,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
}
else
@@ -6586,8 +6596,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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..9c0e4f6f9da 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 87ab7775aee..aeae43d479a 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -690,21 +690,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (FreezeLimit - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- FreezeLimit, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) FreezeLimit, diff);
}
if (minmulti_updated)
{
diff = (int32) (MultiXactCutoff - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- MultiXactCutoff, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) 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..bbb5910633a 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0a..4b2e9bc2ff0 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa1580..1d77fa65fb6 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16c..9030e74b88c 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65e..f3fb61971f5 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f2..4cf8a9a4b15 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf8..a55b69dedfe 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a1..937662e5d48 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349c..a9d1fa9d39a 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6ce..3eeac8280eb 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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..efaf02fe462 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b3..7bfff478eaa 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 aa0cf37c029..b141aac8907 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 2e875825839..3b37b9b0991 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %u: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9e..9b057a6b040 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e88..b243878094f 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 874c8ed1256..8affeb8ec85 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2054,7 +2055,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2145,15 +2147,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2165,15 +2167,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2197,13 +2199,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2358,8 +2360,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2465,7 +2467,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2508,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) 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..505195c5a45 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1727,8 +1727,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5434,22 +5434,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae25..4514dde25d9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 934aa13f2d3..4661a1ed76b 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1702,8 +1702,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index c2d9be81fae..1598a188661 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2774,8 +2774,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3213,7 +3213,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3855,8 +3856,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4165,8 +4166,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4848,9 +4849,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5479,8 +5480,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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..4e03f27ac86 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 82dcffc2db8..36af624d9cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3290,14 +3292,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3459,7 +3463,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3975,33 +3979,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ceaff097b97..0ffaf460a54 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 2d0292a092e..90847007146 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2214,10 +2214,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 13d192ec2b4..3e78bcc8ec1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1105,9 +1105,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1191,8 +1191,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1276,9 +1276,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3992,7 +3992,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4008,7 +4009,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4385,8 +4387,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4896,7 +4898,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4956,7 +4959,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5144,7 +5148,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 27361ac8610..e8a479cf5a6 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20dfc..108d3a9a203 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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..0a872d02415 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d9..7285734402c 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..261691dc0fa 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) 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..440737cea64 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b87580..88f6f33ef50 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a3..1bf1abf42c1 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 94d691a614d..16f9663c314 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -363,7 +363,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -374,7 +374,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -386,7 +386,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -395,7 +395,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d946..4d9cb821ce4 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e5816c4ccea..d8f2fd1e04b 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15471,9 +15472,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15485,10 +15487,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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..4ff167f794b 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f6474..3e5db964abe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 92238f30c9e..ca0bcf01b75 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi hackers,
Here is v30.
I took another look at the patchset. Personally I don't think it will get much
better than it is now. I'm inclined to change the status of the CF entry to
"Ready for Committer" unless anyone disagrees.
cfbot reports a problem with t/013_partition.pl but the test seems to be flaky
on `master` [1]https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=frogfish&dt=2022-03-25%2018%3A37%3A10. I couldn't find anything useful in the logs except for
"[postmaster] LOG: received immediate shutdown request". Then I re-checked the
patchset on FreeBSD 13 locally. The patchset passed `make installcked-world`.
About v25-0002-Use-64-bit-format-to-output-XIDs.patch:
I don't see the point of applying this now. It doesn't make PG15 any
better. It's just a patch part of which we might need later.
It was proposed in [1] that we'd better cut it into separate threads and
commit by parts, some into v15, the other into v16. So we did. In view of
this, I can not accept that 0002 patch doesn't make v15 better. I consider
it is separate enough to be committed as a base to further 64xid parts.
I understand how disappointing this may be.
Personally I don't have a strong opinion here. Merging the patch sooner will
allow us to move toward 64-bit XIDs faster (e.g. to gather the feedback from
the early adopters, allow the translators to do their thing earlier, etc).
Merging it later will make PG15 more stable (you can't break anything new if
you don't change anything). As always, engineering is all about compromises.
It's up to the committer to decide.
[1]: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=frogfish&dt=2022-03-25%2018%3A37%3A10
--
Best regards,
Aleksander Alekseev
On 28.03.22 12:46, Aleksander Alekseev wrote:
Personally I don't have a strong opinion here. Merging the patch sooner will
allow us to move toward 64-bit XIDs faster (e.g. to gather the feedback from
the early adopters, allow the translators to do their thing earlier, etc).
Merging it later will make PG15 more stable (you can't break anything new if
you don't change anything). As always, engineering is all about compromises.
At this point, I'm more concerned that code review is still finding
bugs, and that we have no test coverage for any of this, so we are
supposed to gain confidence in this patch by staring at it very hard. ;-)
AFAICT, this patch provides no actual functionality change, so holding
it a bit for early in the PG16 cycle wouldn't lose anything.
Hi hackers,
I took another look at the patchset. Personally I don't think it will get much
better than it is now. I'm inclined to change the status of the CF entry to
"Ready for Committer" unless anyone disagrees.
About v25-0002-Use-64-bit-format-to-output-XIDs.patch:
I don't see the point of applying this now. It doesn't make PG15 any
better. It's just a patch part of which we might need later.AFAICT, this patch provides no actual functionality change, so holding
it a bit for early in the PG16 cycle wouldn't lose anything.
OK. As I understand we still have a consensus that v30-0001 (SLRU refactoring,
not the XID formatting) is targeting PG15, so I changed the CF entry to
"Ready for Committer" for this single patch. I rechecked it again on the
current `master` branch without the other patches and it is OK. cfbot is happy
with the patchset as well.
--
Best regards,
Aleksander Alekseev
On 29.03.22 15:09, Aleksander Alekseev wrote:
Hi hackers,
I took another look at the patchset. Personally I don't think it will get much
better than it is now. I'm inclined to change the status of the CF entry to
"Ready for Committer" unless anyone disagrees.About v25-0002-Use-64-bit-format-to-output-XIDs.patch:
I don't see the point of applying this now. It doesn't make PG15 any
better. It's just a patch part of which we might need later.AFAICT, this patch provides no actual functionality change, so holding
it a bit for early in the PG16 cycle wouldn't lose anything.OK. As I understand we still have a consensus that v30-0001 (SLRU refactoring,
not the XID formatting) is targeting PG15, so I changed the CF entry to
"Ready for Committer" for this single patch. I rechecked it again on the
current `master` branch without the other patches and it is OK. cfbot is happy
with the patchset as well.
That isn't really what I meant. When I said
At this point, I'm more concerned that code review is still finding
bugs, and that we have no test coverage for any of this
this meant especially the SLRU refactoring patch.
Hi Peter,
That isn't really what I meant. When I said
At this point, I'm more concerned that code review is still finding
bugs, and that we have no test coverage for any of thisthis meant especially the SLRU refactoring patch.
Got it, and sorry for the confusion. I decided to invest some time
into improving the SLRU test coverage. I created a new thread, please
join the discussion [1]/messages/by-id/CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com.
Maxim, Pavel and I agreed (offlist) that I will rebase v30 patchset if
[1]: /messages/by-id/CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com
[1]: /messages/by-id/CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com
--
Best regards,
Aleksander Alekseev
Hi!
Here is rebased version of a patch with minor improvements.
--
Best regards,
Maxim Orlov.
Attachments:
v31-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v31-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 88a67735dcb1bc8b3b47f1f983379010b694454e Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v31 2/7] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb..20a3733e7d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 3daa31c84d..113de447c1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 c7a87f5fe5..5247d36d0c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -360,7 +360,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -413,7 +413,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -435,7 +435,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -459,7 +459,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -840,7 +840,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -858,7 +860,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -892,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -912,8 +918,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -943,7 +951,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -977,7 +987,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -1062,7 +1073,8 @@ 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 %llu",
+ (unsigned long long) 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 1ee985f633..e6199a0552 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5152,7 +5152,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6135,8 +6136,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6149,8 +6151,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6168,8 +6171,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6180,7 +6184,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6271,8 +6276,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6321,8 +6327,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6486,8 +6493,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6495,8 +6503,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6623,8 +6632,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6638,8 +6648,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6660,8 +6670,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 3a9532cb4f..9b27c922cc 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 9cdc8008c1..bc04c411e8 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -710,21 +710,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (orig_rel_pages > 0)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa158..1d77fa65fb 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65..f3fb61971f 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf..a55b69dedf 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 025d556f6c..3eeac8280e 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, " %llu", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, "%llu: ", (unsigned long long) 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, " %llu", (unsigned long long) 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 %llu: ", (unsigned long long) 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 e7452af679..efaf02fe46 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b..7bfff478ea 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 7887e2cd99..3d19412d7d 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -722,8 +726,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1200,7 +1204,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1250,7 +1255,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1529,7 +1535,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1552,7 +1559,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1633,8 +1641,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1675,11 +1683,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2156,8 +2166,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2191,8 +2202,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2377,7 +2388,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2627,12 +2639,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2656,8 +2668,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3040,8 +3053,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3058,16 +3071,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3321,9 +3334,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3372,7 +3386,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3408,7 +3422,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 2e87582583..3b37b9b099 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %u: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e8..b243878094 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 4dc8ccc12b..12bc31429c 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -849,7 +849,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2055,7 +2056,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2146,15 +2148,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2166,15 +2168,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2198,13 +2200,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2360,8 +2362,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2467,7 +2469,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2510,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) 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 3596a7d734..c4a96f6393 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1728,8 +1728,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5435,22 +5435,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 8d2395dae2..4514dde25d 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -518,8 +518,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -798,18 +798,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2494,15 +2497,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2639,16 +2642,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2683,9 +2686,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index e1f14aeecb..2b14b59593 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1704,8 +1704,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 4702750a2e..31c38d4a55 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2781,8 +2781,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -3220,7 +3220,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3862,8 +3863,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -4172,8 +4173,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4855,9 +4856,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5486,8 +5487,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 83fca8a77d..4e03f27ac8 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index f3868b3e1f..04c0b1470b 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1090,7 +1090,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1532,7 +1533,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3346,14 +3348,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3515,7 +3519,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4031,33 +4035,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3c9411e221..9c8a58a776 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 75400a53f2..4ffa355d24 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2252,10 +2252,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 735763cc24..8981a932a8 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1111,9 +1111,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1197,8 +1197,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1282,9 +1282,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -4004,7 +4004,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4020,7 +4021,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4397,8 +4399,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4908,7 +4910,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4968,7 +4971,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5156,7 +5160,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 2850867323..c90bb063bc 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 28cddf20df..108d3a9a20 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 944cd6df03..0a872d0241 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 89f78b447d..7285734402 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986..261691dc0f 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 843641c865..440737cea6 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a..1bf1abf42c 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index f911f98d94..4d9cb821ce 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 535b160165..d06a93fdd4 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3063,9 +3063,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15553,9 +15554,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15567,10 +15569,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 1eb4509fca..4ff167f794 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -182,7 +182,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -198,7 +199,8 @@ 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 %llu",
+ (unsigned long long) FirstNormalTransactionId);
exit(1);
}
break;
@@ -772,29 +774,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -841,18 +843,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -863,10 +865,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -879,13 +881,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f647..3e5db964ab 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 4cb40d068a..35224c92e0 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -548,10 +548,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogDumpRecordLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
v31-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v31-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From c98c5b5be285fa7748f821d7e7343700ce88daa3 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v31 1/7] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4..76dfd2b13b 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 9f65c600d0..7887e2cd99 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2870,7 +2870,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2878,7 +2878,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3129,7 +3129,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3149,7 +3149,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 30a476ed5d..2e87582583 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %u: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 455d895a44..2f27348a9c 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1337,7 +1337,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1410,7 +1410,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e337aad5b2..28cddf20df 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 9737e1eb67..35fc1dff1a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileNode rnode;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.35.1
v31-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v31-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From ca82605f7dcf8fc5e86a2c3c1386040d361fefa9 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v31 3/7] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20a3733e7d..4a87a8fa42 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 113de447c1..cc81ab2d26 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 1d77fa65fb..0570978652 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -52,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index a55b69dedf..cd980053ab 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index efaf02fe46..1c71d61cfc 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 4d9cb821ce..cb81514185 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8c..2b1b1a3435 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.35.1
Hi!
To keep this thread up to date with [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com -- Best regards, Maxim Orlov., here is the rebased v32 version of
the patch.
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com -- Best regards, Maxim Orlov.
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Maxim Orlov.
Attachments:
v32-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v32-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From cb5a614e6dd90d40ef4c6fa2b9c8c237fe020a3b Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v32 3/7] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20a3733e7d..4a87a8fa42 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 113de447c1..cc81ab2d26 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 1d77fa65fb..0570978652 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -52,9 +51,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index a55b69dedf..cd980053ab 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index c73e9df63f..db876c2777 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8c..2b1b1a3435 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.35.1
v32-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v32-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 1e23c94ac78f239cda6f538720850d5cad1cfb18 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v32 1/7] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4..76dfd2b13b 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..69ff2d111b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2857,7 +2857,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2865,7 +2865,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3116,7 +3116,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3136,7 +3136,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 7240454ca4..de09068395 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -72,7 +72,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -377,7 +377,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 25e7e4e37b..bea5d810e0 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 9737e1eb67..35fc1dff1a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileNode rnode;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.35.1
v32-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v32-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From f5a3b0a823a5f64525346979781c4882f1420c60 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v32 2/7] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb..20a3733e7d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 3daa31c84d..113de447c1 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 08d366a594..2cfac27807 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -314,7 +314,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -390,7 +390,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -412,7 +412,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -436,7 +436,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -785,7 +785,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -803,7 +805,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -837,7 +841,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -857,8 +863,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -888,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -922,7 +932,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -975,7 +986,8 @@ 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 %llu",
+ (unsigned long long) 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 ba11bcd99e..086195ace0 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5152,7 +5152,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6135,8 +6136,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6149,8 +6151,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6168,8 +6171,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6180,7 +6184,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6271,8 +6276,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6321,8 +6327,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6486,8 +6493,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6495,8 +6503,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6623,8 +6632,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6638,8 +6648,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6660,8 +6670,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 666b6205a7..24573fcdc2 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index a1c2af33f1..67d79bf07f 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -710,21 +710,21 @@ 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"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, older by %d xids when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d xids ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d xids ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d mxids ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d mxids ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (orig_rel_pages > 0)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 9cab4fa158..1d77fa65fb 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
@@ -51,9 +52,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65..f3fb61971f 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf..a55b69dedf 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index d3f625d072..9cfdd65d83 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 c0dfea40c7..c73e9df63f 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b..7bfff478ea 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 69ff2d111b..2b36029b10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2144,8 +2154,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2179,8 +2190,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2365,7 +2376,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2614,12 +2626,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2643,8 +2655,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3027,8 +3040,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3045,16 +3058,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3308,9 +3321,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3359,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3395,7 +3409,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 de09068395..fcb95820a5 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -183,8 +183,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e8..b243878094 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index dc0266693e..d8fc2afbcd 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -852,7 +852,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2091,7 +2092,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2184,15 +2186,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2204,15 +2206,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2236,13 +2238,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2403,8 +2405,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2511,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2554,7 +2557,8 @@ 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 %llu",
+ (unsigned long long) 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 53f3e7fd1a..e225cfce26 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5449,22 +5449,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 26be94b3f1..909e4e4d42 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -525,8 +525,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -815,18 +815,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2519,15 +2522,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2664,16 +2667,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2708,9 +2711,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 788769dd73..6d95c2f612 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1616,8 +1616,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 6887dc23f6..2268a9af2a 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2449,8 +2449,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2888,7 +2888,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3530,8 +3531,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3807,8 +3808,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4450,9 +4451,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5081,8 +5082,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 83fca8a77d..4e03f27ac8 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 9181d3e863..26f68d95cf 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3296,14 +3298,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3465,7 +3469,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3981,33 +3985,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3c9411e221..9c8a58a776 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 75400a53f2..4ffa355d24 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2252,10 +2252,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index cb39fdde33..66976445f1 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1102,9 +1102,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1188,8 +1188,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1273,9 +1273,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3996,7 +3996,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4012,7 +4013,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4389,8 +4391,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4900,7 +4902,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4960,7 +4963,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5148,7 +5152,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 2850867323..c90bb063bc 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index bea5d810e0..f0e4ac8898 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 023a004ac8..359cde8772 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 72778b896a..12e05a3b18 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2754,12 +2754,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2767,9 +2769,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index f336c063e5..f0ce2b26f5 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index a0be0c411a..1bf1abf42c 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 969e2a7a46..0de9d8906d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3057,9 +3057,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15498,9 +15499,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15512,10 +15514,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f647..3e5db964ab 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 4f265ef546..ccf59ed728 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
Hi hackers,
here is the rebased v32 version of the patch.
The patchset rotted a bit. Here is a rebased version.
--
Best regards,
Aleksander Alekseev
Attachments:
v33-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v33-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 27dcbdbd4049df9ee77c1cf857187bfc545ab427 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v33 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 20950eb1e4..76dfd2b13b 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..69ff2d111b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2857,7 +2857,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2865,7 +2865,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3116,7 +3116,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3136,7 +3136,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 7240454ca4..de09068395 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -72,7 +72,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -377,7 +377,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 25e7e4e37b..bea5d810e0 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 9737e1eb67..35fc1dff1a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileNode rnode;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.35.1
v33-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v33-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 3803771295ce219f294a077c9f7c9e34dc3e4713 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v33 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20a3733e7d..4a87a8fa42 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index fbda52c2f0..33ef9f2f45 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 1e89c97d6f..27f949a38d 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index a55b69dedf..cd980053ab 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index c73e9df63f..db876c2777 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8c..2b1b1a3435 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.35.1
v33-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v33-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 3cb1e4f7c77922343d385828330038eaf6ace324 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v33 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e5f7355dcb..20a3733e7d 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62f2c1b315..fbda52c2f0 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 08d366a594..2cfac27807 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -314,7 +314,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -390,7 +390,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -412,7 +412,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -436,7 +436,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -785,7 +785,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -803,7 +805,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -837,7 +841,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -857,8 +863,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -888,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -922,7 +932,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -975,7 +986,8 @@ 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 %llu",
+ (unsigned long long) 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 7421851027..863b0e560c 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5162,7 +5162,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6145,8 +6146,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6159,8 +6161,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6178,8 +6181,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6190,7 +6194,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6281,8 +6286,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6331,8 +6337,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6496,8 +6503,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6505,8 +6513,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6633,8 +6642,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6648,8 +6658,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6670,8 +6680,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 444f027149..dbb93b1aa9 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 9482f99e68..ca2d0b6294 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -705,21 +705,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (vacrel->do_index_vacuuming)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index d0c8e247c1..1e89c97d6f 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 6238085d65..f3fb61971f 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index dfbbf4ebaf..a55b69dedf 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index d3f625d072..9cfdd65d83 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 c0dfea40c7..c73e9df63f 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 76dfd2b13b..7bfff478ea 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 69ff2d111b..2b36029b10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2144,8 +2154,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2179,8 +2190,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2365,7 +2376,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2614,12 +2626,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2643,8 +2655,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3027,8 +3040,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3045,16 +3058,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3308,9 +3321,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3359,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3395,7 +3409,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 de09068395..fcb95820a5 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -183,8 +183,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index dbc5f884e8..b243878094 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index dc0266693e..d8fc2afbcd 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -852,7 +852,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2091,7 +2092,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2184,15 +2186,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2204,15 +2206,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2236,13 +2238,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2403,8 +2405,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2511,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2554,7 +2557,8 @@ 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 %llu",
+ (unsigned long long) 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 53f3e7fd1a..e225cfce26 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5449,22 +5449,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 39ef865ed9..5dba6775aa 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -525,8 +525,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -815,18 +815,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2518,15 +2521,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2663,16 +2666,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2707,9 +2710,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 788769dd73..6d95c2f612 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1616,8 +1616,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 6887dc23f6..2268a9af2a 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2449,8 +2449,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2888,7 +2888,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3530,8 +3531,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3807,8 +3808,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4450,9 +4451,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5081,8 +5082,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 1119a12db9..115e066de6 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 4171371296..a8811d3fa2 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1088,7 +1088,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1479,7 +1480,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3295,14 +3297,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3464,7 +3468,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -3980,33 +3984,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3c9411e221..9c8a58a776 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 63a818140b..404c0e783e 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 25c310f675..611054c7a6 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1101,9 +1101,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1187,8 +1187,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1272,9 +1272,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -4005,7 +4005,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4021,7 +4022,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4398,8 +4400,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4909,7 +4911,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4969,7 +4972,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5157,7 +5161,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 2850867323..c90bb063bc 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -995,14 +995,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1306,20 +1306,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index bea5d810e0..f0e4ac8898 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 023a004ac8..359cde8772 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 55ee5423af..b6c6edc206 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2752,12 +2752,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2765,9 +2767,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 5bc2a15160..8e03a9f0f4 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 786d592e2b..032fe5e796 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3115,9 +3115,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15556,9 +15557,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15570,10 +15572,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index ecb3e1f647..3e5db964ab 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -538,16 +538,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -555,10 +557,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -581,11 +583,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -609,10 +611,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -671,14 +673,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -712,24 +714,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 4f265ef546..ccf59ed728 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.35.1
here is the rebased v32 version of the patch.
The patchset rotted a bit. Here is a rebased version.
We have posted an updated version v34 of the whole patchset in [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com.
Changes of patches 0001-0003 there are identical to v33. So, no update is
needed in this thread.
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Maxim Orlov.
Hi hackers,
Here is the rebased patchset.
--
Best regards,
Aleksander Alekseev
Attachments:
v34-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v34-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 31fa24c3b4956f1468dd3f15f37de18a282ac468 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v34 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 8f649eea41..3bea8052d2 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 6de9e19964..e7c357c8fd 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8c..2b1b1a3435 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.36.1
v34-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v34-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From f184e982de689267230de9e6077a6218ac696f9c Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v34 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
8 files changed, 92 insertions(+), 82 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 4dc8d402bd..408e67aa2e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..69ff2d111b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2857,7 +2857,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2865,7 +2865,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3116,7 +3116,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3136,7 +3136,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 5136da6ea3..90128bfa6c 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
--
2.36.1
v34-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v34-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 953c812e1c8d5e41e47eb710a541fff4ccf842b4 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v34 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
47 files changed, 566 insertions(+), 460 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e488f5e234..8f649eea41 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 3736da6784..d5715f6330 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -314,7 +314,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -390,7 +390,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -412,7 +412,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -436,7 +436,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -785,7 +785,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -803,7 +805,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -837,7 +841,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -857,8 +863,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -888,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -922,7 +932,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -975,7 +986,8 @@ 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 %llu",
+ (unsigned long long) 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 aab8d6fa4e..36b2ba7100 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5162,7 +5162,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6145,8 +6146,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6159,8 +6161,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6178,8 +6181,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6190,7 +6194,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6281,8 +6286,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6331,8 +6337,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6496,8 +6503,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6505,8 +6513,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6633,8 +6642,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6648,8 +6658,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6670,8 +6680,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index b802ed247e..1171616ba6 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -705,21 +705,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (vacrel->do_index_vacuuming)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 6fec4853f1..6de9e19964 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 408e67aa2e..0bc15b5f6c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 69ff2d111b..2b36029b10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2144,8 +2154,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2179,8 +2190,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2365,7 +2376,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2614,12 +2626,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2643,8 +2655,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3027,8 +3040,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3045,16 +3058,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3308,9 +3321,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3359,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3395,7 +3409,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 41b31c5c6f..5deb27bb83 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -852,7 +852,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2091,7 +2092,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2184,15 +2186,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2204,15 +2206,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2236,13 +2238,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2403,8 +2405,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2511,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2554,7 +2557,8 @@ 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 %llu",
+ (unsigned long long) 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 116de1175b..843f3462f8 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5449,22 +5449,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 5d6f1b5e46..5bf6618702 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -525,8 +525,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -815,18 +815,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2519,15 +2522,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2664,16 +2667,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2708,9 +2711,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 88a37fde72..491eba1d17 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2448,8 +2448,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2887,7 +2887,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3529,8 +3530,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3806,8 +3807,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4449,9 +4450,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5080,8 +5081,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 73c0f15214..b901ea861f 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..247ed6c74a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1088,7 +1088,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1479,7 +1480,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3318,14 +3320,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3487,7 +3491,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4003,33 +4007,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3d37c1fe62..c5f4d6956e 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 3c407ab964..ec3f784f4a 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index dadaa958a8..1c9cb21043 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1106,9 +1106,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1192,8 +1192,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1277,9 +1277,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3987,7 +3987,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4003,7 +4004,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4380,8 +4382,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4891,7 +4893,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4951,7 +4954,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5139,7 +5143,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 90128bfa6c..539dffc311 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 dedee7af5c..5b54863c81 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 59124bd9cc..f076c1ec68 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2751,12 +2751,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2764,9 +2766,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 5bc2a15160..8e03a9f0f4 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f317f0a681..d16e29a3cc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3115,9 +3115,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15552,9 +15553,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15566,10 +15568,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 265d829490..d2b519132f 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -576,16 +576,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -593,10 +595,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -619,11 +621,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -647,10 +649,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -709,14 +711,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -750,24 +752,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 6528113628..649ac0f485 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.36.1
Here is the rebased patchset.
Hi!
While working on v40 of 64-bit XID patch [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com, we've noticed a couple of
forgotten things in v34 in this thread.
So, update the patchset to v40 from the thread [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com.
It seems convenient to use common numbering of versions in this thread and
the thread [1]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com.
So, please, don't be surprised to see v40 here just after v34.
[1]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com
--
Best regards,
Maxim Orlov.
Attachments:
v40-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v40-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 9b9f2cb539554fa81912f5d8e1260a4a261a19ae Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v40 1/8] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 4dc8d402bd..408e67aa2e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..69ff2d111b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2857,7 +2857,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2865,7 +2865,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3116,7 +3116,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3136,7 +3136,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 5136da6ea3..90128bfa6c 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.17.2 (Apple Git-113)
v40-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v40-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 1709a5e4535810257377372227127764eb59475a Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v40 3/8] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 8f649eea41..3bea8052d2 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 6de9e19964..e7c357c8fd 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 41b8f69b8c..2b1b1a3435 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -263,13 +264,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem\n", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -284,11 +294,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem\n", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.17.2 (Apple Git-113)
v40-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v40-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 77badc6a7d9ac60af838561f59da1a4c9aafe1b8 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v40 2/8] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e488f5e234..8f649eea41 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 3736da6784..d5715f6330 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -314,7 +314,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -390,7 +390,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -412,7 +412,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -436,7 +436,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -785,7 +785,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -803,7 +805,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -837,7 +841,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -857,8 +863,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -888,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -922,7 +932,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -975,7 +986,8 @@ 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 %llu",
+ (unsigned long long) 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 aab8d6fa4e..36b2ba7100 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5162,7 +5162,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6145,8 +6146,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6159,8 +6161,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6178,8 +6181,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6190,7 +6194,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6281,8 +6286,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6331,8 +6337,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6496,8 +6503,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6505,8 +6513,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6633,8 +6642,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6648,8 +6658,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6670,8 +6680,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index b802ed247e..1171616ba6 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -705,21 +705,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (vacrel->do_index_vacuuming)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 6fec4853f1..6de9e19964 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 408e67aa2e..0bc15b5f6c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 69ff2d111b..2b36029b10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2144,8 +2154,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2179,8 +2190,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2365,7 +2376,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2614,12 +2626,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2643,8 +2655,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3027,8 +3040,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3045,16 +3058,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3308,9 +3321,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3359,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3395,7 +3409,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 41b31c5c6f..5deb27bb83 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -852,7 +852,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2091,7 +2092,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2184,15 +2186,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2204,15 +2206,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2236,13 +2238,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2403,8 +2405,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2511,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2554,7 +2557,8 @@ 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 %llu",
+ (unsigned long long) 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 116de1175b..843f3462f8 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5449,22 +5449,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 5d6f1b5e46..5bf6618702 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -525,8 +525,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -815,18 +815,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2519,15 +2522,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2664,16 +2667,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2708,9 +2711,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 77a7a868ca..11e9cfe773 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -242,7 +242,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 88a37fde72..491eba1d17 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2448,8 +2448,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2887,7 +2887,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3529,8 +3530,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3806,8 +3807,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4449,9 +4450,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5080,8 +5081,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 73c0f15214..b901ea861f 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..247ed6c74a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1088,7 +1088,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1479,7 +1480,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3318,14 +3320,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3487,7 +3491,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4003,33 +4007,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3d37c1fe62..c5f4d6956e 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 3c407ab964..ec3f784f4a 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index dadaa958a8..1c9cb21043 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1106,9 +1106,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1192,8 +1192,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1277,9 +1277,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3987,7 +3987,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4003,7 +4004,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4380,8 +4382,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4891,7 +4893,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4951,7 +4954,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5139,7 +5143,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 90128bfa6c..539dffc311 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 dedee7af5c..5b54863c81 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 59124bd9cc..f076c1ec68 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2751,12 +2751,14 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2764,9 +2766,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 5bc2a15160..8e03a9f0f4 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f317f0a681..d16e29a3cc 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3115,9 +3115,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15552,9 +15553,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15566,10 +15568,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 265d829490..d2b519132f 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -576,16 +576,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -593,10 +595,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -619,11 +621,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -647,10 +649,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -709,14 +711,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -750,24 +752,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 6528113628..649ac0f485 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.17.2 (Apple Git-113)
Hi Maxim,
It seems convenient to use common numbering of versions in this thread and the thread [1].
Agree!
Here is the rebased patchset v41.
--
Best regards,
Aleksander Alekseev
Attachments:
v41-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v41-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 931601abf76b3e8e5feeaf30e8fe3ea3acbf6aad Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v41 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 8f649eea41..3bea8052d2 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +781,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -853,24 +847,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1016,24 +1007,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1078,24 +1066,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 6de9e19964..e7c357c8fd 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 07de918358..c5f010a40f 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -267,13 +268,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -288,11 +298,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.36.1
v41-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v41-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 2546e76e5a5cd76275b31e38febb42b8fc6ee331 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v41 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 4dc8d402bd..408e67aa2e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -111,7 +111,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -939,7 +939,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..69ff2d111b 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2857,7 +2857,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2865,7 +2865,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3116,7 +3116,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3136,7 +3136,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 5136da6ea3..90128bfa6c 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -438,7 +438,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.36.1
v41-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v41-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 0f27aa6fd0aeecd6fd0bcc8655a692d5f926465a Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v41 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index e488f5e234..8f649eea41 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -743,24 +743,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -784,24 +784,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -811,13 +811,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -853,24 +853,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -880,13 +880,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -956,19 +956,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1016,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1078,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 3736da6784..d5715f6330 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -314,7 +314,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -337,7 +337,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -390,7 +390,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -412,7 +412,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -436,7 +436,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -785,7 +785,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -803,7 +805,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -837,7 +841,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -857,8 +863,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -888,7 +896,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -922,7 +932,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -975,7 +986,8 @@ 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 %llu",
+ (unsigned long long) 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 aab8d6fa4e..36b2ba7100 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5162,7 +5162,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6145,8 +6146,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6159,8 +6161,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6178,8 +6181,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6190,7 +6194,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6281,8 +6286,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6331,8 +6337,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6496,8 +6503,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6505,8 +6513,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6633,8 +6642,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6648,8 +6658,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6670,8 +6680,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index b802ed247e..1171616ba6 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -705,21 +705,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
if (vacrel->do_index_vacuuming)
{
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 6fec4853f1..6de9e19964 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 408e67aa2e..0bc15b5f6c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -279,7 +279,8 @@ 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 %llu",
+ (unsigned long long) 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 69ff2d111b..2b36029b10 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2144,8 +2154,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2179,8 +2190,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2365,7 +2376,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2614,12 +2626,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2643,8 +2655,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3027,8 +3040,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3045,16 +3058,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3308,9 +3321,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3359,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3395,7 +3409,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 41b31c5c6f..5deb27bb83 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -852,7 +852,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2091,7 +2092,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2184,15 +2186,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2204,15 +2206,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2236,13 +2238,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2403,8 +2405,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2511,7 +2513,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2554,7 +2557,8 @@ 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 %llu",
+ (unsigned long long) 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 116de1175b..843f3462f8 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5449,22 +5449,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 5d6f1b5e46..5bf6618702 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -525,8 +525,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -815,18 +815,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2519,15 +2522,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2664,16 +2667,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2708,9 +2711,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 9e43fec86d..3721d00d59 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -228,7 +228,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 88a37fde72..491eba1d17 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2448,8 +2448,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2887,7 +2887,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3529,8 +3530,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3806,8 +3807,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4449,9 +4450,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5080,8 +5081,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 73c0f15214..b901ea861f 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -847,8 +847,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -922,9 +922,9 @@ 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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -988,8 +988,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1014,8 +1014,8 @@ 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",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1027,7 +1027,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1149,8 +1150,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1239,8 +1243,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1322,8 +1327,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1346,8 +1352,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 38e3b1c1b3..247ed6c74a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1088,7 +1088,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1479,7 +1480,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3318,14 +3320,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3487,7 +3491,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4003,33 +4007,33 @@ 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 %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) 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 %llu finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3d37c1fe62..c5f4d6956e 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 3c407ab964..ec3f784f4a 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index dadaa958a8..1c9cb21043 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1106,9 +1106,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1192,8 +1192,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1277,9 +1277,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3987,7 +3987,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4003,7 +4004,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4380,8 +4382,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4891,7 +4893,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4951,7 +4954,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5139,7 +5143,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 90128bfa6c..539dffc311 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4168,7 +4168,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4176,7 +4177,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4806,7 +4808,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 dedee7af5c..5b54863c81 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 95f32de4e2..423f1efd43 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2760,12 +2760,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2773,9 +2775,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 5bc2a15160..8e03a9f0f4 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1202,14 +1202,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1226,9 +1227,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1242,9 +1244,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index e4fdb6b75b..cf72858386 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3115,9 +3115,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15559,9 +15560,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15573,10 +15575,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 6528113628..649ac0f485 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.36.1
On Fri, May 13, 2022 at 04:21:29PM +0300, Maxim Orlov wrote:
We have posted an updated version v34 of the whole patchset in [1].
Changes of patches 0001-0003 there are identical to v33. So, no update is
needed in this thread.
Is there any reason to continue with two separate threads and CF entries ?
The original reason was to have a smaller patch for considerate late in v15.
But right now, it just seems to cause every update to imply two email messages
rather than one.
Since the patch is split into 0001, 0002, 0003, 0004+, both can continue in the
main thread. The early patches can still be applied independently from each
later patch (the same as with any other patch series).
Also, since this patch series is large, and expects a lot of conflicts, it
seems better to update the cfapp with a "git link" [0]Note that cirrusci will run the same checks as cfbot if you push a branch to github. where you can maintain a
rebased branch. It avoids the need to mail new patches to the list several
times more often than it's being reviewed.
[0]: Note that cirrusci will run the same checks as cfbot if you push a branch to github.
to github.
Is there any reason to continue with two separate threads and CF entries ?
The original reason was to have a smaller patch for considerate late in
v15.But right now, it just seems to cause every update to imply two email
messages
rather than one.Since the patch is split into 0001, 0002, 0003, 0004+, both can continue
in the
main thread. The early patches can still be applied independently from
each
later patch (the same as with any other patch series).
I see the main goal of this split is to make discussion of this (easier)
thread separate to the discussion of a whole patchset which is expected to
be more thorough.
Also I see the chances of this thread to be committed into v16 to be much
higher than of a main patch, which will be for v17 then.
Thanks for the advice to add git thread instead of patch posting. Will try
to do this.
--
Best regards,
Pavel Borisov
Pavel, Justin,
Is there any reason to continue with two separate threads and CF entries ?
The original reason was to have a smaller patch for considerate late in v15.
I see the main goal of this split is to make discussion of this (easier) thread separate to the discussion of a whole patchset which is expected to be more thorough.
+1. This was done per explicit request in the first thread.
But right now, it just seems to cause every update to imply two email messages
rather than one.Also, since this patch series is large, and expects a lot of conflicts, it
seems better to update the cfapp with a "git link" [0] where you can maintain a
rebased branch. It avoids the need to mail new patches to the list several
times more often than it's being reviewed.
Yep, this is a bit inconvenient. Personally I didn't expect that
merging patches in this thread would take that long. They are in
"Ready for Committer" state for a long time now and there are no known
issues with them other than unit tests for SLRU [1]https://commitfest.postgresql.org/38/3608/ should be merged
first.
I suggest we use "git link" for the larger patchset in the other
thread since I'm not contributing to it right now and all in all that
thread is waiting for this one. For this thread we continue using
patches since several people contribute to them.
[1]: https://commitfest.postgresql.org/38/3608/
--
Best regards,
Aleksander Alekseev
On Fri, 15 Jul 2022 at 12:29, Aleksander Alekseev
<aleksander@timescale.com> wrote:
Personally I didn't expect that
merging patches in this thread would take that long. They are in
"Ready for Committer" state for a long time now and there are no known
issues with them other than unit tests for SLRU [1] should be merged
first.
These patches look ready to me, including the SLRU tests.
Even though they do very little, these patches touch many aspects of
the code, so it would make sense to apply these as the last step in
the CF.
To encourage committers to take that next step, let's have a
democratic vote on moving this forwards:
+1 from me.
--
Simon Riggs http://www.EnterpriseDB.com/
On Tue, 26 Jul 2022 at 21:35, Simon Riggs <simon.riggs@enterprisedb.com>
wrote:
On Fri, 15 Jul 2022 at 12:29, Aleksander Alekseev
<aleksander@timescale.com> wrote:Personally I didn't expect that
merging patches in this thread would take that long. They are in
"Ready for Committer" state for a long time now and there are no known
issues with them other than unit tests for SLRU [1] should be merged
first.These patches look ready to me, including the SLRU tests.
Even though they do very little, these patches touch many aspects of
the code, so it would make sense to apply these as the last step in
the CF.To encourage committers to take that next step, let's have a
democratic vote on moving this forwards:
+1 from me.
This set of patches no longer applies cleanly to the master branch. There
are lots of
hunks as well as failures. Please rebase the patches.
There are failures for multiple files including the one given below:
patching file src/backend/replication/logical/worker.c
Hunk #1 succeeded at 1089 (offset 1 line).
Hunk #2 succeeded at 1481 (offset 1 line).
Hunk #3 succeeded at 3322 (offset 2 lines).
Hunk #4 succeeded at 3493 (offset 2 lines).
Hunk #5 FAILED at 4009.
1 out of 5 hunks FAILED -- saving rejects to file
src/backend/replication/logical/worker.c.rej
Hi Hamid,
There are failures for multiple files including the one given below:
Thanks for letting us know. There was a little conflict in
src/backend/replication/logical/worker.c since the message format has
changed. Nothing particularly awful.
Here is the rebased patchset.
These patches look ready to me, including the SLRU tests.
To encourage committers to take that next step, let's have a
democratic vote on moving this forwards: +1 from me.
Thanks, Simon. Not 100% sure who exactly is invited to vote, but just
in case here is +1 from me. These patches were "Ready for Committer"
for several months now and are unlikely to get any better. So I
suggest we merge them.
--
Best regards,
Aleksander Alekseev
Attachments:
v42-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v42-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 05e6b406010b1fc8735fccce95a1f965f1f02da2 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v42 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..e03c167a27 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index a7383f553b..67e07e118a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2856,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2864,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3135,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index c9a7b97949..2bc1281ea5 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.37.2
v42-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v42-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 428f8d27cb5daec0c15a3a8c21007e664e609858 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v42 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index d33f33f170..f0ab5fabec 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 75b214824d..fe24219bea 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5170,7 +5170,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6153,8 +6154,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6167,8 +6169,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6186,8 +6189,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6198,7 +6202,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6289,8 +6294,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6339,8 +6345,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6504,8 +6511,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6513,8 +6521,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6641,8 +6650,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6656,8 +6666,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6678,8 +6688,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index dfbe37472f..864876adf7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 67e07e118a..ef4bd47eed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1628,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1670,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2143,8 +2153,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2178,8 +2189,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2364,7 +2375,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2613,12 +2625,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2642,8 +2654,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3026,8 +3039,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3044,16 +3057,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3307,9 +3320,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3358,7 +3372,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3394,7 +3408,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 2bc1281ea5..cab1a47681 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 2bb975943c..e15afec4d4 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5461,22 +5461,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index b41e682664..0339169a99 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 64c65f060b..27e5cdee6f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 03d9c9c86a..ff60d9c97d 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2461,8 +2461,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2900,7 +2900,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3592,8 +3593,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3869,8 +3870,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4512,9 +4513,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5143,8 +5144,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 54499c06fe..d518746ddd 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1103,7 +1103,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1248,8 +1249,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1338,8 +1342,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1421,8 +1426,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1445,8 +1451,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 207a5805ba..e62de43e09 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3320,14 +3322,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3489,7 +3493,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4006,33 +4010,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index f6ef0ace2c..98d8938728 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e9ba500a15..66cbec488c 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 207c4b27fd..67c159a492 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index eb724a9d7f..f4a445e5e3 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2931,12 +2931,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2944,9 +2946,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f1f2ddac17..f76bab65cb 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f8c4cb8d18..60fead02ed 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3115,9 +3115,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15626,9 +15627,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15640,10 +15642,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 d4772a2965..626f1608bc 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.37.2
v42-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v42-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From d0019a412ca7bb8a096f0b8e472393e388c63310 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v42 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index f0ab5fabec..c9e71e4e50 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 018cd310f7..a5b4a77570 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -265,13 +266,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -286,11 +296,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.37.2
Hi hackers,
Thanks, Simon. Not 100% sure who exactly is invited to vote, but just
in case here is +1 from me. These patches were "Ready for Committer"
for several months now and are unlikely to get any better. So I
suggest we merge them.
Here is the rebased patchset.
--
Best regards,
Aleksander Alekseev
Attachments:
v43-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v43-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 9c443e783a70285fdb0cfba0904946bed43d0d34 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v43 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index f0ab5fabec..c9e71e4e50 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 018cd310f7..a5b4a77570 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -265,13 +266,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -286,11 +296,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.37.3
v43-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v43-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From eb0316a1ec83ab9982972ccdbaf4f99e0717c24c Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v43 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index a7dfcfb4da..3d06f7c82a 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index a7383f553b..67e07e118a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2856,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2864,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3135,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.37.3
v43-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v43-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 475a94b27b5b4cd064d4f3866ed075261437fd63 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v43 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index d33f33f170..f0ab5fabec 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 bd4d85041d..685200d154 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5170,7 +5170,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6153,8 +6154,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6167,8 +6169,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6186,8 +6189,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6198,7 +6202,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6289,8 +6294,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6339,8 +6345,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6504,8 +6511,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6513,8 +6521,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6641,8 +6650,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6656,8 +6666,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6678,8 +6688,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index dfbe37472f..864876adf7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 67e07e118a..ef4bd47eed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1628,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1670,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2143,8 +2153,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2178,8 +2189,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2364,7 +2375,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2613,12 +2625,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2642,8 +2654,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3026,8 +3039,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3044,16 +3057,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3307,9 +3320,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3358,7 +3372,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3394,7 +3408,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 c1ffbd89b8..a5116d10b1 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5471,22 +5471,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 64c65f060b..27e5cdee6f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 6dff9915a5..9b20e158eb 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2461,8 +2461,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2900,7 +2900,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3592,8 +3593,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3869,8 +3870,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4512,9 +4513,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5143,8 +5144,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 54499c06fe..d518746ddd 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1103,7 +1103,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1248,8 +1249,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1338,8 +1342,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1421,8 +1426,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1445,8 +1451,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 207a5805ba..e62de43e09 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3320,14 +3322,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3489,7 +3493,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4006,33 +4010,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 6cbb67c92a..927fd2dbe5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e9ba500a15..66cbec488c 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 207c4b27fd..67c159a492 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index eb724a9d7f..f4a445e5e3 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2931,12 +2931,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2944,9 +2946,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f1f2ddac17..f76bab65cb 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index bd9b066e4e..dcb3b11d57 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.37.3
Hi!
Here is a rebased version of the patch set.
Major changes are:
1. Fix rare replica fault.
Upon page pruning in heap_page_prune, page fragmentation repair is
determined
by
a parameter repairFragmentation. At the same time, on a replica, upon
handling XLOG_HEAP2_PRUNE record type
in heap_xlog_prune, we always call heap_page_prune_execute with
repairFragmentation
parameter equal to true.
This caused page inconsistency and lead to the crash of the replica. Fix
this by adding new flag in
struct xl_heap_prune.
2. Add support for meson build.
3. Add assertion "buffer is locked" in HeapTupleCopyBaseFromPage.
4. Add assertion "buffer is locked exclusive" in heap_page_shift_base.
5. Prevent excessive growth of xmax in heap_prepare_freeze_tuple.
As always, reviews are very welcome!
--
Best regards,
Maxim Orlov.
Attachments:
v47-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v47-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 15b91ae9e1f039936df3bc761cc8c32c982157f0 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v47 1/8] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index a7dfcfb4da..3d06f7c82a 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index a7383f553b..67e07e118a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2856,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2864,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3135,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..faf561f225 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:;
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.37.0 (Apple Git-136)
v47-0004-Use-64-bit-pages-representation-in-SLRU-callers.patchapplication/octet-stream; name=v47-0004-Use-64-bit-pages-representation-in-SLRU-callers.patchDownload
From 254a38334003a9978cf46bb4e2b8634f1d1c26f1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Wed, 23 Mar 2022 13:16:26 +0300
Subject: [PATCH v47 4/8] Use 64-bit pages representation in SLRU callers.
Previously SLRU page counters were changed to unsigned 64-bit. As a next
separate step to making XID's 64-bit, we switch internal page counters to 64-bit
in SLRU callers: clog, mxact, commit_ts etc. This patch still doesn't change
xid's representation but is a requirement to do so.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 11 ++---
src/backend/access/rmgrdesc/committsdesc.c | 11 ++---
src/backend/access/rmgrdesc/mxactdesc.c | 6 +--
src/backend/access/transam/clog.c | 47 ++++++++++-----------
src/backend/access/transam/commit_ts.c | 33 +++++++--------
src/backend/access/transam/multixact.c | 44 +++++++++----------
src/backend/access/transam/slru.c | 8 +---
src/backend/access/transam/subtrans.c | 16 +++----
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/storage/proc.h | 2 +-
11 files changed, 89 insertions(+), 93 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index bbb5910633..3555daa04b 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,19 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %llu",
- xlrec.pageno, (unsigned long long) xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %llu",
+ (long long) xlrec.pageno,
+ (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 4b2e9bc2ff..c3db0f5e47 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,18 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %llu",
- trunc->pageno, (unsigned long long) trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %llu",
+ (long long) trunc->pageno,
+ (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 4cf8a9a4b1..950f9269f7 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d06f7c82a..1f621aba70 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -89,24 +89,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
static bool CLOGPagePrecedes(int64 page1, int64 page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -164,7 +164,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -238,7 +238,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -247,7 +247,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -273,7 +273,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -339,7 +339,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -413,7 +413,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -639,7 +639,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -736,7 +736,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -756,7 +756,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -775,7 +775,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -840,7 +840,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -879,7 +879,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -946,15 +946,14 @@ CLOGPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + CLOG_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -965,7 +964,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -993,10 +992,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index d978226bfb..b91097ce0e 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -103,16 +103,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +170,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +214,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +266,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -588,7 +588,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -681,7 +681,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -814,7 +814,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -852,7 +852,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -951,15 +951,14 @@ CommitTsPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + COMMIT_TS_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -967,7 +966,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -992,10 +991,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index ef4bd47eed..f553707291 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -353,8 +353,8 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
@@ -365,7 +365,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -866,8 +866,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1228,8 +1228,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1937,7 +1937,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1953,7 +1953,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1983,7 +1983,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2018,7 +2018,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2043,7 +2043,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2414,7 +2414,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2463,7 +2463,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2746,7 +2746,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -3206,10 +3206,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3254,10 +3254,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3269,10 +3269,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3314,7 +3314,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index ea66084410..9e765c6c28 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -63,11 +63,7 @@
static int inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
- /*
- * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
- */
- Assert(segno <= PG_INT32_MAX);
- return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
}
/*
@@ -1583,7 +1579,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
segno = (int) strtol(clde->d_name, NULL, 16);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 9b057a6b04..e2e20ed06c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -63,7 +63,7 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
+static int ZeroSUBTRANSPage(int64 pageno);
static bool SubTransPagePrecedes(int64 page1, int64 page2);
@@ -73,7 +73,7 @@ static bool SubTransPagePrecedes(int64 page1, int64 page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +108,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -234,7 +234,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -250,8 +250,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -308,7 +308,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -338,7 +338,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 3dba7d8a69..f1ceb4a4bd 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 7662f8e1a9..d2cfb02e14 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 91824b4691..fdc18f8180 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -277,7 +277,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
--
2.37.0 (Apple Git-136)
v47-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v47-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 4fb07df3d64bfef26551157604a3e90ffe92689d Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v47 2/8] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index d33f33f170..f0ab5fabec 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 bd4d85041d..685200d154 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5170,7 +5170,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6153,8 +6154,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6167,8 +6169,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6186,8 +6189,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6198,7 +6202,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6289,8 +6294,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6339,8 +6345,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6504,8 +6511,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6513,8 +6521,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6641,8 +6650,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6656,8 +6666,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6678,8 +6688,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index dfbe37472f..864876adf7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 67e07e118a..ef4bd47eed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1628,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1670,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2143,8 +2153,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2178,8 +2189,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2364,7 +2375,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2613,12 +2625,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2642,8 +2654,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3026,8 +3039,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3044,16 +3057,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3307,9 +3320,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3358,7 +3372,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3394,7 +3408,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 faf561f225..ea66084410 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 c1ffbd89b8..a5116d10b1 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5471,22 +5471,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 64c65f060b..27e5cdee6f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 6dff9915a5..9b20e158eb 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2461,8 +2461,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2900,7 +2900,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3592,8 +3593,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3869,8 +3870,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4512,9 +4513,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5143,8 +5144,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 54499c06fe..d518746ddd 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1103,7 +1103,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1248,8 +1249,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1338,8 +1342,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1421,8 +1426,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1445,8 +1451,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 207a5805ba..e62de43e09 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3320,14 +3322,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3489,7 +3493,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4006,33 +4010,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 6cbb67c92a..927fd2dbe5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e9ba500a15..66cbec488c 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 207c4b27fd..67c159a492 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 9dab931990..99341c3e87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -994,14 +994,14 @@ StandbyReleaseLockList(List *locks)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- lock->xid, lock->dbOid, lock->relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) 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",
- lock->xid, lock->dbOid, lock->relOid);
+ "RecoveryLockLists contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) lock->xid, lock->dbOid, lock->relOid);
Assert(false);
}
}
@@ -1305,20 +1305,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index eb724a9d7f..f4a445e5e3 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2931,12 +2931,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2944,9 +2946,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f1f2ddac17..f76bab65cb 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index bd9b066e4e..dcb3b11d57 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.37.0 (Apple Git-136)
v47-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v47-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 55c482b8f94a9967a81c07e097681229b9dc9aef Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v47 3/8] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index f0ab5fabec..c9e71e4e50 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 018cd310f7..a5b4a77570 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -265,13 +266,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -286,11 +296,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.37.0 (Apple Git-136)
v47-0005-Add-initdb-option-to-initialize-cluster-with-non.patchapplication/octet-stream; name=v47-0005-Add-initdb-option-to-initialize-cluster-with-non.patchDownload
From feb8e8d9d37e8017586fecd515dd7344b0b17d5e Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Wed, 4 May 2022 15:53:36 +0300
Subject: [PATCH v47 5/8] Add initdb option to initialize cluster with
non-standard xid/mxid/mxoff.
To date testing database cluster wraparund was not easy as initdb has always
inited it with default xid/mxid/mxoff. The option to specify any valid
xid/mxid/mxoff at cluster startup will make these things easier.
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CACG%3Dezaa4vqYjJ16yoxgrpa-%3DgXnf0Vv3Ey9bjGrRRFN2YyWFQ%40mail.gmail.com
---
src/backend/access/transam/clog.c | 9 +++
src/backend/access/transam/multixact.c | 35 ++++++++
src/backend/access/transam/xlog.c | 15 ++--
src/backend/bootstrap/bootstrap.c | 56 ++++++++++++-
src/backend/main/main.c | 6 ++
src/backend/postmaster/postmaster.c | 15 +++-
src/backend/tcop/postgres.c | 59 +++++++++++++-
src/bin/initdb/initdb.c | 107 ++++++++++++++++++++++++-
src/bin/initdb/t/001_initdb.pl | 86 ++++++++++++++++++++
src/include/access/xlog.h | 3 +
src/include/catalog/pg_class.h | 2 +-
11 files changed, 380 insertions(+), 13 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 1f621aba70..afbb5d6b11 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -713,6 +713,7 @@ void
BootStrapCLOG(void)
{
int slotno;
+ int pageno;
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -723,6 +724,14 @@ BootStrapCLOG(void)
SimpleLruWritePage(XactCtl, slotno);
Assert(!XactCtl->shared->page_dirty[slotno]);
+ pageno = TransactionIdToPage(XidFromFullTransactionId(ShmemVariableCache->nextXid));
+ if (pageno != 0)
+ {
+ slotno = ZeroCLOGPage(pageno, false);
+ SimpleLruWritePage(XactCtl, slotno);
+ Assert(!XactCtl->shared->page_dirty[slotno]);
+ }
+
LWLockRelease(XactSLRULock);
}
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index f553707291..35b90229a2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1903,6 +1903,7 @@ void
BootStrapMultiXact(void)
{
int slotno;
+ int pageno;
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -1913,6 +1914,17 @@ BootStrapMultiXact(void)
SimpleLruWritePage(MultiXactOffsetCtl, slotno);
Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+ pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
+ if (pageno != 0)
+ {
+ /* Create and zero the first page of the offsets log */
+ slotno = ZeroMultiXactOffsetPage(pageno, false);
+
+ /* Make sure it's written out */
+ SimpleLruWritePage(MultiXactOffsetCtl, slotno);
+ Assert(!MultiXactOffsetCtl->shared->page_dirty[slotno]);
+ }
+
LWLockRelease(MultiXactOffsetSLRULock);
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -1924,7 +1936,30 @@ BootStrapMultiXact(void)
SimpleLruWritePage(MultiXactMemberCtl, slotno);
Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+ pageno = MXOffsetToMemberPage(MultiXactState->nextOffset);
+ if (pageno != 0)
+ {
+ /* Create and zero the first page of the members log */
+ slotno = ZeroMultiXactMemberPage(pageno, false);
+
+ /* Make sure it's written out */
+ SimpleLruWritePage(MultiXactMemberCtl, slotno);
+ Assert(!MultiXactMemberCtl->shared->page_dirty[slotno]);
+ }
+
LWLockRelease(MultiXactMemberSLRULock);
+
+ /*
+ * If we're starting not from zero offset, initilize dummy multixact to
+ * evade too long loop in PerformMembersTruncation().
+ */
+ if (MultiXactState->nextOffset > 0 && MultiXactState->nextMXact > 0)
+ {
+ RecordNewMultiXact(FirstMultiXactId,
+ MultiXactState->nextOffset, 0, NULL);
+ RecordNewMultiXact(MultiXactState->nextMXact,
+ MultiXactState->nextOffset, 0, NULL);
+ }
}
/*
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 27085b15a8..3c74f1502a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -139,6 +139,10 @@ int max_slot_wal_keep_size_mb = -1;
int wal_decode_buffer_size = 512 * 1024;
bool track_wal_io_timing = false;
+TransactionId start_xid = FirstNormalTransactionId;
+MultiXactId start_mxid = FirstMultiXactId;
+MultiXactOffset start_mxoff = 0;
+
#ifdef WAL_DEBUG
bool XLOG_DEBUG = false;
#endif
@@ -4710,13 +4714,14 @@ BootStrapXLOG(void)
checkPoint.PrevTimeLineID = BootstrapTimeLineID;
checkPoint.fullPageWrites = fullPageWrites;
checkPoint.nextXid =
- FullTransactionIdFromEpochAndXid(0, FirstNormalTransactionId);
+ FullTransactionIdFromEpochAndXid(0, Max(FirstNormalTransactionId,
+ start_xid));
checkPoint.nextOid = FirstGenbkiObjectId;
- checkPoint.nextMulti = FirstMultiXactId;
- checkPoint.nextMultiOffset = 0;
- checkPoint.oldestXid = FirstNormalTransactionId;
+ checkPoint.nextMulti = Max(FirstMultiXactId, start_mxid);
+ checkPoint.nextMultiOffset = start_mxoff;
+ checkPoint.oldestXid = XidFromFullTransactionId(checkPoint.nextXid);
checkPoint.oldestXidDB = Template1DbOid;
- checkPoint.oldestMulti = FirstMultiXactId;
+ checkPoint.oldestMulti = checkPoint.nextMulti;
checkPoint.oldestMultiDB = Template1DbOid;
checkPoint.oldestCommitTsXid = InvalidTransactionId;
checkPoint.newestCommitTsXid = InvalidTransactionId;
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 22635f8094..a6edfcda32 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -221,7 +221,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
argv++;
argc--;
- while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:X:-:")) != -1)
+ while ((flag = getopt(argc, argv, "B:c:d:D:Fkm:o:r:X:x:-:")) != -1)
{
switch (flag)
{
@@ -250,6 +250,42 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
case 'k':
bootstrap_data_checksum_version = PG_DATA_CHECKSUM_VERSION;
break;
+ case 'm':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxid) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster multixact id")));
+ }
+ }
+ break;
+ case 'o':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxoff = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxoff) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster multixact offset")));
+ }
+ }
+ break;
case 'r':
strlcpy(OutputFileName, optarg, MAXPGPATH);
break;
@@ -265,6 +301,24 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
PGC_S_DYNAMIC_DEFAULT);
}
break;
+ case 'x':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_xid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_xid) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster xid value")));
+ }
+ }
+ break;
case 'c':
case '-':
{
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index f5da4260a1..dbd80a93ec 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -366,12 +366,18 @@ help(const char *progname)
printf(_(" -E echo statement before execution\n"));
printf(_(" -j do not use newline as interactive query delimiter\n"));
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
+ printf(_(" -m START_MXID set initial database cluster multixact id\n"));
+ printf(_(" -o START_MXOFF set initial database cluster multixact offset\n"));
+ printf(_(" -x START_XID set initial database cluster xid\n"));
printf(_("\nOptions for bootstrapping mode:\n"));
printf(_(" --boot selects bootstrapping mode (must be first argument)\n"));
printf(_(" --check selects check mode (must be first argument)\n"));
printf(_(" DBNAME database name (mandatory argument in bootstrapping mode)\n"));
printf(_(" -r FILENAME send stdout and stderr to given file\n"));
+ printf(_(" -m START_MXID set initial database cluster multixact id\n"));
+ printf(_(" -o START_MXOFF set initial database cluster multixact offset\n"));
+ printf(_(" -x START_XID set initial database cluster xid\n"));
printf(_("\nPlease read the documentation for the complete list of run-time\n"
"configuration settings and how to set them on the command line or in\n"
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 383bc4776e..d1ee6e3053 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -697,7 +697,8 @@ PostmasterMain(int argc, char *argv[])
* tcop/postgres.c (the option sets should not conflict) and with the
* common help() function in main/main.c.
*/
- while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:W:-:")) != -1)
+
+ while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lm:N:nOo:Pp:r:S:sTt:W:x:-:")) != -1)
{
switch (opt)
{
@@ -767,6 +768,10 @@ PostmasterMain(int argc, char *argv[])
SetConfigOption("max_connections", optarg, PGC_POSTMASTER, PGC_S_ARGV);
break;
+ case 'm':
+ /* only used by single-user backend */
+ break;
+
case 'n':
/* Don't reinit shared mem after abnormal exit */
Reinit = false;
@@ -776,6 +781,10 @@ PostmasterMain(int argc, char *argv[])
SetConfigOption("allow_system_table_mods", "true", PGC_POSTMASTER, PGC_S_ARGV);
break;
+ case 'o':
+ /* only used by single-user backend */
+ break;
+
case 'P':
SetConfigOption("ignore_system_indexes", "true", PGC_POSTMASTER, PGC_S_ARGV);
break;
@@ -827,6 +836,10 @@ PostmasterMain(int argc, char *argv[])
SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
break;
+ case 'x':
+ /* only used by single-user backend */
+ break;
+
case 'c':
case '-':
{
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 5352d5f4c6..662b5b50db 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3718,7 +3718,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
* postmaster/postmaster.c (the option sets should not conflict) and with
* the common help() function in main/main.c.
*/
- while ((flag = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
+ while ((flag = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lm:N:nOo:Pp:r:S:sTt:v:W:x:-:")) != -1)
{
switch (flag)
{
@@ -3784,6 +3784,25 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
SetConfigOption("ssl", "true", ctx, gucsource);
break;
+ case 'm':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxid) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster multixact id")));
+ }
+ }
+ break;
+
case 'N':
SetConfigOption("max_connections", optarg, ctx, gucsource);
break;
@@ -3796,6 +3815,25 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
SetConfigOption("allow_system_table_mods", "true", ctx, gucsource);
break;
+ case 'o':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxoff = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxoff) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster multixact offset")));
+ }
+ }
+ break;
+
case 'P':
SetConfigOption("ignore_system_indexes", "true", ctx, gucsource);
break;
@@ -3850,6 +3888,25 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
SetConfigOption("post_auth_delay", optarg, ctx, gucsource);
break;
+ case 'x':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_xid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_xid) /* overflow */
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("invalid initial database cluster xid")));
+ }
+ }
+ break;
+
case 'c':
case '-':
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index f61a043055..c56e1ac86c 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -78,7 +78,6 @@
#include "mb/pg_wchar.h"
#include "miscadmin.h"
-
/* Ideally this would be in a .h file, but it hardly seems worth the trouble */
extern const char *select_default_timezone(const char *share_path);
@@ -152,6 +151,9 @@ static bool data_checksums = false;
static char *xlog_dir = NULL;
static char *str_wal_segment_size_mb = NULL;
static int wal_segment_size_mb;
+static TransactionId start_xid = 0;
+static MultiXactId start_mxid = 0;
+static MultiXactOffset start_mxoff = 0;
/* internal vars */
@@ -1302,6 +1304,11 @@ bootstrap_template1(void)
bki_lines = replace_token(bki_lines, "POSTGRES",
escape_quotes_bki(username));
+ /* relfrozenxid must not be less than FirstNormalTransactionId */
+ sprintf(buf, "%u", Max(start_xid, 3));
+ bki_lines = replace_token(bki_lines, "RECENTXMIN",
+ buf);
+
bki_lines = replace_token(bki_lines, "ENCODING",
encodingid_to_string(encodingid));
@@ -1321,10 +1328,13 @@ bootstrap_template1(void)
unsetenv("PGCLIENTENCODING");
snprintf(cmd, sizeof(cmd),
- "\"%s\" --boot -X %d %s %s %s %s",
+ "\"%s\" --boot -X %d %s %s %u %s %u %s %u %s %s %s",
backend_exec,
wal_segment_size_mb * (1024 * 1024),
data_checksums ? "-k" : "",
+ "-m", start_mxid,
+ "-o", start_mxoff,
+ "-x", start_xid,
boot_options, extra_options,
debug ? "-d 5" : "");
@@ -2166,11 +2176,16 @@ usage(const char *progname)
printf(_(" -d, --debug generate lots of debugging output\n"));
printf(_(" --discard-caches set debug_discard_caches=1\n"));
printf(_(" -L DIRECTORY where to find the input files\n"));
+ printf(_(" -m, --multixact-id=START_MXID\n"
+ " set initial database cluster multixact id\n"));
printf(_(" -n, --no-clean do not clean up after errors\n"));
printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" --no-instructions do not print instructions for next steps\n"));
+ printf(_(" -o, --multixact-offset=START_MXOFF\n"
+ " set initial database cluster multixact offset\n"));
printf(_(" -s, --show show internal settings\n"));
printf(_(" -S, --sync-only only sync database files to disk, then exit\n"));
+ printf(_(" -x, --xid=START_XID set initial database cluster xid\n"));
printf(_("\nOther options:\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
@@ -2707,6 +2722,15 @@ initialize_data_directory(void)
/* Now create all the text config files */
setup_config();
+ if (start_mxid != 0)
+ printf(_("selecting initial multixact id ... %u\n"), start_mxid);
+
+ if (start_mxoff != 0)
+ printf(_("selecting initial multixact offset ... %u\n"), start_mxoff);
+
+ if (start_xid != 0)
+ printf(_("selecting initial xid ... %u\n"), start_xid);
+
/* Bootstrap template1 */
bootstrap_template1();
@@ -2723,8 +2747,11 @@ initialize_data_directory(void)
fflush(stdout);
snprintf(cmd, sizeof(cmd),
- "\"%s\" %s %s template1 >%s",
+ "\"%s\" %s %s %s %u %s %u %s %u template1 >%s",
backend_exec, backend_options, extra_options,
+ "-m", start_mxid,
+ "-o", start_mxoff,
+ "-x", start_xid,
DEVNULL);
PG_CMD_OPEN;
@@ -2806,6 +2833,9 @@ main(int argc, char *argv[])
{"discard-caches", no_argument, NULL, 14},
{"locale-provider", required_argument, NULL, 15},
{"icu-locale", required_argument, NULL, 16},
+ {"xid", required_argument, NULL, 'x'},
+ {"multixact-id", required_argument, NULL, 'm'},
+ {"multixact-offset", required_argument, NULL, 'o'},
{NULL, 0, NULL, 0}
};
@@ -2847,7 +2877,7 @@ main(int argc, char *argv[])
/* process command-line options */
- while ((c = getopt_long(argc, argv, "A:dD:E:gkL:nNsST:U:WX:", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "A:dD:E:gkL:m:nNo:sST:U:Wx:X:", long_options, &option_index)) != -1)
{
switch (c)
{
@@ -2886,6 +2916,32 @@ main(int argc, char *argv[])
debug = true;
printf(_("Running in debug mode.\n"));
break;
+ case 'm':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxid) /* overflow */
+ {
+ pg_log_error("invalid initial database cluster multixact id");
+ exit(1);
+ }
+ else if (start_mxid < 1) /* FirstMultiXactId */
+ {
+ /*
+ * We avoid mxid to be silently set to
+ * FirstMultiXactId, though it does not harm.
+ */
+ pg_log_error("multixact id should be greater than 0");
+ exit(1);
+ }
+ }
+ break;
case 'n':
noclean = true;
printf(_("Running in no-clean mode. Mistakes will not be cleaned up.\n"));
@@ -2893,6 +2949,23 @@ main(int argc, char *argv[])
case 'N':
do_sync = false;
break;
+ case 'o':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_mxoff = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_mxoff) /* overflow */
+ {
+ pg_log_error("invalid initial database cluster multixact offset");
+ exit(1);
+ }
+ }
+ break;
case 'S':
sync_only = true;
break;
@@ -2963,6 +3036,32 @@ main(int argc, char *argv[])
case 16:
icu_locale = pg_strdup(optarg);
break;
+ case 'x':
+ {
+ unsigned long value;
+ char *endptr;
+
+ errno = 0;
+ value = strtoul(optarg, &endptr, 0);
+ start_xid = value;
+
+ if (endptr == optarg || *endptr != '\0' || errno != 0 ||
+ value != start_xid) /* overflow */
+ {
+ pg_log_error("invalid value for initial database cluster xid");
+ exit(1);
+ }
+ else if (start_xid < 3) /* FirstNormalTransactionId */
+ {
+ /*
+ * We avoid xid to be silently set to
+ * FirstNormalTransactionId, though it does not harm.
+ */
+ pg_log_error("xid should be greater than 2");
+ exit(1);
+ }
+ }
+ break;
default:
/* getopt_long already emitted a complaint */
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl
index 164fc11cbf..57a68091d4 100644
--- a/src/bin/initdb/t/001_initdb.pl
+++ b/src/bin/initdb/t/001_initdb.pl
@@ -147,4 +147,90 @@ command_fails(
],
'fails for invalid option combination');
+# Set non-standard initial mxid/mxoff/xid.
+command_fails_like(
+ [ 'initdb', '-m', '4294967296', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact id/,
+ 'fails for invalid initial database cluster multixact id');
+command_fails_like(
+ [ 'initdb', '-o', '4294967296', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact offset/,
+ 'fails for invalid initial database cluster multixact offset');
+command_fails_like(
+ [ 'initdb', '-x', '4294967296', $datadir ],
+ qr/initdb: error: invalid value for initial database cluster xid/,
+ 'fails for invalid initial database cluster xid');
+
+command_fails_like(
+ [ 'initdb', '-m', '0x100000000', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact id/,
+ 'fails for invalid initial database cluster multixact id');
+command_fails_like(
+ [ 'initdb', '-o', '0x100000000', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact offset/,
+ 'fails for invalid initial database cluster multixact offset');
+command_fails_like(
+ [ 'initdb', '-x', '0x100000000', $datadir ],
+ qr/initdb: error: invalid value for initial database cluster xid/,
+ 'fails for invalid initial database cluster xid');
+
+command_fails_like(
+ [ 'initdb', '-m', 'seven', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact id/,
+ 'fails for invalid initial database cluster multixact id');
+command_fails_like(
+ [ 'initdb', '-o', 'seven', $datadir ],
+ qr/initdb: error: invalid initial database cluster multixact offset/,
+ 'fails for invalid initial database cluster multixact offset');
+command_fails_like(
+ [ 'initdb', '-x', 'seven', $datadir ],
+ qr/initdb: error: invalid value for initial database cluster xid/,
+ 'fails for invalid initial database cluster xid');
+
+command_checks_all(
+ [ 'initdb', '-m', '65535', "$tempdir/data-m65535" ],
+ 0,
+ [qr/selecting initial multixact id ... 65535/],
+ [],
+ 'selecting initial multixact id');
+command_checks_all(
+ [ 'initdb', '-o', '65535', "$tempdir/data-o65535" ],
+ 0,
+ [qr/selecting initial multixact offset ... 65535/],
+ [],
+ 'selecting initial multixact offset');
+command_checks_all(
+ [ 'initdb', '-x', '65535', "$tempdir/data-x65535" ],
+ 0,
+ [qr/selecting initial xid ... 65535/],
+ [],
+ 'selecting initial xid');
+
+# Setup new cluster with given mxid/mxoff/xid.
+my $node;
+my $result;
+
+$node = PostgreSQL::Test::Cluster->new('test-mxid');
+$node->init(extra => ['-m', '16777215']); # 0xFFFFFF
+$node->start;
+$result = $node->safe_psql('postgres', "SELECT next_multixact_id FROM pg_control_checkpoint();");
+ok($result >= 16777215, 'setup cluster with given mxid');
+$node->stop;
+
+$node = PostgreSQL::Test::Cluster->new('test-mxoff');
+$node->init(extra => ['-o', '16777215']); # 0xFFFFFF
+$node->start;
+$result = $node->safe_psql('postgres', "SELECT next_multi_offset FROM pg_control_checkpoint();");
+ok($result >= 16777215, 'setup cluster with given mxoff');
+$node->stop;
+
+$node = PostgreSQL::Test::Cluster->new('test-xid');
+$node->init(extra => ['-x', '16777215']); # 0xFFFFFF
+$node->start;
+$result = $node->safe_psql('postgres', "SELECT txid_current();");
+ok($result >= 16777215, 'setup cluster with given xid - check 1');
+$result = $node->safe_psql('postgres', "SELECT oldest_xid FROM pg_control_checkpoint();");
+ok($result >= 16777215, 'setup cluster with given xid - check 2');
+$node->stop;
+
done_testing();
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index dce265098e..afe526df63 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -90,6 +90,9 @@ typedef enum RecoveryState
} RecoveryState;
extern PGDLLIMPORT int wal_level;
+extern PGDLLIMPORT TransactionId start_xid;
+extern PGDLLIMPORT MultiXactId start_mxid;
+extern PGDLLIMPORT MultiXactOffset start_mxoff;
/* Is WAL archiving enabled (always or only while server is running normally)? */
#define XLogArchivingActive() \
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index e1f4eefa22..b4d627b88c 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -123,7 +123,7 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
Oid relrewrite BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
/* all Xids < this are frozen in this rel */
- TransactionId relfrozenxid BKI_DEFAULT(3); /* FirstNormalTransactionId */
+ TransactionId relfrozenxid BKI_DEFAULT(RECENTXMIN); /* FirstNormalTransactionId */
/* all multixacts in this rel are >= this; it is really a MultiXactId */
TransactionId relminmxid BKI_DEFAULT(1); /* FirstMultiXactId */
--
2.37.0 (Apple Git-136)
v47-0007-Use-64-bit-GUCs.patchapplication/octet-stream; name=v47-0007-Use-64-bit-GUCs.patchDownload
From 6e668d6f65a22433dbded57b7ae650f9fdb00f2f Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:34:26 +0300
Subject: [PATCH v47 7/8] Use 64-bit GUCs
Authors:
- Alexander Korotkov <aekorotkov@gmail.com>
- Teodor Sigaev <teodor@sigaev.ru>
- Nikita Glukhov <n.gluhov@postgrespro.ru>
- Maxim Orlov <orlovmg@gmail.com>
- Pavel Borisov <pashkin.elfe@gmail.com>
- Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/common/reloptions.c | 69 +++++
src/backend/utils/misc/guc.c | 352 +++++++++++++++++++++++++
src/backend/utils/misc/guc_funcs.c | 25 ++
src/backend/utils/misc/guc_tables.c | 10 +
src/include/access/reloptions.h | 13 +
src/include/utils/guc.h | 17 ++
src/include/utils/guc_tables.h | 19 ++
7 files changed, 505 insertions(+)
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 6458a9c276..b0993f37d4 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -382,7 +382,12 @@ static relopt_int intRelOpts[] =
},
-1, 0, 1024
},
+ /* list terminator */
+ {{NULL}}
+};
+static relopt_int64 int64RelOpts[] =
+{
/* list terminator */
{{NULL}}
};
@@ -597,6 +602,12 @@ initialize_reloptions(void)
intRelOpts[i].gen.lockmode));
j++;
}
+ for (i = 0; int64RelOpts[i].gen.name; i++)
+ {
+ Assert(DoLockModesConflict(int64RelOpts[i].gen.lockmode,
+ int64RelOpts[i].gen.lockmode));
+ j++;
+ }
for (i = 0; realRelOpts[i].gen.name; i++)
{
Assert(DoLockModesConflict(realRelOpts[i].gen.lockmode,
@@ -639,6 +650,14 @@ initialize_reloptions(void)
j++;
}
+ for (i = 0; int64RelOpts[i].gen.name; i++)
+ {
+ relOpts[j] = &int64RelOpts[i].gen;
+ relOpts[j]->type = RELOPT_TYPE_INT64;
+ relOpts[j]->namelen = strlen(relOpts[j]->name);
+ j++;
+ }
+
for (i = 0; realRelOpts[i].gen.name; i++)
{
relOpts[j] = &realRelOpts[i].gen;
@@ -794,6 +813,9 @@ allocate_reloption(bits32 kinds, int type, const char *name, const char *desc,
case RELOPT_TYPE_INT:
size = sizeof(relopt_int);
break;
+ case RELOPT_TYPE_INT64:
+ size = sizeof(relopt_int64);
+ break;
case RELOPT_TYPE_REAL:
size = sizeof(relopt_real);
break;
@@ -948,6 +970,26 @@ init_real_reloption(bits32 kinds, const char *name, const char *desc,
return newoption;
}
+/*
+ * add_int64_reloption
+ * Add a new 64-bit integer reloption
+ */
+void
+add_int64_reloption(bits32 kinds, const char *name, char *desc,
+ int64 default_val, int64 min_val, int64 max_val,
+ LOCKMODE lockmode)
+{
+ relopt_int64 *newoption;
+
+ newoption = (relopt_int64 *) allocate_reloption(kinds, RELOPT_TYPE_INT64,
+ name, desc, lockmode);
+ newoption->default_val = default_val;
+ newoption->min = min_val;
+ newoption->max = max_val;
+
+ add_reloption((relopt_gen *) newoption);
+}
+
/*
* add_real_reloption
* Add a new float reloption
@@ -1619,6 +1661,28 @@ parse_one_reloption(relopt_value *option, char *text_str, int text_len,
optint->min, optint->max)));
}
break;
+ case RELOPT_TYPE_INT64:
+ {
+ relopt_int64 *optint = (relopt_int64 *) option->gen;
+
+ parsed = parse_int64(value, &option->values.int64_val, 0, NULL);
+ if (validate && !parsed)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid value for 64-bit integer option \"%s\": %s",
+ option->gen->name, value)));
+ if (validate && (option->values.int64_val < optint->min ||
+ option->values.int64_val > optint->max))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("value %s out of bounds for option \"%s\"",
+ value, option->gen->name),
+ errdetail("Valid values are between \"%lld"
+ "\" and \"%lld\".",
+ (long long ) optint->min,
+ (long long) optint->max)));
+ }
+ break;
case RELOPT_TYPE_REAL:
{
relopt_real *optreal = (relopt_real *) option->gen;
@@ -1774,6 +1838,11 @@ fillRelOptions(void *rdopts, Size basesize,
options[i].values.int_val :
((relopt_int *) options[i].gen)->default_val;
break;
+ case RELOPT_TYPE_INT64:
+ *(int64 *) itempos = options[i].isset ?
+ options[i].values.int64_val :
+ ((relopt_int64 *) options[i].gen)->default_val;
+ break;
case RELOPT_TYPE_REAL:
*(double *) itempos = options[i].isset ?
options[i].values.real_val :
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 0135766035..12a1f30f7c 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -235,6 +235,8 @@ static bool call_bool_check_hook(struct config_bool *conf, bool *newval,
void **extra, GucSource source, int elevel);
static bool call_int_check_hook(struct config_int *conf, int *newval,
void **extra, GucSource source, int elevel);
+static bool call_int64_check_hook(struct config_int64 *conf, int64 *newval,
+ void **extra, GucSource source, int elevel);
static bool call_real_check_hook(struct config_real *conf, double *newval,
void **extra, GucSource source, int elevel);
static bool call_string_check_hook(struct config_string *conf, char **newval,
@@ -703,6 +705,10 @@ extra_field_used(struct config_generic *gconf, void *extra)
if (extra == ((struct config_int *) gconf)->reset_extra)
return true;
break;
+ case PGC_INT64:
+ if (extra == ((struct config_int64 *) gconf)->reset_extra)
+ return true;
+ break;
case PGC_REAL:
if (extra == ((struct config_real *) gconf)->reset_extra)
return true;
@@ -764,6 +770,10 @@ set_stack_value(struct config_generic *gconf, config_var_value *val)
val->val.intval =
*((struct config_int *) gconf)->variable;
break;
+ case PGC_INT64:
+ val->val.int64val =
+ *((struct config_int64 *) gconf)->variable;
+ break;
case PGC_REAL:
val->val.realval =
*((struct config_real *) gconf)->variable;
@@ -792,6 +802,7 @@ discard_stack_value(struct config_generic *gconf, config_var_value *val)
{
case PGC_BOOL:
case PGC_INT:
+ case PGC_INT64:
case PGC_REAL:
case PGC_ENUM:
/* no need to do anything */
@@ -1406,6 +1417,24 @@ InitializeOneGUCOption(struct config_generic *gconf)
conf->gen.extra = conf->reset_extra = extra;
break;
}
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+ int64 newval = conf->boot_val;
+ void *extra = NULL;
+
+ Assert(newval >= conf->min);
+ Assert(newval <= conf->max);
+ if (!call_int64_check_hook(conf, &newval, &extra,
+ PGC_S_DEFAULT, LOG))
+ elog(FATAL, "failed to initialize %s to %lld",
+ conf->gen.name, (long long) newval);
+ if (conf->assign_hook)
+ (*conf->assign_hook) (newval, extra);
+ *conf->variable = conf->reset_val = newval;
+ conf->gen.extra = conf->reset_extra = extra;
+ break;
+ }
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) gconf;
@@ -1713,6 +1742,18 @@ ResetAllOptions(void)
{
struct config_int *conf = (struct config_int *) gconf;
+ if (conf->assign_hook)
+ conf->assign_hook(conf->reset_val,
+ conf->reset_extra);
+ *conf->variable = conf->reset_val;
+ set_extra_field(&conf->gen, &conf->gen.extra,
+ conf->reset_extra);
+ break;
+ }
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+
if (conf->assign_hook)
conf->assign_hook(conf->reset_val,
conf->reset_extra);
@@ -2067,6 +2108,24 @@ AtEOXact_GUC(bool isCommit, int nestLevel)
int newval = newvalue.val.intval;
void *newextra = newvalue.extra;
+ if (*conf->variable != newval ||
+ conf->gen.extra != newextra)
+ {
+ if (conf->assign_hook)
+ conf->assign_hook(newval, newextra);
+ *conf->variable = newval;
+ set_extra_field(&conf->gen, &conf->gen.extra,
+ newextra);
+ changed = true;
+ }
+ break;
+ }
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+ int64 newval = newvalue.val.int64val;
+ void *newextra = newvalue.extra;
+
if (*conf->variable != newval ||
conf->gen.extra != newextra)
{
@@ -2592,6 +2651,71 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
return true;
}
+/*
+ * Try to parse value as an 64-bit integer. The accepted format is
+ * decimal number.
+ *
+ * If the string parses okay, return true, else false.
+ * If okay and result is not NULL, return the value in *result.
+ * If not okay and hintmsg is not NULL, *hintmsg is set to a suitable
+ * HINT message, or NULL if no hint provided.
+ */
+bool
+parse_int64(const char *value, int64 *result, int flags, const char **hintmsg)
+{
+ int64 val;
+ char *endptr;
+
+ /* To suppress compiler warnings, always set output params */
+ if (result)
+ *result = 0;
+ if (hintmsg)
+ *hintmsg = NULL;
+
+ /* We assume here that int64 is at least as wide as long */
+ errno = 0;
+ val = strtoi64(value, &endptr, 0);
+
+ if (endptr == value)
+ return false; /* no HINT for integer syntax error */
+
+ if (errno == ERANGE)
+ {
+ if (hintmsg)
+ *hintmsg = gettext_noop("Value exceeds 64-bit integer range.");
+ return false;
+ }
+
+ /*
+ * got double format and/or units. For now we attempts parse it as double
+ * and throw error on 53bit overflow
+ */
+ if (*endptr != '\0')
+ {
+ double dval;
+ bool ok;
+
+ ok = parse_real(value, &dval, flags, hintmsg);
+ if (!ok)
+ return false;
+
+ dval = rint(val);
+
+ if (fabs(dval) >= (double) ((uint64) 1 << 53))
+ {
+ *hintmsg = gettext_noop("Int64 value with units should be positive number < 2^53");
+ return false;
+ }
+
+ val = (int64) dval;
+ }
+
+
+ if (result)
+ *result = val;
+ return true;
+}
+
/*
* Try to parse value as a floating point number in the usual format.
* Optionally, the value can be followed by a unit name if "flags" indicates
@@ -2833,6 +2957,36 @@ parse_and_validate_value(struct config_generic *record,
return false;
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) record;
+ const char *hintmsg;
+
+ if (!parse_int64(value, &newval->int64val, conf->gen.flags, &hintmsg))
+ {
+ ereport(elevel,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid value for parameter \"%s\": \"%s\"",
+ name, value),
+ hintmsg ? errhint("%s", _(hintmsg)) : 0));
+ return false;
+ }
+
+ if (newval->int64val < conf->min || newval->int64val > conf->max)
+ {
+ ereport(elevel,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("%lld is outside the valid range for parameter \"%s\" (%lld .. %lld)",
+ (long long) newval->int64val, name,
+ (long long) conf->min, (long long) conf->max)));
+ return false;
+ }
+
+ if (!call_int64_check_hook(conf, &newval->int64val, newextra,
+ source, elevel))
+ return false;
+ }
+ break;
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) record;
@@ -3488,6 +3642,96 @@ set_config_option_ext(const char *name, const char *value,
free(newextra);
break;
+#undef newval
+ }
+
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) record;
+
+#define newval (newval_union.int64val)
+
+ if (value)
+ {
+ if (!parse_and_validate_value(record, name, value,
+ source, elevel,
+ &newval_union, &newextra))
+ return 0;
+ }
+ else if (source == PGC_S_DEFAULT)
+ {
+ newval = conf->boot_val;
+ if (!call_int64_check_hook(conf, &newval, &newextra,
+ source, elevel))
+ return 0;
+ }
+ else
+ {
+ newval = conf->reset_val;
+ newextra = conf->reset_extra;
+ source = conf->gen.reset_source;
+ context = conf->gen.reset_scontext;
+ }
+
+ if (prohibitValueChange)
+ {
+ if (*conf->variable != newval)
+ {
+ record->status |= GUC_PENDING_RESTART;
+ ereport(elevel,
+ (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
+ errmsg("parameter \"%s\" cannot be changed without restarting the server",
+ name)));
+ return 0;
+ }
+ record->status &= ~GUC_PENDING_RESTART;
+ return -1;
+ }
+
+ if (changeVal)
+ {
+ /* Save old value to support transaction abort */
+ if (!makeDefault)
+ push_old_value(&conf->gen, action);
+
+ if (conf->assign_hook)
+ (*conf->assign_hook) (newval, newextra);
+ *conf->variable = newval;
+ set_extra_field(&conf->gen, &conf->gen.extra,
+ newextra);
+ conf->gen.source = source;
+ conf->gen.scontext = context;
+ }
+ if (makeDefault)
+ {
+ GucStack *stack;
+
+ if (conf->gen.reset_source <= source)
+ {
+ conf->reset_val = newval;
+ set_extra_field(&conf->gen, &conf->reset_extra,
+ newextra);
+ conf->gen.reset_source = source;
+ conf->gen.reset_scontext = context;
+ }
+ for (stack = conf->gen.stack; stack; stack = stack->prev)
+ {
+ if (stack->source <= source)
+ {
+ stack->prior.val.intval = newval;
+ set_extra_field(&conf->gen, &stack->prior.extra,
+ newextra);
+ stack->source = source;
+ stack->scontext = context;
+ }
+ }
+ }
+
+ /* Perhaps we didn't install newextra anywhere */
+ if (newextra && !extra_field_used(&conf->gen, newextra))
+ free(newextra);
+ break;
+
#undef newval
}
@@ -3914,6 +4158,11 @@ GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
*((struct config_int *) record)->variable);
return buffer;
+ case PGC_INT64:
+ snprintf(buffer, sizeof(buffer), "%lld",
+ (long long) *((struct config_int64 *) record)->variable);
+ return buffer;
+
case PGC_REAL:
snprintf(buffer, sizeof(buffer), "%g",
*((struct config_real *) record)->variable);
@@ -3961,6 +4210,11 @@ GetConfigOptionResetString(const char *name)
((struct config_int *) record)->reset_val);
return buffer;
+ case PGC_INT64:
+ snprintf(buffer, sizeof(buffer), "%lld",
+ (long long) ((struct config_int64 *) record)->reset_val);
+ return buffer;
+
case PGC_REAL:
snprintf(buffer, sizeof(buffer), "%g",
((struct config_real *) record)->reset_val);
@@ -4875,6 +5129,14 @@ get_explain_guc_options(int *num)
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *lconf = (struct config_int64 *) conf;
+
+ modified = (lconf->boot_val != *(lconf->variable));
+ }
+ break;
+
case PGC_REAL:
{
struct config_real *lconf = (struct config_real *) conf;
@@ -5009,6 +5271,21 @@ ShowGUCOption(struct config_generic *record, bool use_units)
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) record;
+
+ if (conf->show_hook)
+ val = (*conf->show_hook) ();
+ else
+ {
+ snprintf(buffer, sizeof(buffer), "%lld",
+ (long long) *conf->variable);
+ val = buffer;
+ }
+ }
+ break;
+
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) record;
@@ -5112,6 +5389,14 @@ write_one_nondefault_variable(FILE *fp, struct config_generic *gconf)
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+
+ fprintf(fp, "%lld", (long long) *conf->variable);
+ }
+ break;
+
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) gconf;
@@ -5385,6 +5670,23 @@ estimate_variable_size(struct config_generic *gconf)
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+
+ /*
+ * Instead of getting the exact display length, use max
+ * length. Also reduce the max length for typical ranges of
+ * small values. Maximum value is 2^63, i.e. 20 chars.
+ * Include one byte for sign.
+ */
+ if (Abs(*conf->variable) < 1000)
+ valsize = 3 + 1;
+ else
+ valsize = 20 + 1;
+ }
+ break;
+
case PGC_REAL:
{
/*
@@ -5543,6 +5845,14 @@ serialize_variable(char **destptr, Size *maxbytes,
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+
+ do_serialize(destptr, maxbytes, "%lld", (long long) *conf->variable);
+ }
+ break;
+
case PGC_REAL:
{
struct config_real *conf = (struct config_real *) gconf;
@@ -5748,6 +6058,14 @@ RestoreGUCState(void *gucstate)
{
struct config_int *conf = (struct config_int *) gconf;
+ if (conf->reset_extra && conf->reset_extra != gconf->extra)
+ free(conf->reset_extra);
+ break;
+ }
+ case PGC_INT64:
+ {
+ struct config_int64 *conf = (struct config_int64 *) gconf;
+
if (conf->reset_extra && conf->reset_extra != gconf->extra)
free(conf->reset_extra);
break;
@@ -6323,6 +6641,40 @@ call_int_check_hook(struct config_int *conf, int *newval, void **extra,
return true;
}
+static bool
+call_int64_check_hook(struct config_int64 *conf, int64 *newval, void **extra,
+ GucSource source, int elevel)
+{
+ /* Quick success if no hook */
+ if (!conf->check_hook)
+ return true;
+
+ /* Reset variables that might be set by hook */
+ GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
+ GUC_check_errmsg_string = NULL;
+ GUC_check_errdetail_string = NULL;
+ GUC_check_errhint_string = NULL;
+
+ if (!(*conf->check_hook) (newval, extra, source))
+ {
+ ereport(elevel,
+ (errcode(GUC_check_errcode_value),
+ GUC_check_errmsg_string ?
+ errmsg_internal("%s", GUC_check_errmsg_string) :
+ errmsg("invalid value for parameter \"%s\": %lld",
+ conf->gen.name, (long long) *newval),
+ GUC_check_errdetail_string ?
+ errdetail_internal("%s", GUC_check_errdetail_string) : 0,
+ GUC_check_errhint_string ?
+ errhint("%s", GUC_check_errhint_string) : 0));
+ /* Flush any strings created in ErrorContext */
+ FlushErrorState();
+ return false;
+ }
+
+ return true;
+}
+
static bool
call_real_check_hook(struct config_real *conf, double *newval, void **extra,
GucSource source, int elevel)
diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c
index ffc71726f9..3ea346382b 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -673,6 +673,31 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
}
break;
+ case PGC_INT64:
+ {
+ struct config_int64 *lconf = (struct config_int64 *) conf;
+
+ /* min_val */
+ snprintf(buffer, sizeof(buffer), "%lld", (long long) lconf->min);
+ values[9] = pstrdup(buffer);
+
+ /* max_val */
+ snprintf(buffer, sizeof(buffer), "%lld", (long long) lconf->max);
+ values[10] = pstrdup(buffer);
+
+ /* enumvals */
+ values[11] = NULL;
+
+ /* boot_val */
+ snprintf(buffer, sizeof(buffer), "%lld", (long long) lconf->boot_val);
+ values[12] = pstrdup(buffer);
+
+ /* reset_val */
+ snprintf(buffer, sizeof(buffer), "%lld", (long long) lconf->reset_val);
+ values[13] = pstrdup(buffer);
+ }
+ break;
+
case PGC_REAL:
{
struct config_real *lconf = (struct config_real *) conf;
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 05ab087934..8869eb4112 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -727,6 +727,7 @@ const char *const config_type_names[] =
{
/* PGC_BOOL */ "bool",
/* PGC_INT */ "integer",
+ /* PGC_INT64 */ "int64",
/* PGC_REAL */ "real",
/* PGC_STRING */ "string",
/* PGC_ENUM */ "enum"
@@ -3412,6 +3413,15 @@ struct config_int ConfigureNamesInt[] =
};
+struct config_int64 ConfigureNamesInt64[] =
+{
+ /* End-of-list marker */
+ {
+ {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
+ }
+};
+
+
struct config_real ConfigureNamesReal[] =
{
{
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index 21bde78ed0..b8a8eb84e7 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -30,6 +30,7 @@ typedef enum relopt_type
{
RELOPT_TYPE_BOOL,
RELOPT_TYPE_INT,
+ RELOPT_TYPE_INT64,
RELOPT_TYPE_REAL,
RELOPT_TYPE_ENUM,
RELOPT_TYPE_STRING
@@ -81,6 +82,7 @@ typedef struct relopt_value
{
bool bool_val;
int int_val;
+ int64 int64_val;
double real_val;
int enum_val;
char *string_val; /* allocated separately */
@@ -102,6 +104,14 @@ typedef struct relopt_int
int max;
} relopt_int;
+typedef struct relopt_int64
+{
+ relopt_gen gen;
+ int64 default_val;
+ int64 min;
+ int64 max;
+} relopt_int64;
+
typedef struct relopt_real
{
relopt_gen gen;
@@ -185,6 +195,9 @@ extern void add_bool_reloption(bits32 kinds, const char *name, const char *desc,
extern void add_int_reloption(bits32 kinds, const char *name, const char *desc,
int default_val, int min_val, int max_val,
LOCKMODE lockmode);
+extern void add_int64_reloption(bits32 kinds, const char *name, char *desc,
+ int64 default_val, int64 min_val, int64 max_val,
+ LOCKMODE lockmode);
extern void add_real_reloption(bits32 kinds, const char *name, const char *desc,
double default_val, double min_val, double max_val,
LOCKMODE lockmode);
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 1788361974..5adb223fbe 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -176,12 +176,14 @@ struct config_enum_entry
*/
typedef bool (*GucBoolCheckHook) (bool *newval, void **extra, GucSource source);
typedef bool (*GucIntCheckHook) (int *newval, void **extra, GucSource source);
+typedef bool (*GucInt64CheckHook) (int64 *newval, void **extra, GucSource source);
typedef bool (*GucRealCheckHook) (double *newval, void **extra, GucSource source);
typedef bool (*GucStringCheckHook) (char **newval, void **extra, GucSource source);
typedef bool (*GucEnumCheckHook) (int *newval, void **extra, GucSource source);
typedef void (*GucBoolAssignHook) (bool newval, void *extra);
typedef void (*GucIntAssignHook) (int newval, void *extra);
+typedef void (*GucInt64AssignHook) (int64 newval, void *extra);
typedef void (*GucRealAssignHook) (double newval, void *extra);
typedef void (*GucStringAssignHook) (const char *newval, void *extra);
typedef void (*GucEnumAssignHook) (int newval, void *extra);
@@ -316,6 +318,19 @@ extern void DefineCustomIntVariable(const char *name,
GucIntAssignHook assign_hook,
GucShowHook show_hook) pg_attribute_nonnull(1, 4);
+extern void DefineCustomInt64Variable(const char *name,
+ const char *short_desc,
+ const char *long_desc,
+ int64 *valueAddr,
+ int64 bootValue,
+ int64 minValue,
+ int64 maxValue,
+ GucContext context,
+ int flags,
+ GucInt64CheckHook check_hook,
+ GucInt64AssignHook assign_hook,
+ GucShowHook show_hook);
+
extern void DefineCustomRealVariable(const char *name,
const char *short_desc,
const char *long_desc,
@@ -376,6 +391,8 @@ extern void ParseLongOption(const char *string, char **name, char **value);
extern const char *get_config_unit_name(int flags);
extern bool parse_int(const char *value, int *result, int flags,
const char **hintmsg);
+extern bool parse_int64(const char *value, int64 *result, int flags,
+ const char **hintmsg);
extern bool parse_real(const char *value, double *result, int flags,
const char **hintmsg);
extern int set_config_option(const char *name, const char *value,
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index b3d2a959c3..7fe43973d6 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -23,6 +23,7 @@ enum config_type
{
PGC_BOOL,
PGC_INT,
+ PGC_INT64,
PGC_REAL,
PGC_STRING,
PGC_ENUM
@@ -32,6 +33,7 @@ union config_var_val
{
bool boolval;
int intval;
+ int64 int64val;
double realval;
char *stringval;
int enumval;
@@ -212,6 +214,22 @@ struct config_int
void *reset_extra;
};
+struct config_int64
+{
+ struct config_generic gen;
+ /* constant fields, must be set correctly in initial value: */
+ int64 *variable;
+ int64 boot_val;
+ int64 min;
+ int64 max;
+ GucInt64CheckHook check_hook;
+ GucInt64AssignHook assign_hook;
+ GucShowHook show_hook;
+ /* variable fields, initialized at runtime: */
+ int64 reset_val;
+ void *reset_extra;
+};
+
struct config_real
{
struct config_generic gen;
@@ -266,6 +284,7 @@ extern PGDLLIMPORT const char *const GucSource_Names[];
/* data arrays defining all the built-in GUC variables */
extern PGDLLIMPORT struct config_bool ConfigureNamesBool[];
extern PGDLLIMPORT struct config_int ConfigureNamesInt[];
+extern PGDLLIMPORT struct config_int64 ConfigureNamesInt64[];
extern PGDLLIMPORT struct config_real ConfigureNamesReal[];
extern PGDLLIMPORT struct config_string ConfigureNamesString[];
extern PGDLLIMPORT struct config_enum ConfigureNamesEnum[];
--
2.37.0 (Apple Git-136)
v47-0006-README.XID64.patchapplication/octet-stream; name=v47-0006-README.XID64.patchDownload
From 6139f35c0628895b2aed28230ab5d568ddd02dc6 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:35:16 +0300
Subject: [PATCH v47 6/8] README.XID64
Authors:
- Alexander Korotkov <aekorotkov@gmail.com>
- Teodor Sigaev <teodor@sigaev.ru>
- Nikita Glukhov <n.gluhov@postgrespro.ru>
- Maxim Orlov <orlovmg@gmail.com>
- Pavel Borisov <pashkin.elfe@gmail.com>
- Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/heap/README.XID64 | 134 +++++++++++++++++++++++++++
1 file changed, 134 insertions(+)
create mode 100644 src/backend/access/heap/README.XID64
diff --git a/src/backend/access/heap/README.XID64 b/src/backend/access/heap/README.XID64
new file mode 100644
index 0000000000..9b4e6e03a2
--- /dev/null
+++ b/src/backend/access/heap/README.XID64
@@ -0,0 +1,134 @@
+src/backend/access/heap/README.XID64
+
+64-bit Transaction ID's (XID)
+=============================
+
+A limited number (N = 2^32) of XID's required to do vacuum freeze to prevent
+wraparound every N/2 transactions. This causes performance degradation due
+to the need to read and rewrite all not yet frozen pages tables while being
+vacuumed. In each wraparound cycle, SLRU buffers are also being cut.
+
+With 64-bit XID's wraparound is effectively postponed to a very distant
+future. Even in highly loaded systems that had 2^32 transactions per day
+it will take huge 2^31 days before the first enforced "vacuum to prevent
+wraparound"). Buffers cutting and routine vacuum are not enforced, and DBA
+can plan them independently at the time with the least system load and least
+critical for database performance. Also, it can be done less frequently
+(several times a year vs every several days) on systems with transaction rates
+similar to those mentioned above.
+
+On-disk tuple and page format
+-----------------------------
+
+On-disk tuple format remains unchanged. 32-bit t_xmin and t_xmax store the
+lower parts of 64-bit XMIN and XMAX values. Each heap page has additional
+64-bit pd_xid_base and pd_multi_base which are common for all tuples on a page.
+They are placed into a pd_special area - 16 bytes in the end of a heap page.
+Actual XMIN/XMAX for a tuple are calculated upon reading a tuple from a page
+as follows:
+
+XMIN = t_xmin + pd_xid_base. (1)
+XMAX = t_xmax + pd_xid_base/pd_multi_base. (2)
+
+"Double XMAX" page format
+---------------------------------
+
+At first read of a heap page after pg_upgrade from 32-bit XID PostgreSQL
+version pd_special area with a size of 16 bytes should be added to a page.
+Though a page may not have space for this. Then it can be converted to a
+temporary format called "double XMAX".
+
+All tuples after pg-upgrade doesn't need t_xmin anymore as no older transactions
+could be running. So we don't need tuple header t_xmin field and we reuse
+t_xmin to store higher 32 bits of its XMAX.
+
+Double XMAX format is only for full pages that don't have 16 bytes for
+pd_special. So it neither has a place for a single tuple. Insert and HOT update
+for double XMAX pages is impossible and not supported. We can only read or
+delete tuples from it.
+
+When we are able to prune page double XMAX it will be converted from it to
+general 64-bit XID page format with all operations on its tuples supported.
+
+In-memory tuple format
+----------------------
+
+In-memory tuple representation consists of two parts:
+- HeapTupleHeader from disk page (contains all heap tuple contents, not only
+header)
+- HeapTuple with additional in-memory fields
+
+HeapTuple for each tuple in memory stores 64bit XMIN/XMAX. They are
+precalculated on tuple read from page with (1) and (2).
+
+The filling of XMIN and XMAX in HeapTuple is done in the same way as the other
+fields of HeapTuple struct. It is done in all cases of HeapTuple manipulation.
+
+Update/delete with 64-bit XIDs and 32-bit t_xmin/t_xmax
+--------------------------------------------------------------
+
+When we try to delete/update a tuple, we check that XMAX for a page fits (2).
+I.e. that t_xmax will not be over MaxShortTransactionId relative to
+pd_xid_base/pd_multi_base of a its page.
+
+If the current XID doesn't fit a range
+(pd_xid_base, pd_xid_base + MaxShortTransactionId) (3):
+
+- heap_page_prepare_for_xid() will try to increase pd_xid_base/pd_multi_base on
+a page and update all t_xmin/t_xmax of the other tuples on the page to
+correspond new pd_xid_base/pd_multi_base.
+
+- If it was impossible, it will try to prune and freeze tuples on a page.
+
+- If this is unsuccessful it will throw an error. Normally this is very
+unlikely but if there is a very old living transaction with an age of around
+2^32 this can arise. Basically, this is a behavior similar to one during the
+vacuum to prevent wraparound when XID was 32-bit. DBA should take care and
+avoid very-long-living transactions with an age close to 2^32. So long-living
+transactions often they are most likely defunct.
+
+Insert with 64-bit XIDs and 32-bit t_xmin/t_xmax
+------------------------------------------------
+
+On insert we check if current XID fits a range (3). Otherwise:
+
+- heap_page_prepare_for_xid() will try to increase pd_xid_base for t_xmin will
+not be over MaxShortTransactionId.
+
+- If it is impossible, then it will try to prune and freeze tuples on a page.
+
+Known issue: if pd_xid_base could not be shifted to accommodate a tuple being
+inserted due to a very long-running transaction, we just throw an error. We
+neither try to insert a tuple into another page nor mark the current page as
+full. So, in this (unlikely) case we will get regular insert errors on the next
+tries to insert to the page 'locked' by this very long-running transaction.
+
+Upgrade from 32-bit XID versions
+--------------------------------
+
+pg_upgrade doesn't change pages format itself. It is done lazily after.
+
+1. At first heap page read, tuples on a page are repacked to free 16 bytes
+at the end of a page, possibly freeing space from dead tuples.
+
+2A. 16 bytes of pd_special is added if there is a place for it
+
+2B. Page is converted to "Double XMAX" format if there is no place for
+pd_special
+
+3. If a page is in double XMAX format after its first read, and vacuum (or
+micro-vacuum at select query) could prune some tuples and free space for
+pd_special, prune_page will add pd_special and convert page from double XMAX
+to general 64-bit XID page format.
+
+This lazy conversion is called only on pages being read. This can slow down
+performance after upgrade, but just for a short period of time while "hot"
+pages are read (and therefore converted to 64-bit format).
+
+There is a special case when the first read of a tuple is done in read-only
+state (in read-only transaction or on replica). This tuples are to be converted
+"in memory", but not sync "to disk", unless cluster or transaction changed to
+read-write state (e.g. replica is promoted). In order to support this, we mark
+"in memory" pages with converted tuples with bit REGBUF_CONVERTED in buffer
+descriptor. When in read-write state this will trigger full page write xlog
+record.
--
2.37.0 (Apple Git-136)
v47-0008-Use-64-bit-XIDs.patchapplication/octet-stream; name=v47-0008-Use-64-bit-XIDs.patchDownload
From 3140bbb4fa49c5d6f14f99b9910dea3e7fb0d970 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:37:29 +0300
Subject: [PATCH v47 8/8] Use 64-bit XIDs
- change TransactionId to 64bit
- disk tuple format (HeapTupleHeader) is (almost) unchanged: xmin and xmax remains 32bit
-- now 32bit xid is named ShortTransactionId
- heap page format is changed to contain xid and multixact base value, tuple's
xmin and xmax are offsets from.
-- xid_base and multi_base are stored as a page special data. PageHeader remains unmodified.
- in-memory tuple (HeapTuple) were enriched with precalulated 64bit xmin/xmax.
Authors:
- Alexander Korotkov <aekorotkov@gmail.com>
- Teodor Sigaev <teodor@sigaev.ru>
- Nikita Glukhov <n.gluhov@postgrespro.ru>
- Maxim Orlov <orlovmg@gmail.com>
- Pavel Borisov <pashkin.elfe@gmail.com>
- Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
- Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 79 +-
contrib/amcheck/verify_nbtree.c | 2 +-
contrib/hstore/hstore_io.c | 2 +
contrib/pageinspect/Makefile | 3 +-
contrib/pageinspect/btreefuncs.c | 16 +-
contrib/pageinspect/expected/btree.out | 4 +-
contrib/pageinspect/expected/hash_1.out | 166 +++
.../pageinspect/expected/oldextversions.out | 10 +-
contrib/pageinspect/expected/page.out | 28 +-
contrib/pageinspect/heapfuncs.c | 9 +-
contrib/pageinspect/meson.build | 1 +
.../pageinspect/pageinspect--1.10--1.11.sql | 145 ++
contrib/pageinspect/pageinspect--1.5.sql | 2 +
contrib/pageinspect/pageinspect.control | 2 +-
contrib/pageinspect/rawpage.c | 35 +-
contrib/pageinspect/sql/btree.sql | 3 +-
contrib/pg_surgery/heap_surgery.c | 22 +-
.../pg_visibility/expected/pg_visibility.out | 17 +
contrib/pg_visibility/pg_visibility.c | 7 +-
contrib/pg_visibility/sql/pg_visibility.sql | 18 +
contrib/pgrowlocks/pgrowlocks.c | 2 +-
contrib/pgstattuple/pgstatapprox.c | 2 +
contrib/pgstattuple/pgstatindex.c | 2 +-
.../postgres_fdw/expected/postgres_fdw.out | 55 +-
contrib/postgres_fdw/postgres_fdw.c | 9 +-
contrib/postgres_fdw/sql/postgres_fdw.sql | 15 +-
src/backend/access/common/heaptuple.c | 8 +-
src/backend/access/common/reloptions.c | 118 +-
src/backend/access/hash/hashvalidate.c | 5 +-
src/backend/access/heap/heapam.c | 1256 +++++++++++++++--
src/backend/access/heap/heapam_handler.c | 53 +-
src/backend/access/heap/heapam_visibility.c | 173 +--
src/backend/access/heap/heaptoast.c | 3 +
src/backend/access/heap/hio.c | 46 +-
src/backend/access/heap/pruneheap.c | 92 +-
src/backend/access/heap/rewriteheap.c | 101 +-
src/backend/access/heap/vacuumlazy.c | 150 +-
src/backend/access/nbtree/nbtpage.c | 2 +
src/backend/access/nbtree/nbtsplitloc.c | 16 +-
src/backend/access/nbtree/nbtxlog.c | 2 +
src/backend/access/rmgrdesc/gistdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 32 +
src/backend/access/rmgrdesc/mxactdesc.c | 9 +-
src/backend/access/rmgrdesc/nbtdesc.c | 4 +-
src/backend/access/rmgrdesc/xactdesc.c | 6 +-
src/backend/access/rmgrdesc/xlogdesc.c | 6 +-
src/backend/access/transam/clog.c | 24 +-
src/backend/access/transam/commit_ts.c | 19 -
src/backend/access/transam/multixact.c | 686 +--------
src/backend/access/transam/slru.c | 13 +-
src/backend/access/transam/subtrans.c | 9 +-
src/backend/access/transam/transam.c | 18 +-
src/backend/access/transam/twophase.c | 15 +-
src/backend/access/transam/varsup.c | 161 +--
src/backend/access/transam/xact.c | 36 +-
src/backend/access/transam/xlog.c | 10 +-
src/backend/access/transam/xloginsert.c | 7 +
src/backend/access/transam/xlogreader.c | 34 -
src/backend/access/transam/xlogrecovery.c | 2 +-
src/backend/bootstrap/bootstrap.c | 26 +-
src/backend/catalog/heap.c | 8 +-
src/backend/catalog/pg_inherits.c | 2 +-
src/backend/commands/async.c | 2 +-
src/backend/commands/dbcommands.c | 9 +-
src/backend/commands/indexcmds.c | 6 +-
src/backend/commands/sequence.c | 25 +-
src/backend/commands/vacuum.c | 45 +-
src/backend/executor/execExprInterp.c | 1 +
src/backend/executor/execUtils.c | 1 +
src/backend/executor/nodeModifyTable.c | 1 +
src/backend/executor/spi.c | 1 +
src/backend/nodes/gen_node_support.pl | 6 +-
src/backend/nodes/outfuncs.c | 1 -
src/backend/optimizer/util/plancat.c | 2 +-
src/backend/postmaster/autovacuum.c | 72 +-
src/backend/replication/logical/decode.c | 18 +-
src/backend/replication/logical/proto.c | 50 +-
.../replication/logical/reorderbuffer.c | 17 +-
src/backend/replication/logical/snapbuild.c | 9 +-
src/backend/replication/logical/worker.c | 2 +-
src/backend/replication/pgoutput/pgoutput.c | 3 +-
src/backend/replication/walreceiver.c | 28 +-
src/backend/replication/walsender.c | 73 +-
src/backend/statistics/extended_stats.c | 1 +
src/backend/storage/buffer/Makefile | 3 +-
src/backend/storage/buffer/bufmgr.c | 134 +-
src/backend/storage/buffer/heap_convert.c | 546 +++++++
src/backend/storage/buffer/meson.build | 1 +
src/backend/storage/ipc/procarray.c | 183 +--
src/backend/storage/ipc/sinvaladt.c | 4 +-
src/backend/storage/ipc/standby.c | 6 +-
src/backend/storage/lmgr/lmgr.c | 16 +-
src/backend/storage/lmgr/lock.c | 4 +-
src/backend/storage/lmgr/predicate.c | 6 +-
src/backend/storage/lmgr/proc.c | 11 +-
src/backend/storage/page/bufpage.c | 254 +++-
src/backend/tcop/postgres.c | 25 +-
src/backend/utils/adt/enum.c | 2 +-
src/backend/utils/adt/jsonfuncs.c | 1 +
src/backend/utils/adt/lockfuncs.c | 9 +-
src/backend/utils/adt/pgstatfuncs.c | 1 +
src/backend/utils/adt/rowtypes.c | 12 +
src/backend/utils/adt/xid.c | 37 +-
src/backend/utils/adt/xid8funcs.c | 83 +-
src/backend/utils/cache/catcache.c | 1 +
src/backend/utils/cache/relcache.c | 3 +-
src/backend/utils/fmgr/fmgr.c | 4 +-
src/backend/utils/misc/guc.c | 11 +
src/backend/utils/misc/guc_tables.c | 180 +--
src/backend/utils/misc/help_config.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 2 +-
src/backend/utils/misc/postgresql.conf.sample | 4 +-
src/backend/utils/sort/tuplesortvariants.c | 14 +-
src/backend/utils/time/combocid.c | 18 +-
src/backend/utils/time/snapmgr.c | 25 +-
src/bin/initdb/initdb.c | 60 +-
src/bin/initdb/t/001_initdb.pl | 12 +-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 210 ++-
src/bin/pg_controldata/pg_controldata.c | 2 +-
src/bin/pg_dump/pg_dump.c | 27 +-
src/bin/pg_dump/pg_dump.h | 8 +-
src/bin/pg_resetwal/pg_resetwal.c | 56 +-
src/bin/pg_upgrade/Makefile | 1 +
src/bin/pg_upgrade/check.c | 149 +-
src/bin/pg_upgrade/controldata.c | 17 +-
src/bin/pg_upgrade/file.c | 99 +-
src/bin/pg_upgrade/meson.build | 1 +
src/bin/pg_upgrade/pg_upgrade.c | 145 +-
src/bin/pg_upgrade/pg_upgrade.h | 34 +-
src/bin/pg_upgrade/relfilenumber.c | 34 +-
src/bin/pg_upgrade/segresize.c | 586 ++++++++
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 20 +-
src/bin/pg_upgrade/version.c | 104 +-
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/bin/pg_waldump/pg_waldump.c | 2 +-
src/include/access/clog.h | 2 +-
src/include/access/ginblock.h | 11 +-
src/include/access/gist.h | 2 +-
src/include/access/heapam.h | 20 +-
src/include/access/heapam_xlog.h | 38 +-
src/include/access/heaptoast.h | 11 +-
src/include/access/htup.h | 18 +-
src/include/access/htup_details.h | 237 +++-
src/include/access/multixact.h | 11 +-
src/include/access/nbtree.h | 10 +
src/include/access/rewriteheap.h | 4 +-
src/include/access/rmgrlist.h | 1 +
src/include/access/slru.h | 10 +-
src/include/access/tableam.h | 2 +-
src/include/access/transam.h | 89 +-
src/include/access/tupmacs.h | 3 +-
src/include/access/xact.h | 13 +-
src/include/access/xloginsert.h | 1 +
src/include/access/xlogreader.h | 4 -
src/include/access/xlogrecord.h | 5 +-
src/include/c.h | 27 +-
src/include/catalog/catversion.h | 3 +-
src/include/catalog/pg_amproc.dat | 4 +-
src/include/catalog/pg_control.h | 6 +
src/include/catalog/pg_operator.dat | 8 +-
src/include/catalog/pg_proc.dat | 12 +-
src/include/catalog/pg_type.dat | 4 +-
src/include/catalog/pg_type.h | 5 +
src/include/commands/vacuum.h | 30 +-
src/include/fmgr.h | 2 +
src/include/nodes/pg_list.h | 4 +
src/include/pg_config.h.in | 3 +
src/include/port/pg_lfind.h | 163 ++-
src/include/postgres.h | 9 +-
src/include/postmaster/autovacuum.h | 4 +-
src/include/storage/buf_internals.h | 5 +-
src/include/storage/bufmgr.h | 6 +
src/include/storage/bufpage.h | 232 ++-
src/include/storage/itemid.h | 2 +
src/include/storage/lock.h | 14 +-
src/include/storage/proc.h | 7 +-
src/include/storage/standby.h | 2 +-
src/include/utils/combocid.h | 2 +-
src/include/utils/rel.h | 12 +-
src/include/utils/xid8.h | 4 +-
src/pl/plperl/plperl.c | 4 +-
src/pl/plpgsql/src/pl_comp.c | 4 +-
src/pl/plpgsql/src/pl_exec.c | 2 +
src/pl/plpython/plpy_procedure.c | 4 +-
src/pl/tcl/pltcl.c | 4 +-
src/test/Makefile | 3 +-
src/test/meson.build | 1 +
src/test/modules/test_lfind/test_lfind.c | 30 +-
src/test/perl/PostgreSQL/Test/Cluster.pm | 4 +-
src/test/recovery/t/003_recovery_targets.pl | 2 +-
src/test/regress/expected/indirect_toast.out | 8 +
src/test/regress/expected/insert.out | 16 +-
src/test/regress/expected/opr_sanity.out | 6 +-
src/test/regress/expected/select_views.out | 70 +-
src/test/regress/expected/txid.out | 8 +-
src/test/regress/expected/type_sanity.out | 5 +-
src/test/regress/expected/xid.out | 14 +-
src/test/regress/expected/xid64.out | 92 ++
src/test/regress/parallel_schedule | 2 +-
src/test/regress/pg_regress.c | 2 +-
src/test/regress/regress.c | 291 ++++
src/test/regress/sql/indirect_toast.sql | 11 +
src/test/regress/sql/insert.sql | 17 +-
src/test/regress/sql/select_views.sql | 2 +-
src/test/regress/sql/type_sanity.sql | 5 +-
src/test/regress/sql/xid64.sql | 84 ++
src/test/xid-64/Makefile | 22 +
src/test/xid-64/README | 16 +
src/test/xid-64/meson.build | 15 +
src/test/xid-64/t/001_test_large_xids.pl | 54 +
src/test/xid-64/t/002_test_gucs.pl | 79 ++
src/test/xid-64/t/003_test_integrity.pl | 58 +
src/test/xid-64/t/004_test_relminmxid.pl | 90 ++
src/test/xid-64/t/005_stream_subxact.pl | 100 ++
src/test/xid-64/t/006_zeropage.pl | 33 +
src/tools/msvc/Solution.pm | 1 +
src/tools/pgindent/typedefs.list | 4 +-
217 files changed, 6981 insertions(+), 2606 deletions(-)
create mode 100644 contrib/pageinspect/expected/hash_1.out
create mode 100644 contrib/pageinspect/pageinspect--1.10--1.11.sql
create mode 100644 src/backend/storage/buffer/heap_convert.c
create mode 100644 src/bin/pg_upgrade/segresize.c
create mode 100644 src/test/regress/expected/xid64.out
create mode 100644 src/test/regress/sql/xid64.sql
create mode 100644 src/test/xid-64/Makefile
create mode 100644 src/test/xid-64/README
create mode 100644 src/test/xid-64/meson.build
create mode 100644 src/test/xid-64/t/001_test_large_xids.pl
create mode 100644 src/test/xid-64/t/002_test_gucs.pl
create mode 100644 src/test/xid-64/t/003_test_integrity.pl
create mode 100644 src/test/xid-64/t/004_test_relminmxid.pl
create mode 100644 src/test/xid-64/t/005_stream_subxact.pl
create mode 100644 src/test/xid-64/t/006_zeropage.pl
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index c9e71e4e50..63e043e6dd 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -17,6 +17,7 @@
#include "access/multixact.h"
#include "access/toast_internals.h"
#include "access/visibilitymap.h"
+#include "catalog/catalog.h"
#include "catalog/pg_am.h"
#include "funcapi.h"
#include "miscadmin.h"
@@ -85,7 +86,7 @@ typedef struct HeapCheckContext
* from them.
*/
FullTransactionId next_fxid; /* ShmemVariableCache->nextXid */
- TransactionId next_xid; /* 32-bit version of next_fxid */
+ TransactionId next_xid; /* 64-bit version of next_fxid */
TransactionId oldest_xid; /* ShmemVariableCache->oldestXid */
FullTransactionId oldest_fxid; /* 64-bit version of oldest_xid, computed
* relative to next_fxid */
@@ -126,6 +127,7 @@ typedef struct HeapCheckContext
uint16 lp_len;
uint16 lp_off;
HeapTupleHeader tuphdr;
+ HeapTupleData tuple;
int natts;
/* Values for iterating over attributes within the tuple */
@@ -165,8 +167,6 @@ static bool check_tuple_visibility(HeapCheckContext *ctx);
static void report_corruption(HeapCheckContext *ctx, char *msg);
static void report_toast_corruption(HeapCheckContext *ctx,
ToastedAttribute *ta, char *msg);
-static FullTransactionId FullTransactionIdFromXidAndCtx(TransactionId xid,
- const HeapCheckContext *ctx);
static void update_cached_xid_range(HeapCheckContext *ctx);
static void update_cached_mxid_range(HeapCheckContext *ctx);
static XidBoundsViolation check_mxid_in_range(MultiXactId mxid,
@@ -390,7 +390,7 @@ verify_heapam(PG_FUNCTION_ARGS)
update_cached_xid_range(&ctx);
update_cached_mxid_range(&ctx);
ctx.relfrozenxid = ctx.rel->rd_rel->relfrozenxid;
- ctx.relfrozenfxid = FullTransactionIdFromXidAndCtx(ctx.relfrozenxid, &ctx);
+ ctx.relfrozenfxid = FullTransactionIdFromXid(ctx.relfrozenxid);
ctx.relminmxid = ctx.rel->rd_rel->relminmxid;
if (TransactionIdIsNormal(ctx.relfrozenxid))
@@ -505,6 +505,12 @@ verify_heapam(PG_FUNCTION_ARGS)
ctx.tuphdr = (HeapTupleHeader) PageGetItem(ctx.page, ctx.itemid);
ctx.natts = HeapTupleHeaderGetNatts(ctx.tuphdr);
+ ctx.tuple.t_data = ctx.tuphdr;
+ ctx.tuple.t_len = ItemIdGetLength(ctx.itemid);
+ ctx.tuple.t_tableOid = RelationGetRelid(ctx.rel);
+ HeapTupleCopyBaseFromPage(ctx.buffer, &ctx.tuple, ctx.page,
+ IsToastRelation(ctx.rel));
+
/* Ok, ready to check this next tuple */
check_tuple(&ctx);
}
@@ -728,12 +734,13 @@ check_tuple_visibility(HeapCheckContext *ctx)
XidCommitStatus xmin_status;
XidCommitStatus xvac_status;
XidCommitStatus xmax_status;
+ HeapTuple tuple = &ctx->tuple;
HeapTupleHeader tuphdr = ctx->tuphdr;
ctx->tuple_could_be_pruned = true; /* have not yet proven otherwise */
/* If xmin is normal, it should be within valid range */
- xmin = HeapTupleHeaderGetXmin(tuphdr);
+ xmin = HeapTupleGetXmin(tuple);
switch (get_xid_status(xmin, ctx, &xmin_status))
{
case XID_INVALID:
@@ -743,19 +750,19 @@ check_tuple_visibility(HeapCheckContext *ctx)
report_corruption(ctx,
psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -781,19 +788,19 @@ check_tuple_visibility(HeapCheckContext *ctx)
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -847,19 +854,19 @@ check_tuple_visibility(HeapCheckContext *ctx)
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -936,7 +943,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
* HEAP_XMAX_IS_LOCKED_ONLY is true, but for now we err on the side of
* avoiding possibly-bogus complaints about missing TOAST entries.
*/
- xmax = HeapTupleHeaderGetRawXmax(tuphdr);
+ xmax = HeapTupleGetRawXmax(tuple);
switch (check_mxid_valid_in_rel(xmax, ctx))
{
case XID_INVALID:
@@ -995,7 +1002,7 @@ check_tuple_visibility(HeapCheckContext *ctx)
* We already checked above that this multixact is within limits for
* this table. Now check the update xid from this multixact.
*/
- xmax = HeapTupleGetUpdateXid(tuphdr);
+ xmax = HeapTupleGetUpdateXid(tuple);
switch (get_xid_status(xmax, ctx, &xmax_status))
{
case XID_INVALID:
@@ -1007,19 +1014,19 @@ check_tuple_visibility(HeapCheckContext *ctx)
report_corruption(ctx,
psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1059,26 +1066,26 @@ check_tuple_visibility(HeapCheckContext *ctx)
}
/* xmax is an XID, not a MXID. Sanity check it. */
- xmax = HeapTupleHeaderGetRawXmax(tuphdr);
+ xmax = HeapTupleGetRawXmax(tuple);
switch (get_xid_status(xmax, ctx, &xmax_status))
{
case XID_IN_FUTURE:
report_corruption(ctx,
psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
@@ -1553,24 +1560,6 @@ check_tuple(HeapCheckContext *ctx)
ctx->attnum = -1;
}
-/*
- * Convert a TransactionId into a FullTransactionId using our cached values of
- * the valid transaction ID range. It is the caller's responsibility to have
- * already updated the cached values, if necessary.
- */
-static FullTransactionId
-FullTransactionIdFromXidAndCtx(TransactionId xid, const HeapCheckContext *ctx)
-{
- uint32 epoch;
-
- if (!TransactionIdIsNormal(xid))
- return FullTransactionIdFromEpochAndXid(0, xid);
- epoch = EpochFromFullTransactionId(ctx->next_fxid);
- if (xid > ctx->next_xid)
- epoch--;
- return FullTransactionIdFromEpochAndXid(epoch, xid);
-}
-
/*
* Update our cached range of valid transaction IDs.
*/
@@ -1584,7 +1573,7 @@ update_cached_xid_range(HeapCheckContext *ctx)
LWLockRelease(XidGenLock);
/* And compute alternate versions of the same */
- ctx->oldest_fxid = FullTransactionIdFromXidAndCtx(ctx->oldest_xid, ctx);
+ ctx->oldest_fxid = FullTransactionIdFromXid(ctx->oldest_xid);
ctx->next_xid = XidFromFullTransactionId(ctx->next_fxid);
}
@@ -1684,7 +1673,7 @@ get_xid_status(TransactionId xid, HeapCheckContext *ctx,
}
/* Check if the xid is within bounds */
- fxid = FullTransactionIdFromXidAndCtx(xid, ctx);
+ fxid = FullTransactionIdFromXid(xid);
if (!fxid_in_cached_range(fxid, ctx))
{
/*
@@ -1693,7 +1682,6 @@ get_xid_status(TransactionId xid, HeapCheckContext *ctx,
* performed the full xid conversion, reconvert.
*/
update_cached_xid_range(ctx);
- fxid = FullTransactionIdFromXidAndCtx(xid, ctx);
}
if (FullTransactionIdPrecedesOrEquals(ctx->next_fxid, fxid))
@@ -1717,8 +1705,7 @@ get_xid_status(TransactionId xid, HeapCheckContext *ctx,
*status = XID_COMMITTED;
LWLockAcquire(XactTruncationLock, LW_SHARED);
clog_horizon =
- FullTransactionIdFromXidAndCtx(ShmemVariableCache->oldestClogXid,
- ctx);
+ FullTransactionIdFromXid(ShmemVariableCache->oldestClogXid);
if (FullTransactionIdPrecedesOrEquals(clog_horizon, fxid))
{
if (TransactionIdIsCurrentTransactionId(xid))
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index 9021d156eb..d2720124d7 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -526,7 +526,7 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
* avoid this.
*/
if (IsolationUsesXactSnapshot() && rel->rd_index->indcheckxmin &&
- !TransactionIdPrecedes(HeapTupleHeaderGetXmin(rel->rd_indextuple->t_data),
+ !TransactionIdPrecedes(HeapTupleGetXmin(rel->rd_indextuple),
snapshot->xmin))
ereport(ERROR,
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index 6161df2790..ed4dcbe9a3 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -853,6 +853,7 @@ hstore_from_record(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
tuple.t_data = rec;
+ HeapTupleSetZeroBase(&tuple);
values = (Datum *) palloc(ncolumns * sizeof(Datum));
nulls = (bool *) palloc(ncolumns * sizeof(bool));
@@ -1006,6 +1007,7 @@ hstore_populate_record(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
tuple.t_data = rec;
+ HeapTupleSetZeroBase(&tuple);
}
/*
diff --git a/contrib/pageinspect/Makefile b/contrib/pageinspect/Makefile
index 5c0736564a..5ca80c9d76 100644
--- a/contrib/pageinspect/Makefile
+++ b/contrib/pageinspect/Makefile
@@ -13,7 +13,8 @@ OBJS = \
rawpage.o
EXTENSION = pageinspect
-DATA = pageinspect--1.9--1.10.sql pageinspect--1.8--1.9.sql \
+DATA = pageinspect--1.10--1.11.sql \
+ pageinspect--1.9--1.10.sql pageinspect--1.8--1.9.sql \
pageinspect--1.7--1.8.sql pageinspect--1.6--1.7.sql \
pageinspect--1.5.sql pageinspect--1.5--1.6.sql \
pageinspect--1.4--1.5.sql pageinspect--1.3--1.4.sql \
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index b18aa0af7f..7b3a57dcf5 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -105,6 +105,9 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
stat->page_size = PageGetPageSize(page);
+ stat->btpo_prev = opaque->btpo_prev;
+ stat->btpo_level = opaque->btpo_level;
+
/* page type (flags) */
if (P_ISDELETED(opaque))
{
@@ -126,11 +129,18 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
FullTransactionId safexid = BTPageGetDeleteXid(page);
elog(DEBUG2, "deleted page from block %u has safexid %llu",
- blkno, (unsigned long long) U64FromFullTransactionId(safexid));
+ blkno, (unsigned long long) XidFromFullTransactionId(safexid));
}
else
+ {
+ ShortTransactionId safexid = BTP_GET_XACT(opaque);
+
+ stat->btpo_prev = 0;
+ stat->btpo_level = 0;
+
elog(DEBUG2, "deleted page from block %u has safexid %u",
- blkno, opaque->btpo_level);
+ blkno, safexid);
+ }
/* Don't interpret BTDeletedPageData as index tuples */
maxoff = InvalidOffsetNumber;
@@ -145,9 +155,7 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
stat->type = 'i';
/* btpage opaque data */
- stat->btpo_prev = opaque->btpo_prev;
stat->btpo_next = opaque->btpo_next;
- stat->btpo_level = opaque->btpo_level;
stat->btpo_flags = opaque->btpo_flags;
stat->btpo_cycleid = opaque->btpo_cycleid;
diff --git a/contrib/pageinspect/expected/btree.out b/contrib/pageinspect/expected/btree.out
index 035a81a759..5fb9122466 100644
--- a/contrib/pageinspect/expected/btree.out
+++ b/contrib/pageinspect/expected/btree.out
@@ -94,8 +94,8 @@ SELECT bt_page_items('aaa'::bytea);
ERROR: invalid page size
-- invalid special area size
CREATE INDEX test1_a_brin ON test1 USING brin(a);
-SELECT bt_page_items(get_raw_page('test1', 0));
-ERROR: input page is not a valid btree page
+-- XXX: false positive in 64xids due to equal sizes of BTPageOpaque and HeapPageSpecialData
+-- SELECT bt_page_items(get_raw_page('test1', 0));
SELECT bt_page_items(get_raw_page('test1_a_brin', 0));
ERROR: input page is not a valid btree page
\set VERBOSITY default
diff --git a/contrib/pageinspect/expected/hash_1.out b/contrib/pageinspect/expected/hash_1.out
new file mode 100644
index 0000000000..5e64eb9260
--- /dev/null
+++ b/contrib/pageinspect/expected/hash_1.out
@@ -0,0 +1,166 @@
+CREATE TABLE test_hash (a int, b text);
+INSERT INTO test_hash VALUES (1, 'one');
+CREATE INDEX test_hash_a_idx ON test_hash USING hash (a);
+\x
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 0));
+-[ RECORD 1 ]--+---------
+hash_page_type | metapage
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 1));
+-[ RECORD 1 ]--+-------
+hash_page_type | bucket
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 2));
+-[ RECORD 1 ]--+-------
+hash_page_type | bucket
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 3));
+-[ RECORD 1 ]--+-------
+hash_page_type | bucket
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 4));
+-[ RECORD 1 ]--+-------
+hash_page_type | bucket
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 5));
+-[ RECORD 1 ]--+-------
+hash_page_type | bitmap
+
+SELECT hash_page_type(get_raw_page('test_hash_a_idx', 6));
+ERROR: block number 6 is out of range for relation "test_hash_a_idx"
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', -1);
+ERROR: invalid block number
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 0);
+ERROR: invalid overflow block number 0
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 1);
+ERROR: invalid overflow block number 1
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 2);
+ERROR: invalid overflow block number 2
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 3);
+ERROR: invalid overflow block number 3
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 4);
+ERROR: invalid overflow block number 4
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 5);
+ERROR: invalid overflow block number 5
+SELECT * FROM hash_bitmap_info('test_hash_a_idx', 6);
+ERROR: block number 6 is out of range for relation "test_hash_a_idx"
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 0));
+-[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+magic | 105121344
+version | 4
+ntuples | 1
+bsize | 8156
+bmsize | 4096
+bmshift | 15
+maxbucket | 3
+highmask | 7
+lowmask | 3
+ovflpoint | 2
+firstfree | 0
+nmaps | 1
+procid | 450
+spares | {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+mapp | {5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 1));
+ERROR: page is not a hash meta page
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 2));
+ERROR: page is not a hash meta page
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 3));
+ERROR: page is not a hash meta page
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 4));
+ERROR: page is not a hash meta page
+SELECT magic, version, ntuples, bsize, bmsize, bmshift, maxbucket, highmask,
+lowmask, ovflpoint, firstfree, nmaps, procid, spares, mapp FROM
+hash_metapage_info(get_raw_page('test_hash_a_idx', 5));
+ERROR: page is not a hash meta page
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 0));
+ERROR: page is not a hash bucket or overflow page
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 1));
+-[ RECORD 1 ]---+-----------
+live_items | 0
+dead_items | 0
+page_size | 8192
+hasho_prevblkno | 3
+hasho_nextblkno | 4294967295
+hasho_bucket | 0
+hasho_flag | 2
+hasho_page_id | 65408
+
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 2));
+-[ RECORD 1 ]---+-----------
+live_items | 0
+dead_items | 0
+page_size | 8192
+hasho_prevblkno | 3
+hasho_nextblkno | 4294967295
+hasho_bucket | 1
+hasho_flag | 2
+hasho_page_id | 65408
+
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 3));
+-[ RECORD 1 ]---+-----------
+live_items | 1
+dead_items | 0
+page_size | 8192
+hasho_prevblkno | 3
+hasho_nextblkno | 4294967295
+hasho_bucket | 2
+hasho_flag | 2
+hasho_page_id | 65408
+
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 4));
+-[ RECORD 1 ]---+-----------
+live_items | 0
+dead_items | 0
+page_size | 8192
+hasho_prevblkno | 3
+hasho_nextblkno | 4294967295
+hasho_bucket | 3
+hasho_flag | 2
+hasho_page_id | 65408
+
+SELECT live_items, dead_items, page_size, hasho_prevblkno, hasho_nextblkno,
+hasho_bucket, hasho_flag, hasho_page_id FROM
+hash_page_stats(get_raw_page('test_hash_a_idx', 5));
+ERROR: page is not a hash bucket or overflow page
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 0));
+ERROR: page is not a hash bucket or overflow page
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 1));
+(0 rows)
+
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 2));
+(0 rows)
+
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 3));
+-[ RECORD 1 ]----------
+itemoffset | 1
+ctid | (0,1)
+data | 2389907270
+
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 4));
+(0 rows)
+
+SELECT * FROM hash_page_items(get_raw_page('test_hash_a_idx', 5));
+ERROR: page is not a hash bucket or overflow page
+DROP TABLE test_hash;
diff --git a/contrib/pageinspect/expected/oldextversions.out b/contrib/pageinspect/expected/oldextversions.out
index f5c4b61bd7..00323d392d 100644
--- a/contrib/pageinspect/expected/oldextversions.out
+++ b/contrib/pageinspect/expected/oldextversions.out
@@ -40,16 +40,16 @@ SELECT * FROM bt_page_items('test1_a_idx', 1);
-- pagesize in pageinspect >= 1.10.
ALTER EXTENSION pageinspect UPDATE TO '1.9';
\df page_header
- List of functions
- Schema | Name | Result data type | Argument data types | Type
---------+-------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------
- public | page_header | record | page bytea, OUT lsn pg_lsn, OUT checksum smallint, OUT flags smallint, OUT lower smallint, OUT upper smallint, OUT special smallint, OUT pagesize smallint, OUT version smallint, OUT prune_xid xid | func
+ List of functions
+ Schema | Name | Result data type | Argument data types | Type
+--------+-------------+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------
+ public | page_header | record | page bytea, OUT lsn pg_lsn, OUT checksum smallint, OUT flags smallint, OUT lower smallint, OUT upper smallint, OUT special smallint, OUT pagesize smallint, OUT version smallint, OUT xid_base xid, OUT multi_base xid, OUT prune_xid xid | func
(1 row)
SELECT pagesize, version FROM page_header(get_raw_page('test1', 0));
pagesize | version
----------+---------
- 8192 | 4
+ 8192 | 5
(1 row)
DROP TABLE test1;
diff --git a/contrib/pageinspect/expected/page.out b/contrib/pageinspect/expected/page.out
index 3bdc37bbf5..5ca00378df 100644
--- a/contrib/pageinspect/expected/page.out
+++ b/contrib/pageinspect/expected/page.out
@@ -48,7 +48,7 @@ SELECT get_raw_page('test1', 0) = get_raw_page('test1', 'main', 0);
SELECT pagesize, version FROM page_header(get_raw_page('test1', 0));
pagesize | version
----------+---------
- 8192 | 4
+ 8192 | 5
(1 row)
SELECT page_checksum(get_raw_page('test1', 0), 0) IS NOT NULL AS silly_checksum_test;
@@ -69,19 +69,19 @@ SELECT tuple_data_split('test1'::regclass, t_data, t_infomask, t_infomask2, t_bi
SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
fsm_page_contents
-------------------
- 0: 254 +
- 1: 254 +
- 3: 254 +
- 7: 254 +
- 15: 254 +
- 31: 254 +
- 63: 254 +
- 127: 254 +
- 255: 254 +
- 511: 254 +
- 1023: 254 +
- 2047: 254 +
- 4095: 254 +
+ 0: 253 +
+ 1: 253 +
+ 3: 253 +
+ 7: 253 +
+ 15: 253 +
+ 31: 253 +
+ 63: 253 +
+ 127: 253 +
+ 255: 253 +
+ 511: 253 +
+ 1023: 253 +
+ 2047: 253 +
+ 4095: 253 +
fp_next_slot: 0 +
(1 row)
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index aed2753253..c65f7099b7 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -163,7 +163,7 @@ heap_page_items(PG_FUNCTION_ARGS)
inter_call_data->tupd = tupdesc;
inter_call_data->offset = FirstOffsetNumber;
- inter_call_data->page = VARDATA(raw_page);
+ inter_call_data->page = get_page_from_raw(raw_page);
fctx->max_calls = PageGetMaxOffsetNumber(inter_call_data->page);
fctx->user_fctx = inter_call_data;
@@ -211,6 +211,7 @@ heap_page_items(PG_FUNCTION_ARGS)
lp_offset == MAXALIGN(lp_offset) &&
lp_offset + lp_len <= raw_page_size)
{
+ HeapTupleData tup;
HeapTupleHeader tuphdr;
bytea *tuple_data_bytea;
int tuple_data_len;
@@ -218,9 +219,11 @@ heap_page_items(PG_FUNCTION_ARGS)
/* Extract information from the tuple header */
tuphdr = (HeapTupleHeader) PageGetItem(page, id);
+ tup.t_data = tuphdr;
+ HeapTupleCopyBaseFromPage(InvalidBuffer, &tup, page, false);
- values[4] = UInt32GetDatum(HeapTupleHeaderGetRawXmin(tuphdr));
- values[5] = UInt32GetDatum(HeapTupleHeaderGetRawXmax(tuphdr));
+ values[4] = TransactionIdGetDatum(HeapTupleGetXmin(&tup));
+ values[5] = TransactionIdGetDatum(HeapTupleGetRawXmax(&tup));
/* shared with xvac */
values[6] = UInt32GetDatum(HeapTupleHeaderGetRawCommandId(tuphdr));
values[7] = PointerGetDatum(&tuphdr->t_ctid);
diff --git a/contrib/pageinspect/meson.build b/contrib/pageinspect/meson.build
index 4af8153e4f..8af29aa7fb 100644
--- a/contrib/pageinspect/meson.build
+++ b/contrib/pageinspect/meson.build
@@ -27,6 +27,7 @@ install_data(
'pageinspect--1.7--1.8.sql',
'pageinspect--1.8--1.9.sql',
'pageinspect--1.9--1.10.sql',
+ 'pageinspect--1.10--1.11.sql',
'pageinspect.control',
kwargs: contrib_data_args,
)
diff --git a/contrib/pageinspect/pageinspect--1.10--1.11.sql b/contrib/pageinspect/pageinspect--1.10--1.11.sql
new file mode 100644
index 0000000000..236f18aa2f
--- /dev/null
+++ b/contrib/pageinspect/pageinspect--1.10--1.11.sql
@@ -0,0 +1,145 @@
+/* contrib/pageinspect/pageinspect--1.10--1.11.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION pageinspect UPDATE TO '1.11'" to load this file. \quit
+
+--
+-- gist_page_opaque_info()
+--
+DROP FUNCTION gist_page_opaque_info(bytea);
+CREATE FUNCTION gist_page_opaque_info(IN page bytea,
+ OUT lsn pg_lsn,
+ OUT nsn pg_lsn,
+ OUT rightlink bigint,
+ OUT flags text[])
+AS 'MODULE_PATHNAME', 'gist_page_opaque_info'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+
+--
+-- gist_page_items_bytea()
+--
+DROP FUNCTION gist_page_items_bytea(bytea);
+CREATE FUNCTION gist_page_items_bytea(IN page bytea,
+ OUT itemoffset smallint,
+ OUT ctid tid,
+ OUT itemlen smallint,
+ OUT dead boolean,
+ OUT key_data bytea)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', 'gist_page_items_bytea'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- gist_page_items()
+--
+DROP FUNCTION gist_page_items(bytea, regclass);
+CREATE FUNCTION gist_page_items(IN page bytea,
+ IN index_oid regclass,
+ OUT itemoffset smallint,
+ OUT ctid tid,
+ OUT itemlen smallint,
+ OUT dead boolean,
+ OUT keys text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', 'gist_page_items'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- get_raw_page()
+--
+DROP FUNCTION get_raw_page(text, int8);
+DROP FUNCTION IF EXISTS get_raw_page(text, int4);
+CREATE FUNCTION get_raw_page(text, int8)
+RETURNS bytea
+AS 'MODULE_PATHNAME', 'get_raw_page_1_9'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+DROP FUNCTION get_raw_page(text, text, int8);
+DROP FUNCTION IF EXISTS get_raw_page(text, text, int4);
+CREATE FUNCTION get_raw_page(text, text, int8)
+RETURNS bytea
+AS 'MODULE_PATHNAME', 'get_raw_page_fork_1_9'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- page_checksum()
+--
+DROP FUNCTION page_checksum(IN page bytea, IN blkno int8);
+DROP FUNCTION IF EXISTS page_checksum(IN page bytea, IN blkno int4);
+CREATE FUNCTION page_checksum(IN page bytea, IN blkno int8)
+RETURNS smallint
+AS 'MODULE_PATHNAME', 'page_checksum_1_9'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- bt_metap()
+--
+DROP FUNCTION bt_metap(text);
+CREATE FUNCTION bt_metap(IN relname text,
+ OUT magic int4,
+ OUT version int4,
+ OUT root int8,
+ OUT level int8,
+ OUT fastroot int8,
+ OUT fastlevel int8,
+ OUT last_cleanup_num_delpages int8,
+ OUT last_cleanup_num_tuples float8,
+ OUT allequalimage boolean)
+AS 'MODULE_PATHNAME', 'bt_metap'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- bt_page_stats()
+--
+DROP FUNCTION bt_page_stats(text, int8);
+DROP FUNCTION IF EXISTS bt_page_stats(text, int4);
+CREATE FUNCTION bt_page_stats(IN relname text, IN blkno int8,
+ OUT blkno int8,
+ OUT type "char",
+ OUT live_items int4,
+ OUT dead_items int4,
+ OUT avg_item_size int4,
+ OUT page_size int4,
+ OUT free_size int4,
+ OUT btpo_prev int8,
+ OUT btpo_next int8,
+ OUT btpo_level int8,
+ OUT btpo_flags int4)
+AS 'MODULE_PATHNAME', 'bt_page_stats_1_9'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- bt_page_items()
+--
+DROP FUNCTION bt_page_items(text, int8);
+DROP FUNCTION IF EXISTS bt_page_items(text, int4);
+CREATE FUNCTION bt_page_items(IN relname text, IN blkno int8,
+ OUT itemoffset smallint,
+ OUT ctid tid,
+ OUT itemlen smallint,
+ OUT nulls bool,
+ OUT vars bool,
+ OUT data text,
+ OUT dead boolean,
+ OUT htid tid,
+ OUT tids tid[])
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', 'bt_page_items_1_9'
+LANGUAGE C STRICT PARALLEL SAFE;
+
+--
+-- brin_page_items()
+--
+DROP FUNCTION brin_page_items(IN page bytea, IN index_oid regclass);
+CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
+ OUT itemoffset int,
+ OUT blknum int8,
+ OUT attnum int,
+ OUT allnulls bool,
+ OUT hasnulls bool,
+ OUT placeholder bool,
+ OUT value text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', 'brin_page_items'
+LANGUAGE C STRICT PARALLEL SAFE;
diff --git a/contrib/pageinspect/pageinspect--1.5.sql b/contrib/pageinspect/pageinspect--1.5.sql
index 1e40c3c97e..fdbd2995a2 100644
--- a/contrib/pageinspect/pageinspect--1.5.sql
+++ b/contrib/pageinspect/pageinspect--1.5.sql
@@ -28,6 +28,8 @@ CREATE FUNCTION page_header(IN page bytea,
OUT special smallint,
OUT pagesize smallint,
OUT version smallint,
+ OUT xid_base xid,
+ OUT multi_base xid,
OUT prune_xid xid)
AS 'MODULE_PATHNAME', 'page_header'
LANGUAGE C STRICT PARALLEL SAFE;
diff --git a/contrib/pageinspect/pageinspect.control b/contrib/pageinspect/pageinspect.control
index 7cdf37913d..f277413dd8 100644
--- a/contrib/pageinspect/pageinspect.control
+++ b/contrib/pageinspect/pageinspect.control
@@ -1,5 +1,5 @@
# pageinspect extension
comment = 'inspect the contents of database pages at a low level'
-default_version = '1.10'
+default_version = '1.11'
module_pathname = '$libdir/pageinspect'
relocatable = true
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
index 90942be71e..6d50940955 100644
--- a/contrib/pageinspect/rawpage.c
+++ b/contrib/pageinspect/rawpage.c
@@ -17,6 +17,7 @@
#include "access/htup_details.h"
#include "access/relation.h"
+#include "commands/sequence.h"
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
@@ -251,8 +252,9 @@ page_header(PG_FUNCTION_ARGS)
Datum result;
HeapTuple tuple;
- Datum values[9];
- bool nulls[9];
+ Datum values[11];
+ bool nulls[11];
+ bool is_toast;
Page page;
PageHeader pageheader;
@@ -314,12 +316,37 @@ page_header(PG_FUNCTION_ARGS)
}
values[7] = UInt16GetDatum(PageGetPageLayoutVersion(page));
- values[8] = TransactionIdGetDatum(pageheader->pd_prune_xid);
+ is_toast = PageGetSpecialSize(page) ==
+ MAXALIGN(sizeof(ToastPageSpecialData));
+ values[8] = TransactionIdGetDatum(HeapPageGetPruneXidNoAssert((Page) page,
+ is_toast));
/* Build and return the tuple. */
-
memset(nulls, 0, sizeof(nulls));
+ if (PageGetSpecialSize(page) == MAXALIGN(sizeof(HeapPageSpecialData)))
+ {
+ /* Heap page */
+ HeapPageSpecial pageSpecial = HeapPageGetSpecial((Page) page);
+
+ values[9] = TransactionIdGetDatum(pageSpecial->pd_xid_base);
+ values[10] = TransactionIdGetDatum(pageSpecial->pd_multi_base);
+ }
+ else if (PageGetSpecialSize(page) == MAXALIGN(sizeof(ToastPageSpecialData)))
+ {
+ /* TOAST page */
+ ToastPageSpecial pageSpecial = ToastPageGetSpecial((Page) page);
+
+ values[9] = TransactionIdGetDatum(pageSpecial->pd_xid_base);
+ nulls[10] = true;
+ }
+ else
+ {
+ /* Double xmax page */
+ nulls[9] = true;
+ nulls[10] = true;
+ }
+
tuple = heap_form_tuple(tupdesc, values, nulls);
result = HeapTupleGetDatum(tuple);
diff --git a/contrib/pageinspect/sql/btree.sql b/contrib/pageinspect/sql/btree.sql
index 1f554f0f67..538d71d23a 100644
--- a/contrib/pageinspect/sql/btree.sql
+++ b/contrib/pageinspect/sql/btree.sql
@@ -40,7 +40,8 @@ SELECT bt_page_items(get_raw_page('test1_b_gist', 0));
SELECT bt_page_items('aaa'::bytea);
-- invalid special area size
CREATE INDEX test1_a_brin ON test1 USING brin(a);
-SELECT bt_page_items(get_raw_page('test1', 0));
+-- XXX: false positive in 64xids due to equal sizes of BTPageOpaque and HeapPageSpecialData
+-- SELECT bt_page_items(get_raw_page('test1', 0));
SELECT bt_page_items(get_raw_page('test1_a_brin', 0));
\set VERBOSITY default
diff --git a/contrib/pg_surgery/heap_surgery.c b/contrib/pg_surgery/heap_surgery.c
index 8a2ad9773d..439ebaf8e2 100644
--- a/contrib/pg_surgery/heap_surgery.c
+++ b/contrib/pg_surgery/heap_surgery.c
@@ -15,6 +15,7 @@
#include "access/heapam.h"
#include "access/visibilitymap.h"
#include "access/xloginsert.h"
+#include "catalog/catalog.h"
#include "catalog/pg_am_d.h"
#include "catalog/pg_proc_d.h"
#include "miscadmin.h"
@@ -272,11 +273,18 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt)
else
{
HeapTupleHeader htup;
+ HeapTupleData tuple;
Assert(heap_force_opt == HEAP_FORCE_FREEZE);
htup = (HeapTupleHeader) PageGetItem(page, itemid);
+ tuple.t_data = htup;
+ tuple.t_len = ItemIdGetLength(itemid);
+ tuple.t_tableOid = RelationGetRelid(rel);
+ HeapTupleCopyBaseFromPage(buf, &tuple, page,
+ IsToastRelation(rel));
+
/*
* Reset all visibility-related fields of the tuple. This
* logic should mimic heap_execute_freeze_tuple(), but we
@@ -284,8 +292,18 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt)
* potentially-garbled data is left behind.
*/
ItemPointerSet(&htup->t_ctid, blkno, curoff);
- HeapTupleHeaderSetXmin(htup, FrozenTransactionId);
- HeapTupleHeaderSetXmax(htup, InvalidTransactionId);
+ if (IsToastRelation(rel))
+ {
+ ToastTupleHeaderSetXmin(page, &tuple);
+ ToastTupleHeaderSetXmax(page, &tuple);
+ }
+ else
+ {
+ HeapTupleHeaderSetXmin(page, &tuple);
+ HeapTupleHeaderSetXmax(page, &tuple);
+ }
+ HeapTupleSetXmin(&tuple, FrozenTransactionId);
+ HeapTupleSetXmax(&tuple, InvalidTransactionId);
if (htup->t_infomask & HEAP_MOVED)
{
if (htup->t_infomask & HEAP_MOVED_OFF)
diff --git a/contrib/pg_visibility/expected/pg_visibility.out b/contrib/pg_visibility/expected/pg_visibility.out
index 9de54db2a2..d3c893b4e3 100644
--- a/contrib/pg_visibility/expected/pg_visibility.out
+++ b/contrib/pg_visibility/expected/pg_visibility.out
@@ -267,6 +267,22 @@ select * from pg_check_frozen('copyfreeze');
--------
(0 rows)
+create table vacuum_test as select 42 i;
+vacuum (disable_page_skipping) vacuum_test;
+-- pg_check_visible() can report false positive due to autovacuum activity.
+-- To workaround this issue, repeat the call.
+do $$
+declare
+ non_visible_count bigint;
+ i integer;
+begin
+ for i in 1 .. 10 loop
+ if i > 1 then perform pg_sleep(1); end if;
+ select count(*) from pg_check_visible('vacuum_test') into non_visible_count;
+ if non_visible_count = 0 then exit; end if;
+ end loop;
+ if non_visible_count > 0 then raise exception 'The visibility map is corrupt.'; end if;
+end $$;
-- cleanup
drop table test_partitioned;
drop view test_view;
@@ -277,3 +293,4 @@ drop foreign data wrapper dummy;
drop materialized view matview_visibility_test;
drop table regular_table;
drop table copyfreeze;
+drop table vacuum_test;
diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c
index a95f73ec79..d2296c2d02 100644
--- a/contrib/pg_visibility/pg_visibility.c
+++ b/contrib/pg_visibility/pg_visibility.c
@@ -14,6 +14,7 @@
#include "access/htup_details.h"
#include "access/visibilitymap.h"
#include "access/xloginsert.h"
+#include "catalog/catalog.h"
#include "catalog/pg_type.h"
#include "catalog/storage_xlog.h"
#include "funcapi.h"
@@ -652,6 +653,8 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid);
tuple.t_tableOid = relid;
+ HeapTupleCopyBaseFromPage(buffer, &tuple, page,
+ IsToastRelation(rel));
/*
* If we're checking whether the page is all-visible, we expect
@@ -695,7 +698,7 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
*/
if (check_frozen)
{
- if (heap_tuple_needs_eventual_freeze(tuple.t_data))
+ if (heap_tuple_needs_eventual_freeze(&tuple))
record_corrupt_item(items, &tuple.t_self);
}
}
@@ -758,7 +761,7 @@ tuple_all_visible(HeapTuple tup, TransactionId OldestXmin, Buffer buffer)
* be set here. So just check the xmin.
*/
- xmin = HeapTupleHeaderGetXmin(tup->t_data);
+ xmin = HeapTupleGetXmin(tup);
if (!TransactionIdPrecedes(xmin, OldestXmin))
return false; /* xmin not old enough for all to see */
diff --git a/contrib/pg_visibility/sql/pg_visibility.sql b/contrib/pg_visibility/sql/pg_visibility.sql
index ff3538f996..a0d9525df9 100644
--- a/contrib/pg_visibility/sql/pg_visibility.sql
+++ b/contrib/pg_visibility/sql/pg_visibility.sql
@@ -170,6 +170,23 @@ commit;
select * from pg_visibility_map('copyfreeze');
select * from pg_check_frozen('copyfreeze');
+create table vacuum_test as select 42 i;
+vacuum (disable_page_skipping) vacuum_test;
+-- pg_check_visible() can report false positive due to autovacuum activity.
+-- To workaround this issue, repeat the call.
+do $$
+declare
+ non_visible_count bigint;
+ i integer;
+begin
+ for i in 1 .. 10 loop
+ if i > 1 then perform pg_sleep(1); end if;
+ select count(*) from pg_check_visible('vacuum_test') into non_visible_count;
+ if non_visible_count = 0 then exit; end if;
+ end loop;
+ if non_visible_count > 0 then raise exception 'The visibility map is corrupt.'; end if;
+end $$;
+
-- cleanup
drop table test_partitioned;
drop view test_view;
@@ -180,3 +197,4 @@ drop foreign data wrapper dummy;
drop materialized view matview_visibility_test;
drop table regular_table;
drop table copyfreeze;
+drop table vacuum_test;
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index ef89b84ec3..0abf1ea21a 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -130,7 +130,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
htsu = HeapTupleSatisfiesUpdate(tuple,
GetCurrentCommandId(false),
hscan->rs_cbuf);
- xmax = HeapTupleHeaderGetRawXmax(tuple->t_data);
+ xmax = HeapTupleGetRawXmax(tuple);
infomask = tuple->t_data->t_infomask;
/*
diff --git a/contrib/pgstattuple/pgstatapprox.c b/contrib/pgstattuple/pgstatapprox.c
index b827728326..5bf73251b7 100644
--- a/contrib/pgstattuple/pgstatapprox.c
+++ b/contrib/pgstattuple/pgstatapprox.c
@@ -19,6 +19,7 @@
#include "access/transam.h"
#include "access/visibilitymap.h"
#include "access/xact.h"
+#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "catalog/pg_am_d.h"
#include "commands/vacuum.h"
@@ -153,6 +154,7 @@ statapprox_heap(Relation rel, output_type *stat)
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid);
tuple.t_tableOid = RelationGetRelid(rel);
+ HeapTupleCopyBaseFromPage(buf, &tuple, page, IsToastRelation(rel));
/*
* We follow VACUUM's lead in counting INSERT_IN_PROGRESS tuples
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index d69ac1c93d..4d045b2764 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -605,7 +605,7 @@ pgstathashindex(PG_FUNCTION_ARGS)
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
metap = HashPageGetMeta(BufferGetPage(metabuf));
stats.version = metap->hashm_version;
- stats.space_per_page = metap->hashm_bsize;
+ stats.space_per_page = BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(HashPageOpaqueData));
_hash_relbuf(rel, metabuf);
/* Get the current relation length */
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out
index cc9e39c4a5..69bd2c929f 100644
--- a/contrib/postgres_fdw/expected/postgres_fdw.out
+++ b/contrib/postgres_fdw/expected/postgres_fdw.out
@@ -4599,16 +4599,24 @@ UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3;
UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3;
EXPLAIN (verbose, costs off)
-UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *; -- can be pushed down
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------
- Update on public.ft2
- Output: c1, c2, c3, c4, c5, c6, c7, c8
- -> Foreign Update on public.ft2
- Remote SQL: UPDATE "S 1"."T 1" SET c2 = (c2 + 400), c3 = (c3 || '_update7') WHERE ((("C 1" % 10) = 7)) RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
-(4 rows)
+WITH t AS (UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *)
+SELECT * FROM t ORDER BY c1; -- can be pushed down
+ QUERY PLAN
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Sort
+ Output: t.c1, t.c2, t.c3, t.c4, t.c5, t.c6, t.c7, t.c8
+ Sort Key: t.c1
+ CTE t
+ -> Update on public.ft2
+ Output: ft2.c1, ft2.c2, ft2.c3, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8
+ -> Foreign Update on public.ft2
+ Remote SQL: UPDATE "S 1"."T 1" SET c2 = (c2 + 400), c3 = (c3 || '_update7') WHERE ((("C 1" % 10) = 7)) RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
+ -> CTE Scan on t
+ Output: t.c1, t.c2, t.c3, t.c4, t.c5, t.c6, t.c7, t.c8
+(10 rows)
-UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *;
+WITH t AS (UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *)
+SELECT * FROM t ORDER BY c1;
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
------+-----+--------------------+------------------------------+--------------------------+----+------------+-----
7 | 407 | 00007_update7 | Thu Jan 08 00:00:00 1970 PST | Thu Jan 08 00:00:00 1970 | 7 | 7 | foo
@@ -4728,16 +4736,24 @@ UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9;
EXPLAIN (verbose, costs off)
- DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4; -- can be pushed down
- QUERY PLAN
---------------------------------------------------------------------------------------------
- Delete on public.ft2
- Output: c1, c4
- -> Foreign Delete on public.ft2
- Remote SQL: DELETE FROM "S 1"."T 1" WHERE ((("C 1" % 10) = 5)) RETURNING "C 1", c4
-(4 rows)
+ WITH t AS (DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4)
+ SELECT * FROM t ORDER BY c1; -- can be pushed down
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------
+ Sort
+ Output: t.c1, t.c4
+ Sort Key: t.c1
+ CTE t
+ -> Delete on public.ft2
+ Output: ft2.c1, ft2.c4
+ -> Foreign Delete on public.ft2
+ Remote SQL: DELETE FROM "S 1"."T 1" WHERE ((("C 1" % 10) = 5)) RETURNING "C 1", c4
+ -> CTE Scan on t
+ Output: t.c1, t.c4
+(10 rows)
-DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4;
+WITH t AS (DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4)
+SELECT * FROM t ORDER BY c1;
c1 | c4
------+------------------------------
5 | Tue Jan 06 00:00:00 1970 PST
@@ -5998,7 +6014,8 @@ INSERT INTO ft2 (c1,c2,c3,c6) VALUES (1218, 818, 'ggg', '(--;') RETURNING *;
1218 | 818 | ggg_trig_update | | | (--; | ft2 |
(1 row)
-UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *;
+WITH t AS (UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *)
+SELECT * FROM t ORDER BY c1;
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
------+-----+------------------------+------------------------------+--------------------------+----+------------+-----
8 | 608 | 00008_trig_update | Fri Jan 09 00:00:00 1970 PST | Fri Jan 09 00:00:00 1970 | 8 | 8 | foo
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index dd858aba03..b54fbeccca 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -4814,8 +4814,8 @@ apply_returning_filter(PgFdwDirectModifyState *dmstate,
* Note: no need to care about tableoid here because it will be
* initialized in ExecProcessReturning().
*/
- HeapTupleHeaderSetXmin(resultTup->t_data, InvalidTransactionId);
- HeapTupleHeaderSetXmax(resultTup->t_data, InvalidTransactionId);
+ HeapTupleSetXmin(resultTup, InvalidTransactionId);
+ HeapTupleSetXmax(resultTup, InvalidTransactionId);
HeapTupleHeaderSetCmin(resultTup->t_data, InvalidTransactionId);
}
@@ -7328,6 +7328,7 @@ make_tuple_from_result_row(PGresult *res,
*/
if (ctid)
tuple->t_self = tuple->t_data->t_ctid = *ctid;
+ HeapTupleSetZeroBase(tuple);
/*
* Stomp on the xmin, xmax, and cmin fields from the tuple created by
@@ -7337,8 +7338,8 @@ make_tuple_from_result_row(PGresult *res,
* assumption. If we don't do this then, for example, the tuple length
* ends up in the xmin field, which isn't what we want.
*/
- HeapTupleHeaderSetXmax(tuple->t_data, InvalidTransactionId);
- HeapTupleHeaderSetXmin(tuple->t_data, InvalidTransactionId);
+ HeapTupleSetXmax(tuple, InvalidTransactionId);
+ HeapTupleSetXmin(tuple, InvalidTransactionId);
HeapTupleHeaderSetCmin(tuple->t_data, InvalidTransactionId);
/* Clean up */
diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql
index e48ccd286b..b2f035b50f 100644
--- a/contrib/postgres_fdw/sql/postgres_fdw.sql
+++ b/contrib/postgres_fdw/sql/postgres_fdw.sql
@@ -1285,16 +1285,20 @@ EXPLAIN (verbose, costs off)
UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3; -- can be pushed down
UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3;
EXPLAIN (verbose, costs off)
-UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *; -- can be pushed down
-UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *;
+WITH t AS (UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *)
+SELECT * FROM t ORDER BY c1; -- can be pushed down
+WITH t AS (UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *)
+SELECT * FROM t ORDER BY c1;
EXPLAIN (verbose, costs off)
UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9; -- can be pushed down
UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9;
EXPLAIN (verbose, costs off)
- DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4; -- can be pushed down
-DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4;
+ WITH t AS (DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4)
+ SELECT * FROM t ORDER BY c1; -- can be pushed down
+WITH t AS (DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4)
+SELECT * FROM t ORDER BY c1;
EXPLAIN (verbose, costs off)
DELETE FROM ft2 USING ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 2; -- can be pushed down
DELETE FROM ft2 USING ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 2;
@@ -1401,7 +1405,8 @@ CREATE TRIGGER t1_br_insert BEFORE INSERT OR UPDATE
INSERT INTO ft2 (c1,c2,c3) VALUES (1208, 818, 'fff') RETURNING *;
INSERT INTO ft2 (c1,c2,c3,c6) VALUES (1218, 818, 'ggg', '(--;') RETURNING *;
-UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *;
+WITH t AS (UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *)
+SELECT * FROM t ORDER BY c1;
-- Test errors thrown on remote side during update
ALTER TABLE "S 1"."T 1" ADD CONSTRAINT c2positive CHECK (c2 >= 0);
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 7e355585a0..9ce239bbbf 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -640,10 +640,10 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
result = PointerGetDatum(&(tup->t_self));
break;
case MinTransactionIdAttributeNumber:
- result = TransactionIdGetDatum(HeapTupleHeaderGetRawXmin(tup->t_data));
+ result = TransactionIdGetDatum(HeapTupleGetRawXmin(tup));
break;
case MaxTransactionIdAttributeNumber:
- result = TransactionIdGetDatum(HeapTupleHeaderGetRawXmax(tup->t_data));
+ result = TransactionIdGetDatum(HeapTupleGetRawXmax(tup));
break;
case MinCommandIdAttributeNumber:
case MaxCommandIdAttributeNumber:
@@ -688,6 +688,7 @@ heap_copytuple(HeapTuple tuple)
newTuple->t_len = tuple->t_len;
newTuple->t_self = tuple->t_self;
newTuple->t_tableOid = tuple->t_tableOid;
+ HeapTupleCopyBase(newTuple, tuple);
newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
memcpy((char *) newTuple->t_data, (char *) tuple->t_data, tuple->t_len);
return newTuple;
@@ -714,6 +715,7 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
dest->t_len = src->t_len;
dest->t_self = src->t_self;
dest->t_tableOid = src->t_tableOid;
+ HeapTupleCopyBase(dest, src);
dest->t_data = (HeapTupleHeader) palloc(src->t_len);
memcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);
}
@@ -1161,6 +1163,7 @@ heap_modify_tuple(HeapTuple tuple,
newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
newTuple->t_self = tuple->t_self;
newTuple->t_tableOid = tuple->t_tableOid;
+ HeapTupleCopyBase(newTuple, tuple);
return newTuple;
}
@@ -1224,6 +1227,7 @@ heap_modify_tuple_by_cols(HeapTuple tuple,
newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
newTuple->t_self = tuple->t_self;
newTuple->t_tableOid = tuple->t_tableOid;
+ HeapTupleCopyBase(newTuple, tuple);
return newTuple;
}
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index b0993f37d4..1da7f572c3 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -260,58 +260,6 @@ static relopt_int intRelOpts[] =
},
-1, 1, 10000
},
- {
- {
- "autovacuum_freeze_min_age",
- "Minimum age at which VACUUM should freeze a table row, for autovacuum",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- },
- -1, 0, 1000000000
- },
- {
- {
- "autovacuum_multixact_freeze_min_age",
- "Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- },
- -1, 0, 1000000000
- },
- {
- {
- "autovacuum_freeze_max_age",
- "Age at which to autovacuum a table to prevent transaction ID wraparound",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- },
- -1, 100000, 2000000000
- },
- {
- {
- "autovacuum_multixact_freeze_max_age",
- "Multixact age at which to autovacuum a table to prevent multixact wraparound",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- },
- -1, 10000, 2000000000
- },
- {
- {
- "autovacuum_freeze_table_age",
- "Age at which VACUUM should perform a full table sweep to freeze row versions",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- }, -1, 0, 2000000000
- },
- {
- {
- "autovacuum_multixact_freeze_table_age",
- "Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
- RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
- ShareUpdateExclusiveLock
- }, -1, 0, 2000000000
- },
{
{
"log_autovacuum_min_duration",
@@ -388,6 +336,60 @@ static relopt_int intRelOpts[] =
static relopt_int64 int64RelOpts[] =
{
+ {
+ {
+ "autovacuum_freeze_min_age",
+ "Minimum age at which VACUUM should freeze a table row, for autovacuum",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(0), INT64CONST(1000000000)
+ },
+ {
+ {
+ "autovacuum_multixact_freeze_min_age",
+ "Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(0), INT64CONST(1000000000)
+ },
+ {
+ {
+ "autovacuum_freeze_max_age",
+ "Age at which to autovacuum a table to prevent transaction ID wraparound",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(100000), INT64CONST(2000000000)
+ },
+ {
+ {
+ "autovacuum_multixact_freeze_max_age",
+ "Multixact age at which to autovacuum a table to prevent multixact wraparound",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(10000), INT64CONST(2000000000)
+ },
+ {
+ {
+ "autovacuum_freeze_table_age",
+ "Age at which VACUUM should perform a full table sweep to freeze row versions",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(0), INT64CONST(2000000000)
+ },
+ {
+ {
+ "autovacuum_multixact_freeze_table_age",
+ "Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
+ RELOPT_KIND_HEAP | RELOPT_KIND_TOAST,
+ ShareUpdateExclusiveLock
+ },
+ INT64CONST(-1), INT64CONST(0), INT64CONST(2000000000)
+ },
/* list terminator */
{{NULL}}
};
@@ -1920,17 +1922,17 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
{"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)},
- {"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
+ {"autovacuum_freeze_min_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
- {"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
+ {"autovacuum_freeze_max_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
- {"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
+ {"autovacuum_freeze_table_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
- {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
+ {"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
- {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
+ {"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
- {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
+ {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT64,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
{"log_autovacuum_min_duration", RELOPT_TYPE_INT,
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_min_duration)},
diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c
index 10bf26ce7c..83e033b93c 100644
--- a/src/backend/access/hash/hashvalidate.c
+++ b/src/backend/access/hash/hashvalidate.c
@@ -317,11 +317,10 @@ check_hash_func_signature(Oid funcid, int16 amprocnum, Oid argtype)
* INTERNAL and allowing any such function seems too scary.
*/
if ((funcid == F_HASHINT4 || funcid == F_HASHINT4EXTENDED) &&
- (argtype == DATEOID ||
- argtype == XIDOID || argtype == CIDOID))
+ (argtype == DATEOID || argtype == CIDOID))
/* okay, allowed use of hashint4() */ ;
else if ((funcid == F_HASHINT8 || funcid == F_HASHINT8EXTENDED) &&
- (argtype == XID8OID))
+ (argtype == XID8OID || argtype == XIDOID))
/* okay, allowed use of hashint8() */ ;
else if ((funcid == F_TIMESTAMP_HASH ||
funcid == F_TIMESTAMP_HASH_EXTENDED) &&
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 685200d154..5bc35a28d8 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -52,10 +52,14 @@
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
+#include "catalog/index.h"
+#include "catalog/namespace.h"
+#include "commands/vacuum.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "port/atomics.h"
#include "port/pg_bitutils.h"
+#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "storage/freespace.h"
#include "storage/lmgr.h"
@@ -73,7 +77,7 @@
static HeapTuple heap_prepare_insert(Relation relation, HeapTuple tup,
- TransactionId xid, CommandId cid, int options);
+ CommandId cid, int options);
static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
Buffer newbuf, HeapTuple oldtup,
HeapTuple newtup, HeapTuple old_key_tuple,
@@ -110,6 +114,8 @@ static int bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate);
static XLogRecPtr log_heap_new_cid(Relation relation, HeapTuple tup);
static HeapTuple ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
bool *copy);
+static bool heap_page_prepare_for_xid(Relation relation, Buffer buffer,
+ TransactionId xid, bool multi);
/*
@@ -460,6 +466,8 @@ heapgetpage(TableScanDesc sscan, BlockNumber page)
loctup.t_tableOid = RelationGetRelid(scan->rs_base.rs_rd);
loctup.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
loctup.t_len = ItemIdGetLength(lpp);
+ HeapTupleCopyBaseFromPage(buffer, &loctup, dp,
+ IsToastRelation(scan->rs_base.rs_rd));
ItemPointerSet(&(loctup.t_self), page, lineoff);
if (all_visible)
@@ -676,6 +684,8 @@ heapgettup(HeapScanDesc scan,
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp);
+ HeapTupleCopyBaseFromPage(scan->rs_cbuf, tuple, dp,
+ IsToastRelation(scan->rs_base.rs_rd));
return;
}
@@ -702,6 +712,8 @@ heapgettup(HeapScanDesc scan,
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp);
+ HeapTupleCopyBaseFromPage(scan->rs_cbuf, tuple, dp,
+ IsToastRelation(scan->rs_base.rs_rd));
ItemPointerSet(&(tuple->t_self), page, lineoff);
/*
@@ -1001,6 +1013,8 @@ heapgettup_pagemode(HeapScanDesc scan,
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp);
+ HeapTupleCopyBaseFromPage(InvalidBuffer, tuple, dp,
+ IsToastRelation(scan->rs_base.rs_rd));
/* check that rs_cindex is in sync */
Assert(scan->rs_cindex < scan->rs_ntuples);
@@ -1023,6 +1037,8 @@ heapgettup_pagemode(HeapScanDesc scan,
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp);
+ HeapTupleCopyBaseFromPage(InvalidBuffer, tuple, dp,
+ IsToastRelation(scan->rs_base.rs_rd));
ItemPointerSet(&(tuple->t_self), page, lineoff);
/*
@@ -1614,6 +1630,7 @@ heap_fetch(Relation relation,
tuple->t_data = (HeapTupleHeader) PageGetItem(page, lp);
tuple->t_len = ItemIdGetLength(lp);
tuple->t_tableOid = RelationGetRelid(relation);
+ HeapTupleCopyBaseFromPage(buffer, tuple, page, IsToastRelation(relation));
/*
* check tuple visibility, then release lock
@@ -1622,7 +1639,7 @@ heap_fetch(Relation relation,
if (valid)
PredicateLockTID(relation, &(tuple->t_self), snapshot,
- HeapTupleHeaderGetXmin(tuple->t_data));
+ HeapTupleGetXmin(tuple));
HeapCheckForSerializableConflictOut(valid, relation, tuple, buffer, snapshot);
@@ -1699,6 +1716,8 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
Assert(TransactionIdIsValid(RecentXmin));
Assert(BufferGetBlockNumber(buffer) == blkno);
+ heapTuple->t_self = *tid;
+
/* Scan through possible multiple members of HOT-chain */
for (;;)
{
@@ -1734,6 +1753,8 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
heapTuple->t_data = (HeapTupleHeader) PageGetItem(dp, lp);
heapTuple->t_len = ItemIdGetLength(lp);
heapTuple->t_tableOid = RelationGetRelid(relation);
+ HeapTupleCopyBaseFromPage(buffer, heapTuple, dp,
+ IsToastRelation(relation));
ItemPointerSet(&heapTuple->t_self, blkno, offnum);
/*
@@ -1748,7 +1769,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
*/
if (TransactionIdIsValid(prev_xmax) &&
!TransactionIdEquals(prev_xmax,
- HeapTupleHeaderGetXmin(heapTuple->t_data)))
+ HeapTupleGetXmin(heapTuple)))
break;
/*
@@ -1769,7 +1790,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
{
ItemPointerSetOffsetNumber(tid, offnum);
PredicateLockTID(relation, &heapTuple->t_self, snapshot,
- HeapTupleHeaderGetXmin(heapTuple->t_data));
+ HeapTupleGetXmin(heapTuple));
if (all_dead)
*all_dead = false;
return true;
@@ -1804,7 +1825,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
blkno);
offnum = ItemPointerGetOffsetNumber(&heapTuple->t_data->t_ctid);
at_chain_start = false;
- prev_xmax = HeapTupleHeaderGetUpdateXid(heapTuple->t_data);
+ prev_xmax = HeapTupleGetUpdateXidAny(heapTuple);
}
else
break; /* end of chain */
@@ -1891,13 +1912,14 @@ heap_get_latest_tid(TableScanDesc sscan,
tp.t_data = (HeapTupleHeader) PageGetItem(page, lp);
tp.t_len = ItemIdGetLength(lp);
tp.t_tableOid = RelationGetRelid(relation);
+ HeapTupleCopyBaseFromPage(buffer, &tp, page, IsToastRelation(relation));
/*
* After following a t_ctid link, we might arrive at an unrelated
* tuple. Check for XMIN match.
*/
if (TransactionIdIsValid(priorXmax) &&
- !TransactionIdEquals(priorXmax, HeapTupleHeaderGetXmin(tp.t_data)))
+ !TransactionIdEquals(priorXmax, HeapTupleGetXmin(&tp)))
{
UnlockReleaseBuffer(buffer);
break;
@@ -1916,7 +1938,7 @@ heap_get_latest_tid(TableScanDesc sscan,
* If there's a valid t_ctid link, follow it, else we're done.
*/
if ((tp.t_data->t_infomask & HEAP_XMAX_INVALID) ||
- HeapTupleHeaderIsOnlyLocked(tp.t_data) ||
+ HeapTupleIsOnlyLocked(&tp) ||
HeapTupleHeaderIndicatesMovedPartitions(tp.t_data) ||
ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid))
{
@@ -1925,7 +1947,7 @@ heap_get_latest_tid(TableScanDesc sscan,
}
ctid = tp.t_data->t_ctid;
- priorXmax = HeapTupleHeaderGetUpdateXid(tp.t_data);
+ priorXmax = HeapTupleGetUpdateXidAny(&tp);
UnlockReleaseBuffer(buffer);
} /* end of loop */
}
@@ -1950,7 +1972,7 @@ heap_get_latest_tid(TableScanDesc sscan,
static void
UpdateXmaxHintBits(HeapTupleHeader tuple, Buffer buffer, TransactionId xid)
{
- Assert(TransactionIdEquals(HeapTupleHeaderGetRawXmax(tuple), xid));
+ Assert(TransactionIdEquals(HeapTupleHeaderGetRawXmax(BufferGetPage(buffer), tuple), xid));
Assert(!(tuple->t_infomask & HEAP_XMAX_IS_MULTI));
if (!(tuple->t_infomask & (HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID)))
@@ -2042,7 +2064,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
* Note: below this point, heaptup is the data we actually intend to store
* into the relation; tup is the caller's original untoasted data.
*/
- heaptup = heap_prepare_insert(relation, tup, xid, cid, options);
+ heaptup = heap_prepare_insert(relation, tup, cid, options);
/*
* Find buffer to insert this tuple into. If the page is all visible,
@@ -2069,6 +2091,9 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
*/
CheckForSerializableConflictIn(relation, NULL, InvalidBlockNumber);
+ heap_page_prepare_for_xid(relation, buffer, xid, false);
+ HeapTupleSetXmin(heaptup, xid);
+
/* NO EREPORT(ERROR) from here till changes are logged */
START_CRIT_SECTION();
@@ -2144,12 +2169,23 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
{
xlrec.flags |= XLH_INSERT_CONTAINS_NEW_TUPLE;
bufflags |= REGBUF_KEEP_DATA;
-
- if (IsToastRelation(relation))
- xlrec.flags |= XLH_INSERT_ON_TOAST_RELATION;
}
+ if (IsToastRelation(relation))
+ xlrec.flags |= XLH_INSERT_ON_TOAST_RELATION;
+
XLogBeginInsert();
+
+ if (info & XLOG_HEAP_INIT_PAGE)
+ {
+ char *base;
+
+ base = IsToastRelation(relation) ?
+ (char *) &ToastPageGetSpecial(page)->pd_xid_base :
+ (char *) &HeapPageGetSpecial(page)->pd_xid_base;
+ XLogRegisterData(base, sizeof(TransactionId));
+ }
+
XLogRegisterData((char *) &xlrec, SizeOfHeapInsert);
xlhdr.t_infomask2 = heaptup->t_data->t_infomask2;
@@ -2204,6 +2240,535 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
}
}
+static void
+xid_min_max(ShortTransactionId *min, ShortTransactionId *max,
+ ShortTransactionId xid,
+ bool *found)
+{
+ Assert(TransactionIdIsNormal(xid));
+ Assert(xid <= MaxShortTransactionId);
+
+ if (!*found)
+ {
+ *min = *max = xid;
+ *found = true;
+ }
+ else
+ {
+ *min = Min(*min, xid);
+ *max = Max(*max, xid);
+ }
+}
+
+/*
+ * Find minimum and maximum short transaction ids which occurs in the page.
+ *
+ * Works for multi and non multi transaction. Which is defined by "multi"
+ * argument.
+ */
+static bool
+heap_page_xid_min_max(Page page, bool multi,
+ ShortTransactionId *min, ShortTransactionId *max,
+ bool is_toast)
+{
+ bool found;
+ OffsetNumber offnum,
+ maxoff;
+ ItemId itemid;
+ HeapTupleHeader htup;
+
+ maxoff = PageGetMaxOffsetNumber(page);
+ found = false;
+
+ Assert(!multi || !is_toast);
+
+ for (offnum = FirstOffsetNumber;
+ offnum <= maxoff;
+ offnum = OffsetNumberNext(offnum))
+ {
+ itemid = PageGetItemId(page, offnum);
+
+ if (!ItemIdIsNormal(itemid))
+ continue;
+
+ htup = (HeapTupleHeader) PageGetItem(page, itemid);
+
+ if (!multi)
+ {
+ /*
+ * For non multi transactions we should see inside the tuple for
+ * update transaction.
+ */
+ Assert(!is_toast || !(htup->t_infomask & HEAP_XMAX_IS_MULTI));
+
+ if (TransactionIdIsNormal(htup->t_choice.t_heap.t_xmin) &&
+ !HeapTupleHeaderXminFrozen(htup))
+ {
+ xid_min_max(min, max, htup->t_choice.t_heap.t_xmin, &found);
+ }
+
+ if ((htup->t_infomask & HEAP_XMAX_IS_MULTI) &&
+ (!(htup->t_infomask & HEAP_XMAX_LOCK_ONLY)))
+ {
+ TransactionId update_xid;
+ ShortTransactionId xid;
+
+ Assert(!is_toast);
+ update_xid = MultiXactIdGetUpdateXid(HeapTupleHeaderGetRawXmax(page, htup),
+ htup->t_infomask);
+ xid = NormalTransactionIdToShort(HeapPageGetSpecial(page)->pd_xid_base,
+ update_xid);
+
+ xid_min_max(min, max, xid, &found);
+ }
+ }
+
+ if (!TransactionIdIsNormal(htup->t_choice.t_heap.t_xmax))
+ continue;
+
+ if (multi != ((htup->t_infomask & HEAP_XMAX_IS_MULTI) != 0))
+ continue;
+
+ xid_min_max(min, max, htup->t_choice.t_heap.t_xmax, &found);
+ }
+
+ Assert(!found || (*min > InvalidTransactionId && *max <= MaxShortTransactionId));
+
+ return found;
+}
+
+/*
+ * Shift xid base in the page. WAL-logged if buffer is specified.
+ */
+static void
+heap_page_shift_base(Relation relation, Buffer buffer, Page page,
+ bool multi, int64 delta, bool is_toast)
+{
+ TransactionId *xid_base,
+ *multi_base;
+ OffsetNumber offnum,
+ maxoff;
+ ItemId itemid;
+ HeapTupleHeader htup;
+
+ Assert(IsBufferLockedExclusive(buffer));
+
+ xid_base = multi_base = NULL;
+
+ START_CRIT_SECTION();
+
+ if (is_toast)
+ {
+ Assert(!multi);
+ xid_base = &ToastPageGetSpecial(page)->pd_xid_base;
+ }
+ else
+ {
+ HeapPageSpecial special;
+
+ special = HeapPageGetSpecial(page);
+ xid_base = &special->pd_xid_base;
+ multi_base = &special->pd_multi_base;
+ }
+
+ /* Iterate over page items */
+ maxoff = PageGetMaxOffsetNumber(page);
+ for (offnum = FirstOffsetNumber;
+ offnum <= maxoff;
+ offnum = OffsetNumberNext(offnum))
+ {
+ itemid = PageGetItemId(page, offnum);
+
+ if (!ItemIdIsNormal(itemid))
+ continue;
+
+ htup = (HeapTupleHeader) PageGetItem(page, itemid);
+
+ /* Apply xid shift to heap tuple */
+ if (!multi)
+ {
+ /* shift xmin */
+ if (TransactionIdIsNormal(htup->t_choice.t_heap.t_xmin) &&
+ !HeapTupleHeaderXminFrozen(htup))
+ {
+ Assert(htup->t_choice.t_heap.t_xmin - delta >= FirstNormalTransactionId);
+ Assert(htup->t_choice.t_heap.t_xmin - delta <= MaxShortTransactionId);
+ htup->t_choice.t_heap.t_xmin -= delta;
+ }
+ }
+
+ /* shift xmax */
+ if (!TransactionIdIsNormal(htup->t_choice.t_heap.t_xmax))
+ continue;
+
+ if (multi != (bool) (htup->t_infomask & HEAP_XMAX_IS_MULTI))
+ continue;
+
+ Assert(htup->t_choice.t_heap.t_xmax - delta >= FirstNormalTransactionId);
+ Assert(htup->t_choice.t_heap.t_xmax - delta <= MaxShortTransactionId);
+ htup->t_choice.t_heap.t_xmax -= delta;
+ }
+
+ /* Apply xid shift to base as well */
+ if (!multi)
+ *xid_base += delta;
+ else
+ *multi_base += delta;
+
+ if (BufferIsValid(buffer))
+ MarkBufferDirty(buffer);
+
+ /* Write WAL record if needed */
+ if (relation && RelationNeedsWAL(relation))
+ {
+ XLogRecPtr recptr;
+ xl_heap_base_shift xlrec;
+
+ xlrec.delta = delta;
+ xlrec.multi = multi;
+ xlrec.flags = 0;
+ if (IsToastRelation(relation))
+ xlrec.flags |= XLH_BASE_SHIFT_ON_TOAST_RELATION;
+
+ XLogBeginInsert();
+ XLogRegisterData((char *) &xlrec, SizeOfHeapBaseShift);
+ XLogRegisterBuffer(0, buffer, REGBUF_STANDARD);
+
+ recptr = XLogInsert(RM_HEAP3_ID, XLOG_HEAP3_BASE_SHIFT);
+
+ PageSetLSN(page, recptr);
+ }
+
+ END_CRIT_SECTION();
+}
+
+/*
+ * Freeze xids in the single heap page. Useful when we can't fit new xid even
+ * with base shift.
+ */
+static void
+freeze_single_heap_page(Relation relation, Buffer buffer)
+{
+ Page page = BufferGetPage(buffer);
+ OffsetNumber offnum,
+ maxoff;
+ HeapTupleData tuple;
+ int nfrozen = 0;
+ xl_heap_freeze_tuple *frozen;
+ TransactionId OldestXmin,
+ FreezeXid;
+ MultiXactId OldestMxact,
+ MultiXactCutoff;
+ GlobalVisState *vistest;
+ ItemId itemid;
+ bool tuple_totally_frozen;
+ int ndeleted,
+ nnewlpdead;
+
+ vacuum_set_xid_limits(relation, 0, 0, 0, 0, &OldestMxact,
+ &OldestXmin, &FreezeXid, &MultiXactCutoff);
+
+ vistest = GlobalVisTestFor(relation);
+
+ ndeleted = heap_page_prune(relation, buffer, vistest, InvalidTransactionId, 0,
+ &nnewlpdead, &offnum, false);
+ if (ndeleted > nnewlpdead)
+ pgstat_update_heap_dead_tuples(relation,
+ ndeleted - nnewlpdead);
+
+ /*
+ * Now scan the page to collect vacuumable items and check for tuples
+ * requiring freezing.
+ */
+ maxoff = PageGetMaxOffsetNumber(page);
+ frozen = palloc(sizeof(xl_heap_freeze_tuple) * MaxHeapTuplesPerPage);
+
+ /*
+ * Note: If you change anything in the loop below, also look at
+ * heap_page_is_all_visible to see if that needs to be changed.
+ */
+ for (offnum = FirstOffsetNumber;
+ offnum <= maxoff;
+ offnum = OffsetNumberNext(offnum))
+ {
+ TransactionId NewRelfrozenXid;
+ MultiXactId NewRelminMxid;
+
+ itemid = PageGetItemId(page, offnum);
+
+ if (!ItemIdIsNormal(itemid))
+ continue;
+
+ tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+ tuple.t_len = ItemIdGetLength(itemid);
+ tuple.t_tableOid = RelationGetRelid(relation);
+ HeapTupleCopyBaseFromPage(buffer, &tuple, page,
+ IsToastRelation(relation));
+
+ /*
+ * Each non-removable tuple must be checked to see if it needs
+ * freezing. Note we already have exclusive buffer lock.
+ */
+ if (heap_prepare_freeze_tuple(&tuple,
+ relation->rd_rel->relfrozenxid,
+ relation->rd_rel->relminmxid,
+ FreezeXid, MultiXactCutoff,
+ &frozen[nfrozen], &tuple_totally_frozen,
+ &NewRelfrozenXid, &NewRelminMxid))
+ frozen[nfrozen++].offset = offnum;
+ }
+
+ /*
+ * If we froze any tuples, mark the buffer dirty, and write a WAL record
+ * recording the changes. We must log the changes to be crash-safe
+ * against future truncation of CLOG.
+ */
+ if (nfrozen > 0)
+ {
+ int i;
+ ItemId itemid;
+ HeapTupleHeader htup;
+
+ START_CRIT_SECTION();
+
+ MarkBufferDirty(buffer);
+
+ /* execute collected freezes */
+ for (i = 0; i < nfrozen; i++)
+ {
+ itemid = PageGetItemId(page, frozen[i].offset);
+ htup = (HeapTupleHeader) PageGetItem(page, itemid);
+ heap_execute_freeze_tuple_page(page, htup, &frozen[i],
+ IsToastRelation(relation));
+ }
+
+ /* Now WAL-log freezing if necessary */
+ if (RelationNeedsWAL(relation))
+ {
+ XLogRecPtr recptr;
+
+ recptr = log_heap_freeze(relation, buffer, FreezeXid,
+ frozen, nfrozen);
+ PageSetLSN(page, recptr);
+ }
+
+ END_CRIT_SECTION();
+ }
+
+ pfree(frozen);
+
+ return;
+}
+
+/*
+ * Check if xid still fits on a page with given base and delta.
+ */
+static inline bool
+is_delta_fits_heap_page(TransactionId xid, TransactionId base, int64 delta)
+{
+ return xid >= base + delta + FirstNormalTransactionId &&
+ xid <= base + delta + MaxShortTransactionId;
+}
+
+/*
+ * Check if xid fits on a page with given base.
+ */
+static inline bool
+is_xid_fits_heap_page(TransactionId xid, TransactionId base)
+{
+ return xid >= base + FirstNormalTransactionId &&
+ xid <= base + MaxShortTransactionId;
+}
+
+/*
+ * Check if delta fits on a page.
+ *
+ * If delta does not fits, never return.
+ */
+static void
+heap_page_check_delta(Buffer buffer,
+ TransactionId xid, TransactionId base,
+ ShortTransactionId min, ShortTransactionId max,
+ int64 delta, int64 *freeDelta, int64 *requiredDelta)
+{
+ BufferDesc *buf;
+ char *path;
+ BackendId backend;
+
+ Assert((freeDelta == NULL) == (requiredDelta == NULL));
+
+ /*
+ * If delta fits the page, we good to go ...
+ */
+ if (is_delta_fits_heap_page(xid, base, delta))
+ return;
+
+ /*
+ * ... otherwise handle the error.
+ */
+ if (buffer == InvalidBuffer)
+ return;
+
+ if (BufferIsLocal(buffer))
+ {
+ buf = GetLocalBufferDescriptor(-buffer - 1);
+ backend = MyBackendId;
+ }
+ else
+ {
+ buf = GetBufferDescriptor(buffer - 1);
+ backend = InvalidBackendId;
+ }
+
+ path = relpathbackend(BufTagGetRelFileLocator(&buf->tag), backend,
+ buf->tag.forkNum);
+
+ if (freeDelta == NULL)
+ elog(FATAL, "Fatal xid base calculation error: xid = %llu, base = %llu, min = %u, max = %u, delta = %lld (rel=%s, blockNum=%u)",
+ (unsigned long long) xid, (unsigned long long) base,
+ min, max,
+ (long long) delta,
+ path, buf->tag.blockNum);
+
+ elog(FATAL, "Fatal xid base calculation error: xid = %llu, base = %llu, min = %u, max = %u, freeDelta = %lld, requiredDelta = %lld, delta = %lld (rel=%s, blockNum=%u)",
+ (unsigned long long) xid, (unsigned long long) base,
+ min, max,
+ (long long) *freeDelta, (long long) *requiredDelta,
+ (long long) delta,
+ path, buf->tag.blockNum);
+}
+
+/*
+ * Shift page base.
+ */
+static void
+heap_page_apply_delta(Relation relation, Buffer buffer, Page page,
+ TransactionId xid, bool multi,
+ TransactionId base, int64 delta, bool is_toast)
+{
+ Assert(is_delta_fits_heap_page(xid, base, delta));
+
+ heap_page_shift_base(relation, buffer, page, multi, delta, is_toast);
+
+#ifdef USE_ASSERT_CHECKING
+ if (is_toast)
+ {
+ Assert(!multi);
+ base = ToastPageGetSpecial(page)->pd_xid_base;
+ }
+ else
+ base = multi ? HeapPageGetSpecial(page)->pd_multi_base :
+ HeapPageGetSpecial(page)->pd_xid_base;
+
+ Assert(is_xid_fits_heap_page(xid, base));
+#endif /* USE_ASSERT_CHECKING */
+}
+
+/*
+ * Try to fit xid on a page.
+ */
+static int
+heap_page_try_prepare_for_xid(Relation relation, Buffer buffer, Page page,
+ TransactionId xid, bool multi, bool is_toast)
+{
+ TransactionId base;
+ ShortTransactionId min = InvalidTransactionId,
+ max = InvalidTransactionId;
+ int64 delta,
+ freeDelta,
+ requiredDelta;
+
+ if (is_toast)
+ {
+ Assert(!multi);
+ base = ToastPageGetSpecial(page)->pd_xid_base;
+ }
+ else
+ {
+ HeapPageSpecial special;
+
+ special = HeapPageGetSpecial(page);
+ base = multi ? special->pd_multi_base : special->pd_xid_base;
+ }
+
+ /* If xid fits the page no action needed. */
+ if (is_xid_fits_heap_page(xid, base))
+ return 0;
+
+ /* No items on the page? */
+ if (!heap_page_xid_min_max(page, multi, &min, &max, is_toast))
+ {
+ delta = (int64) (xid - FirstNormalTransactionId) - (int64) base;
+ heap_page_check_delta(buffer, xid, base, min, max, delta, NULL, NULL);
+ heap_page_apply_delta(relation, buffer, page, xid, multi, base, delta,
+ is_toast);
+ return 0;
+ }
+
+ /* Can we just shift base on the page? */
+ if (xid < base + FirstNormalTransactionId)
+ {
+ freeDelta = MaxShortTransactionId - max;
+ requiredDelta = (base + FirstNormalTransactionId) - xid;
+ /* Shouldn't consider setting base less than 0 */
+ freeDelta = Min(freeDelta, base);
+
+ if (requiredDelta > freeDelta)
+ return -1;
+
+ delta = -(freeDelta + requiredDelta) / 2;
+ }
+ else
+ {
+ freeDelta = min - FirstNormalTransactionId;
+ requiredDelta = xid - (base + MaxShortTransactionId);
+
+ if (requiredDelta > freeDelta)
+ return -1;
+
+ delta = (freeDelta + requiredDelta) / 2;
+ }
+
+ heap_page_check_delta(buffer, xid, base, min, max,
+ delta, &freeDelta, &requiredDelta);
+ heap_page_apply_delta(relation, buffer, page, xid, multi, base,
+ delta, is_toast);
+
+ return 0;
+}
+
+/*
+ * Ensure that given xid fits base of given page.
+ */
+void
+rewrite_page_prepare_for_xid(Page page, HeapTuple tup, bool is_toast)
+{
+ TransactionId xid;
+ int res;
+
+ /* xmin */
+ xid = HeapTupleGetXmin(tup);
+ if (TransactionIdIsNormal(xid))
+ {
+ res = heap_page_try_prepare_for_xid(NULL, InvalidBuffer, page, xid,
+ false, is_toast);
+ if (res == -1)
+ elog(ERROR, "could not fit xid into page");
+ }
+
+ /* xmax */
+ xid = HeapTupleGetRawXmax(tup);
+ if (TransactionIdIsNormal(xid))
+ {
+ res = heap_page_try_prepare_for_xid(NULL, InvalidBuffer, page, xid,
+ tup->t_data->t_infomask & HEAP_XMAX_IS_MULTI,
+ is_toast);
+ if (res == -1)
+ elog(ERROR, "could not fit xid into page");
+ }
+}
+
+
/*
* Subroutine for heap_insert(). Prepares a tuple for insertion. This sets the
* tuple header fields and toasts the tuple if necessary. Returns a toasted
@@ -2211,7 +2776,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
* that in any case, the header fields are also set in the original tuple.
*/
static HeapTuple
-heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
+heap_prepare_insert(Relation relation, HeapTuple tup,
CommandId cid, int options)
{
/*
@@ -2228,12 +2793,12 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
tup->t_data->t_infomask2 &= ~(HEAP2_XACT_MASK);
tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
- HeapTupleHeaderSetXmin(tup->t_data, xid);
+ HeapTupleSetXmin(tup, InvalidTransactionId);
if (options & HEAP_INSERT_FROZEN)
HeapTupleHeaderSetXminFrozen(tup->t_data);
HeapTupleHeaderSetCmin(tup->t_data, cid);
- HeapTupleHeaderSetXmax(tup->t_data, 0); /* for cleanliness */
+ HeapTupleSetXmax(tup, 0); /* for cleanliness */
tup->t_tableOid = RelationGetRelid(relation);
/*
@@ -2296,8 +2861,7 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
tuple = ExecFetchSlotHeapTuple(slots[i], true, NULL);
slots[i]->tts_tableOid = RelationGetRelid(relation);
tuple->t_tableOid = slots[i]->tts_tableOid;
- heaptuples[i] = heap_prepare_insert(relation, tuple, xid, cid,
- options);
+ heaptuples[i] = heap_prepare_insert(relation, tuple, cid, options);
}
/*
@@ -2353,6 +2917,8 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
if (starting_with_empty_page && (options & HEAP_INSERT_FROZEN))
all_frozen_set = true;
+ heap_page_prepare_for_xid(relation, buffer, xid, false);
+
/* NO EREPORT(ERROR) from here till changes are logged */
START_CRIT_SECTION();
@@ -2360,6 +2926,7 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
* RelationGetBufferForTuple has ensured that the first tuple fits.
* Put that on the page, and then as many other tuples as fit.
*/
+ HeapTupleSetXmin(heaptuples[ndone], xid);
RelationPutHeapTuple(relation, buffer, heaptuples[ndone], false);
/*
@@ -2376,6 +2943,7 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
if (PageGetHeapFreeSpace(page) < MAXALIGN(heaptup->t_len) + saveFreeSpace)
break;
+ HeapTupleSetXmin(heaptup, xid);
RelationPutHeapTuple(relation, buffer, heaptup, false);
/*
@@ -2511,6 +3079,17 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
bufflags |= REGBUF_KEEP_DATA;
XLogBeginInsert();
+
+ if (info & XLOG_HEAP_INIT_PAGE)
+ {
+ char *base;
+
+ base = IsToastRelation(relation) ?
+ (char *) &ToastPageGetSpecial(page)->pd_xid_base :
+ (char *) &HeapPageGetSpecial(page)->pd_xid_base;
+ XLogRegisterData(base, sizeof(TransactionId));
+ }
+
XLogRegisterData((char *) xlrec, tupledata - scratch.data);
XLogRegisterBuffer(0, buffer, REGBUF_STANDARD | bufflags);
@@ -2718,6 +3297,7 @@ heap_delete(Relation relation, ItemPointer tid,
tp.t_data = (HeapTupleHeader) PageGetItem(page, lp);
tp.t_len = ItemIdGetLength(lp);
tp.t_self = *tid;
+ HeapTupleCopyBaseFromPage(buffer, &tp, page, IsToastRelation(relation));
l1:
/*
@@ -2748,7 +3328,7 @@ l1:
uint16 infomask;
/* must copy state data before unlocking buffer */
- xwait = HeapTupleHeaderGetRawXmax(tp.t_data);
+ xwait = HeapTupleGetRawXmax(&tp);
infomask = tp.t_data->t_infomask;
/*
@@ -2787,6 +3367,10 @@ l1:
NULL);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ /* Copy possibly updated xid base after relocking */
+ HeapTupleCopyBaseFromPage(buffer, &tp, page,
+ IsToastRelation(relation));
+
/*
* If xwait had just locked the tuple then some other xact
* could update this tuple before we get to this point. Check
@@ -2797,7 +3381,7 @@ l1:
*/
if ((vmbuffer == InvalidBuffer && PageIsAllVisible(page)) ||
xmax_infomask_changed(tp.t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tp.t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(&tp),
xwait))
goto l1;
}
@@ -2824,6 +3408,10 @@ l1:
XactLockTableWait(xwait, relation, &(tp.t_self), XLTW_Delete);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ /* Copy possibly updated xid base after relocking */
+ HeapTupleCopyBaseFromPage(buffer, &tp, page,
+ IsToastRelation(relation));
+
/*
* xwait is done, but if xwait had just locked the tuple then some
* other xact could update this tuple before we get to this point.
@@ -2834,7 +3422,7 @@ l1:
*/
if ((vmbuffer == InvalidBuffer && PageIsAllVisible(page)) ||
xmax_infomask_changed(tp.t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tp.t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(&tp),
xwait))
goto l1;
@@ -2848,7 +3436,7 @@ l1:
*/
if ((tp.t_data->t_infomask & HEAP_XMAX_INVALID) ||
HEAP_XMAX_IS_LOCKED_ONLY(tp.t_data->t_infomask) ||
- HeapTupleHeaderIsOnlyLocked(tp.t_data))
+ HeapTupleIsOnlyLocked(&tp))
result = TM_Ok;
else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid))
result = TM_Updated;
@@ -2873,9 +3461,9 @@ l1:
Assert(result != TM_Updated ||
!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid));
tmfd->ctid = tp.t_data->t_ctid;
- tmfd->xmax = HeapTupleHeaderGetUpdateXid(tp.t_data);
+ tmfd->xmax = HeapTupleGetUpdateXidAny(&tp);
if (result == TM_SelfModified)
- tmfd->cmax = HeapTupleHeaderGetCmax(tp.t_data);
+ tmfd->cmax = HeapTupleGetCmax(&tp);
else
tmfd->cmax = InvalidCommandId;
UnlockReleaseBuffer(buffer);
@@ -2898,7 +3486,7 @@ l1:
CheckForSerializableConflictIn(relation, tid, BufferGetBlockNumber(buffer));
/* replace cid with a combo CID if necessary */
- HeapTupleHeaderAdjustCmax(tp.t_data, &cid, &iscombo);
+ HeapTupleHeaderAdjustCmax(&tp, &cid, &iscombo);
/*
* Compute replica identity tuple before entering the critical section so
@@ -2916,11 +3504,20 @@ l1:
*/
MultiXactIdSetOldestMember();
- compute_new_xmax_infomask(HeapTupleHeaderGetRawXmax(tp.t_data),
+ compute_new_xmax_infomask(HeapTupleGetRawXmax(&tp),
tp.t_data->t_infomask, tp.t_data->t_infomask2,
xid, LockTupleExclusive, true,
&new_xmax, &new_infomask, &new_infomask2);
+#ifdef USE_ASSERT_CHECKING
+ if (IsToastRelation(relation))
+ Assert((new_infomask & HEAP_XMAX_IS_MULTI) == false);
+#endif
+
+ heap_page_prepare_for_xid(relation, buffer, new_xmax,
+ (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
+ HeapTupleCopyBaseFromPage(buffer, &tp, page, IsToastRelation(relation));
+
START_CRIT_SECTION();
/*
@@ -2930,7 +3527,7 @@ l1:
* the subsequent page pruning will be a no-op and the hint will be
* cleared.
*/
- PageSetPrunable(page, xid);
+ PageSetPrunable(page, xid, IsToastRelation(relation));
if (PageIsAllVisible(page))
{
@@ -2946,10 +3543,15 @@ l1:
tp.t_data->t_infomask |= new_infomask;
tp.t_data->t_infomask2 |= new_infomask2;
HeapTupleHeaderClearHotUpdated(tp.t_data);
- HeapTupleHeaderSetXmax(tp.t_data, new_xmax);
+ HeapTupleSetXmax(&tp, new_xmax);
+ if (IsToastRelation(relation))
+ ToastTupleHeaderSetXmax(page, &tp);
+ else
+ HeapTupleHeaderSetXmax(page, &tp);
HeapTupleHeaderSetCmax(tp.t_data, cid, iscombo);
/* Make sure there is no forward chain link in t_ctid */
tp.t_data->t_ctid = tp.t_self;
+ HeapTupleCopyBaseFromPage(buffer, &tp, page, IsToastRelation(relation));
/* Signal that this is actually a move into another partition */
if (changingPart)
@@ -2985,6 +3587,8 @@ l1:
tp.t_data->t_infomask2);
xlrec.offnum = ItemPointerGetOffsetNumber(&tp.t_self);
xlrec.xmax = new_xmax;
+ if (IsToastRelation(relation))
+ xlrec.flags |= XLH_DELETE_PAGE_ON_TOAST_RELATION;
if (old_key_tuple != NULL)
{
@@ -3140,7 +3744,8 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
HeapTuple heaptup;
HeapTuple old_key_tuple = NULL;
bool old_key_copied = false;
- Page page;
+ Page page,
+ newpage;
BlockNumber block;
MultiXactStatus mxact_status;
Buffer buffer,
@@ -3233,6 +3838,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
oldtup.t_data = (HeapTupleHeader) PageGetItem(page, lp);
oldtup.t_len = ItemIdGetLength(lp);
oldtup.t_self = *otid;
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page, IsToastRelation(relation));
/* the new tuple is ready, except for this: */
newtup->t_tableOid = RelationGetRelid(relation);
@@ -3326,7 +3932,7 @@ l2:
*/
/* must copy state data before unlocking buffer */
- xwait = HeapTupleHeaderGetRawXmax(oldtup.t_data);
+ xwait = HeapTupleGetRawXmax(&oldtup);
infomask = oldtup.t_data->t_infomask;
/*
@@ -3377,6 +3983,8 @@ l2:
checked_lockers = true;
locker_remains = remain != 0;
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
/*
* If xwait had just locked the tuple then some other xact
@@ -3385,7 +3993,7 @@ l2:
*/
if (xmax_infomask_changed(oldtup.t_data->t_infomask,
infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(oldtup.t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(&oldtup),
xwait))
goto l2;
}
@@ -3411,7 +4019,7 @@ l2:
* subxact aborts.
*/
if (!HEAP_XMAX_IS_LOCKED_ONLY(oldtup.t_data->t_infomask))
- update_xact = HeapTupleGetUpdateXid(oldtup.t_data);
+ update_xact = HeapTupleGetUpdateXid(&oldtup);
else
update_xact = InvalidTransactionId;
@@ -3459,6 +4067,9 @@ l2:
checked_lockers = true;
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
+
/*
* xwait is done, but if xwait had just locked the tuple then some
* other xact could update this tuple before we get to this point.
@@ -3466,7 +4077,7 @@ l2:
*/
if (xmax_infomask_changed(oldtup.t_data->t_infomask, infomask) ||
!TransactionIdEquals(xwait,
- HeapTupleHeaderGetRawXmax(oldtup.t_data)))
+ HeapTupleGetRawXmax(&oldtup)))
goto l2;
/* Otherwise check if it committed or aborted */
@@ -3503,9 +4114,9 @@ l2:
Assert(result != TM_Updated ||
!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid));
tmfd->ctid = oldtup.t_data->t_ctid;
- tmfd->xmax = HeapTupleHeaderGetUpdateXid(oldtup.t_data);
+ tmfd->xmax = HeapTupleGetUpdateXidAny(&oldtup);
if (result == TM_SelfModified)
- tmfd->cmax = HeapTupleHeaderGetCmax(oldtup.t_data);
+ tmfd->cmax = HeapTupleGetCmax(&oldtup);
else
tmfd->cmax = InvalidCommandId;
UnlockReleaseBuffer(buffer);
@@ -3535,6 +4146,8 @@ l2:
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
visibilitymap_pin(relation, block, &vmbuffer);
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
goto l2;
}
@@ -3544,7 +4157,7 @@ l2:
* If the tuple we're updating is locked, we need to preserve the locking
* info in the old tuple's Xmax. Prepare a new Xmax value for this.
*/
- compute_new_xmax_infomask(HeapTupleHeaderGetRawXmax(oldtup.t_data),
+ compute_new_xmax_infomask(HeapTupleGetRawXmax(&oldtup),
oldtup.t_data->t_infomask,
oldtup.t_data->t_infomask2,
xid, *lockmode, true,
@@ -3563,7 +4176,7 @@ l2:
(checked_lockers && !locker_remains))
xmax_new_tuple = InvalidTransactionId;
else
- xmax_new_tuple = HeapTupleHeaderGetRawXmax(oldtup.t_data);
+ xmax_new_tuple = HeapTupleGetRawXmax(&oldtup);
if (!TransactionIdIsValid(xmax_new_tuple))
{
@@ -3596,17 +4209,15 @@ l2:
*/
newtup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
newtup->t_data->t_infomask2 &= ~(HEAP2_XACT_MASK);
- HeapTupleHeaderSetXmin(newtup->t_data, xid);
HeapTupleHeaderSetCmin(newtup->t_data, cid);
newtup->t_data->t_infomask |= HEAP_UPDATED | infomask_new_tuple;
newtup->t_data->t_infomask2 |= infomask2_new_tuple;
- HeapTupleHeaderSetXmax(newtup->t_data, xmax_new_tuple);
/*
* Replace cid with a combo CID if necessary. Note that we already put
* the plain cid into the new tuple.
*/
- HeapTupleHeaderAdjustCmax(oldtup.t_data, &cid, &iscombo);
+ HeapTupleHeaderAdjustCmax(&oldtup, &cid, &iscombo);
/*
* If the toaster needs to be activated, OR if the new tuple will not fit
@@ -3636,7 +4247,7 @@ l2:
newtupsize = MAXALIGN(newtup->t_len);
- if (need_toast || newtupsize > pagefree)
+ if (need_toast || newtupsize > pagefree || HeapPageIsDoubleXmax(page))
{
TransactionId xmax_lock_old_tuple;
uint16 infomask_lock_old_tuple,
@@ -3661,7 +4272,7 @@ l2:
* updating, because the potentially created multixact would otherwise
* be wrong.
*/
- compute_new_xmax_infomask(HeapTupleHeaderGetRawXmax(oldtup.t_data),
+ compute_new_xmax_infomask(HeapTupleGetRawXmax(&oldtup),
oldtup.t_data->t_infomask,
oldtup.t_data->t_infomask2,
xid, *lockmode, false,
@@ -3670,6 +4281,16 @@ l2:
Assert(HEAP_XMAX_IS_LOCKED_ONLY(infomask_lock_old_tuple));
+#ifdef USE_ASSERT_CHECKING
+ if (IsToastRelation(relation))
+ Assert((infomask_lock_old_tuple & HEAP_XMAX_IS_MULTI) == false);
+#endif
+
+ heap_page_prepare_for_xid(relation, buffer, xmax_lock_old_tuple,
+ (infomask_lock_old_tuple & HEAP_XMAX_IS_MULTI) ? true : false);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
+
START_CRIT_SECTION();
/* Clear obsolete visibility flags ... */
@@ -3678,10 +4299,13 @@ l2:
HeapTupleClearHotUpdated(&oldtup);
/* ... and store info about transaction updating this tuple */
Assert(TransactionIdIsValid(xmax_lock_old_tuple));
- HeapTupleHeaderSetXmax(oldtup.t_data, xmax_lock_old_tuple);
oldtup.t_data->t_infomask |= infomask_lock_old_tuple;
oldtup.t_data->t_infomask2 |= infomask2_lock_old_tuple;
+ HeapTupleSetXmax(&oldtup, xmax_lock_old_tuple);
+ HeapTupleHeaderSetXmax(page, &oldtup);
HeapTupleHeaderSetCmax(oldtup.t_data, cid, iscombo);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
/* temporarily make it look not-updated, but locked */
oldtup.t_data->t_ctid = oldtup.t_self;
@@ -3763,7 +4387,11 @@ l2:
*/
for (;;)
{
- if (newtupsize > pagefree)
+ /*
+ * We can't fit new tuple to "double xmax" page, since it's
+ * impossible to set xmin there.
+ */
+ if (newtupsize > pagefree || HeapPageIsDoubleXmax(page))
{
/* It doesn't fit, must use RelationGetBufferForTuple. */
newbuf = RelationGetBufferForTuple(relation, heaptup->t_len,
@@ -3796,6 +4424,10 @@ l2:
break;
}
}
+
+ /* Copy possibly updated xid base to old tuple after relocking */
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
}
else
{
@@ -3855,6 +4487,48 @@ l2:
id_has_external,
&old_key_copied);
+ newpage = BufferGetPage(newbuf);
+
+ /*
+ * Prepare pages for the current xid, that witten to the new tuple's Xmax
+ * and old page's pd_prune_xid.
+ */
+ heap_page_prepare_for_xid(relation, buffer, xid, false);
+ if (newbuf != buffer)
+ heap_page_prepare_for_xid(relation, newbuf, xid, false);
+
+#ifdef USE_ASSERT_CHECKING
+ if (IsToastRelation(relation))
+ {
+ Assert((infomask_old_tuple & HEAP_XMAX_IS_MULTI) == false);
+ Assert((heaptup->t_data->t_infomask & HEAP_XMAX_IS_MULTI) == false);
+ }
+#endif
+
+ /* Prepare pages for tuple's Xmax */
+ heap_page_prepare_for_xid(relation, buffer, xmax_old_tuple,
+ (infomask_old_tuple & HEAP_XMAX_IS_MULTI) ? true : false);
+ heap_page_prepare_for_xid(relation, newbuf, xmax_new_tuple,
+ (heaptup->t_data->t_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
+
+ /* Copy possibly updated Xid bases to the both tuples. */
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page,
+ IsToastRelation(relation));
+
+ /*
+ * Set new tuple's Xmin/Xmax, old tuple's Xmin/Xmax were already shifted.
+ */
+ HeapTupleSetXmin(heaptup, xid);
+ if (IsToastRelation(relation))
+ ToastTupleHeaderSetXmin(newpage, heaptup);
+ else
+ HeapTupleHeaderSetXmin(newpage, heaptup);
+ HeapTupleSetXmax(heaptup, xmax_new_tuple);
+ if (IsToastRelation(relation))
+ ToastTupleHeaderSetXmax(newpage, heaptup);
+ else
+ HeapTupleHeaderSetXmax(newpage, heaptup);
+
/* NO EREPORT(ERROR) from here till changes are logged */
START_CRIT_SECTION();
@@ -3870,7 +4544,9 @@ l2:
* not to optimize for aborts. Note that heap_xlog_update must be kept in
* sync if this decision changes.
*/
- PageSetPrunable(page, xid);
+
+ Assert(!IsToastRelation(relation));
+ PageSetPrunable(page, xid, false);
if (use_hot_update)
{
@@ -3897,10 +4573,12 @@ l2:
oldtup.t_data->t_infomask2 &= ~HEAP_KEYS_UPDATED;
/* ... and store info about transaction updating this tuple */
Assert(TransactionIdIsValid(xmax_old_tuple));
- HeapTupleHeaderSetXmax(oldtup.t_data, xmax_old_tuple);
oldtup.t_data->t_infomask |= infomask_old_tuple;
oldtup.t_data->t_infomask2 |= infomask2_old_tuple;
+ HeapTupleSetXmax(&oldtup, xmax_old_tuple);
+ HeapTupleHeaderSetXmax(page, &oldtup);
HeapTupleHeaderSetCmax(oldtup.t_data, cid, iscombo);
+ HeapTupleCopyBaseFromPage(buffer, &oldtup, page, IsToastRelation(relation));
/* record address of new tuple in t_ctid of old one */
oldtup.t_data->t_ctid = heaptup->t_self;
@@ -3954,6 +4632,20 @@ l2:
END_CRIT_SECTION();
+ if (newtup != heaptup)
+ {
+ /*
+ * Set new tuple's Xmin/Xmax only after both xid base preparations.
+ * Old tuple's Xmin/Xmax were already shifted because old tuple is on
+ * the page.
+ */
+ HeapTupleCopyBase(newtup, heaptup);
+ HeapTupleSetXmin(newtup, xid);
+ HeapTupleHeaderSetXmin(newpage, newtup);
+ HeapTupleSetXmax(newtup, xmax_new_tuple);
+ HeapTupleHeaderSetXmax(newpage, newtup);
+ }
+
if (newbuf != buffer)
LockBuffer(newbuf, BUFFER_LOCK_UNLOCK);
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
@@ -4292,6 +4984,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
tuple->t_data = (HeapTupleHeader) PageGetItem(page, lp);
tuple->t_len = ItemIdGetLength(lp);
tuple->t_tableOid = RelationGetRelid(relation);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page, IsToastRelation(relation));
l3:
result = HeapTupleSatisfiesUpdate(tuple, cid, *buffer);
@@ -4318,7 +5011,7 @@ l3:
ItemPointerData t_ctid;
/* must copy state data before unlocking buffer */
- xwait = HeapTupleHeaderGetRawXmax(tuple->t_data);
+ xwait = HeapTupleGetRawXmax(tuple);
infomask = tuple->t_data->t_infomask;
infomask2 = tuple->t_data->t_infomask2;
ItemPointerCopy(&tuple->t_data->t_ctid, &t_ctid);
@@ -4476,11 +5169,15 @@ l3:
result = res;
/* recovery code expects to have buffer lock held */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
}
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
/*
* Make sure it's still an appropriate lock, else start over.
@@ -4489,7 +5186,7 @@ l3:
* now need to follow the update chain to lock the new
* versions.
*/
- if (!HeapTupleHeaderIsOnlyLocked(tuple->t_data) &&
+ if (!HeapTupleIsOnlyLocked(tuple) &&
((tuple->t_data->t_infomask2 & HEAP_KEYS_UPDATED) ||
!updated))
goto l3;
@@ -4516,6 +5213,8 @@ l3:
!HEAP_XMAX_IS_EXCL_LOCKED(infomask))
{
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
/*
* Make sure it's still an appropriate lock, else start over.
@@ -4544,8 +5243,11 @@ l3:
* meantime, start over.
*/
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
+
if (xmax_infomask_changed(tuple->t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tuple->t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(tuple),
xwait))
goto l3;
@@ -4556,10 +5258,12 @@ l3:
else if (HEAP_XMAX_IS_KEYSHR_LOCKED(infomask))
{
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
/* if the xmax changed in the meantime, start over */
if (xmax_infomask_changed(tuple->t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tuple->t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(tuple),
xwait))
goto l3;
/* otherwise, we're good */
@@ -4584,8 +5288,11 @@ l3:
{
/* ... but if the xmax changed in the meantime, start over */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
+
if (xmax_infomask_changed(tuple->t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tuple->t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(tuple),
xwait))
goto l3;
Assert(HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_data->t_infomask));
@@ -4606,6 +5313,8 @@ l3:
if (require_sleep && (result == TM_Updated || result == TM_Deleted))
{
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
else if (require_sleep)
@@ -4631,6 +5340,8 @@ l3:
result = TM_WouldBlock;
/* recovery code expects to have buffer lock held */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
@@ -4657,6 +5368,8 @@ l3:
result = TM_WouldBlock;
/* recovery code expects to have buffer lock held */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
break;
@@ -4697,6 +5410,8 @@ l3:
result = TM_WouldBlock;
/* recovery code expects to have buffer lock held */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
break;
@@ -4723,11 +5438,15 @@ l3:
result = res;
/* recovery code expects to have buffer lock held */
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto failed;
}
}
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
/*
* xwait is done, but if xwait had just locked the tuple then some
@@ -4735,7 +5454,7 @@ l3:
* Check for xmax change, and start over if so.
*/
if (xmax_infomask_changed(tuple->t_data->t_infomask, infomask) ||
- !TransactionIdEquals(HeapTupleHeaderGetRawXmax(tuple->t_data),
+ !TransactionIdEquals(HeapTupleGetRawXmax(tuple),
xwait))
goto l3;
@@ -4763,7 +5482,7 @@ l3:
if (!require_sleep ||
(tuple->t_data->t_infomask & HEAP_XMAX_INVALID) ||
HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_data->t_infomask) ||
- HeapTupleHeaderIsOnlyLocked(tuple->t_data))
+ HeapTupleIsOnlyLocked(tuple))
result = TM_Ok;
else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid))
result = TM_Updated;
@@ -4789,9 +5508,9 @@ failed:
Assert(result != TM_Updated ||
!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid));
tmfd->ctid = tuple->t_data->t_ctid;
- tmfd->xmax = HeapTupleHeaderGetUpdateXid(tuple->t_data);
+ tmfd->xmax = HeapTupleGetUpdateXidAny(tuple);
if (result == TM_SelfModified)
- tmfd->cmax = HeapTupleHeaderGetCmax(tuple->t_data);
+ tmfd->cmax = HeapTupleGetCmax(tuple);
else
tmfd->cmax = InvalidCommandId;
goto out_locked;
@@ -4811,10 +5530,12 @@ failed:
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
visibilitymap_pin(relation, block, &vmbuffer);
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page,
+ IsToastRelation(relation));
goto l3;
}
- xmax = HeapTupleHeaderGetRawXmax(tuple->t_data);
+ xmax = HeapTupleGetRawXmax(tuple);
old_infomask = tuple->t_data->t_infomask;
/*
@@ -4836,6 +5557,15 @@ failed:
GetCurrentTransactionId(), mode, false,
&xid, &new_infomask, &new_infomask2);
+#ifdef USE_ASSERT_CHECKING
+ if (IsToastRelation(relation))
+ Assert((new_infomask & HEAP_XMAX_IS_MULTI) == false);
+#endif
+
+ heap_page_prepare_for_xid(relation, *buffer, xid,
+ (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
+ HeapTupleCopyBaseFromPage(*buffer, tuple, page, IsToastRelation(relation));
+
START_CRIT_SECTION();
/*
@@ -4854,7 +5584,8 @@ failed:
tuple->t_data->t_infomask2 |= new_infomask2;
if (HEAP_XMAX_IS_LOCKED_ONLY(new_infomask))
HeapTupleHeaderClearHotUpdated(tuple->t_data);
- HeapTupleHeaderSetXmax(tuple->t_data, xid);
+ HeapTupleSetXmax(tuple, xid);
+ HeapTupleHeaderSetXmax(page, tuple);
/*
* Make sure there is no forward chain link in t_ctid. Note that in the
@@ -5448,12 +6179,19 @@ l4:
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
}
+ /*
+ * Copy xid base after buffer relocking, it could have changed since
+ * heap_fetch().
+ */
+ HeapTupleCopyBaseFromPage(buf, &mytup, BufferGetPage(buf),
+ IsToastRelation(rel));
+
/*
* Check the tuple XMIN against prior XMAX, if any. If we reached the
* end of the chain, we're done, so return success.
*/
if (TransactionIdIsValid(priorXmax) &&
- !TransactionIdEquals(HeapTupleHeaderGetXmin(mytup.t_data),
+ !TransactionIdEquals(HeapTupleGetXmin(&mytup),
priorXmax))
{
result = TM_Ok;
@@ -5465,7 +6203,7 @@ l4:
* (sub)transaction, then we already locked the last live one in the
* chain, thus we're done, so return success.
*/
- if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(mytup.t_data)))
+ if (TransactionIdDidAbort(HeapTupleGetXmin(&mytup)))
{
result = TM_Ok;
goto out_locked;
@@ -5473,7 +6211,7 @@ l4:
old_infomask = mytup.t_data->t_infomask;
old_infomask2 = mytup.t_data->t_infomask2;
- xmax = HeapTupleHeaderGetRawXmax(mytup.t_data);
+ xmax = HeapTupleGetRawXmax(&mytup);
/*
* If this tuple version has been updated or locked by some concurrent
@@ -5486,7 +6224,7 @@ l4:
TransactionId rawxmax;
bool needwait;
- rawxmax = HeapTupleHeaderGetRawXmax(mytup.t_data);
+ rawxmax = HeapTupleGetRawXmax(&mytup);
if (old_infomask & HEAP_XMAX_IS_MULTI)
{
int nmembers;
@@ -5627,14 +6365,25 @@ l4:
VISIBILITYMAP_ALL_FROZEN))
cleared_all_frozen = true;
+#ifdef USE_ASSERT_CHECKING
+ if (IsToastRelation(rel))
+ Assert((new_infomask & HEAP_XMAX_IS_MULTI) == false);
+#endif
+
+ heap_page_prepare_for_xid(rel, buf, new_xmax,
+ (new_infomask & HEAP_XMAX_IS_MULTI) ? true : false);
+ HeapTupleCopyBaseFromPage(buf, &mytup, BufferGetPage(buf),
+ IsToastRelation(rel));
+
START_CRIT_SECTION();
/* ... and set them */
- HeapTupleHeaderSetXmax(mytup.t_data, new_xmax);
mytup.t_data->t_infomask &= ~HEAP_XMAX_BITS;
mytup.t_data->t_infomask2 &= ~HEAP_KEYS_UPDATED;
mytup.t_data->t_infomask |= new_infomask;
mytup.t_data->t_infomask2 |= new_infomask2;
+ HeapTupleSetXmax(&mytup, new_xmax);
+ HeapTupleHeaderSetXmax(BufferGetPage(buf), &mytup);
MarkBufferDirty(buf);
@@ -5668,14 +6417,14 @@ next:
if (mytup.t_data->t_infomask & HEAP_XMAX_INVALID ||
HeapTupleHeaderIndicatesMovedPartitions(mytup.t_data) ||
ItemPointerEquals(&mytup.t_self, &mytup.t_data->t_ctid) ||
- HeapTupleHeaderIsOnlyLocked(mytup.t_data))
+ HeapTupleIsOnlyLocked(&mytup))
{
result = TM_Ok;
goto out_locked;
}
/* tail recursion */
- priorXmax = HeapTupleHeaderGetUpdateXid(mytup.t_data);
+ priorXmax = HeapTupleGetUpdateXidAny(&mytup);
ItemPointerCopy(&(mytup.t_data->t_ctid), &tupid);
UnlockReleaseBuffer(buf);
}
@@ -5882,12 +6631,13 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
tp.t_data = (HeapTupleHeader) PageGetItem(page, lp);
tp.t_len = ItemIdGetLength(lp);
tp.t_self = *tid;
+ HeapTupleCopyBaseFromPage(buffer, &tp, page, IsToastRelation(relation));
/*
* Sanity check that the tuple really is a speculatively inserted tuple,
* inserted by us.
*/
- if (tp.t_data->t_choice.t_heap.t_xmin != xid)
+ if (HeapTupleGetRawXmin(&tp) != xid)
elog(ERROR, "attempted to kill a tuple inserted by another transaction");
if (!(IsToastRelation(relation) || HeapTupleHeaderIsSpeculative(tp.t_data)))
elog(ERROR, "attempted to kill a non-speculative tuple");
@@ -5916,7 +6666,9 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
prune_xid = relation->rd_rel->relfrozenxid;
else
prune_xid = TransactionXmin;
- PageSetPrunable(page, prune_xid);
+ Assert(TransactionIdIsValid(prune_xid));
+ heap_page_prepare_for_xid(relation, buffer, prune_xid, false);
+ PageSetPrunable(page, prune_xid, IsToastRelation(relation));
/* store transaction information of xact deleting the tuple */
tp.t_data->t_infomask &= ~(HEAP_XMAX_BITS | HEAP_MOVED);
@@ -5925,9 +6677,15 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
/*
* Set the tuple header xmin to InvalidTransactionId. This makes the
* tuple immediately invisible everyone. (In particular, to any
- * transactions waiting on the speculative token, woken up later.)
+ * transactions waiting on the speculative token, woken up later.) Don't
+ * need to reload xid base from page because InvalidTransactionId doesn't
+ * require xid base to be valid.
*/
- HeapTupleHeaderSetXmin(tp.t_data, InvalidTransactionId);
+ HeapTupleSetXmin(&tp, InvalidTransactionId);
+ if (IsToastRelation(relation))
+ ToastTupleHeaderSetXmin(page, &tp);
+ else
+ HeapTupleHeaderSetXmin(page, &tp);
/* Clear the speculative insertion token too */
tp.t_data->t_ctid = tp.t_self;
@@ -5946,6 +6704,8 @@ heap_abort_speculative(Relation relation, ItemPointer tid)
XLogRecPtr recptr;
xlrec.flags = XLH_DELETE_IS_SUPER;
+ if (IsToastRelation(relation))
+ xlrec.flags |= XLH_DELETE_PAGE_ON_TOAST_RELATION;
xlrec.infobits_set = compute_infobits(tp.t_data->t_infomask,
tp.t_data->t_infomask2);
xlrec.offnum = ItemPointerGetOffsetNumber(&tp.t_self);
@@ -6275,7 +7035,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
* individual members might even show that we don't need to keep anything.
*/
nnewmembers = 0;
- newmembers = palloc(sizeof(MultiXactMember) * nmembers);
+ newmembers = palloc0(sizeof(MultiXactMember) * nmembers);
has_lockers = false;
update_xid = InvalidTransactionId;
update_committed = false;
@@ -6475,7 +7235,7 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
* The *frz WAL record we output completely removes all old XIDs during REDO.
*/
bool
-heap_prepare_freeze_tuple(HeapTupleHeader tuple,
+heap_prepare_freeze_tuple(HeapTuple htup,
TransactionId relfrozenxid, TransactionId relminmxid,
TransactionId cutoff_xid, TransactionId cutoff_multi,
xl_heap_freeze_tuple *frz, bool *totally_frozen,
@@ -6487,11 +7247,12 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
bool xmin_frozen;
bool freeze_xmax;
TransactionId xid;
+ HeapTupleHeader tuple = htup->t_data;
frz->frzflags = 0;
frz->t_infomask2 = tuple->t_infomask2;
frz->t_infomask = tuple->t_infomask;
- frz->xmax = HeapTupleHeaderGetRawXmax(tuple);
+ frz->xmax = HeapTupleGetRawXmax(htup);
/*
* Process xmin. xmin_frozen has two slightly different meanings: in the
@@ -6503,7 +7264,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
* handling, since either way the tuple's xmin will be a permanent value
* once we're done with it.
*/
- xid = HeapTupleHeaderGetXmin(tuple);
+ xid = HeapTupleGetXmin(htup);
if (!TransactionIdIsNormal(xid))
xmin_frozen = true;
else
@@ -6545,7 +7306,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
*
* Make sure to keep heap_tuple_would_freeze in sync with this.
*/
- xid = HeapTupleHeaderGetRawXmax(tuple);
+ xid = HeapTupleGetRawXmax(htup);
if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
{
@@ -6645,6 +7406,15 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
Assert(!TransactionIdIsValid(newxmax));
}
}
+ else if ((tuple->t_infomask & HEAP_XMAX_INVALID) &&
+ TransactionIdIsNormal(xid))
+ {
+ /*
+ * To reset xmax without reading clog.
+ * This prevent excess growth of xmax.
+ */
+ freeze_xmax = true;
+ }
else if (TransactionIdIsNormal(xid))
{
if (TransactionIdPrecedes(xid, relfrozenxid))
@@ -6679,7 +7449,7 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
}
}
else if ((tuple->t_infomask & HEAP_XMAX_INVALID) ||
- !TransactionIdIsValid(HeapTupleHeaderGetRawXmax(tuple)))
+ !TransactionIdIsValid(HeapTupleGetRawXmax(htup)))
{
freeze_xmax = false;
xmax_already_frozen = true;
@@ -6775,18 +7545,35 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
* NB: All code in here must be safe to execute during crash recovery!
*/
void
-heap_execute_freeze_tuple(HeapTupleHeader tuple, xl_heap_freeze_tuple *frz)
+heap_execute_freeze_tuple(HeapTuple htup, xl_heap_freeze_tuple *frz)
{
- HeapTupleHeaderSetXmax(tuple, frz->xmax);
+ HeapTupleHeader tuple = htup->t_data;
+
+ tuple->t_infomask = frz->t_infomask;
+ tuple->t_infomask2 = frz->t_infomask2;
+
+ HeapTupleSetXmax(htup, frz->xmax);
if (frz->frzflags & XLH_FREEZE_XVAC)
HeapTupleHeaderSetXvac(tuple, FrozenTransactionId);
if (frz->frzflags & XLH_INVALID_XVAC)
HeapTupleHeaderSetXvac(tuple, InvalidTransactionId);
+}
- tuple->t_infomask = frz->t_infomask;
- tuple->t_infomask2 = frz->t_infomask2;
+void
+heap_execute_freeze_tuple_page(Page page, HeapTupleHeader htup,
+ xl_heap_freeze_tuple *frz, bool is_toast)
+{
+ HeapTupleData tuple;
+
+ tuple.t_data = htup;
+ heap_execute_freeze_tuple(&tuple, frz);
+
+ if (is_toast)
+ ToastTupleHeaderSetXmax(page, &tuple);
+ else
+ HeapTupleHeaderSetXmax(page, &tuple);
}
/*
@@ -6796,7 +7583,7 @@ heap_execute_freeze_tuple(HeapTupleHeader tuple, xl_heap_freeze_tuple *frz)
* Useful for callers like CLUSTER that perform their own WAL logging.
*/
bool
-heap_freeze_tuple(HeapTupleHeader tuple,
+heap_freeze_tuple(HeapTuple tuple,
TransactionId relfrozenxid, TransactionId relminmxid,
TransactionId cutoff_xid, TransactionId cutoff_multi)
{
@@ -6963,10 +7750,10 @@ MultiXactIdGetUpdateXid(TransactionId xmax, uint16 t_infomask)
* checking the hint bits.
*/
TransactionId
-HeapTupleGetUpdateXid(HeapTupleHeader tuple)
+HeapTupleGetUpdateXid(HeapTuple tuple)
{
- return MultiXactIdGetUpdateXid(HeapTupleHeaderGetRawXmax(tuple),
- tuple->t_infomask);
+ return MultiXactIdGetUpdateXid(HeapTupleGetRawXmax(tuple),
+ tuple->t_data->t_infomask);
}
/*
@@ -7192,15 +7979,18 @@ ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status,
* will eventually require freezing (if tuple isn't removed by pruning first).
*/
bool
-heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
+heap_tuple_needs_eventual_freeze(HeapTuple htup)
{
TransactionId xid;
+ HeapTupleHeader tuple;
+
+ tuple = htup->t_data;
/*
* If xmin is a normal transaction ID, this tuple is definitely not
* frozen.
*/
- xid = HeapTupleHeaderGetXmin(tuple);
+ xid = HeapTupleGetXmin(htup);
if (TransactionIdIsNormal(xid))
return true;
@@ -7211,13 +8001,13 @@ heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
{
MultiXactId multi;
- multi = HeapTupleHeaderGetRawXmax(tuple);
+ multi = HeapTupleGetRawXmax(htup);
if (MultiXactIdIsValid(multi))
return true;
}
else
{
- xid = HeapTupleHeaderGetRawXmax(tuple);
+ xid = HeapTupleGetRawXmax(htup);
if (TransactionIdIsNormal(xid))
return true;
}
@@ -7245,7 +8035,7 @@ heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
* never freeze here, which makes tracking the oldest extant XID/MXID simple.
*/
bool
-heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
+heap_tuple_would_freeze(HeapTuple htup, TransactionId cutoff_xid,
MultiXactId cutoff_multi,
TransactionId *relfrozenxid_out,
MultiXactId *relminmxid_out)
@@ -7253,9 +8043,10 @@ heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
TransactionId xid;
MultiXactId multi;
bool would_freeze = false;
+ HeapTupleHeader tuple = htup->t_data;
/* First deal with xmin */
- xid = HeapTupleHeaderGetXmin(tuple);
+ xid = HeapTupleGetXmin(htup);
if (TransactionIdIsNormal(xid))
{
if (TransactionIdPrecedes(xid, *relfrozenxid_out))
@@ -7268,9 +8059,9 @@ heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
xid = InvalidTransactionId;
multi = InvalidMultiXactId;
if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
- multi = HeapTupleHeaderGetRawXmax(tuple);
+ multi = HeapTupleGetRawXmax(htup);
else
- xid = HeapTupleHeaderGetRawXmax(tuple);
+ xid = HeapTupleGetRawXmax(htup);
if (TransactionIdIsNormal(xid))
{
@@ -7343,14 +8134,14 @@ heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
* with queries.
*/
void
-HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
+HeapTupleHeaderAdvanceLatestRemovedXid(HeapTuple tuple,
TransactionId *latestRemovedXid)
{
- TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
- TransactionId xmax = HeapTupleHeaderGetUpdateXid(tuple);
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
+ TransactionId xmin = HeapTupleGetXmin(tuple);
+ TransactionId xmax = HeapTupleGetUpdateXidAny(tuple);
+ TransactionId xvac = HeapTupleHeaderGetXvac(tuple->t_data);
- if (tuple->t_infomask & HEAP_MOVED)
+ if (tuple->t_data->t_infomask & HEAP_MOVED)
{
if (TransactionIdPrecedes(*latestRemovedXid, xvac))
*latestRemovedXid = xvac;
@@ -7362,8 +8153,8 @@ HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
*
* Look for a committed hint bit, or if no xmin bit is set, check clog.
*/
- if (HeapTupleHeaderXminCommitted(tuple) ||
- (!HeapTupleHeaderXminInvalid(tuple) && TransactionIdDidCommit(xmin)))
+ if (HeapTupleHeaderXminCommitted(tuple->t_data) ||
+ (!HeapTupleHeaderXminInvalid(tuple->t_data) && TransactionIdDidCommit(xmin)))
{
if (xmax != xmin &&
TransactionIdFollows(xmax, *latestRemovedXid))
@@ -7713,7 +8504,7 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
for (;;)
{
ItemId lp;
- HeapTupleHeader htup;
+ HeapTupleData htup;
/* Sanity check (pure paranoia) */
if (offnum < FirstOffsetNumber)
@@ -7750,16 +8541,18 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
if (!ItemIdIsNormal(lp))
break;
- htup = (HeapTupleHeader) PageGetItem(page, lp);
+ htup.t_data = (HeapTupleHeader) PageGetItem(page, lp);
+ htup.t_len = ItemIdGetLength(lp);
+ HeapTupleCopyBaseFromPage(buf, &htup, page, IsToastRelation(rel));
/*
* Check the tuple XMIN against prior XMAX, if any
*/
if (TransactionIdIsValid(priorXmax) &&
- !TransactionIdEquals(HeapTupleHeaderGetXmin(htup), priorXmax))
+ !TransactionIdEquals(HeapTupleGetXmin(&htup), priorXmax))
break;
- HeapTupleHeaderAdvanceLatestRemovedXid(htup, &latestRemovedXid);
+ HeapTupleHeaderAdvanceLatestRemovedXid(&htup, &latestRemovedXid);
/*
* If the tuple is not HOT-updated, then we are at the end of this
@@ -7767,13 +8560,13 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
* chain (they get their own index entries) -- just move on to
* next htid from index AM caller.
*/
- if (!HeapTupleHeaderIsHotUpdated(htup))
+ if (!HeapTupleHeaderIsHotUpdated(htup.t_data))
break;
/* Advance to next HOT chain member */
- Assert(ItemPointerGetBlockNumber(&htup->t_ctid) == blkno);
- offnum = ItemPointerGetOffsetNumber(&htup->t_ctid);
- priorXmax = HeapTupleHeaderGetUpdateXid(htup);
+ Assert(ItemPointerGetBlockNumber(&htup.t_data->t_ctid) == blkno);
+ offnum = ItemPointerGetOffsetNumber(&htup.t_data->t_ctid);
+ priorXmax = HeapTupleGetUpdateXidAny(&htup);
}
/* Enable further/final shrinking of deltids for caller */
@@ -8179,6 +8972,9 @@ log_heap_freeze(Relation reln, Buffer buffer, TransactionId cutoff_xid,
xlrec.cutoff_xid = cutoff_xid;
xlrec.ntuples = ntuples;
+ xlrec.flags = 0;
+ if (IsToastRelation(reln))
+ xlrec.flags |= XLH_FREEZE_PAGE_ON_TOAST_RELATION;
XLogBeginInsert();
XLogRegisterData((char *) &xlrec, SizeOfHeapFreezePage);
@@ -8353,13 +9149,13 @@ log_heap_update(Relation reln, Buffer oldbuf,
/* Prepare WAL data for the old page */
xlrec.old_offnum = ItemPointerGetOffsetNumber(&oldtup->t_self);
- xlrec.old_xmax = HeapTupleHeaderGetRawXmax(oldtup->t_data);
+ xlrec.old_xmax = HeapTupleGetRawXmax(oldtup);
xlrec.old_infobits_set = compute_infobits(oldtup->t_data->t_infomask,
oldtup->t_data->t_infomask2);
/* Prepare WAL data for the new page */
xlrec.new_offnum = ItemPointerGetOffsetNumber(&newtup->t_self);
- xlrec.new_xmax = HeapTupleHeaderGetRawXmax(newtup->t_data);
+ xlrec.new_xmax = HeapTupleGetRawXmax(newtup);
bufflags = REGBUF_STANDARD;
if (init)
@@ -8371,6 +9167,10 @@ log_heap_update(Relation reln, Buffer oldbuf,
if (oldbuf != newbuf)
XLogRegisterBuffer(1, oldbuf, REGBUF_STANDARD);
+ if (info & XLOG_HEAP_INIT_PAGE)
+ XLogRegisterData((char *) &HeapPageGetSpecial(page)->pd_xid_base,
+ sizeof(TransactionId));
+
XLogRegisterData((char *) &xlrec, SizeOfHeapUpdate);
/*
@@ -8483,8 +9283,8 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
{
Assert(!(hdr->t_infomask & HEAP_XMAX_INVALID));
Assert(!HeapTupleHeaderXminInvalid(hdr));
- xlrec.cmin = HeapTupleHeaderGetCmin(hdr);
- xlrec.cmax = HeapTupleHeaderGetCmax(hdr);
+ xlrec.cmin = HeapTupleGetCmin(tup);
+ xlrec.cmax = HeapTupleGetCmax(tup);
xlrec.combocid = HeapTupleHeaderGetRawCommandId(hdr);
}
/* No combo CID, so only cmin or cmax can be set by this TX */
@@ -8686,7 +9486,9 @@ heap_xlog_prune(XLogReaderState *record)
heap_page_prune_execute(buffer,
redirected, nredirected,
nowdead, ndead,
- nowunused, nunused);
+ nowunused, nunused,
+ xlrec->flags & XLH_PRUNE_REPAIR_FRAGMENTATION,
+ xlrec->flags & XLH_PRUNE_ON_TOAST_RELATION);
/*
* Note: we don't worry about updating the page's prunability hints.
@@ -8978,7 +9780,8 @@ heap_xlog_freeze_page(XLogReaderState *record)
lp = PageGetItemId(page, xlrec_tp->offset); /* offsets are one-based */
tuple = (HeapTupleHeader) PageGetItem(page, lp);
- heap_execute_freeze_tuple(tuple, xlrec_tp);
+ heap_execute_freeze_tuple_page(page, tuple, xlrec_tp,
+ xlrec->flags & XLH_FREEZE_PAGE_ON_TOAST_RELATION);
}
PageSetLSN(page, lsn);
@@ -9049,6 +9852,8 @@ heap_xlog_delete(XLogReaderState *record)
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
{
+ HeapTupleData tuple;
+
page = BufferGetPage(buffer);
if (PageGetMaxOffsetNumber(page) >= xlrec->offnum)
@@ -9064,14 +9869,29 @@ heap_xlog_delete(XLogReaderState *record)
HeapTupleHeaderClearHotUpdated(htup);
fix_infomask_from_infobits(xlrec->infobits_set,
&htup->t_infomask, &htup->t_infomask2);
+ tuple.t_data = htup;
+
if (!(xlrec->flags & XLH_DELETE_IS_SUPER))
- HeapTupleHeaderSetXmax(htup, xlrec->xmax);
+ {
+ HeapTupleSetXmax(&tuple, xlrec->xmax);
+ if (xlrec->flags & XLH_DELETE_PAGE_ON_TOAST_RELATION)
+ ToastTupleHeaderSetXmax(page, &tuple);
+ else
+ HeapTupleHeaderSetXmax(page, &tuple);
+ }
else
- HeapTupleHeaderSetXmin(htup, InvalidTransactionId);
+ {
+ HeapTupleSetXmin(&tuple, InvalidTransactionId);
+ if (xlrec->flags & XLH_DELETE_PAGE_ON_TOAST_RELATION)
+ ToastTupleHeaderSetXmin(page, &tuple);
+ else
+ HeapTupleHeaderSetXmin(page, &tuple);
+ }
HeapTupleHeaderSetCmax(htup, FirstCommandId, false);
/* Mark the page as a candidate for pruning */
- PageSetPrunable(page, XLogRecGetXid(record));
+ PageSetPrunable(page, XLogRecGetXid(record),
+ xlrec->flags & XLH_DELETE_PAGE_ON_TOAST_RELATION);
if (xlrec->flags & XLH_DELETE_ALL_VISIBLE_CLEARED)
PageClearAllVisible(page);
@@ -9092,7 +9912,7 @@ static void
heap_xlog_insert(XLogReaderState *record)
{
XLogRecPtr lsn = record->EndRecPtr;
- xl_heap_insert *xlrec = (xl_heap_insert *) XLogRecGetData(record);
+ xl_heap_insert *xlrec;
Buffer buffer;
Page page;
union
@@ -9108,6 +9928,17 @@ heap_xlog_insert(XLogReaderState *record)
BlockNumber blkno;
ItemPointerData target_tid;
XLogRedoAction action;
+ bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
+ TransactionId pd_xid_base = InvalidTransactionId;
+ Pointer rec_data = (Pointer) XLogRecGetData(record);
+
+ if (isinit)
+ {
+ pd_xid_base = *((TransactionId *) rec_data);
+ rec_data += sizeof(TransactionId);
+ }
+
+ xlrec = (xl_heap_insert *) rec_data;
XLogRecGetBlockTag(record, 0, &target_locator, NULL, &blkno);
ItemPointerSetBlockNumber(&target_tid, blkno);
@@ -9132,11 +9963,24 @@ heap_xlog_insert(XLogReaderState *record)
* If we inserted the first and only tuple on the page, re-initialize the
* page from scratch.
*/
- if (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE)
+ if (isinit)
{
buffer = XLogInitBufferForRedo(record, 0);
page = BufferGetPage(buffer);
- PageInit(page, BufferGetPageSize(buffer), 0);
+
+ if (xlrec->flags & XLH_INSERT_ON_TOAST_RELATION)
+ {
+ PageInit(page, BufferGetPageSize(buffer),
+ sizeof(ToastPageSpecialData));
+ ToastPageGetSpecial(page)->pd_xid_base = pd_xid_base;
+ }
+ else
+ {
+ PageInit(page, BufferGetPageSize(buffer),
+ sizeof(HeapPageSpecialData));
+ HeapPageGetSpecial(page)->pd_xid_base = pd_xid_base;
+ }
+
action = BLK_NEEDS_REDO;
}
else
@@ -9145,6 +9989,7 @@ heap_xlog_insert(XLogReaderState *record)
{
Size datalen;
char *data;
+ HeapTupleData tuple;
page = BufferGetPage(buffer);
@@ -9168,7 +10013,12 @@ heap_xlog_insert(XLogReaderState *record)
htup->t_infomask2 = xlhdr.t_infomask2;
htup->t_infomask = xlhdr.t_infomask;
htup->t_hoff = xlhdr.t_hoff;
- HeapTupleHeaderSetXmin(htup, XLogRecGetXid(record));
+ tuple.t_data = htup;
+ HeapTupleSetXmin(&tuple, XLogRecGetXid(record));
+ if (xlrec->flags & XLH_INSERT_ON_TOAST_RELATION)
+ ToastTupleHeaderSetXmin(page, &tuple);
+ else
+ HeapTupleHeaderSetXmin(page, &tuple);
HeapTupleHeaderSetCmin(htup, FirstCommandId);
htup->t_ctid = target_tid;
@@ -9189,6 +10039,7 @@ heap_xlog_insert(XLogReaderState *record)
MarkBufferDirty(buffer);
}
+
if (BufferIsValid(buffer))
UnlockReleaseBuffer(buffer);
@@ -9228,12 +10079,19 @@ heap_xlog_multi_insert(XLogReaderState *record)
int i;
bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
XLogRedoAction action;
+ TransactionId pd_xid_base = InvalidTransactionId;
+ Pointer rec_data = (Pointer) XLogRecGetData(record);
/*
* Insertion doesn't overwrite MVCC data, so no conflict processing is
* required.
*/
- xlrec = (xl_heap_multi_insert *) XLogRecGetData(record);
+ if (isinit)
+ {
+ pd_xid_base = *((TransactionId *) rec_data);
+ rec_data += sizeof(TransactionId);
+ }
+ xlrec = (xl_heap_multi_insert *) rec_data;
XLogRecGetBlockTag(record, 0, &rlocator, NULL, &blkno);
@@ -9260,7 +10118,18 @@ heap_xlog_multi_insert(XLogReaderState *record)
{
buffer = XLogInitBufferForRedo(record, 0);
page = BufferGetPage(buffer);
- PageInit(page, BufferGetPageSize(buffer), 0);
+
+ if (xlrec->flags & XLH_INSERT_ON_TOAST_RELATION)
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(ToastPageSpecialData));
+ ToastPageGetSpecial(page)->pd_xid_base = pd_xid_base;
+ }
+ else
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(HeapPageSpecialData));
+ HeapPageGetSpecial(page)->pd_xid_base = pd_xid_base;
+ }
+
action = BLK_NEEDS_REDO;
}
else
@@ -9281,6 +10150,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
{
OffsetNumber offnum;
xl_multi_insert_tuple *xlhdr;
+ HeapTupleData tuple;
/*
* If we're reinitializing the page, the tuples are stored in
@@ -9311,7 +10181,9 @@ heap_xlog_multi_insert(XLogReaderState *record)
htup->t_infomask2 = xlhdr->t_infomask2;
htup->t_infomask = xlhdr->t_infomask;
htup->t_hoff = xlhdr->t_hoff;
- HeapTupleHeaderSetXmin(htup, XLogRecGetXid(record));
+ tuple.t_data = htup;
+ HeapTupleSetXmin(&tuple, XLogRecGetXid(record));
+ HeapTupleHeaderSetXmin(page, &tuple);
HeapTupleHeaderSetCmin(htup, FirstCommandId);
ItemPointerSetBlockNumber(&htup->t_ctid, blkno);
ItemPointerSetOffsetNumber(&htup->t_ctid, offnum);
@@ -9359,8 +10231,8 @@ static void
heap_xlog_update(XLogReaderState *record, bool hot_update)
{
XLogRecPtr lsn = record->EndRecPtr;
- xl_heap_update *xlrec = (xl_heap_update *) XLogRecGetData(record);
RelFileLocator rlocator;
+ xl_heap_update *xlrec;
BlockNumber oldblk;
BlockNumber newblk;
ItemPointerData newtid;
@@ -9384,6 +10256,17 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
Size freespace = 0;
XLogRedoAction oldaction;
XLogRedoAction newaction;
+ bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
+ TransactionId pd_xid_base = InvalidTransactionId;
+ Pointer rec_data = (Pointer) XLogRecGetData(record);
+
+ if (isinit)
+ {
+ pd_xid_base = *((TransactionId *) rec_data);
+ rec_data += sizeof(TransactionId);
+ }
+
+ xlrec = (xl_heap_update *) rec_data;
/* initialize to keep the compiler quiet */
oldtup.t_data = NULL;
@@ -9430,6 +10313,8 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
&obuffer);
if (oldaction == BLK_NEEDS_REDO)
{
+ HeapTupleData tuple;
+
page = BufferGetPage(obuffer);
offnum = xlrec->old_offnum;
if (PageGetMaxOffsetNumber(page) >= offnum)
@@ -9442,6 +10327,8 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
oldtup.t_data = htup;
oldtup.t_len = ItemIdGetLength(lp);
+ /* Toast tuples are never updated. */
+ HeapTupleCopyBaseFromPage(obuffer, &oldtup, page, false);
htup->t_infomask &= ~(HEAP_XMAX_BITS | HEAP_MOVED);
htup->t_infomask2 &= ~HEAP_KEYS_UPDATED;
@@ -9451,13 +10338,16 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
HeapTupleHeaderClearHotUpdated(htup);
fix_infomask_from_infobits(xlrec->old_infobits_set, &htup->t_infomask,
&htup->t_infomask2);
- HeapTupleHeaderSetXmax(htup, xlrec->old_xmax);
+ tuple.t_data = htup;
+ HeapTupleSetXmax(&tuple, xlrec->old_xmax);
+ HeapTupleHeaderSetXmax(page, &tuple);
HeapTupleHeaderSetCmax(htup, FirstCommandId, false);
/* Set forward chain link in t_ctid */
htup->t_ctid = newtid;
/* Mark the page as a candidate for pruning */
- PageSetPrunable(page, XLogRecGetXid(record));
+ /* Toast tuples are never updated. */
+ PageSetPrunable(page, XLogRecGetXid(record), false);
if (xlrec->flags & XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED)
PageClearAllVisible(page);
@@ -9474,11 +10364,15 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
nbuffer = obuffer;
newaction = oldaction;
}
- else if (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE)
+ else if (isinit)
{
nbuffer = XLogInitBufferForRedo(record, 0);
page = (Page) BufferGetPage(nbuffer);
- PageInit(page, BufferGetPageSize(nbuffer), 0);
+
+ /* Toast tuples are never updated. */
+ PageInit(page, BufferGetPageSize(nbuffer), sizeof(HeapPageSpecialData));
+
+ HeapPageGetSpecial(page)->pd_xid_base = pd_xid_base;
newaction = BLK_NEEDS_REDO;
}
else
@@ -9506,6 +10400,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
char *recdata_end;
Size datalen;
Size tuplen;
+ HeapTupleData tuple;
recdata = XLogRecGetBlockData(record, 0, &datalen);
recdata_end = recdata + datalen;
@@ -9584,9 +10479,12 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
htup->t_infomask = xlhdr.t_infomask;
htup->t_hoff = xlhdr.t_hoff;
- HeapTupleHeaderSetXmin(htup, XLogRecGetXid(record));
+ tuple.t_data = htup;
+ HeapTupleSetXmin(&tuple, XLogRecGetXid(record));
+ HeapTupleHeaderSetXmin(page, &tuple);
HeapTupleHeaderSetCmin(htup, FirstCommandId);
- HeapTupleHeaderSetXmax(htup, xlrec->new_xmax);
+ HeapTupleSetXmax(&tuple, xlrec->new_xmax);
+ HeapTupleHeaderSetXmax(page, &tuple);
/* Make sure there is no forward chain link in t_ctid */
htup->t_ctid = newtid;
@@ -9697,6 +10595,8 @@ heap_xlog_lock(XLogReaderState *record)
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
{
+ HeapTupleData tuple;
+
page = (Page) BufferGetPage(buffer);
offnum = xlrec->offnum;
@@ -9725,7 +10625,10 @@ heap_xlog_lock(XLogReaderState *record)
BufferGetBlockNumber(buffer),
offnum);
}
- HeapTupleHeaderSetXmax(htup, xlrec->locking_xid);
+
+ tuple.t_data = htup;
+ HeapTupleSetXmax(&tuple, xlrec->locking_xid);
+ HeapTupleHeaderSetXmax(page, &tuple);
HeapTupleHeaderSetCmax(htup, FirstCommandId, false);
PageSetLSN(page, lsn);
MarkBufferDirty(buffer);
@@ -9770,6 +10673,8 @@ heap_xlog_lock_updated(XLogReaderState *record)
if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
{
+ HeapTupleData tuple;
+
page = BufferGetPage(buffer);
offnum = xlrec->offnum;
@@ -9785,7 +10690,9 @@ heap_xlog_lock_updated(XLogReaderState *record)
htup->t_infomask2 &= ~HEAP_KEYS_UPDATED;
fix_infomask_from_infobits(xlrec->infobits_set, &htup->t_infomask,
&htup->t_infomask2);
- HeapTupleHeaderSetXmax(htup, xlrec->xmax);
+ tuple.t_data = htup;
+ HeapTupleSetXmax(&tuple, xlrec->xmax);
+ HeapTupleHeaderSetXmax(page, &tuple);
PageSetLSN(page, lsn);
MarkBufferDirty(buffer);
@@ -9835,6 +10742,33 @@ heap_xlog_inplace(XLogReaderState *record)
UnlockReleaseBuffer(buffer);
}
+static void
+heap_xlog_base_shift(XLogReaderState *record)
+{
+ XLogRecPtr lsn = record->EndRecPtr;
+ xl_heap_base_shift *xlrec = (xl_heap_base_shift *) XLogRecGetData(record);
+ Buffer buffer;
+ Page page;
+ BlockNumber blkno;
+ RelFileLocator target_node;
+
+ XLogRecGetBlockTag(record, 0, &target_node, NULL, &blkno);
+
+ if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO)
+ {
+ page = BufferGetPage(buffer);
+ heap_page_shift_base(NULL, InvalidBuffer, page, xlrec->multi,
+ xlrec->delta,
+ xlrec->flags & XLH_BASE_SHIFT_ON_TOAST_RELATION);
+ PageSetLSN(page, lsn);
+ MarkBufferDirty(buffer);
+ }
+
+ if (BufferIsValid(buffer))
+ UnlockReleaseBuffer(buffer);
+}
+
+
void
heap_redo(XLogReaderState *record)
{
@@ -9921,6 +10855,21 @@ heap2_redo(XLogReaderState *record)
}
}
+void
+heap3_redo(XLogReaderState *record)
+{
+ uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+
+ switch (info & XLOG_HEAP_OPMASK)
+ {
+ case XLOG_HEAP3_BASE_SHIFT:
+ heap_xlog_base_shift(record);
+ break;
+ default:
+ elog(PANIC, "heap3_redo: unknown op code %u", info);
+ }
+}
+
/*
* Mask a heap page before performing consistency checks on it.
*/
@@ -9933,6 +10882,10 @@ heap_mask(char *pagedata, BlockNumber blkno)
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);
+
+ /* Ignore prune_xid (it's like a hint-bit) */
+ HeapPageSetPruneXid(page, InvalidTransactionId, false);
+
mask_unused_space(page);
for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
@@ -10048,14 +11001,14 @@ HeapCheckForSerializableConflictOut(bool visible, Relation relation,
case HEAPTUPLE_LIVE:
if (visible)
return;
- xid = HeapTupleHeaderGetXmin(tuple->t_data);
+ xid = HeapTupleGetXmin(tuple);
break;
case HEAPTUPLE_RECENTLY_DEAD:
case HEAPTUPLE_DELETE_IN_PROGRESS:
if (visible)
- xid = HeapTupleHeaderGetUpdateXid(tuple->t_data);
+ xid = HeapTupleGetUpdateXidAny(tuple);
else
- xid = HeapTupleHeaderGetXmin(tuple->t_data);
+ xid = HeapTupleGetXmin(tuple);
if (TransactionIdPrecedes(xid, TransactionXmin))
{
@@ -10065,7 +11018,7 @@ HeapCheckForSerializableConflictOut(bool visible, Relation relation,
}
break;
case HEAPTUPLE_INSERT_IN_PROGRESS:
- xid = HeapTupleHeaderGetXmin(tuple->t_data);
+ xid = HeapTupleGetXmin(tuple);
break;
case HEAPTUPLE_DEAD:
Assert(!visible);
@@ -10103,3 +11056,38 @@ HeapCheckForSerializableConflictOut(bool visible, Relation relation,
CheckForSerializableConflictOut(relation, xid, snapshot);
}
+
+/*
+ * Ensure that given xid fits base of given page.
+ */
+static bool
+heap_page_prepare_for_xid(Relation relation, Buffer buffer,
+ TransactionId xid, bool multi)
+{
+ Page page = BufferGetPage(buffer);
+ int res;
+
+ /* "Double xmax" page format doesn't require any preparation */
+ if (HeapPageIsDoubleXmax(page))
+ return false;
+
+ if (!TransactionIdIsNormal(xid))
+ return false;
+
+ res = heap_page_try_prepare_for_xid(relation, buffer, page, xid, multi,
+ IsToastRelation(relation));
+ if (res != -1)
+ return res == 1;
+
+ /* Have to try freeing the page... */
+ freeze_single_heap_page(relation, buffer);
+
+ res = heap_page_try_prepare_for_xid(relation, buffer, page, xid, multi,
+ IsToastRelation(relation));
+ if (res != -1)
+ return res == 1;
+
+ elog(ERROR, "could not fit xid into page");
+
+ return false;
+}
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 335abea67c..ffbfae09dd 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -413,7 +413,7 @@ tuple_lock_retry:
* changes in an existing tuple, except to invalid or
* frozen, and neither of those can match priorXmax.)
*/
- if (!TransactionIdEquals(HeapTupleHeaderGetXmin(tuple->t_data),
+ if (!TransactionIdEquals(HeapTupleGetXmin(tuple),
priorXmax))
{
ReleaseBuffer(buffer);
@@ -473,7 +473,7 @@ tuple_lock_retry:
* variable instead of doing HeapTupleHeaderGetXmin again.
*/
if (TransactionIdIsCurrentTransactionId(priorXmax) &&
- HeapTupleHeaderGetCmin(tuple->t_data) >= cid)
+ HeapTupleGetCmin(tuple) >= cid)
{
tmfd->xmax = priorXmax;
@@ -481,7 +481,7 @@ tuple_lock_retry:
* Cmin is the problematic value, so store that. See
* above.
*/
- tmfd->cmax = HeapTupleHeaderGetCmin(tuple->t_data);
+ tmfd->cmax = HeapTupleGetCmin(tuple);
ReleaseBuffer(buffer);
return TM_SelfModified;
}
@@ -507,7 +507,7 @@ tuple_lock_retry:
/*
* As above, if xmin isn't what we're expecting, do nothing.
*/
- if (!TransactionIdEquals(HeapTupleHeaderGetXmin(tuple->t_data),
+ if (!TransactionIdEquals(HeapTupleGetXmin(tuple),
priorXmax))
{
ReleaseBuffer(buffer);
@@ -538,7 +538,7 @@ tuple_lock_retry:
/* updated, so look at the updated row */
*tid = tuple->t_data->t_ctid;
/* updated row should have xmin matching this xmax */
- priorXmax = HeapTupleHeaderGetUpdateXid(tuple->t_data);
+ priorXmax = HeapTupleGetUpdateXidAny(tuple);
ReleaseBuffer(buffer);
/* loop back to fetch next in chain */
}
@@ -858,7 +858,7 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
* case we had better copy it.
*/
if (!is_system_catalog &&
- !TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple->t_data)))
+ !TransactionIdIsCurrentTransactionId(HeapTupleGetXmin(tuple)))
elog(WARNING, "concurrent insert in progress within table \"%s\"",
RelationGetRelationName(OldHeap));
/* treat as live */
@@ -870,7 +870,7 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
* Similar situation to INSERT_IN_PROGRESS case.
*/
if (!is_system_catalog &&
- !TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tuple->t_data)))
+ !TransactionIdIsCurrentTransactionId(HeapTupleGetUpdateXidAny(tuple)))
elog(WARNING, "concurrent delete in progress within table \"%s\"",
RelationGetRelationName(OldHeap));
/* treat as recently dead */
@@ -1055,6 +1055,8 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
targtuple->t_tableOid = RelationGetRelid(scan->rs_rd);
targtuple->t_data = (HeapTupleHeader) PageGetItem(targpage, itemid);
targtuple->t_len = ItemIdGetLength(itemid);
+ HeapTupleCopyBaseFromPage(hscan->rs_cbuf, targtuple, targpage,
+ IsToastRelation(scan->rs_rd));
switch (HeapTupleSatisfiesVacuum(targtuple, OldestXmin,
hscan->rs_cbuf))
@@ -1090,7 +1092,7 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
* numbers we report to the cumulative stats system to make
* this come out right.)
*/
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(targtuple->t_data)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetXmin(targtuple)))
{
sample_it = true;
*liverows += 1;
@@ -1121,7 +1123,7 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
* but not the post-image. We also get sane results if the
* concurrent transaction never commits.
*/
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(targtuple->t_data)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetUpdateXidAny(targtuple)))
*deadrows += 1;
else
{
@@ -1370,7 +1372,8 @@ heapam_index_build_range_scan(Relation heapRelation,
Page page = BufferGetPage(hscan->rs_cbuf);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_SHARE);
- heap_get_root_tuples(page, root_offsets);
+ heap_get_root_tuples(heapRelation, hscan->rs_cbuf, page,
+ root_offsets);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_UNLOCK);
root_blkno = hscan->rs_cblock;
@@ -1463,7 +1466,7 @@ heapam_index_build_range_scan(Relation heapRelation,
* before commit there. Give a warning if neither case
* applies.
*/
- xwait = HeapTupleHeaderGetXmin(heapTuple->t_data);
+ xwait = HeapTupleGetXmin(heapTuple);
if (!TransactionIdIsCurrentTransactionId(xwait))
{
if (!is_system_catalog)
@@ -1522,7 +1525,7 @@ heapam_index_build_range_scan(Relation heapRelation,
break;
}
- xwait = HeapTupleHeaderGetUpdateXid(heapTuple->t_data);
+ xwait = HeapTupleGetUpdateXidAny(heapTuple);
if (!TransactionIdIsCurrentTransactionId(xwait))
{
if (!is_system_catalog)
@@ -1667,7 +1670,8 @@ heapam_index_build_range_scan(Relation heapRelation,
Page page = BufferGetPage(hscan->rs_cbuf);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_SHARE);
- heap_get_root_tuples(page, root_offsets);
+ heap_get_root_tuples(heapRelation, hscan->rs_cbuf, page,
+ root_offsets);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_UNLOCK);
}
@@ -1833,7 +1837,8 @@ heapam_index_validate_scan(Relation heapRelation,
Page page = BufferGetPage(hscan->rs_cbuf);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_SHARE);
- heap_get_root_tuples(page, root_offsets);
+ heap_get_root_tuples(heapRelation, hscan->rs_cbuf, page,
+ root_offsets);
LockBuffer(hscan->rs_cbuf, BUFFER_LOCK_UNLOCK);
memset(in_index, 0, sizeof(in_index));
@@ -2200,13 +2205,15 @@ heapam_scan_bitmap_next_block(TableScanDesc scan,
loctup.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
loctup.t_len = ItemIdGetLength(lp);
loctup.t_tableOid = scan->rs_rd->rd_id;
+ HeapTupleCopyBaseFromPage(hscan->rs_cbuf, &loctup, dp,
+ IsToastRelation(scan->rs_rd));
ItemPointerSet(&loctup.t_self, page, offnum);
valid = HeapTupleSatisfiesVisibility(&loctup, snapshot, buffer);
if (valid)
{
hscan->rs_vistuples[ntup++] = offnum;
PredicateLockTID(scan->rs_rd, &loctup.t_self, snapshot,
- HeapTupleHeaderGetXmin(loctup.t_data));
+ HeapTupleGetXmin(&loctup));
}
HeapCheckForSerializableConflictOut(valid, scan->rs_rd, &loctup,
buffer, snapshot);
@@ -2221,6 +2228,13 @@ heapam_scan_bitmap_next_block(TableScanDesc scan,
return ntup > 0;
}
+static inline void
+HeapTupleSetInvalid(HeapTuple tuple)
+{
+ tuple->t_xmin = InvalidTransactionId;
+ tuple->t_xmax = InvalidTransactionId;
+}
+
static bool
heapam_scan_bitmap_next_tuple(TableScanDesc scan,
TBMIterateResult *tbmres,
@@ -2245,6 +2259,7 @@ heapam_scan_bitmap_next_tuple(TableScanDesc scan,
hscan->rs_ctup.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
hscan->rs_ctup.t_len = ItemIdGetLength(lp);
hscan->rs_ctup.t_tableOid = scan->rs_rd->rd_id;
+ HeapTupleSetInvalid(&hscan->rs_ctup);
ItemPointerSet(&hscan->rs_ctup.t_self, hscan->rs_cblock, targoffset);
pgstat_count_heap_fetch(scan->rs_rd);
@@ -2385,8 +2400,14 @@ heapam_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate,
tuple->t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple->t_len = ItemIdGetLength(itemid);
- ItemPointerSet(&(tuple->t_self), blockno, tupoffset);
+ if (pagemode)
+ HeapTupleSetInvalid(tuple);
+ else
+ HeapTupleCopyBaseFromPage(hscan->rs_cbuf, tuple, page,
+ IsToastRelation(scan->rs_rd));
+
+ ItemPointerSet(&(tuple->t_self), blockno, tupoffset);
if (all_visible)
visible = true;
diff --git a/src/backend/access/heap/heapam_visibility.c b/src/backend/access/heap/heapam_visibility.c
index 6e33d1c881..370a8a67d8 100644
--- a/src/backend/access/heap/heapam_visibility.c
+++ b/src/backend/access/heap/heapam_visibility.c
@@ -217,7 +217,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
}
}
}
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(htup)))
{
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
return true;
@@ -229,7 +229,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
{
TransactionId xmax;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -241,7 +241,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
return false;
}
- if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -251,11 +251,11 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
return false;
}
- else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsInProgress(HeapTupleGetRawXmin(htup)))
return false;
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmin(htup)))
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
+ HeapTupleGetRawXmin(htup));
else
{
/* it must have aborted or crashed */
@@ -284,7 +284,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
return true;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -299,17 +299,17 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
return true;
}
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
return true;
return false;
}
- if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsInProgress(HeapTupleGetRawXmax(htup)))
return true;
- if (!TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdDidCommit(HeapTupleGetRawXmax(htup)))
{
/* it must have aborted or crashed */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -327,7 +327,7 @@ HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
}
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
return false;
}
@@ -416,7 +416,7 @@ HeapTupleSatisfiesToast(HeapTuple htup, Snapshot snapshot,
* is canceled by super-deleting the tuple. This also applies to
* TOAST tuples created during speculative insertion.
*/
- else if (!TransactionIdIsValid(HeapTupleHeaderGetXmin(tuple)))
+ else if (!TransactionIdIsValid(HeapTupleGetXmin(htup)))
return false;
}
@@ -506,9 +506,9 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
}
}
}
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(htup)))
{
- if (HeapTupleHeaderGetCmin(tuple) >= curcid)
+ if (HeapTupleGetCmin(htup) >= curcid)
return TM_Invisible; /* inserted after scan started */
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
@@ -518,7 +518,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
{
TransactionId xmax;
- xmax = HeapTupleHeaderGetRawXmax(tuple);
+ xmax = HeapTupleGetRawXmax(htup);
/*
* Careful here: even though this tuple was created by our own
@@ -549,7 +549,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
{
TransactionId xmax;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -557,21 +557,21 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
/* deleting subtransaction must have aborted */
if (!TransactionIdIsCurrentTransactionId(xmax))
{
- if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple),
+ if (MultiXactIdIsRunning(HeapTupleGetRawXmax(htup),
false))
return TM_BeingModified;
return TM_Ok;
}
else
{
- if (HeapTupleHeaderGetCmax(tuple) >= curcid)
+ if (HeapTupleGetCmax(htup) >= curcid)
return TM_SelfModified; /* updated after scan started */
else
return TM_Invisible; /* updated before scan started */
}
}
- if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -579,16 +579,16 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
return TM_Ok;
}
- if (HeapTupleHeaderGetCmax(tuple) >= curcid)
+ if (HeapTupleGetCmax(htup) >= curcid)
return TM_SelfModified; /* updated after scan started */
else
return TM_Invisible; /* updated before scan started */
}
- else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsInProgress(HeapTupleGetRawXmin(htup)))
return TM_Invisible;
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmin(htup)))
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
+ HeapTupleGetRawXmin(htup));
else
{
/* it must have aborted or crashed */
@@ -622,17 +622,17 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
{
- if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), true))
+ if (MultiXactIdIsRunning(HeapTupleGetRawXmax(htup), true))
return TM_BeingModified;
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, InvalidTransactionId);
return TM_Ok;
}
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
if (!TransactionIdIsValid(xmax))
{
- if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
+ if (MultiXactIdIsRunning(HeapTupleGetRawXmax(htup), false))
return TM_BeingModified;
}
@@ -641,13 +641,13 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
if (TransactionIdIsCurrentTransactionId(xmax))
{
- if (HeapTupleHeaderGetCmax(tuple) >= curcid)
+ if (HeapTupleGetCmax(htup) >= curcid)
return TM_SelfModified; /* updated after scan started */
else
return TM_Invisible; /* updated before scan started */
}
- if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
+ if (MultiXactIdIsRunning(HeapTupleGetRawXmax(htup), false))
return TM_BeingModified;
if (TransactionIdDidCommit(xmax))
@@ -663,7 +663,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
* what about the other members?
*/
- if (!MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
+ if (!MultiXactIdIsRunning(HeapTupleGetRawXmax(htup), false))
{
/*
* There's no member, even just a locker, alive anymore, so we can
@@ -680,20 +680,20 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
}
}
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
return TM_BeingModified;
- if (HeapTupleHeaderGetCmax(tuple) >= curcid)
+ if (HeapTupleGetCmax(htup) >= curcid)
return TM_SelfModified; /* updated after scan started */
else
return TM_Invisible; /* updated before scan started */
}
- if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsInProgress(HeapTupleGetRawXmax(htup)))
return TM_BeingModified;
- if (!TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdDidCommit(HeapTupleGetRawXmax(htup)))
{
/* it must have aborted or crashed */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -711,7 +711,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
}
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid))
return TM_Updated; /* updated by other */
else
@@ -794,7 +794,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
}
}
}
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(htup)))
{
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
return true;
@@ -806,7 +806,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
{
TransactionId xmax;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -818,7 +818,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
return false;
}
- if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -828,7 +828,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
return false;
}
- else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsInProgress(HeapTupleGetRawXmin(htup)))
{
/*
* Return the speculative token to caller. Caller can worry about
@@ -844,13 +844,13 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
Assert(snapshot->speculativeToken != 0);
}
- snapshot->xmin = HeapTupleHeaderGetRawXmin(tuple);
+ snapshot->xmin = HeapTupleGetRawXmin(htup);
/* XXX shouldn't we fall through to look at xmax? */
return true; /* in insertion by other */
}
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmin(htup)))
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
+ HeapTupleGetRawXmin(htup));
else
{
/* it must have aborted or crashed */
@@ -879,7 +879,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
return true;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -897,21 +897,21 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
return true;
}
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
return true;
return false;
}
- if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsInProgress(HeapTupleGetRawXmax(htup)))
{
if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
- snapshot->xmax = HeapTupleHeaderGetRawXmax(tuple);
+ snapshot->xmax = HeapTupleGetRawXmax(htup);
return true;
}
- if (!TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdDidCommit(HeapTupleGetRawXmax(htup)))
{
/* it must have aborted or crashed */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -929,7 +929,7 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
}
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
return false; /* updated by other */
}
@@ -1008,9 +1008,9 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
}
}
}
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(htup)))
{
- if (HeapTupleHeaderGetCmin(tuple) >= snapshot->curcid)
+ if (HeapTupleGetCmin(htup) >= snapshot->curcid)
return false; /* inserted after scan started */
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
@@ -1023,7 +1023,7 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
{
TransactionId xmax;
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -1031,13 +1031,13 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
/* updating subtransaction must have aborted */
if (!TransactionIdIsCurrentTransactionId(xmax))
return true;
- else if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
+ else if (HeapTupleGetCmax(htup) >= snapshot->curcid)
return true; /* updated after scan started */
else
return false; /* updated before scan started */
}
- if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
/* deleting subtransaction must have aborted */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -1045,16 +1045,16 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
return true;
}
- if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
+ if (HeapTupleGetCmax(htup) >= snapshot->curcid)
return true; /* deleted after scan started */
else
return false; /* deleted before scan started */
}
- else if (XidInMVCCSnapshot(HeapTupleHeaderGetRawXmin(tuple), snapshot))
+ else if (XidInMVCCSnapshot(HeapTupleGetRawXmin(htup), snapshot))
return false;
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmin(htup)))
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
+ HeapTupleGetRawXmin(htup));
else
{
/* it must have aborted or crashed */
@@ -1067,7 +1067,7 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
{
/* xmin is committed, but maybe not according to our snapshot */
if (!HeapTupleHeaderXminFrozen(tuple) &&
- XidInMVCCSnapshot(HeapTupleHeaderGetRawXmin(tuple), snapshot))
+ XidInMVCCSnapshot(HeapTupleGetRawXmin(htup), snapshot))
return false; /* treat as still in progress */
}
@@ -1086,14 +1086,14 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
/* already checked above */
Assert(!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask));
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
if (TransactionIdIsCurrentTransactionId(xmax))
{
- if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
+ if (HeapTupleGetCmax(htup) >= snapshot->curcid)
return true; /* deleted after scan started */
else
return false; /* deleted before scan started */
@@ -1108,18 +1108,18 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED))
{
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmax(htup)))
{
- if (HeapTupleHeaderGetCmax(tuple) >= snapshot->curcid)
+ if (HeapTupleGetCmax(htup) >= snapshot->curcid)
return true; /* deleted after scan started */
else
return false; /* deleted before scan started */
}
- if (XidInMVCCSnapshot(HeapTupleHeaderGetRawXmax(tuple), snapshot))
+ if (XidInMVCCSnapshot(HeapTupleGetRawXmax(htup), snapshot))
return true;
- if (!TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdDidCommit(HeapTupleGetRawXmax(htup)))
{
/* it must have aborted or crashed */
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
@@ -1129,12 +1129,12 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
/* xmax transaction committed */
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
}
else
{
/* xmax is committed, but maybe not according to our snapshot */
- if (XidInMVCCSnapshot(HeapTupleHeaderGetRawXmax(tuple), snapshot))
+ if (XidInMVCCSnapshot(HeapTupleGetRawXmax(htup), snapshot))
return true; /* treat as still in progress */
}
@@ -1249,21 +1249,21 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
return HEAPTUPLE_DEAD;
}
}
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(htup)))
{
if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
return HEAPTUPLE_INSERT_IN_PROGRESS;
/* only locked? run infomask-only check first, for performance */
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask) ||
- HeapTupleHeaderIsOnlyLocked(tuple))
+ HeapTupleIsOnlyLocked(htup))
return HEAPTUPLE_INSERT_IN_PROGRESS;
/* inserted and then deleted by same xact */
- if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tuple)))
+ if (TransactionIdIsCurrentTransactionId(HeapTupleGetUpdateXidAny(htup)))
return HEAPTUPLE_DELETE_IN_PROGRESS;
/* deleting subtransaction must have aborted */
return HEAPTUPLE_INSERT_IN_PROGRESS;
}
- else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdIsInProgress(HeapTupleGetRawXmin(htup)))
{
/*
* It'd be possible to discern between INSERT/DELETE in progress
@@ -1275,9 +1275,9 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
*/
return HEAPTUPLE_INSERT_IN_PROGRESS;
}
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmin(htup)))
SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
+ HeapTupleGetRawXmin(htup));
else
{
/*
@@ -1319,14 +1319,14 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
* possibly be running; otherwise have to check.
*/
if (!HEAP_LOCKED_UPGRADED(tuple->t_infomask) &&
- MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple),
+ MultiXactIdIsRunning(HeapTupleGetRawXmax(htup),
true))
return HEAPTUPLE_LIVE;
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, InvalidTransactionId);
}
else
{
- if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsInProgress(HeapTupleGetRawXmax(htup)))
return HEAPTUPLE_LIVE;
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
InvalidTransactionId);
@@ -1344,7 +1344,7 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
{
- TransactionId xmax = HeapTupleGetUpdateXid(tuple);
+ TransactionId xmax = HeapTupleGetUpdateXid(htup);
/* already checked above */
Assert(!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask));
@@ -1367,7 +1367,7 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
*dead_after = xmax;
return HEAPTUPLE_RECENTLY_DEAD;
}
- else if (!MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
+ else if (!MultiXactIdIsRunning(HeapTupleGetRawXmax(htup), false))
{
/*
* Not in Progress, Not Committed, so either Aborted or crashed.
@@ -1381,11 +1381,11 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED))
{
- if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
+ if (TransactionIdIsInProgress(HeapTupleGetRawXmax(htup)))
return HEAPTUPLE_DELETE_IN_PROGRESS;
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmax(tuple)))
+ else if (TransactionIdDidCommit(HeapTupleGetRawXmax(htup)))
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
else
{
/*
@@ -1407,7 +1407,7 @@ HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *de
* Deleter committed, allow caller to check if it was recent enough that
* some open transactions could still see the tuple.
*/
- *dead_after = HeapTupleHeaderGetRawXmax(tuple);
+ *dead_after = HeapTupleGetRawXmax(htup);
return HEAPTUPLE_RECENTLY_DEAD;
}
@@ -1503,7 +1503,7 @@ HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
/* Deleter committed, so tuple is dead if the XID is old enough. */
return GlobalVisTestIsRemovableXid(vistest,
- HeapTupleHeaderGetRawXmax(tuple));
+ HeapTupleGetRawXmax(htup));
}
/*
@@ -1516,8 +1516,9 @@ HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
* at the top of this file.
*/
bool
-HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple)
+HeapTupleIsOnlyLocked(HeapTuple htup)
{
+ HeapTupleHeader tuple = htup->t_data;
TransactionId xmax;
/* if there's no valid Xmax, then there's obviously no update either */
@@ -1528,7 +1529,7 @@ HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple)
return true;
/* invalid xmax means no update */
- if (!TransactionIdIsValid(HeapTupleHeaderGetRawXmax(tuple)))
+ if (!TransactionIdIsValid(HeapTupleGetRawXmax(htup)))
return true;
/*
@@ -1539,7 +1540,7 @@ HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple)
return false;
/* ... but if it's a multi, then perhaps the updating Xid aborted. */
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
/* not LOCKED_ONLY, so it has to have an xmax */
Assert(TransactionIdIsValid(xmax));
@@ -1587,8 +1588,8 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
Buffer buffer)
{
HeapTupleHeader tuple = htup->t_data;
- TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
- TransactionId xmax = HeapTupleHeaderGetRawXmax(tuple);
+ TransactionId xmin = HeapTupleGetXmin(htup);
+ TransactionId xmax = HeapTupleGetRawXmax(htup);
Assert(ItemPointerIsValid(&htup->t_self));
Assert(htup->t_tableOid != InvalidOid);
@@ -1688,7 +1689,7 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
*/
else if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
{
- xmax = HeapTupleGetUpdateXid(tuple);
+ xmax = HeapTupleGetUpdateXid(htup);
}
/* check if it's one of our txids, toplevel is also in there */
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 1575a81b01..252e57cc1d 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -307,6 +307,7 @@ heap_toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
result_tuple->t_len = new_tuple_len;
result_tuple->t_self = newtup->t_self;
result_tuple->t_tableOid = newtup->t_tableOid;
+ HeapTupleCopyBase(result_tuple, newtup);
new_data = (HeapTupleHeader) ((char *) result_tuple + HEAPTUPLESIZE);
result_tuple->t_data = new_data;
@@ -395,6 +396,7 @@ toast_flatten_tuple(HeapTuple tup, TupleDesc tupleDesc)
*/
new_tuple->t_self = tup->t_self;
new_tuple->t_tableOid = tup->t_tableOid;
+ HeapTupleCopyBase(new_tuple, tup);
new_tuple->t_data->t_choice = tup->t_data->t_choice;
new_tuple->t_data->t_ctid = tup->t_data->t_ctid;
@@ -467,6 +469,7 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
tmptup.t_data = tup;
+ HeapTupleSetZeroBase(&tmptup);
/*
* Break down the tuple into fields.
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index b0ece66629..49a91b727b 100644
--- a/src/backend/access/heap/hio.c
+++ b/src/backend/access/heap/hio.c
@@ -19,6 +19,7 @@
#include "access/hio.h"
#include "access/htup_details.h"
#include "access/visibilitymap.h"
+#include "catalog/catalog.h"
#include "storage/bufmgr.h"
#include "storage/freespace.h"
#include "storage/lmgr.h"
@@ -59,6 +60,19 @@ RelationPutHeapTuple(Relation relation,
/* Add the tuple to the page */
pageHeader = BufferGetPage(buffer);
+ HeapTupleSetXmin(tuple, tuple->t_xmin);
+ if (IsToastRelation(relation))
+ {
+ ToastTupleHeaderSetXmin(pageHeader, tuple);
+ ToastTupleHeaderSetXmax(pageHeader, tuple);
+ }
+ else
+ {
+ HeapTupleHeaderSetXmin(pageHeader, tuple);
+ HeapTupleHeaderSetXmax(pageHeader, tuple);
+ }
+ HeapTupleSetXmax(tuple, tuple->t_xmax);
+
offnum = PageAddItem(pageHeader, (Item) tuple->t_data,
tuple->t_len, InvalidOffsetNumber, false, true);
@@ -243,7 +257,7 @@ RelationAddExtraBlocks(Relation relation, BulkInsertState bistate)
/* we'll need this info below */
blockNum = BufferGetBlockNumber(buffer);
- freespace = BufferGetPageSize(buffer) - SizeOfPageHeaderData;
+ freespace = BufferGetPageSize(buffer) - SizeOfPageHeaderData - MAXALIGN(sizeof(HeapPageSpecialData));
UnlockReleaseBuffer(buffer);
@@ -514,6 +528,9 @@ loop:
/*
* Now we can check to see if there's enough free space here. If so,
* we're done.
+ *
+ * "Double xmax" page is not suitable for any new tuple, since xmin
+ * can't be set there.
*/
page = BufferGetPage(buffer);
@@ -525,12 +542,23 @@ loop:
*/
if (PageIsNew(page))
{
- PageInit(page, BufferGetPageSize(buffer), 0);
+ if (IsToastRelation(relation))
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(ToastPageSpecialData));
+ ToastPageGetSpecial(page)->pd_xid_base = RecentXmin - FirstNormalTransactionId;
+ }
+ else
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(HeapPageSpecialData));
+ HeapPageGetSpecial(page)->pd_xid_base = RecentXmin - FirstNormalTransactionId;
+ }
+
MarkBufferDirty(buffer);
}
pageFreeSpace = PageGetHeapFreeSpace(page);
- if (targetFreeSpace <= pageFreeSpace)
+ if (targetFreeSpace <= pageFreeSpace &&
+ !HeapPageIsDoubleXmax(page))
{
/* use this page as future insert target, too */
RelationSetTargetBlock(relation, targetBlock);
@@ -635,7 +663,17 @@ loop:
BufferGetBlockNumber(buffer),
RelationGetRelationName(relation));
- PageInit(page, BufferGetPageSize(buffer), 0);
+ if (IsToastRelation(relation))
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(ToastPageSpecialData));
+ ToastPageGetSpecial(page)->pd_xid_base = RecentXmin - FirstNormalTransactionId;
+ }
+ else
+ {
+ PageInit(page, BufferGetPageSize(buffer), sizeof(HeapPageSpecialData));
+ HeapPageGetSpecial(page)->pd_xid_base = RecentXmin - FirstNormalTransactionId;
+ }
+
MarkBufferDirty(buffer);
/*
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 9f43bbe25f..b1eff5a068 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -91,6 +91,17 @@ static void heap_prune_record_dead(PruneState *prstate, OffsetNumber offnum);
static void heap_prune_record_unused(PruneState *prstate, OffsetNumber offnum);
static void page_verify_redirects(Page page);
+static inline bool
+XidFitsPage(Page page, TransactionId xid, bool is_toast)
+{
+ TransactionId base;
+
+ base = is_toast ? ToastPageGetSpecial(page)->pd_xid_base :
+ HeapPageGetSpecial(page)->pd_xid_base;
+
+ return xid >= base + FirstNormalTransactionId &&
+ xid <= base + MaxShortTransactionId;
+}
/*
* Optionally prune and repair fragmentation in the specified page.
@@ -136,7 +147,8 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
* determining the appropriate horizon is a waste if there's no prune_xid
* (i.e. no updates/deletes left potentially dead tuples around).
*/
- prune_xid = ((PageHeader) page)->pd_prune_xid;
+ prune_xid = HeapPageGetPruneXidNoAssert(page, IsToastRelation(relation));
+
if (!TransactionIdIsValid(prune_xid))
return;
@@ -207,7 +219,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
nnewlpdead;
ndeleted = heap_page_prune(relation, buffer, vistest, limited_xmin,
- limited_ts, &nnewlpdead, NULL);
+ limited_ts, &nnewlpdead, NULL, true);
/*
* Report the number of tuples reclaimed to pgstats. This is
@@ -268,7 +280,8 @@ heap_page_prune(Relation relation, Buffer buffer,
TransactionId old_snap_xmin,
TimestampTz old_snap_ts,
int *nnewlpdead,
- OffsetNumber *off_loc)
+ OffsetNumber *off_loc,
+ bool repairFragmentation)
{
int ndeleted = 0;
Page page = BufferGetPage(buffer);
@@ -339,6 +352,8 @@ heap_page_prune(Relation relation, Buffer buffer,
htup = (HeapTupleHeader) PageGetItem(page, itemid);
tup.t_data = htup;
tup.t_len = ItemIdGetLength(itemid);
+ HeapTupleCopyBaseFromPage(buffer, &tup, page,
+ IsToastRelation(relation));
ItemPointerSet(&(tup.t_self), blockno, offnum);
/*
@@ -393,13 +408,17 @@ heap_page_prune(Relation relation, Buffer buffer,
heap_page_prune_execute(buffer,
prstate.redirected, prstate.nredirected,
prstate.nowdead, prstate.ndead,
- prstate.nowunused, prstate.nunused);
+ prstate.nowunused, prstate.nunused,
+ repairFragmentation,
+ IsToastRelation(relation));
/*
* Update the page's pd_prune_xid field to either zero, or the lowest
* XID of any soon-prunable tuple.
*/
- ((PageHeader) page)->pd_prune_xid = prstate.new_prune_xid;
+ if (XidFitsPage(page, prstate.new_prune_xid, IsToastRelation(relation)))
+ HeapPageSetPruneXid(page, prstate.new_prune_xid,
+ IsToastRelation(relation));
/*
* Also clear the "page is full" flag, since there's no point in
@@ -421,6 +440,13 @@ heap_page_prune(Relation relation, Buffer buffer,
xlrec.latestRemovedXid = prstate.latestRemovedXid;
xlrec.nredirected = prstate.nredirected;
xlrec.ndead = prstate.ndead;
+ xlrec.flags = 0;
+
+ if (IsToastRelation(relation))
+ xlrec.flags |= XLH_PRUNE_ON_TOAST_RELATION;
+
+ if (repairFragmentation)
+ xlrec.flags |= XLH_PRUNE_REPAIR_FRAGMENTATION;
XLogBeginInsert();
XLogRegisterData((char *) &xlrec, SizeOfHeapPrune);
@@ -461,10 +487,12 @@ heap_page_prune(Relation relation, Buffer buffer,
* point in repeating the prune/defrag process until something else
* happens to the page.
*/
- if (((PageHeader) page)->pd_prune_xid != prstate.new_prune_xid ||
+ bool is_toast = IsToastRelation(relation);
+
+ if (HeapPageGetPruneXid(page, is_toast) != prstate.new_prune_xid ||
PageIsFull(page))
{
- ((PageHeader) page)->pd_prune_xid = prstate.new_prune_xid;
+ HeapPageSetPruneXid(page, prstate.new_prune_xid, is_toast);
PageClearFull(page);
MarkBufferDirtyHint(buffer, true);
}
@@ -601,6 +629,9 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
OffsetNumber chainitems[MaxHeapTuplesPerPage];
int nchain = 0,
i;
+ HeapTupleData tup;
+
+ tup.t_tableOid = RelationGetRelid(prstate->rel);
rootlp = PageGetItemId(dp, rootoffnum);
@@ -612,6 +643,12 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
Assert(prstate->htsv[rootoffnum] != -1);
htup = (HeapTupleHeader) PageGetItem(dp, rootlp);
+ tup.t_data = htup;
+ tup.t_len = ItemIdGetLength(rootlp);
+ ItemPointerSet(&(tup.t_self), BufferGetBlockNumber(buffer), rootoffnum);
+ HeapTupleCopyBaseFromPage(buffer, &tup, dp,
+ IsToastRelation(prstate->rel));
+
if (HeapTupleHeaderIsHeapOnly(htup))
{
/*
@@ -636,7 +673,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
!HeapTupleHeaderIsHotUpdated(htup))
{
heap_prune_record_unused(prstate, rootoffnum);
- HeapTupleHeaderAdvanceLatestRemovedXid(htup,
+ HeapTupleHeaderAdvanceLatestRemovedXid(&tup,
&prstate->latestRemovedXid);
ndeleted++;
}
@@ -703,11 +740,17 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
Assert(prstate->htsv[offnum] != -1);
htup = (HeapTupleHeader) PageGetItem(dp, lp);
+ tup.t_data = htup;
+ tup.t_len = ItemIdGetLength(lp);
+ HeapTupleCopyBaseFromPage(buffer, &tup, dp,
+ IsToastRelation(prstate->rel));
+ ItemPointerSet(&(tup.t_self), BufferGetBlockNumber(buffer), offnum);
+
/*
* Check the tuple XMIN against prior XMAX, if any
*/
if (TransactionIdIsValid(priorXmax) &&
- !TransactionIdEquals(HeapTupleHeaderGetXmin(htup), priorXmax))
+ !TransactionIdEquals(HeapTupleGetXmin(&tup), priorXmax))
break;
/*
@@ -734,7 +777,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
* that the page is reconsidered for pruning in future.
*/
heap_prune_record_prunable(prstate,
- HeapTupleHeaderGetUpdateXid(htup));
+ HeapTupleGetUpdateXidAny(&tup));
break;
case HEAPTUPLE_DELETE_IN_PROGRESS:
@@ -744,7 +787,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
* that the page is reconsidered for pruning in future.
*/
heap_prune_record_prunable(prstate,
- HeapTupleHeaderGetUpdateXid(htup));
+ HeapTupleGetUpdateXidAny(&tup));
break;
case HEAPTUPLE_LIVE:
@@ -773,7 +816,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
if (tupdead)
{
latestdead = offnum;
- HeapTupleHeaderAdvanceLatestRemovedXid(htup,
+ HeapTupleHeaderAdvanceLatestRemovedXid(&tup,
&prstate->latestRemovedXid);
}
else if (!recent_dead)
@@ -795,7 +838,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate)
Assert(ItemPointerGetBlockNumber(&htup->t_ctid) ==
BufferGetBlockNumber(buffer));
offnum = ItemPointerGetOffsetNumber(&htup->t_ctid);
- priorXmax = HeapTupleHeaderGetUpdateXid(htup);
+ priorXmax = HeapTupleGetUpdateXidAny(&tup);
}
/*
@@ -912,7 +955,9 @@ void
heap_page_prune_execute(Buffer buffer,
OffsetNumber *redirected, int nredirected,
OffsetNumber *nowdead, int ndead,
- OffsetNumber *nowunused, int nunused)
+ OffsetNumber *nowunused, int nunused,
+ bool repairFragmentation,
+ bool is_toast)
{
Page page = (Page) BufferGetPage(buffer);
OffsetNumber *offnum;
@@ -1036,7 +1081,8 @@ heap_page_prune_execute(Buffer buffer,
* Finally, repair any fragmentation, and update the page's hint bit about
* whether it has free pointers.
*/
- PageRepairFragmentation(page);
+ if (repairFragmentation)
+ PageRepairFragmentation(page, is_toast);
/*
* Now that the page has been modified, assert that redirect items still
@@ -1108,7 +1154,8 @@ page_verify_redirects(Page page)
* and reused by a completely unrelated tuple.
*/
void
-heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
+heap_get_root_tuples(Relation relation, Buffer buffer, Page page,
+ OffsetNumber *root_offsets)
{
OffsetNumber offnum,
maxoff;
@@ -1123,6 +1170,7 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
HeapTupleHeader htup;
OffsetNumber nextoffnum;
TransactionId priorXmax;
+ HeapTupleData tup;
/* skip unused and dead items */
if (!ItemIdIsUsed(lp) || ItemIdIsDead(lp))
@@ -1131,6 +1179,9 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
if (ItemIdIsNormal(lp))
{
htup = (HeapTupleHeader) PageGetItem(page, lp);
+ tup.t_data = htup;
+ HeapTupleCopyBaseFromPage(buffer, &tup, page,
+ IsToastRelation(relation));
/*
* Check if this tuple is part of a HOT-chain rooted at some other
@@ -1152,7 +1203,7 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
/* Set up to scan the HOT-chain */
nextoffnum = ItemPointerGetOffsetNumber(&htup->t_ctid);
- priorXmax = HeapTupleHeaderGetUpdateXid(htup);
+ priorXmax = HeapTupleGetUpdateXidAny(&tup);
}
else
{
@@ -1191,9 +1242,12 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
break;
htup = (HeapTupleHeader) PageGetItem(page, lp);
+ tup.t_data = htup;
+ HeapTupleCopyBaseFromPage(buffer, &tup, page,
+ IsToastRelation(relation));
if (TransactionIdIsValid(priorXmax) &&
- !TransactionIdEquals(priorXmax, HeapTupleHeaderGetXmin(htup)))
+ !TransactionIdEquals(priorXmax, HeapTupleGetXmin(&tup)))
break;
/* Remember the root line pointer for this item */
@@ -1207,7 +1261,7 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
Assert(!HeapTupleHeaderIndicatesMovedPartitions(htup));
nextoffnum = ItemPointerGetOffsetNumber(&htup->t_ctid);
- priorXmax = HeapTupleHeaderGetUpdateXid(htup);
+ priorXmax = HeapTupleGetUpdateXidAny(&tup);
}
}
}
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index b01b39b008..3060a7fdf8 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -380,6 +380,7 @@ rewrite_heap_tuple(RewriteState state,
&old_tuple->t_data->t_choice.t_heap,
sizeof(HeapTupleFields));
+ HeapTupleCopyBase(new_tuple, old_tuple);
new_tuple->t_data->t_infomask &= ~HEAP_XACT_MASK;
new_tuple->t_data->t_infomask2 &= ~HEAP2_XACT_MASK;
new_tuple->t_data->t_infomask |=
@@ -389,7 +390,7 @@ rewrite_heap_tuple(RewriteState state,
* While we have our hands on the tuple, we may as well freeze any
* eligible xmin or xmax, so that future VACUUM effort can be saved.
*/
- heap_freeze_tuple(new_tuple->t_data,
+ heap_freeze_tuple(new_tuple,
state->rs_old_rel->rd_rel->relfrozenxid,
state->rs_old_rel->rd_rel->relminmxid,
state->rs_freeze_xid,
@@ -405,7 +406,7 @@ rewrite_heap_tuple(RewriteState state,
* If the tuple has been updated, check the old-to-new mapping hash table.
*/
if (!((old_tuple->t_data->t_infomask & HEAP_XMAX_INVALID) ||
- HeapTupleHeaderIsOnlyLocked(old_tuple->t_data)) &&
+ HeapTupleIsOnlyLocked(old_tuple)) &&
!HeapTupleHeaderIndicatesMovedPartitions(old_tuple->t_data) &&
!(ItemPointerEquals(&(old_tuple->t_self),
&(old_tuple->t_data->t_ctid))))
@@ -413,7 +414,7 @@ rewrite_heap_tuple(RewriteState state,
OldToNewMapping mapping;
memset(&hashkey, 0, sizeof(hashkey));
- hashkey.xmin = HeapTupleHeaderGetUpdateXid(old_tuple->t_data);
+ hashkey.xmin = HeapTupleGetUpdateXidAny(old_tuple);
hashkey.tid = old_tuple->t_data->t_ctid;
mapping = (OldToNewMapping)
@@ -486,7 +487,7 @@ rewrite_heap_tuple(RewriteState state,
* RECENTLY_DEAD if and only if the xmin is not before OldestXmin.
*/
if ((new_tuple->t_data->t_infomask & HEAP_UPDATED) &&
- !TransactionIdPrecedes(HeapTupleHeaderGetXmin(new_tuple->t_data),
+ !TransactionIdPrecedes(HeapTupleGetXmin(new_tuple),
state->rs_oldest_xmin))
{
/*
@@ -495,7 +496,7 @@ rewrite_heap_tuple(RewriteState state,
UnresolvedTup unresolved;
memset(&hashkey, 0, sizeof(hashkey));
- hashkey.xmin = HeapTupleHeaderGetXmin(new_tuple->t_data);
+ hashkey.xmin = HeapTupleGetXmin(new_tuple);
hashkey.tid = old_tid;
unresolved = hash_search(state->rs_unresolved_tups, &hashkey,
@@ -583,7 +584,7 @@ rewrite_heap_dead_tuple(RewriteState state, HeapTuple old_tuple)
bool found;
memset(&hashkey, 0, sizeof(hashkey));
- hashkey.xmin = HeapTupleHeaderGetXmin(old_tuple->t_data);
+ hashkey.xmin = HeapTupleGetXmin(old_tuple);
hashkey.tid = old_tuple->t_self;
unresolved = hash_search(state->rs_unresolved_tups, &hashkey,
@@ -619,6 +620,8 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
Size len;
OffsetNumber newoff;
HeapTuple heaptup;
+ TransactionId xmin;
+ bool immutable_tuple;
/*
* If the new tuple is too big for storage or contains already toasted
@@ -653,9 +656,19 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
len = MAXALIGN(heaptup->t_len); /* be conservative */
/*
- * If we're gonna fail for oversize tuple, do it right away
+ * Due to update to 64-xid maximum plain tuple size was decreased due to adding
+ * PageSpecial to a heap page. Pages with tuple that became too large to fit,
+ * should remain in Double Xmax format (read only). Inserting plain tuples with
+ * size over new MaxHeapTupleSizs is prohibited anyway, but vaccum full will
+ * transfer this page to a rebuild relation unmodified.
*/
- if (len > MaxHeapTupleSize)
+ immutable_tuple = len <= MaxHeapTupleSize_32 && len > MaxHeapTupleSize;
+
+ /*
+ * If we're gonna fail for oversize tuple, do it right away. But allow to process
+ * immutable_tuple (see above).
+ */
+ if (len > MaxHeapTupleSize && !immutable_tuple)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("row is too big: size %zu, maximum size %zu",
@@ -704,10 +717,42 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
if (!state->rs_buffer_valid)
{
/* Initialize a new empty page */
- PageInit(page, BLCKSZ, 0);
+ if (immutable_tuple)
+ /* Initialize DoubleXmax page */
+ PageInit(page, BLCKSZ, 0);
+ else
+ {
+ Size special_size;
+
+ special_size = IsToastRelation(state->rs_new_rel) ?
+ sizeof(ToastPageSpecialData) :
+ sizeof(HeapPageSpecialData);
+ PageInit(page, BLCKSZ, special_size);
+ }
state->rs_buffer_valid = true;
}
+ rewrite_page_prepare_for_xid(page, heaptup,
+ IsToastRelation(state->rs_new_rel));
+
+ /*
+ * Tuple with HEAP_XMIN_FROZEN in t_infomask should have xmin set
+ * to FrozenTransactionId to avoid these tuples be treated like normal.
+ */
+ xmin = HeapTupleGetXmin(heaptup);
+ HeapTupleSetXmin(heaptup, xmin);
+
+ /*
+ * Tuples on DoubleXmax page could not appear modified after they had been
+ * frozen by pg_upgrade. Just check this to be safe.
+ */
+ Assert(!immutable_tuple || xmin == FrozenTransactionId);
+
+ if (!immutable_tuple)
+ HeapTupleHeaderSetXmin(page, heaptup);
+
+ HeapTupleHeaderSetXmax(page, heaptup);
+
/* And now we can insert the tuple into the page */
newoff = PageAddItem(page, (Item) heaptup->t_data, heaptup->t_len,
InvalidOffsetNumber, false, true);
@@ -988,19 +1033,24 @@ logical_rewrite_log_mapping(RewriteState state, TransactionId xid,
*/
if (!found)
{
- char path[MAXPGPATH];
- Oid dboid;
+ char path[MAXPGPATH];
+ Oid dboid;
+ TransactionId current_xid;
if (state->rs_old_rel->rd_rel->relisshared)
dboid = InvalidOid;
else
dboid = MyDatabaseId;
+ current_xid = GetCurrentTransactionId();
snprintf(path, MAXPGPATH,
"pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
dboid, relid,
LSN_FORMAT_ARGS(state->rs_begin_lsn),
- xid, GetCurrentTransactionId());
+ (uint32) (xid >> 32),
+ (uint32) xid,
+ (uint32) (current_xid >> 32),
+ (uint32) current_xid);
dlist_init(&src->mappings);
src->num_mappings = 0;
@@ -1049,9 +1099,9 @@ logical_rewrite_heap_tuple(RewriteState state, ItemPointerData old_tid,
if (!state->rs_logical_rewrite)
return;
- xmin = HeapTupleHeaderGetXmin(new_tuple->t_data);
+ xmin = HeapTupleGetXmin(new_tuple);
/* use *GetUpdateXid to correctly deal with multixacts */
- xmax = HeapTupleHeaderGetUpdateXid(new_tuple->t_data);
+ xmax = HeapTupleGetUpdateXidAny(new_tuple);
/*
* Log the mapping iff the tuple has been created recently.
@@ -1115,14 +1165,19 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
xl_heap_rewrite_mapping *xlrec;
uint32 len;
char *data;
+ TransactionId xid;
xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
+ xid = XLogRecGetXid(r);
snprintf(path, MAXPGPATH,
"pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
xlrec->mapped_db, xlrec->mapped_rel,
LSN_FORMAT_ARGS(xlrec->start_lsn),
- xlrec->mapped_xid, XLogRecGetXid(r));
+ (uint32) (xlrec->mapped_xid >> 32),
+ (uint32) xlrec->mapped_xid,
+ (uint32) (xid >> 32),
+ (uint32) xid);
fd = OpenTransientFile(path,
O_CREAT | O_WRONLY | PG_BINARY);
@@ -1217,10 +1272,12 @@ CheckPointLogicalRewriteHeap(void)
Oid dboid;
Oid relid;
XLogRecPtr lsn;
- TransactionId rewrite_xid;
- TransactionId create_xid;
- uint32 hi,
- lo;
+ uint32 lsn_hi,
+ lsn_lo,
+ rewrite_xid_hi,
+ rewrite_xid_lo,
+ create_xid_hi,
+ create_xid_lo;
PGFileType de_type;
if (strcmp(mapping_de->d_name, ".") == 0 ||
@@ -1238,10 +1295,12 @@ CheckPointLogicalRewriteHeap(void)
continue;
if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT,
- &dboid, &relid, &hi, &lo, &rewrite_xid, &create_xid) != 6)
+ &dboid, &relid, &lsn_hi, &lsn_lo,
+ &rewrite_xid_hi, &rewrite_xid_lo,
+ &create_xid_hi, &create_xid_lo) != 8)
elog(ERROR, "could not parse filename \"%s\"", mapping_de->d_name);
- lsn = ((uint64) hi) << 32 | lo;
+ lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
if (lsn < cutoff || cutoff == InvalidXLogRecPtr)
{
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 864876adf7..5ff535d2a8 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -46,6 +46,7 @@
#include "access/xlog.h"
#include "access/xloginsert.h"
#include "catalog/index.h"
+#include "catalog/catalog.h"
#include "catalog/storage.h"
#include "commands/dbcommands.h"
#include "commands/progress.h"
@@ -267,7 +268,6 @@ static bool lazy_vacuum_all_indexes(LVRelState *vacrel);
static void lazy_vacuum_heap_rel(LVRelState *vacrel);
static int lazy_vacuum_heap_page(LVRelState *vacrel, BlockNumber blkno,
Buffer buffer, int index, Buffer *vmbuffer);
-static bool lazy_check_wraparound_failsafe(LVRelState *vacrel);
static void lazy_cleanup_all_indexes(LVRelState *vacrel);
static IndexBulkDeleteResult *lazy_vacuum_one_index(Relation indrel,
IndexBulkDeleteResult *istat,
@@ -528,7 +528,6 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
* ensure that parallel VACUUM won't be attempted at all when relfrozenxid
* is already dangerously old.)
*/
- lazy_check_wraparound_failsafe(vacrel);
dead_items_alloc(vacrel, params->nworkers);
/*
@@ -645,7 +644,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
WalUsage walusage;
StringInfoData buf;
char *msgfmt;
- int32 diff;
+ int64 diff;
int64 PageHitOp = VacuumPageHit - StartPageHit,
PageMissOp = VacuumPageMiss - StartPageMiss,
PageDirtyOp = VacuumPageDirty - StartPageDirty;
@@ -698,32 +697,35 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
orig_rel_pages == 0 ? 100.0 :
100.0 * vacrel->scanned_pages / orig_rel_pages);
appendStringInfo(&buf,
- _("tuples: %lld removed, %lld remain, %lld are dead but not yet removable\n"),
+ _("tuples: %lld removed, %lld remain, %lld are dead but not yet removable, oldest xmin: %llu\n"),
(long long) vacrel->tuples_deleted,
(long long) vacrel->new_rel_tuples,
- (long long) vacrel->recently_dead_tuples);
+ (long long) vacrel->recently_dead_tuples,
+ (unsigned long long) OldestXmin);
if (vacrel->missed_dead_tuples > 0)
appendStringInfo(&buf,
_("tuples missed: %lld dead from %u pages not removed due to cleanup lock contention\n"),
(long long) vacrel->missed_dead_tuples,
vacrel->missed_dead_pages);
- diff = (int32) (ReadNextTransactionId() - OldestXmin);
+ diff = (int64) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
- (unsigned long long) OldestXmin, diff);
+ _("removable cutoff: %llu, which was %lld XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, (long long) diff);
if (frozenxid_updated)
{
- diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
+ diff = (int64) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
- (unsigned long long) vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %lld XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid,
+ (long long) diff);
}
if (minmulti_updated)
{
- diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
+ diff = (int64) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
- (unsigned long long) vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %lld MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid,
+ (long long) diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
@@ -932,7 +934,6 @@ lazy_scan_heap(LVRelState *vacrel)
*/
if (blkno - next_failsafe_block >= FAILSAFE_EVERY_PAGES)
{
- lazy_check_wraparound_failsafe(vacrel);
next_failsafe_block = blkno;
}
@@ -1452,7 +1453,14 @@ lazy_scan_new_or_empty(LVRelState *vacrel, Buffer buf, BlockNumber blkno,
if (GetRecordedFreeSpace(vacrel->rel, blkno) == 0)
{
- freespace = BLCKSZ - SizeOfPageHeaderData;
+ Size special_size;
+
+ special_size = IsToastRelation(vacrel->rel) ?
+ sizeof(ToastPageSpecialData) :
+ sizeof(HeapPageSpecialData);
+ freespace = BufferGetPageSize(buf)
+ - SizeOfPageHeaderData
+ - special_size;
RecordPageWithFreeSpace(vacrel->rel, blkno, freespace);
}
@@ -1556,6 +1564,7 @@ lazy_scan_prune(LVRelState *vacrel,
maxoff;
ItemId itemid;
HeapTupleData tuple;
+ HeapTupleHeader htup;
HTSV_Result res;
int tuples_deleted,
tuples_frozen,
@@ -1599,7 +1608,7 @@ retry:
*/
tuples_deleted = heap_page_prune(rel, buf, vacrel->vistest,
InvalidTransactionId, 0, &nnewlpdead,
- &vacrel->offnum);
+ &vacrel->offnum, true);
/*
* Now scan the page to collect LP_DEAD items and check for tuples
@@ -1664,6 +1673,7 @@ retry:
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid);
tuple.t_tableOid = RelationGetRelid(rel);
+ HeapTupleCopyBaseFromPage(buf, &tuple, page, IsToastRelation(rel));
/*
* DEAD tuples are almost always pruned into LP_DEAD line pointers by
@@ -1727,7 +1737,7 @@ retry:
* The inserter definitely committed. But is it old enough
* that everyone sees it as committed?
*/
- xmin = HeapTupleHeaderGetXmin(tuple.t_data);
+ xmin = HeapTupleGetXmin(&tuple);
if (!TransactionIdPrecedes(xmin, vacrel->OldestXmin))
{
prunestate->all_visible = false;
@@ -1783,7 +1793,7 @@ retry:
* now.
*/
prunestate->hastup = true; /* page makes rel truncation unsafe */
- if (heap_prepare_freeze_tuple(tuple.t_data,
+ if (heap_prepare_freeze_tuple(&tuple,
vacrel->relfrozenxid,
vacrel->relminmxid,
vacrel->FreezeLimit,
@@ -1840,12 +1850,10 @@ retry:
/* execute collected freezes */
for (int i = 0; i < tuples_frozen; i++)
{
- HeapTupleHeader htup;
-
itemid = PageGetItemId(page, frozen[i].offset);
htup = (HeapTupleHeader) PageGetItem(page, itemid);
-
- heap_execute_freeze_tuple(htup, &frozen[i]);
+ heap_execute_freeze_tuple_page(page, htup, &frozen[i],
+ IsToastRelation(vacrel->rel));
}
/* Now WAL-log freezing if necessary */
@@ -1965,7 +1973,6 @@ lazy_scan_noprune(LVRelState *vacrel,
live_tuples,
recently_dead_tuples,
missed_dead_tuples;
- HeapTupleHeader tupleheader;
TransactionId NewRelfrozenXid = vacrel->NewRelfrozenXid;
MultiXactId NewRelminMxid = vacrel->NewRelminMxid;
OffsetNumber deadoffsets[MaxHeapTuplesPerPage];
@@ -2011,8 +2018,14 @@ lazy_scan_noprune(LVRelState *vacrel,
}
*hastup = true; /* page prevents rel truncation */
- tupleheader = (HeapTupleHeader) PageGetItem(page, itemid);
- if (heap_tuple_would_freeze(tupleheader,
+ ItemPointerSet(&(tuple.t_self), blkno, offnum);
+ tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+ tuple.t_len = ItemIdGetLength(itemid);
+ tuple.t_tableOid = RelationGetRelid(vacrel->rel);
+ HeapTupleCopyBaseFromPage(buf, &tuple, page,
+ IsToastRelation(vacrel->rel));
+
+ if (heap_tuple_would_freeze(&tuple,
vacrel->FreezeLimit,
vacrel->MultiXactCutoff,
&NewRelfrozenXid, &NewRelminMxid))
@@ -2045,11 +2058,6 @@ lazy_scan_noprune(LVRelState *vacrel,
*/
}
- ItemPointerSet(&(tuple.t_self), blkno, offnum);
- tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
- tuple.t_len = ItemIdGetLength(itemid);
- tuple.t_tableOid = RelationGetRelid(vacrel->rel);
-
switch (HeapTupleSatisfiesVacuum(&tuple, vacrel->OldestXmin, buf))
{
case HEAPTUPLE_DELETE_IN_PROGRESS:
@@ -2319,13 +2327,6 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
Assert(vacrel->do_index_vacuuming);
Assert(vacrel->do_index_cleanup);
- /* Precheck for XID wraparound emergencies */
- if (lazy_check_wraparound_failsafe(vacrel))
- {
- /* Wraparound emergency -- don't even start an index scan */
- return false;
- }
-
/* Report that we are now vacuuming indexes */
pgstat_progress_update_param(PROGRESS_VACUUM_PHASE,
PROGRESS_VACUUM_PHASE_VACUUM_INDEX);
@@ -2340,13 +2341,6 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
vacrel->indstats[idx] =
lazy_vacuum_one_index(indrel, istat, vacrel->old_live_tuples,
vacrel);
-
- if (lazy_check_wraparound_failsafe(vacrel))
- {
- /* Wraparound emergency -- end current index scan */
- allindexes = false;
- break;
- }
}
}
else
@@ -2354,13 +2348,6 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
/* Outsource everything to parallel variant */
parallel_vacuum_bulkdel_all_indexes(vacrel->pvs, vacrel->old_live_tuples,
vacrel->num_index_scans);
-
- /*
- * Do a postcheck to consider applying wraparound failsafe now. Note
- * that parallel VACUUM only gets the precheck and this postcheck.
- */
- if (lazy_check_wraparound_failsafe(vacrel))
- allindexes = false;
}
/*
@@ -2606,58 +2593,6 @@ lazy_vacuum_heap_page(LVRelState *vacrel, BlockNumber blkno, Buffer buffer,
return index;
}
-/*
- * Trigger the failsafe to avoid wraparound failure when vacrel table has a
- * relfrozenxid and/or relminmxid that is dangerously far in the past.
- * Triggering the failsafe makes the ongoing VACUUM bypass any further index
- * vacuuming and heap vacuuming. Truncating the heap is also bypassed.
- *
- * Any remaining work (work that VACUUM cannot just bypass) is typically sped
- * up when the failsafe triggers. VACUUM stops applying any cost-based delay
- * that it started out with.
- *
- * Returns true when failsafe has been triggered.
- */
-static bool
-lazy_check_wraparound_failsafe(LVRelState *vacrel)
-{
- Assert(TransactionIdIsNormal(vacrel->relfrozenxid));
- Assert(MultiXactIdIsValid(vacrel->relminmxid));
-
- /* Don't warn more than once per VACUUM */
- if (vacrel->failsafe_active)
- return true;
-
- if (unlikely(vacuum_xid_failsafe_check(vacrel->relfrozenxid,
- vacrel->relminmxid)))
- {
- vacrel->failsafe_active = true;
-
- /* Disable index vacuuming, index cleanup, and heap rel truncation */
- vacrel->do_index_vacuuming = false;
- vacrel->do_index_cleanup = false;
- vacrel->do_rel_truncate = false;
-
- ereport(WARNING,
- (errmsg("bypassing nonessential maintenance of table \"%s.%s.%s\" as a failsafe after %d index scans",
- get_database_name(MyDatabaseId),
- vacrel->relnamespace,
- vacrel->relname,
- vacrel->num_index_scans),
- errdetail("The table's relfrozenxid or relminmxid is too far in the past."),
- errhint("Consider increasing configuration parameter \"maintenance_work_mem\" or \"autovacuum_work_mem\".\n"
- "You might also need to consider other ways for VACUUM to keep up with the allocation of transaction IDs.")));
-
- /* Stop applying cost limits from this point on */
- VacuumCostActive = false;
- VacuumCostBalance = 0;
-
- return true;
- }
-
- return false;
-}
-
/*
* lazy_cleanup_all_indexes() -- cleanup all indexes of relation.
*/
@@ -3285,7 +3220,8 @@ heap_page_is_all_visible(LVRelState *vacrel, Buffer buf,
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid);
tuple.t_tableOid = RelationGetRelid(vacrel->rel);
-
+ HeapTupleCopyBaseFromPage(buf, &tuple, page,
+ IsToastRelation(vacrel->rel));
switch (HeapTupleSatisfiesVacuum(&tuple, vacrel->OldestXmin, buf))
{
case HEAPTUPLE_LIVE:
@@ -3304,7 +3240,7 @@ heap_page_is_all_visible(LVRelState *vacrel, Buffer buf,
* The inserter definitely committed. But is it old enough
* that everyone sees it as committed?
*/
- xmin = HeapTupleHeaderGetXmin(tuple.t_data);
+ xmin = HeapTupleGetXmin(&tuple);
if (!TransactionIdPrecedes(xmin, vacrel->OldestXmin))
{
all_visible = false;
@@ -3318,7 +3254,7 @@ heap_page_is_all_visible(LVRelState *vacrel, Buffer buf,
/* Check whether this tuple is already frozen or not */
if (all_visible && *all_frozen &&
- heap_tuple_needs_eventual_freeze(tuple.t_data))
+ heap_tuple_needs_eventual_freeze(&tuple))
*all_frozen = false;
}
break;
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 8b96708b3e..6c4b1f0f50 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -546,6 +546,7 @@ _bt_getroot(Relation rel, int access)
rootblkno = rootopaque->btpo_next;
}
+ /* Note: can't check btpo_level on deleted pages */
if (rootopaque->btpo_level != rootlevel)
elog(ERROR, "root page %u of index \"%s\" has level %u, expected %u",
rootblkno, RelationGetRelationName(rel),
@@ -649,6 +650,7 @@ _bt_gettrueroot(Relation rel)
rootblkno = rootopaque->btpo_next;
}
+ /* Note: can't check btpo_level on deleted pages */
if (rootopaque->btpo_level != rootlevel)
elog(ERROR, "root page %u of index \"%s\" has level %u, expected %u",
rootblkno, RelationGetRelationName(rel),
diff --git a/src/backend/access/nbtree/nbtsplitloc.c b/src/backend/access/nbtree/nbtsplitloc.c
index 241e26d338..c712ee645f 100644
--- a/src/backend/access/nbtree/nbtsplitloc.c
+++ b/src/backend/access/nbtree/nbtsplitloc.c
@@ -140,6 +140,7 @@ _bt_findsplitloc(Relation rel,
olddataitemstoleft,
perfectpenalty,
leaffillfactor;
+ int maxTupleEnd PG_USED_FOR_ASSERTS_ONLY;
FindSplitData state;
FindSplitStrat strategy;
ItemId itemid;
@@ -153,6 +154,7 @@ _bt_findsplitloc(Relation rel,
opaque = BTPageGetOpaque(origpage);
maxoff = PageGetMaxOffsetNumber(origpage);
+ maxTupleEnd = ItemIdGetTupleEnd(PageGetItemId(origpage, P_HIKEY));
/* Total free space available on a btree page, after fixed overhead */
leftspace = rightspace =
@@ -214,6 +216,18 @@ _bt_findsplitloc(Relation rel,
itemid = PageGetItemId(origpage, offnum);
itemsz = MAXALIGN(ItemIdGetLength(itemid)) + sizeof(ItemIdData);
+#ifdef USE_ASSERT_CHECKING
+
+ /*
+ * Ending of rightmost tuple on a page can be shifted relative to left
+ * boundary of BTPageOpaqueData due to conversion from EE96, which
+ * used different BTPageOpaqueData layout. It is only checked in the
+ * assert below.
+ */
+ if (maxTupleEnd < ItemIdGetTupleEnd(itemid))
+ maxTupleEnd = ItemIdGetTupleEnd(itemid);
+#endif
+
/*
* When item offset number is not newitemoff, neither side of the
* split can be newitem. Record a split after the previous data item
@@ -248,7 +262,7 @@ _bt_findsplitloc(Relation rel,
* (Though only when it's possible that newitem will end up alone on new
* right page.)
*/
- Assert(olddataitemstoleft == olddataitemstotal);
+ Assert(olddataitemstoleft + ((PageHeader) origpage)->pd_special - maxTupleEnd == olddataitemstotal);
if (newitemoff > maxoff)
_bt_recsplitloc(&state, newitemoff, false, olddataitemstotal, 0);
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index ad489e33b3..2c33033441 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -15,6 +15,8 @@
#include "postgres.h"
#include "access/bufmask.h"
+#include "access/heapam_xlog.h"
+#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/nbtxlog.h"
#include "access/transam.h"
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index ad855894be..818c8c27ee 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -29,7 +29,7 @@ out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,7 +51,7 @@ static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
appendStringInfo(buf, "deleteXid %llu; downlink %u",
- (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 503808cf0a..407987d373 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -182,6 +182,23 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
}
}
+void
+heap3_desc(StringInfo buf, XLogReaderState *record)
+{
+ char *rec = XLogRecGetData(record);
+ uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
+
+ info &= XLOG_HEAP_OPMASK;
+ if (info == XLOG_HEAP3_BASE_SHIFT)
+ {
+ xl_heap_base_shift *xlrec = (xl_heap_base_shift *) rec;
+
+ appendStringInfo(buf, "%s delta %lld ",
+ xlrec->multi ? "MultiXactId" : "XactId",
+ (long long) xlrec->delta);
+ }
+}
+
const char *
heap_identify(uint8 info)
{
@@ -265,3 +282,18 @@ heap2_identify(uint8 info)
return id;
}
+
+const char *
+heap3_identify(uint8 info)
+{
+ const char *id = NULL;
+
+ switch (info & ~XLR_INFO_MASK)
+ {
+ case XLOG_HEAP3_BASE_SHIFT:
+ id = "BASE_SHIFT";
+ break;
+ }
+
+ return id;
+}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 950f9269f7..b9c1826770 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -65,9 +65,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
xl_multixact_create *xlrec = (xl_multixact_create *) rec;
int i;
- appendStringInfo(buf, "%llu offset %u nmembers %d: ",
+ appendStringInfo(buf, "%llu offset %llu nmembers %d: ",
(unsigned long long) xlrec->mid,
- xlrec->moff, xlrec->nmembers);
+ (unsigned long long) xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
}
@@ -75,10 +75,11 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%llu, %llu)",
(unsigned long long) xlrec->startTruncOff,
(unsigned long long) xlrec->endTruncOff,
- xlrec->startTruncMemb, xlrec->endTruncMemb);
+ (unsigned long long) xlrec->startTruncMemb,
+ (unsigned long long) xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index bf25c941e4..c739b65942 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -83,7 +83,7 @@ btree_desc(StringInfo buf, XLogReaderState *record)
appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -103,7 +103,7 @@ btree_desc(StringInfo buf, XLogReaderState *record)
appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index b930943bb0..f97996d8e7 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -110,7 +110,8 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
{
xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
- parsed->twophase_xid = xl_twophase->xid;
+ parsed->twophase_xid =
+ ((uint64) xl_twophase->xid_hi << 32) | xl_twophase->xid_lo;
data += sizeof(xl_xact_twophase);
@@ -205,7 +206,8 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
{
xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
- parsed->twophase_xid = xl_twophase->xid;
+ parsed->twophase_xid =
+ ((uint64) xl_twophase->xid_hi << 32) | xl_twophase->xid_lo;
data += sizeof(xl_xact_twophase);
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 647d64dc9a..4c70c125b2 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %llu; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,10 +53,10 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
- checkpoint->nextMultiOffset,
+ (unsigned long long) checkpoint->nextMultiOffset,
(unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
(unsigned long long) checkpoint->oldestMulti,
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index afbb5d6b11..9ae0ccbd56 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -294,7 +294,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
* sub-XIDs and all of the XIDs for which we're adjusting clog should be
* on the same page. Check those conditions, too.
*/
- if (all_xact_same_page && xid == MyProc->xid &&
+ if (all_xact_same_page && xid == pg_atomic_read_u64(&MyProc->xid) &&
nsubxids <= THRESHOLD_SUBTRANS_CLOG_OPT &&
nsubxids == MyProc->subxidStatus.count &&
(nsubxids == 0 ||
@@ -713,7 +713,7 @@ void
BootStrapCLOG(void)
{
int slotno;
- int pageno;
+ int64 pageno;
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -727,7 +727,10 @@ BootStrapCLOG(void)
pageno = TransactionIdToPage(XidFromFullTransactionId(ShmemVariableCache->nextXid));
if (pageno != 0)
{
+ /* Create and zero the first page of the commit log */
slotno = ZeroCLOGPage(pageno, false);
+
+ /* Make sure it's written out */
SimpleLruWritePage(XactCtl, slotno);
Assert(!XactCtl->shared->page_dirty[slotno]);
}
@@ -921,24 +924,11 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
SimpleLruTruncate(XactCtl, cutoffPage);
}
-
/*
* Decide whether a CLOG page number is "older" for truncation purposes.
*
- * We need to use comparison of TransactionIds here in order to do the right
- * thing with wraparound XID arithmetic. However, TransactionIdPrecedes()
- * would get weird about permanent xact IDs. So, offset both such that xid1,
- * xid2, and xid2 + CLOG_XACTS_PER_PAGE - 1 are all normal XIDs; this offset
- * is relevant to page 0 and to the page preceding page 0.
- *
- * The page containing oldestXact-2^31 is the important edge case. The
- * portion of that page equaling or following oldestXact-2^31 is expendable,
- * but the portion preceding oldestXact-2^31 is not. When oldestXact-2^31 is
- * the first XID of a page and segment, the entire page and segment is
- * expendable, and we could truncate the segment. Recognizing that case would
- * require making oldestXact, not just the page containing oldestXact,
- * available to this callback. The benefit would be rare and small, so we
- * don't optimize that edge case.
+ * With 64xid this function is just "<", but we left it as a function in order
+ * for its calls remain "vanilla" like.
*/
static bool
CLOGPagePrecedes(int64 page1, int64 page2)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b91097ce0e..7ca59025a7 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -916,25 +916,6 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
/*
* Decide whether a commitTS page number is "older" for truncation purposes.
* Analogous to CLOGPagePrecedes().
- *
- * At default BLCKSZ, (1 << 31) % COMMIT_TS_XACTS_PER_PAGE == 128. This
- * introduces differences compared to CLOG and the other SLRUs having (1 <<
- * 31) % per_page == 0. This function never tests exactly
- * TransactionIdPrecedes(x-2^31, x). When the system reaches xidStopLimit,
- * there are two possible counts of page boundaries between oldestXact and the
- * latest XID assigned, depending on whether oldestXact is within the first
- * 128 entries of its page. Since this function doesn't know the location of
- * oldestXact within page2, it returns false for one page that actually is
- * expendable. This is a wider (yet still negligible) version of the
- * truncation opportunity that CLOGPagePrecedes() cannot recognize.
- *
- * For the sake of a worked example, number entries with decimal values such
- * that page1==1 entries range from 1.0 to 1.999. Let N+0.15 be the number of
- * pages that 2^31 entries will span (N is an integer). If oldestXact=N+2.1,
- * then the final safe XID assignment leaves newestXact=1.95. We keep page 2,
- * because entry=2.85 is the border that toggles whether entries precede the
- * last entry of the oldestXact page. While page 2 is expendable at
- * oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
CommitTsPagePrecedes(int64 page1, int64 page2)
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 35b90229a2..e9a6964ef2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -112,15 +112,15 @@
((xid) / (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
#define MultiXactIdToOffsetEntry(xid) \
((xid) % (MultiXactOffset) MULTIXACT_OFFSETS_PER_PAGE)
-#define MultiXactIdToOffsetSegment(xid) (MultiXactIdToOffsetPage(xid) / SLRU_PAGES_PER_SEGMENT)
+#define MultiXactIdToOffsetSegment(xid) ((uint64)(MultiXactIdToOffsetPage(xid) / SLRU_PAGES_PER_SEGMENT))
/*
* The situation for members is a bit more complex: we store one byte of
* additional flag bits for each TransactionId. To do this without getting
- * into alignment issues, we store four bytes of flags, and then the
- * corresponding 4 Xids. Each such 5-word (20-byte) set we call a "group", and
- * are stored as a whole in pages. Thus, with 8kB BLCKSZ, we keep 409 groups
- * per page. This wastes 12 bytes per page, but that's OK -- simplicity (and
+ * into alignment issues, we store eight bytes of flags, and then the
+ * corresponding 8 Xids. Each such 9-word (72-byte) set we call a "group", and
+ * are stored as a whole in pages. Thus, with 8kB BLCKSZ, we keep 113 groups
+ * per page. This wastes 56 bytes per page, but that's OK -- simplicity (and
* performance) trumps space efficiency here.
*
* Note that the "offset" macros work with byte offset, not array indexes, so
@@ -132,7 +132,7 @@
#define MXACT_MEMBER_XACT_BITMASK ((1 << MXACT_MEMBER_BITS_PER_XACT) - 1)
/* how many full bytes of flags are there in a group? */
-#define MULTIXACT_FLAGBYTES_PER_GROUP 4
+#define MULTIXACT_FLAGBYTES_PER_GROUP 8
#define MULTIXACT_MEMBERS_PER_MEMBERGROUP \
(MULTIXACT_FLAGBYTES_PER_GROUP * MXACT_MEMBER_FLAGS_PER_BYTE)
/* size in bytes of a complete group */
@@ -142,22 +142,9 @@
#define MULTIXACT_MEMBERS_PER_PAGE \
(MULTIXACT_MEMBERGROUPS_PER_PAGE * MULTIXACT_MEMBERS_PER_MEMBERGROUP)
-/*
- * Because the number of items per page is not a divisor of the last item
- * number (member 0xFFFFFFFF), the last segment does not use the maximum number
- * of pages, and moreover the last used page therein does not use the same
- * number of items as previous pages. (Another way to say it is that the
- * 0xFFFFFFFF member is somewhere in the middle of the last page, so the page
- * has some empty space after that item.)
- *
- * This constant is the number of members in the last page of the last segment.
- */
-#define MAX_MEMBERS_IN_LAST_MEMBERS_PAGE \
- ((uint32) ((0xFFFFFFFF % MULTIXACT_MEMBERS_PER_PAGE) + 1))
-
/* page in which a member is to be found */
#define MXOffsetToMemberPage(xid) ((xid) / (TransactionId) MULTIXACT_MEMBERS_PER_PAGE)
-#define MXOffsetToMemberSegment(xid) (MXOffsetToMemberPage(xid) / SLRU_PAGES_PER_SEGMENT)
+#define MXOffsetToMemberSegment(xid) ((uint64)(MXOffsetToMemberPage(xid) / SLRU_PAGES_PER_SEGMENT))
/* Location (byte offset within page) of flag word for a given member */
#define MXOffsetToFlagsOffset(xid) \
@@ -216,22 +203,8 @@ typedef struct MultiXactStateData
MultiXactId oldestMultiXactId;
Oid oldestMultiXactDB;
- /*
- * Oldest multixact offset that is potentially referenced by a multixact
- * referenced by a relation. We don't always know this value, so there's
- * a flag here to indicate whether or not we currently do.
- */
- MultiXactOffset oldestOffset;
- bool oldestOffsetKnown;
-
/* support for anti-wraparound measures */
MultiXactId multiVacLimit;
- MultiXactId multiWarnLimit;
- MultiXactId multiStopLimit;
- MultiXactId multiWrapLimit;
-
- /* support for members anti-wraparound measures */
- MultiXactOffset offsetStopLimit; /* known if oldestOffsetKnown */
/*
* Per-backend data starts here. We have two arrays stored in the area
@@ -361,9 +334,6 @@ static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
-static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
- MultiXactOffset start, uint32 distance);
-static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
@@ -397,6 +367,9 @@ MultiXactIdCreate(TransactionId xid1, MultiXactStatus status1,
/* MultiXactIdSetOldestMember() must have been called already. */
Assert(MultiXactIdIsValid(OldestMemberMXactId[MyBackendId]));
+ /* memset members array because with 64-bit xids it has a padding hole */
+ MemSet(members, 0, sizeof(members));
+
/*
* Note: unlike MultiXactIdExpand, we don't bother to check that both XIDs
* are still running. In typical usage, xid2 will be our own XID and the
@@ -512,7 +485,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
* end of the loop.
*/
newMembers = (MultiXactMember *)
- palloc(sizeof(MultiXactMember) * (nmembers + 1));
+ palloc0(sizeof(MultiXactMember) * (nmembers + 1));
for (i = 0, j = 0; i < nmembers; i++)
{
@@ -527,7 +500,6 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
newMembers[j].xid = xid;
newMembers[j++].status = status;
-
newMulti = MultiXactIdCreateFromMembers(j, newMembers);
pfree(members);
@@ -903,8 +875,8 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
for (i = 0; i < nmembers; i++, offset++)
{
TransactionId *memberptr;
- uint32 *flagsptr;
- uint32 flagsval;
+ uint64 *flagsptr;
+ uint64 flagsval;
int bshift;
int flagsoff;
int memberoff;
@@ -927,12 +899,12 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
*memberptr = members[i].xid;
- flagsptr = (uint32 *)
+ flagsptr = (uint64 *)
(MultiXactMemberCtl->shared->page_buffer[slotno] + flagsoff);
flagsval = *flagsptr;
- flagsval &= ~(((1 << MXACT_MEMBER_BITS_PER_XACT) - 1) << bshift);
- flagsval |= (members[i].status << bshift);
+ flagsval &= ~((uint64) ((1ULL << MXACT_MEMBER_BITS_PER_XACT) - 1) << bshift);
+ flagsval |= ((uint64) members[i].status << bshift);
*flagsptr = flagsval;
MultiXactMemberCtl->shared->page_dirty[slotno] = true;
@@ -985,8 +957,6 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* If we're past multiVacLimit or the safe threshold for member storage
* space, or we don't know what the safe threshold for member storage is,
* start trying to force autovacuum cycles.
- * If we're past multiWarnLimit, start issuing warnings.
- * If we're past multiStopLimit, refuse to create new MultiXactIds.
*
* Note these are pretty much the same protections in GetNewTransactionId.
*----------
@@ -1000,41 +970,9 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
* possibility of deadlock while doing get_database_name(). First,
* copy all the shared values we'll need in this path.
*/
- MultiXactId multiWarnLimit = MultiXactState->multiWarnLimit;
- MultiXactId multiStopLimit = MultiXactState->multiStopLimit;
- MultiXactId multiWrapLimit = MultiXactState->multiWrapLimit;
- Oid oldest_datoid = MultiXactState->oldestMultiXactDB;
LWLockRelease(MultiXactGenLock);
- if (IsUnderPostmaster &&
- !MultiXactIdPrecedes(result, multiStopLimit))
- {
- char *oldest_datname = get_database_name(oldest_datoid);
-
- /*
- * Immediately kick autovacuum into action as we're already in
- * ERROR territory.
- */
- SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
-
- /* complain even if that DB has disappeared */
- if (oldest_datname)
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("database is not accepting commands that generate new MultiXactIds to avoid wraparound data loss in database \"%s\"",
- oldest_datname),
- errhint("Execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("database is not accepting commands that generate new MultiXactIds to avoid wraparound data loss in database with OID %u",
- oldest_datoid),
- errhint("Execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
-
/*
* To avoid swamping the postmaster with signals, we issue the autovac
* request only once per 64K multis generated. This still gives
@@ -1043,31 +981,6 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
if (IsUnderPostmaster && (result % 65536) == 0)
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
- if (!MultiXactIdPrecedes(result, multiWarnLimit))
- {
- char *oldest_datname = get_database_name(oldest_datoid);
-
- /* complain even if that DB has disappeared */
- if (oldest_datname)
- ereport(WARNING,
- (errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
- "database \"%s\" must be vacuumed before %u more MultiXactIds are used",
- multiWrapLimit - result,
- oldest_datname,
- multiWrapLimit - result),
- errhint("Execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(WARNING,
- (errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
- "database with OID %u must be vacuumed before %u more MultiXactIds are used",
- multiWrapLimit - result,
- oldest_datoid,
- multiWrapLimit - result),
- errhint("Execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
-
/* Re-acquire lock and start over */
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
result = MultiXactState->nextMXact;
@@ -1092,78 +1005,6 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
else
*offset = nextOffset;
- /*----------
- * Protect against overrun of the members space as well, with the
- * following rules:
- *
- * If we're past offsetStopLimit, refuse to generate more multis.
- * If we're close to offsetStopLimit, emit a warning.
- *
- * Arbitrarily, we start emitting warnings when we're 20 segments or less
- * from offsetStopLimit.
- *
- * Note we haven't updated the shared state yet, so if we fail at this
- * point, the multixact ID we grabbed can still be used by the next guy.
- *
- * Note that there is no point in forcing autovacuum runs here: the
- * multixact freeze settings would have to be reduced for that to have any
- * effect.
- *----------
- */
-#define OFFSET_WARN_SEGMENTS 20
- if (MultiXactState->oldestOffsetKnown &&
- MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset,
- nmembers))
- {
- /* see comment in the corresponding offsets wraparound case */
- SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
-
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("multixact \"members\" limit exceeded"),
- errdetail_plural("This command would create a multixact with %u members, but the remaining space is only enough for %u member.",
- "This command would create a multixact with %u members, but the remaining space is only enough for %u members.",
- MultiXactState->offsetStopLimit - nextOffset - 1,
- nmembers,
- MultiXactState->offsetStopLimit - nextOffset - 1),
- errhint("Execute a database-wide VACUUM in database with OID %u with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.",
- MultiXactState->oldestMultiXactDB)));
- }
-
- /*
- * Check whether we should kick autovacuum into action, to prevent members
- * wraparound. NB we use a much larger window to trigger autovacuum than
- * just the warning limit. The warning is just a measure of last resort -
- * this is in line with GetNewTransactionId's behaviour.
- */
- if (!MultiXactState->oldestOffsetKnown ||
- (MultiXactState->nextOffset - MultiXactState->oldestOffset
- > MULTIXACT_MEMBER_SAFE_THRESHOLD))
- {
- /*
- * To avoid swamping the postmaster with signals, we issue the autovac
- * request only when crossing a segment boundary. With default
- * compilation settings that's roughly after 50k members. This still
- * gives plenty of chances before we get into real trouble.
- */
- if ((MXOffsetToMemberPage(nextOffset) / SLRU_PAGES_PER_SEGMENT) !=
- (MXOffsetToMemberPage(nextOffset + nmembers) / SLRU_PAGES_PER_SEGMENT))
- SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
- }
-
- if (MultiXactState->oldestOffsetKnown &&
- MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit,
- nextOffset,
- nmembers + MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT * OFFSET_WARN_SEGMENTS))
- ereport(WARNING,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg_plural("database with OID %u must be vacuumed before %d more multixact member is used",
- "database with OID %u must be vacuumed before %d more multixact members are used",
- MultiXactState->offsetStopLimit - nextOffset + nmembers,
- MultiXactState->oldestMultiXactDB,
- MultiXactState->offsetStopLimit - nextOffset + nmembers),
- errhint("Execute a database-wide VACUUM in that database with reduced vacuum_multixact_freeze_min_age and vacuum_multixact_freeze_table_age settings.")));
-
ExtendMultiXactMember(nextOffset, nmembers);
/*
@@ -1192,8 +1033,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
- (unsigned long long) result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %llu",
+ (unsigned long long) result, (unsigned long long) *offset);
return result;
}
@@ -1303,14 +1144,14 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
if (MultiXactIdPrecedes(multi, oldestMXact))
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("MultiXactId %u does no longer exist -- apparent wraparound",
- multi)));
+ errmsg("MultiXactId %llu does no longer exist -- apparent wraparound",
+ (unsigned long long) multi)));
if (!MultiXactIdPrecedes(multi, nextMXact))
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("MultiXactId %u has not been created yet -- apparent wraparound",
- multi)));
+ errmsg("MultiXactId %llu has not been created yet -- apparent wraparound",
+ (unsigned long long) multi)));
/*
* Find out the offset at which we need to start reading MultiXactMembers
@@ -1356,7 +1197,10 @@ retry:
offptr += entryno;
offset = *offptr;
- Assert(offset != 0);
+ if (offset == 0)
+ ereport(ERROR,
+ (errmsg("found invalid zero offset in multixact %llu",
+ (unsigned long long) multi)));
/*
* Use the same increment rule as GetNewMultiXactId(), that is, don't
@@ -1403,7 +1247,7 @@ retry:
LWLockRelease(MultiXactOffsetSLRULock);
- ptr = (MultiXactMember *) palloc(length * sizeof(MultiXactMember));
+ ptr = (MultiXactMember *) palloc0(length * sizeof(MultiXactMember));
/* Now get the members themselves. */
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -1413,7 +1257,7 @@ retry:
for (i = 0; i < length; i++, offset++)
{
TransactionId *xactptr;
- uint32 *flagsptr;
+ uint64 *flagsptr;
int flagsoff;
int bshift;
int memberoff;
@@ -1439,7 +1283,7 @@ retry:
flagsoff = MXOffsetToFlagsOffset(offset);
bshift = MXOffsetToFlagsBitShift(offset);
- flagsptr = (uint32 *) (MultiXactMemberCtl->shared->page_buffer[slotno] + flagsoff);
+ flagsptr = (uint64 *) (MultiXactMemberCtl->shared->page_buffer[slotno] + flagsoff);
ptr[truelength].xid = *xactptr;
ptr[truelength].status = (*flagsptr >> bshift) & MXACT_MEMBER_XACT_BITMASK;
@@ -1903,7 +1747,7 @@ void
BootStrapMultiXact(void)
{
int slotno;
- int pageno;
+ int64 pageno;
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -2224,8 +2068,9 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
- (unsigned long long) nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %llu",
+ (unsigned long long) nextMulti,
+ (unsigned long long) nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2259,47 +2104,9 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
bool is_startup)
{
MultiXactId multiVacLimit;
- MultiXactId multiWarnLimit;
- MultiXactId multiStopLimit;
- MultiXactId multiWrapLimit;
- MultiXactId curMulti;
- bool needs_offset_vacuum;
Assert(MultiXactIdIsValid(oldest_datminmxid));
- /*
- * We pretend that a wrap will happen halfway through the multixact ID
- * space, but that's not really true, because multixacts wrap differently
- * from transaction IDs. Note that, separately from any concern about
- * multixact IDs wrapping, we must ensure that multixact members do not
- * wrap. Limits for that are set in SetOffsetVacuumLimit, not here.
- */
- multiWrapLimit = oldest_datminmxid + (MaxMultiXactId >> 1);
- if (multiWrapLimit < FirstMultiXactId)
- multiWrapLimit += FirstMultiXactId;
-
- /*
- * We'll refuse to continue assigning MultiXactIds once we get within 3M
- * multi of data loss. See SetTransactionIdLimit.
- */
- multiStopLimit = multiWrapLimit - 3000000;
- if (multiStopLimit < FirstMultiXactId)
- multiStopLimit -= FirstMultiXactId;
-
- /*
- * We'll start complaining loudly when we get within 40M multis of data
- * loss. This is kind of arbitrary, but if you let your gas gauge get
- * down to 2% of full, would you be looking for the next gas station? We
- * need to be fairly liberal about this number because there are lots of
- * scenarios where most transactions are done by automatic clients that
- * won't pay attention to warnings. (No, we're not gonna make this
- * configurable. If you know enough to configure it, you know enough to
- * not get in this kind of trouble in the first place.)
- */
- multiWarnLimit = multiWrapLimit - 40000000;
- if (multiWarnLimit < FirstMultiXactId)
- multiWarnLimit -= FirstMultiXactId;
-
/*
* We'll start trying to force autovacuums when oldest_datminmxid gets to
* be more than autovacuum_multixact_freeze_max_age mxids old.
@@ -2309,25 +2116,14 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
* its value. See SetTransactionIdLimit.
*/
multiVacLimit = oldest_datminmxid + autovacuum_multixact_freeze_max_age;
- if (multiVacLimit < FirstMultiXactId)
- multiVacLimit += FirstMultiXactId;
/* Grab lock for just long enough to set the new limit values */
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->oldestMultiXactId = oldest_datminmxid;
MultiXactState->oldestMultiXactDB = oldest_datoid;
MultiXactState->multiVacLimit = multiVacLimit;
- MultiXactState->multiWarnLimit = multiWarnLimit;
- MultiXactState->multiStopLimit = multiStopLimit;
- MultiXactState->multiWrapLimit = multiWrapLimit;
- curMulti = MultiXactState->nextMXact;
LWLockRelease(MultiXactGenLock);
- /* Log the info */
- ereport(DEBUG1,
- (errmsg_internal("MultiXactId wrap limit is %u, limited by database with OID %u",
- multiWrapLimit, oldest_datoid)));
-
/*
* Computing the actual limits is only possible once the data directory is
* in a consistent state. There's no need to compute the limits while
@@ -2339,59 +2135,6 @@ SetMultiXactIdLimit(MultiXactId oldest_datminmxid, Oid oldest_datoid,
return;
Assert(!InRecovery);
-
- /* Set limits for offset vacuum. */
- needs_offset_vacuum = SetOffsetVacuumLimit(is_startup);
-
- /*
- * If past the autovacuum force point, immediately signal an autovac
- * request. The reason for this is that autovac only processes one
- * database per invocation. Once it's finished cleaning up the oldest
- * database, it'll call here, and we'll signal the postmaster to start
- * another iteration immediately if there are still any old databases.
- */
- if ((MultiXactIdPrecedes(multiVacLimit, curMulti) ||
- needs_offset_vacuum) && IsUnderPostmaster)
- SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
-
- /* Give an immediate warning if past the wrap warn point */
- if (MultiXactIdPrecedes(multiWarnLimit, curMulti))
- {
- char *oldest_datname;
-
- /*
- * We can be called when not inside a transaction, for example during
- * StartupXLOG(). In such a case we cannot do database access, so we
- * must just report the oldest DB's OID.
- *
- * Note: it's also possible that get_database_name fails and returns
- * NULL, for example because the database just got dropped. We'll
- * still warn, even though the warning might now be unnecessary.
- */
- if (IsTransactionState())
- oldest_datname = get_database_name(oldest_datoid);
- else
- oldest_datname = NULL;
-
- if (oldest_datname)
- ereport(WARNING,
- (errmsg_plural("database \"%s\" must be vacuumed before %u more MultiXactId is used",
- "database \"%s\" must be vacuumed before %u more MultiXactIds are used",
- multiWrapLimit - curMulti,
- oldest_datname,
- multiWrapLimit - curMulti),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(WARNING,
- (errmsg_plural("database with OID %u must be vacuumed before %u more MultiXactId is used",
- "database with OID %u must be vacuumed before %u more MultiXactIds are used",
- multiWrapLimit - curMulti,
- oldest_datoid,
- multiWrapLimit - curMulti),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
}
/*
@@ -2416,8 +2159,8 @@ MultiXactAdvanceNextMXact(MultiXactId minMulti,
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
{
- debug_elog3(DEBUG2, "MultiXact: setting next offset to %u",
- minMultiOffset);
+ debug_elog3(DEBUG2, "MultiXact: setting next offset to %llu",
+ (unsigned long long) minMultiOffset);
MultiXactState->nextOffset = minMultiOffset;
}
LWLockRelease(MultiXactGenLock);
@@ -2489,7 +2232,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
{
int flagsoff;
int flagsbit;
- uint32 difference;
+ uint64 difference;
/*
* Only zero when at first entry of a page.
@@ -2510,23 +2253,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
LWLockRelease(MultiXactMemberSLRULock);
}
- /*
- * Compute the number of items till end of current page. Careful: if
- * addition of unsigned ints wraps around, we're at the last page of
- * the last segment; since that page holds a different number of items
- * than other pages, we need to do it differently.
- */
- if (offset + MAX_MEMBERS_IN_LAST_MEMBERS_PAGE < offset)
- {
- /*
- * This is the last page of the last segment; we can compute the
- * number of items left to allocate in it without modulo
- * arithmetic.
- */
- difference = MaxMultiXactOffset - offset + 1;
- }
- else
- difference = MULTIXACT_MEMBERS_PER_PAGE - offset % MULTIXACT_MEMBERS_PER_PAGE;
+ difference = MULTIXACT_MEMBERS_PER_PAGE - offset % MULTIXACT_MEMBERS_PER_PAGE;
/*
* Advance to next page, taking care to properly handle the wraparound
@@ -2590,184 +2317,6 @@ GetOldestMultiXactId(void)
return oldestMXact;
}
-/*
- * Determine how aggressively we need to vacuum in order to prevent member
- * wraparound.
- *
- * To do so determine what's the oldest member offset and install the limit
- * info in MultiXactState, where it can be used to prevent overrun of old data
- * in the members SLRU area.
- *
- * The return value is true if emergency autovacuum is required and false
- * otherwise.
- */
-static bool
-SetOffsetVacuumLimit(bool is_startup)
-{
- MultiXactId oldestMultiXactId;
- MultiXactId nextMXact;
- MultiXactOffset oldestOffset = 0; /* placate compiler */
- MultiXactOffset prevOldestOffset;
- MultiXactOffset nextOffset;
- bool oldestOffsetKnown = false;
- bool prevOldestOffsetKnown;
- MultiXactOffset offsetStopLimit = 0;
- MultiXactOffset prevOffsetStopLimit;
-
- /*
- * NB: Have to prevent concurrent truncation, we might otherwise try to
- * lookup an oldestMulti that's concurrently getting truncated away.
- */
- LWLockAcquire(MultiXactTruncationLock, LW_SHARED);
-
- /* Read relevant fields from shared memory. */
- LWLockAcquire(MultiXactGenLock, LW_SHARED);
- oldestMultiXactId = MultiXactState->oldestMultiXactId;
- nextMXact = MultiXactState->nextMXact;
- nextOffset = MultiXactState->nextOffset;
- prevOldestOffsetKnown = MultiXactState->oldestOffsetKnown;
- prevOldestOffset = MultiXactState->oldestOffset;
- prevOffsetStopLimit = MultiXactState->offsetStopLimit;
- Assert(MultiXactState->finishedStartup);
- LWLockRelease(MultiXactGenLock);
-
- /*
- * Determine the offset of the oldest multixact. Normally, we can read
- * the offset from the multixact itself, but there's an important special
- * case: if there are no multixacts in existence at all, oldestMXact
- * obviously can't point to one. It will instead point to the multixact
- * ID that will be assigned the next time one is needed.
- */
- if (oldestMultiXactId == nextMXact)
- {
- /*
- * When the next multixact gets created, it will be stored at the next
- * offset.
- */
- oldestOffset = nextOffset;
- oldestOffsetKnown = true;
- }
- else
- {
- /*
- * Figure out where the oldest existing multixact's offsets are
- * stored. Due to bugs in early release of PostgreSQL 9.3.X and 9.4.X,
- * the supposedly-earliest multixact might not really exist. We are
- * careful not to fail in that case.
- */
- oldestOffsetKnown =
- find_multixact_start(oldestMultiXactId, &oldestOffset);
-
- if (oldestOffsetKnown)
- ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %llu",
- (unsigned long long) oldestOffset)));
- else
- ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
- (unsigned long long) oldestMultiXactId)));
- }
-
- LWLockRelease(MultiXactTruncationLock);
-
- /*
- * If we can, compute limits (and install them MultiXactState) to prevent
- * overrun of old data in the members SLRU area. We can only do so if the
- * oldest offset is known though.
- */
- if (oldestOffsetKnown)
- {
- /* move back to start of the corresponding segment */
- offsetStopLimit = oldestOffset - (oldestOffset %
- (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT));
-
- /* always leave one segment before the wraparound point */
- offsetStopLimit -= (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT);
-
- if (!prevOldestOffsetKnown && !is_startup)
- ereport(LOG,
- (errmsg("MultiXact member wraparound protections are now enabled")));
-
- ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
- (unsigned long long) offsetStopLimit,
- (unsigned long long) oldestMultiXactId)));
- }
- else if (prevOldestOffsetKnown)
- {
- /*
- * If we failed to get the oldest offset this time, but we have a
- * value from a previous pass through this function, use the old
- * values rather than automatically forcing an emergency autovacuum
- * cycle again.
- */
- oldestOffset = prevOldestOffset;
- oldestOffsetKnown = true;
- offsetStopLimit = prevOffsetStopLimit;
- }
-
- /* Install the computed values */
- LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
- MultiXactState->oldestOffset = oldestOffset;
- MultiXactState->oldestOffsetKnown = oldestOffsetKnown;
- MultiXactState->offsetStopLimit = offsetStopLimit;
- LWLockRelease(MultiXactGenLock);
-
- /*
- * Do we need an emergency autovacuum? If we're not sure, assume yes.
- */
- return !oldestOffsetKnown ||
- (nextOffset - oldestOffset > MULTIXACT_MEMBER_SAFE_THRESHOLD);
-}
-
-/*
- * Return whether adding "distance" to "start" would move past "boundary".
- *
- * We use this to determine whether the addition is "wrapping around" the
- * boundary point, hence the name. The reason we don't want to use the regular
- * 2^31-modulo arithmetic here is that we want to be able to use the whole of
- * the 2^32-1 space here, allowing for more multixacts than would fit
- * otherwise.
- */
-static bool
-MultiXactOffsetWouldWrap(MultiXactOffset boundary, MultiXactOffset start,
- uint32 distance)
-{
- MultiXactOffset finish;
-
- /*
- * Note that offset number 0 is not used (see GetMultiXactIdMembers), so
- * if the addition wraps around the UINT_MAX boundary, skip that value.
- */
- finish = start + distance;
- if (finish < start)
- finish++;
-
- /*-----------------------------------------------------------------------
- * When the boundary is numerically greater than the starting point, any
- * value numerically between the two is not wrapped:
- *
- * <----S----B---->
- * [---) = F wrapped past B (and UINT_MAX)
- * [---) = F not wrapped
- * [----] = F wrapped past B
- *
- * When the boundary is numerically less than the starting point (i.e. the
- * UINT_MAX wraparound occurs somewhere in between) then all values in
- * between are wrapped:
- *
- * <----B----S---->
- * [---) = F not wrapped past B (but wrapped past UINT_MAX)
- * [---) = F wrapped past B (and UINT_MAX)
- * [----] = F not wrapped
- *-----------------------------------------------------------------------
- */
- if (start < boundary)
- return finish >= boundary || finish < start;
- else
- return finish >= boundary && finish < start;
-}
-
/*
* Find the starting offset of the given MultiXactId.
*
@@ -2811,97 +2360,6 @@ find_multixact_start(MultiXactId multi, MultiXactOffset *result)
return true;
}
-/*
- * Determine how many multixacts, and how many multixact members, currently
- * exist. Return false if unable to determine.
- */
-static bool
-ReadMultiXactCounts(uint32 *multixacts, MultiXactOffset *members)
-{
- MultiXactOffset nextOffset;
- MultiXactOffset oldestOffset;
- MultiXactId oldestMultiXactId;
- MultiXactId nextMultiXactId;
- bool oldestOffsetKnown;
-
- LWLockAcquire(MultiXactGenLock, LW_SHARED);
- nextOffset = MultiXactState->nextOffset;
- oldestMultiXactId = MultiXactState->oldestMultiXactId;
- nextMultiXactId = MultiXactState->nextMXact;
- oldestOffset = MultiXactState->oldestOffset;
- oldestOffsetKnown = MultiXactState->oldestOffsetKnown;
- LWLockRelease(MultiXactGenLock);
-
- if (!oldestOffsetKnown)
- return false;
-
- *members = nextOffset - oldestOffset;
- *multixacts = nextMultiXactId - oldestMultiXactId;
- return true;
-}
-
-/*
- * Multixact members can be removed once the multixacts that refer to them
- * are older than every datminmxid. autovacuum_multixact_freeze_max_age and
- * vacuum_multixact_freeze_table_age work together to make sure we never have
- * too many multixacts; we hope that, at least under normal circumstances,
- * this will also be sufficient to keep us from using too many offsets.
- * However, if the average multixact has many members, we might exhaust the
- * members space while still using few enough members that these limits fail
- * to trigger full table scans for relminmxid advancement. At that point,
- * we'd have no choice but to start failing multixact-creating operations
- * with an error.
- *
- * To prevent that, if more than a threshold portion of the members space is
- * used, we effectively reduce autovacuum_multixact_freeze_max_age and
- * to a value just less than the number of multixacts in use. We hope that
- * this will quickly trigger autovacuuming on the table or tables with the
- * oldest relminmxid, thus allowing datminmxid values to advance and removing
- * some members.
- *
- * As the fraction of the member space currently in use grows, we become
- * more aggressive in clamping this value. That not only causes autovacuum
- * to ramp up, but also makes any manual vacuums the user issues more
- * aggressive. This happens because vacuum_set_xid_limits() clamps the
- * freeze table and the minimum freeze age based on the effective
- * autovacuum_multixact_freeze_max_age this function returns. In the worst
- * case, we'll claim the freeze_max_age to zero, and every vacuum of any
- * table will try to freeze every multixact.
- *
- * It's possible that these thresholds should be user-tunable, but for now
- * we keep it simple.
- */
-int
-MultiXactMemberFreezeThreshold(void)
-{
- MultiXactOffset members;
- uint32 multixacts;
- uint32 victim_multixacts;
- double fraction;
-
- /* If we can't determine member space utilization, assume the worst. */
- if (!ReadMultiXactCounts(&multixacts, &members))
- return 0;
-
- /* If member space utilization is low, no special action is required. */
- if (members <= MULTIXACT_MEMBER_SAFE_THRESHOLD)
- return autovacuum_multixact_freeze_max_age;
-
- /*
- * Compute a target for relminmxid advancement. The number of multixacts
- * we try to eliminate from the system is based on how far we are past
- * MULTIXACT_MEMBER_SAFE_THRESHOLD.
- */
- fraction = (double) (members - MULTIXACT_MEMBER_SAFE_THRESHOLD) /
- (MULTIXACT_MEMBER_DANGER_THRESHOLD - MULTIXACT_MEMBER_SAFE_THRESHOLD);
- victim_multixacts = multixacts * fraction;
-
- /* fraction could be > 1.0, but lowest possible freeze age is zero */
- if (victim_multixacts > multixacts)
- return 0;
- return multixacts - victim_multixacts;
-}
-
typedef struct mxtruncinfo
{
int64 earliestExistingPage;
@@ -2928,35 +2386,12 @@ SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data
/*
* Delete members segments [oldest, newOldest)
- *
- * The members SLRU can, in contrast to the offsets one, be filled to almost
- * the full range at once. This means SimpleLruTruncate() can't trivially be
- * used - instead the to-be-deleted range is computed using the offsets
- * SLRU. C.f. TruncateMultiXact().
*/
static void
PerformMembersTruncation(MultiXactOffset oldestOffset, MultiXactOffset newOldestOffset)
{
- const int maxsegment = MXOffsetToMemberSegment(MaxMultiXactOffset);
- int startsegment = MXOffsetToMemberSegment(oldestOffset);
- int endsegment = MXOffsetToMemberSegment(newOldestOffset);
- int segment = startsegment;
-
- /*
- * Delete all the segments but the last one. The last segment can still
- * contain, possibly partially, valid data.
- */
- while (segment != endsegment)
- {
- elog(DEBUG2, "truncating multixact members segment %x", segment);
- SlruDeleteSegment(MultiXactMemberCtl, segment);
-
- /* move to next segment, handling wraparound correctly */
- if (segment == maxsegment)
- segment = 0;
- else
- segment += 1;
- }
+ SimpleLruTruncate(MultiXactMemberCtl,
+ MXOffsetToMemberPage(newOldestOffset));
}
/*
@@ -3075,7 +2510,8 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
{
ereport(LOG,
(errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
- (unsigned long long) oldestMulti, (unsigned long long) earliest)));
+ (unsigned long long) oldestMulti,
+ (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3099,14 +2535,14 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%llu, %llu), offsets segments [%x, %x), "
- "members [%u, %u), members segments [%x, %x)",
+ "offsets [%llu, %llu), offsets segments [%012llx, %012llx), "
+ "members [%lld, %lld), members segments [%012llx, %012llx)",
(unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
- MultiXactIdToOffsetSegment(oldestMulti),
- MultiXactIdToOffsetSegment(newOldestMulti),
- oldestOffset, newOldestOffset,
- MXOffsetToMemberSegment(oldestOffset),
- MXOffsetToMemberSegment(newOldestOffset));
+ (unsigned long long) MultiXactIdToOffsetSegment(oldestMulti),
+ (unsigned long long) MultiXactIdToOffsetSegment(newOldestMulti),
+ (long long) oldestOffset, (long long) newOldestOffset,
+ (unsigned long long) MXOffsetToMemberSegment(oldestOffset),
+ (unsigned long long) MXOffsetToMemberSegment(newOldestOffset));
/*
* Do truncation, and the WAL logging of the truncation, in a critical
@@ -3180,7 +2616,7 @@ MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
/*
* Decide whether a MultiXactMember page number is "older" for truncation
- * purposes. There is no "invalid offset number" so use the numbers verbatim.
+ * purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
MultiXactMemberPagePrecedes(int64 page1, int64 page2)
@@ -3205,7 +2641,7 @@ MultiXactMemberPagePrecedes(int64 page1, int64 page2)
bool
MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
{
- int32 diff = (int32) (multi1 - multi2);
+ int64 diff = (int64) (multi1 - multi2);
return (diff < 0);
}
@@ -3219,7 +2655,7 @@ MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
bool
MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
{
- int32 diff = (int32) (multi1 - multi2);
+ int64 diff = (int64) (multi1 - multi2);
return (diff <= 0);
}
@@ -3231,7 +2667,7 @@ MultiXactIdPrecedesOrEquals(MultiXactId multi1, MultiXactId multi2)
static bool
MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
{
- int32 diff = (int32) (offset1 - offset2);
+ int64 diff = (int64) (offset1 - offset2);
return (diff < 0);
}
@@ -3355,15 +2791,16 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%llu, %llu), offsets segments [%x, %x), "
- "members [%u, %u), members segments [%x, %x)",
+ "offsets [%llu, %llu), offsets segments [%012llx, %012llx), "
+ "members [%llu, %llu), members segments [%012llx, %012llx)",
(unsigned long long) xlrec.startTruncOff,
(unsigned long long) xlrec.endTruncOff,
- MultiXactIdToOffsetSegment(xlrec.startTruncOff),
- MultiXactIdToOffsetSegment(xlrec.endTruncOff),
- xlrec.startTruncMemb, xlrec.endTruncMemb,
- MXOffsetToMemberSegment(xlrec.startTruncMemb),
- MXOffsetToMemberSegment(xlrec.endTruncMemb));
+ (unsigned long long) MultiXactIdToOffsetSegment(xlrec.startTruncOff),
+ (unsigned long long) MultiXactIdToOffsetSegment(xlrec.endTruncOff),
+ (unsigned long long) xlrec.startTruncMemb,
+ (unsigned long long) xlrec.endTruncMemb,
+ (unsigned long long) MXOffsetToMemberSegment(xlrec.startTruncMemb),
+ (unsigned long long) MXOffsetToMemberSegment(xlrec.endTruncMemb));
/* should not be required, but more than cheap enough */
LWLockAcquire(MultiXactTruncationLock, LW_EXCLUSIVE);
@@ -3407,7 +2844,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
if (mxid < FirstMultiXactId)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid MultiXactId: %llu", (unsigned long long) mxid)));
+ errmsg("invalid MultiXactId: %llu",
+ (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9e765c6c28..c186e177ed 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -1428,7 +1428,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
* must not assign.
*/
lhs = per_page + offset; /* skip first page to avoid non-normal XIDs */
- rhs = lhs + (1U << 31);
+ rhs = lhs + (1ULL << 63);
Assert(TransactionIdPrecedes(lhs, rhs));
Assert(TransactionIdPrecedes(rhs, lhs));
Assert(!TransactionIdPrecedes(lhs - 1, rhs));
@@ -1444,13 +1444,14 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
Assert(ctl->PagePrecedes(rhs / per_page, (lhs - 3 * per_page) / per_page));
Assert(ctl->PagePrecedes(rhs / per_page, (lhs - 2 * per_page) / per_page));
Assert(ctl->PagePrecedes(rhs / per_page, (lhs - 1 * per_page) / per_page)
- || (1U << 31) % per_page != 0); /* See CommitTsPagePrecedes() */
+ || (1ULL << 63) % per_page != 0); /* See CommitTsPagePrecedes() */
Assert(ctl->PagePrecedes((lhs + 1 * per_page) / per_page, rhs / per_page)
- || (1U << 31) % per_page != 0);
+ || (1ULL << 63) % per_page != 0);
Assert(ctl->PagePrecedes((lhs + 2 * per_page) / per_page, rhs / per_page));
Assert(ctl->PagePrecedes((lhs + 3 * per_page) / per_page, rhs / per_page));
Assert(!ctl->PagePrecedes(rhs / per_page, (lhs + per_page) / per_page));
+
/*
* GetNewTransactionId() has assigned the last XID it can safely use, and
* that XID is in the *LAST* page of the second segment. We must not
@@ -1460,7 +1461,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
newestXact = newestPage * per_page + offset;
Assert(newestXact / per_page == newestPage);
oldestXact = newestXact + 1;
- oldestXact -= 1U << 31;
+ oldestXact -= 1ULL << 63;
oldestPage = oldestXact / per_page;
Assert(!SlruMayDeleteSegment(ctl,
(newestPage -
@@ -1476,7 +1477,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
newestXact = newestPage * per_page + offset;
Assert(newestXact / per_page == newestPage);
oldestXact = newestXact + 1;
- oldestXact -= 1U << 31;
+ oldestXact -= 1ULL << 63;
oldestPage = oldestXact / per_page;
Assert(!SlruMayDeleteSegment(ctl,
(newestPage -
@@ -1582,7 +1583,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int) strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index e2e20ed06c..2d124d9600 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -212,11 +212,14 @@ void
BootStrapSUBTRANS(void)
{
int slotno;
+ int64 pageno;
+
+ pageno = TransactionIdToPage(XidFromFullTransactionId(ShmemVariableCache->nextXid));
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
/* Create and zero the first page of the subtrans log */
- slotno = ZeroSUBTRANSPage(0);
+ slotno = ZeroSUBTRANSPage(pageno);
/* Make sure it's written out */
SimpleLruWritePage(SubTransCtl, slotno);
@@ -269,9 +272,6 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
{
(void) ZeroSUBTRANSPage(startPage);
startPage++;
- /* must account for wraparound */
- if (startPage > TransactionIdToPage(MaxTransactionId))
- startPage = 0;
}
(void) ZeroSUBTRANSPage(startPage);
@@ -348,6 +348,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* a page and oldestXact == next XID. In that case, if we didn't subtract
* one, we'd trigger SimpleLruTruncate's wraparound detection.
*/
+
TransactionIdRetreat(oldestXact);
cutoffPage = TransactionIdToPage(oldestXact);
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 27410c4697..a2a41e58f2 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -274,14 +274,14 @@ TransactionIdPrecedes(TransactionId id1, TransactionId id2)
{
/*
* If either ID is a permanent XID then we can just do unsigned
- * comparison. If both are normal, do a modulo-2^32 comparison.
+ * comparison. If both are normal, do a modulo-2^64 comparison.
*/
- int32 diff;
+ int64 diff;
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
return (id1 < id2);
- diff = (int32) (id1 - id2);
+ diff = (int64) (id1 - id2);
return (diff < 0);
}
@@ -291,12 +291,12 @@ TransactionIdPrecedes(TransactionId id1, TransactionId id2)
bool
TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
{
- int32 diff;
+ int64 diff;
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
return (id1 <= id2);
- diff = (int32) (id1 - id2);
+ diff = (int64) (id1 - id2);
return (diff <= 0);
}
@@ -306,12 +306,12 @@ TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
bool
TransactionIdFollows(TransactionId id1, TransactionId id2)
{
- int32 diff;
+ int64 diff;
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
return (id1 > id2);
- diff = (int32) (id1 - id2);
+ diff = (int64) (id1 - id2);
return (diff > 0);
}
@@ -321,12 +321,12 @@ TransactionIdFollows(TransactionId id1, TransactionId id2)
bool
TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
{
- int32 diff;
+ int64 diff;
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
return (id1 >= id2);
- diff = (int32) (id1 - id2);
+ diff = (int64) (id1 - id2);
return (diff >= 0);
}
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 4b81dfee16..0732393539 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -476,8 +476,8 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
proc->lxid = xid;
proc->backendId = InvalidBackendId;
}
- proc->xid = xid;
- Assert(proc->xmin == InvalidTransactionId);
+ pg_atomic_write_u64(&proc->xid, xid);
+ Assert(pg_atomic_read_u64(&proc->xmin) == InvalidTransactionId);
proc->delayChkptFlags = 0;
proc->statusFlags = 0;
proc->pid = 0;
@@ -792,7 +792,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
* Form tuple with appropriate data.
*/
- values[0] = TransactionIdGetDatum(proc->xid);
+ values[0] = TransactionIdGetDatum(pg_atomic_read_u64(&proc->xid));
values[1] = CStringGetTextDatum(gxact->gid);
values[2] = TimestampTzGetDatum(gxact->prepared_at);
values[3] = ObjectIdGetDatum(gxact->owner);
@@ -943,7 +943,7 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/************************************************************************/
#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+ snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%016llX", (unsigned long long) xid)
/*
* 2PC state file format:
@@ -1882,13 +1882,13 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ xid = (TransactionId) strtou64(clde->d_name, NULL, 16);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
@@ -2220,7 +2220,6 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
- /* Read and validate file */
buf = ReadTwoPhaseFile(xid, false);
}
else
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 849a7ce9d6..53c79d9a31 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -66,9 +66,9 @@ GetNewTransactionId(bool isSubXact)
if (IsBootstrapProcessingMode())
{
Assert(!isSubXact);
- MyProc->xid = BootstrapTransactionId;
- ProcGlobal->xids[MyProc->pgxactoff] = BootstrapTransactionId;
- return FullTransactionIdFromEpochAndXid(0, BootstrapTransactionId);
+ pg_atomic_write_u64(&MyProc->xid, BootstrapTransactionId);
+ pg_atomic_write_u64(&ProcGlobal->xids[MyProc->pgxactoff], BootstrapTransactionId);
+ return FullTransactionIdFromXid(BootstrapTransactionId);
}
/* safety check, we should never get this far in a HS standby */
@@ -102,11 +102,6 @@ GetNewTransactionId(bool isSubXact)
* possibility of deadlock while doing get_database_name(). First,
* copy all the shared values we'll need in this path.
*/
- TransactionId xidWarnLimit = ShmemVariableCache->xidWarnLimit;
- TransactionId xidStopLimit = ShmemVariableCache->xidStopLimit;
- TransactionId xidWrapLimit = ShmemVariableCache->xidWrapLimit;
- Oid oldest_datoid = ShmemVariableCache->oldestXidDB;
-
LWLockRelease(XidGenLock);
/*
@@ -117,48 +112,6 @@ GetNewTransactionId(bool isSubXact)
if (IsUnderPostmaster && (xid % 65536) == 0)
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
- if (IsUnderPostmaster &&
- TransactionIdFollowsOrEquals(xid, xidStopLimit))
- {
- char *oldest_datname = get_database_name(oldest_datoid);
-
- /* complain even if that DB has disappeared */
- if (oldest_datname)
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("database is not accepting commands to avoid wraparound data loss in database \"%s\"",
- oldest_datname),
- errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("database is not accepting commands to avoid wraparound data loss in database with OID %u",
- oldest_datoid),
- errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
- else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
- {
- char *oldest_datname = get_database_name(oldest_datoid);
-
- /* complain even if that DB has disappeared */
- if (oldest_datname)
- ereport(WARNING,
- (errmsg("database \"%s\" must be vacuumed within %u transactions",
- oldest_datname,
- xidWrapLimit - xid),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(WARNING,
- (errmsg("database with OID %u must be vacuumed within %u transactions",
- oldest_datoid,
- xidWrapLimit - xid),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
-
/* Re-acquire lock and start over */
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
full_xid = ShmemVariableCache->nextXid;
@@ -228,8 +181,8 @@ GetNewTransactionId(bool isSubXact)
Assert(!MyProc->subxidStatus.overflowed);
/* LWLockRelease acts as barrier */
- MyProc->xid = xid;
- ProcGlobal->xids[MyProc->pgxactoff] = xid;
+ pg_atomic_write_u64(&MyProc->xid, xid);
+ pg_atomic_write_u64(&ProcGlobal->xids[MyProc->pgxactoff], xid);
}
else
{
@@ -270,7 +223,7 @@ ReadNextFullTransactionId(void)
}
/*
- * Advance nextXid to the value after a given xid. The epoch is inferred.
+ * Advance nextXid to the value after a given xid.
* This must only be called during recovery or from two-phase start-up code.
*/
void
@@ -278,7 +231,6 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
{
FullTransactionId newNextFullXid;
TransactionId next_xid;
- uint32 epoch;
/*
* It is safe to read nextXid without a lock, because this is only called
@@ -292,19 +244,9 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
if (!TransactionIdFollowsOrEquals(xid, next_xid))
return;
- /*
- * Compute the FullTransactionId that comes after the given xid. To do
- * this, we preserve the existing epoch, but detect when we've wrapped
- * into a new epoch. This is necessary because WAL records and 2PC state
- * currently contain 32 bit xids. The wrap logic is safe in those cases
- * because the span of active xids cannot exceed one epoch at any given
- * point in the WAL stream.
- */
+ /* Compute the FullTransactionId that comes after the given xid. */
TransactionIdAdvance(xid);
- epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
- if (unlikely(xid < next_xid))
- ++epoch;
- newNextFullXid = FullTransactionIdFromEpochAndXid(epoch, xid);
+ newNextFullXid = FullTransactionIdFromXid(xid);
/*
* We still need to take a lock to modify the value when there are
@@ -345,54 +287,10 @@ void
SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
{
TransactionId xidVacLimit;
- TransactionId xidWarnLimit;
- TransactionId xidStopLimit;
- TransactionId xidWrapLimit;
TransactionId curXid;
Assert(TransactionIdIsNormal(oldest_datfrozenxid));
- /*
- * The place where we actually get into deep trouble is halfway around
- * from the oldest potentially-existing XID. (This calculation is
- * probably off by one or two counts, because the special XIDs reduce the
- * size of the loop a little bit. But we throw in plenty of slop below,
- * so it doesn't matter.)
- */
- xidWrapLimit = oldest_datfrozenxid + (MaxTransactionId >> 1);
- if (xidWrapLimit < FirstNormalTransactionId)
- xidWrapLimit += FirstNormalTransactionId;
-
- /*
- * We'll refuse to continue assigning XIDs in interactive mode once we get
- * within 3M transactions of data loss. This leaves lots of room for the
- * DBA to fool around fixing things in a standalone backend, while not
- * being significant compared to total XID space. (VACUUM requires an XID
- * if it truncates at wal_level!=minimal. "VACUUM (ANALYZE)", which a DBA
- * might do by reflex, assigns an XID. Hence, we had better be sure
- * there's lots of XIDs left...) Also, at default BLCKSZ, this leaves two
- * completely-idle segments. In the event of edge-case bugs involving
- * page or segment arithmetic, idle segments render the bugs unreachable
- * outside of single-user mode.
- */
- xidStopLimit = xidWrapLimit - 3000000;
- if (xidStopLimit < FirstNormalTransactionId)
- xidStopLimit -= FirstNormalTransactionId;
-
- /*
- * We'll start complaining loudly when we get within 40M transactions of
- * data loss. This is kind of arbitrary, but if you let your gas gauge
- * get down to 2% of full, would you be looking for the next gas station?
- * We need to be fairly liberal about this number because there are lots
- * of scenarios where most transactions are done by automatic clients that
- * won't pay attention to warnings. (No, we're not gonna make this
- * configurable. If you know enough to configure it, you know enough to
- * not get in this kind of trouble in the first place.)
- */
- xidWarnLimit = xidWrapLimit - 40000000;
- if (xidWarnLimit < FirstNormalTransactionId)
- xidWarnLimit -= FirstNormalTransactionId;
-
/*
* We'll start trying to force autovacuums when oldest_datfrozenxid gets
* to be more than autovacuum_freeze_max_age transactions old.
@@ -416,18 +314,10 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
ShmemVariableCache->oldestXid = oldest_datfrozenxid;
ShmemVariableCache->xidVacLimit = xidVacLimit;
- ShmemVariableCache->xidWarnLimit = xidWarnLimit;
- ShmemVariableCache->xidStopLimit = xidStopLimit;
- ShmemVariableCache->xidWrapLimit = xidWrapLimit;
ShmemVariableCache->oldestXidDB = oldest_datoid;
curXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
LWLockRelease(XidGenLock);
- /* Log the info */
- ereport(DEBUG1,
- (errmsg_internal("transaction ID wrap limit is %u, limited by database with OID %u",
- xidWrapLimit, oldest_datoid)));
-
/*
* If past the autovacuum force point, immediately signal an autovac
* request. The reason for this is that autovac only processes one
@@ -438,41 +328,6 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
if (TransactionIdFollowsOrEquals(curXid, xidVacLimit) &&
IsUnderPostmaster && !InRecovery)
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
-
- /* Give an immediate warning if past the wrap warn point */
- if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit) && !InRecovery)
- {
- char *oldest_datname;
-
- /*
- * We can be called when not inside a transaction, for example during
- * StartupXLOG(). In such a case we cannot do database access, so we
- * must just report the oldest DB's OID.
- *
- * Note: it's also possible that get_database_name fails and returns
- * NULL, for example because the database just got dropped. We'll
- * still warn, even though the warning might now be unnecessary.
- */
- if (IsTransactionState())
- oldest_datname = get_database_name(oldest_datoid);
- else
- oldest_datname = NULL;
-
- if (oldest_datname)
- ereport(WARNING,
- (errmsg("database \"%s\" must be vacuumed within %u transactions",
- oldest_datname,
- xidWrapLimit - curXid),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- else
- ereport(WARNING,
- (errmsg("database with OID %u must be vacuumed within %u transactions",
- oldest_datoid,
- xidWrapLimit - curXid),
- errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
- "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
- }
}
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index a5116d10b1..8a741b48f8 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -402,7 +402,6 @@ IsAbortedTransactionBlockState(void)
return false;
}
-
/*
* GetTopTransactionId
*
@@ -5673,6 +5672,17 @@ XactLogCommitRecord(TimestampTz commit_time,
xl_subxacts.nsubxacts = nsubxacts;
}
+ if (TransactionIdIsValid(twophase_xid))
+ {
+ xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE;
+ xl_twophase.xid_lo = (uint32) (twophase_xid & 0xFFFFFFFF);
+ xl_twophase.xid_hi = (uint32) (twophase_xid >> 32);
+ Assert(twophase_gid != NULL);
+
+ if (XLogLogicalInfoActive())
+ xl_xinfo.xinfo |= XACT_XINFO_HAS_GID;
+ }
+
if (nrels > 0)
{
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILELOCATORS;
@@ -5692,16 +5702,6 @@ XactLogCommitRecord(TimestampTz commit_time,
xl_invals.nmsgs = nmsgs;
}
- if (TransactionIdIsValid(twophase_xid))
- {
- xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE;
- xl_twophase.xid = twophase_xid;
- Assert(twophase_gid != NULL);
-
- if (XLogLogicalInfoActive())
- xl_xinfo.xinfo |= XACT_XINFO_HAS_GID;
- }
-
/* dump transaction origin information */
if (replorigin_session_origin != InvalidRepOriginId)
{
@@ -5822,6 +5822,17 @@ XactLogAbortRecord(TimestampTz abort_time,
xl_subxacts.nsubxacts = nsubxacts;
}
+ if (TransactionIdIsValid(twophase_xid))
+ {
+ xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE;
+ xl_twophase.xid_lo = (uint32) (twophase_xid & 0xFFFFFFFF);
+ xl_twophase.xid_hi = (uint32) (twophase_xid >> 32);
+ Assert(twophase_gid != NULL);
+
+ if (XLogLogicalInfoActive())
+ xl_xinfo.xinfo |= XACT_XINFO_HAS_GID;
+ }
+
if (nrels > 0)
{
xl_xinfo.xinfo |= XACT_XINFO_HAS_RELFILELOCATORS;
@@ -5838,7 +5849,8 @@ XactLogAbortRecord(TimestampTz abort_time,
if (TransactionIdIsValid(twophase_xid))
{
xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE;
- xl_twophase.xid = twophase_xid;
+ xl_twophase.xid_lo = (uint32) (twophase_xid & 0xFFFFFFFF);
+ xl_twophase.xid_hi = (uint32) (twophase_xid >> 32);
Assert(twophase_gid != NULL);
if (XLogLogicalInfoActive())
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3c74f1502a..b3ac2393eb 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4714,8 +4714,8 @@ BootStrapXLOG(void)
checkPoint.PrevTimeLineID = BootstrapTimeLineID;
checkPoint.fullPageWrites = fullPageWrites;
checkPoint.nextXid =
- FullTransactionIdFromEpochAndXid(0, Max(FirstNormalTransactionId,
- start_xid));
+ FullTransactionIdFromXid(Max(FirstNormalTransactionId,
+ start_xid));
checkPoint.nextOid = FirstGenbkiObjectId;
checkPoint.nextMulti = Max(FirstMultiXactId, start_mxid);
checkPoint.nextMultiOffset = start_mxoff;
@@ -6814,7 +6814,7 @@ CreateCheckPoint(int flags)
UpdateControlFile();
LWLockRelease(ControlFileLock);
- /* Update shared-memory copy of checkpoint XID/epoch */
+ /* Update shared-memory copy of checkpoint XID/base */
SpinLockAcquire(&XLogCtl->info_lck);
XLogCtl->ckptFullXid = checkPoint.nextXid;
SpinLockRelease(&XLogCtl->info_lck);
@@ -7840,7 +7840,7 @@ xlog_redo(XLogReaderState *record)
ControlFile->checkPointCopy.nextXid = checkPoint.nextXid;
LWLockRelease(ControlFileLock);
- /* Update shared-memory copy of checkpoint XID/epoch */
+ /* Update shared-memory copy of checkpoint XID/base */
SpinLockAcquire(&XLogCtl->info_lck);
XLogCtl->ckptFullXid = checkPoint.nextXid;
SpinLockRelease(&XLogCtl->info_lck);
@@ -7901,7 +7901,7 @@ xlog_redo(XLogReaderState *record)
ControlFile->checkPointCopy.nextXid = checkPoint.nextXid;
LWLockRelease(ControlFileLock);
- /* Update shared-memory copy of checkpoint XID/epoch */
+ /* Update shared-memory copy of checkpoint XID/base */
SpinLockAcquire(&XLogCtl->info_lck);
XLogCtl->ckptFullXid = checkPoint.nextXid;
SpinLockRelease(&XLogCtl->info_lck);
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 5ca15ebbf2..fbeec030f9 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -260,6 +260,11 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
BufferGetTag(buffer, ®buf->rlocator, ®buf->forkno, ®buf->block);
regbuf->page = BufferGetPage(buffer);
regbuf->flags = flags;
+ if (IsBufferConverted(buffer))
+ {
+ regbuf->flags |= REGBUF_CONVERTED;
+ MarkBufferConverted(buffer, false);
+ }
regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head;
regbuf->rdata_len = 0;
@@ -583,6 +588,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
needs_backup = true;
else if (regbuf->flags & REGBUF_NO_IMAGE)
needs_backup = false;
+ else if (regbuf->flags & REGBUF_CONVERTED)
+ needs_backup = true;
else if (!doPageWrites)
needs_backup = false;
else
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index 5a8fe81f82..f5f9f2cb18 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -2144,37 +2144,3 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
return true;
}
-
-#ifndef FRONTEND
-
-/*
- * Extract the FullTransactionId from a WAL record.
- */
-FullTransactionId
-XLogRecGetFullXid(XLogReaderState *record)
-{
- TransactionId xid,
- next_xid;
- uint32 epoch;
-
- /*
- * This function is only safe during replay, because it depends on the
- * replay state. See AdvanceNextFullTransactionIdPastXid() for more.
- */
- Assert(AmStartupProcess() || !IsUnderPostmaster);
-
- xid = XLogRecGetXid(record);
- next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
-
- /*
- * If xid is numerically greater than next_xid, it has to be from the last
- * epoch.
- */
- if (unlikely(xid > next_xid))
- --epoch;
-
- return FullTransactionIdFromEpochAndXid(epoch, xid);
-}
-
-#endif
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index e83c7dded9..5a72d24f6f 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -816,7 +816,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
wasShutdown ? "true" : "false")));
ereport(DEBUG1,
(errmsg_internal("next transaction ID: " UINT64_FORMAT "; next OID: %u",
- U64FromFullTransactionId(checkPoint.nextXid),
+ XidFromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
(errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index a6edfcda32..af486d324b 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -120,7 +120,7 @@ static const struct typinfo TypInfo[] = {
F_OIDIN, F_OIDOUT},
{"tid", TIDOID, 0, 6, false, TYPALIGN_SHORT, TYPSTORAGE_PLAIN, InvalidOid,
F_TIDIN, F_TIDOUT},
- {"xid", XIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
+ {"xid", XIDOID, 0, 8, FLOAT8PASSBYVAL, TYPALIGN_XID, TYPSTORAGE_PLAIN, InvalidOid,
F_XIDIN, F_XIDOUT},
{"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid,
F_CIDIN, F_CIDOUT},
@@ -252,15 +252,13 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
break;
case 'm':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxid = value;
+ start_mxid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxid) /* overflow */
+ !StartMultiXactIdIsValid(start_mxid))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -270,15 +268,13 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
break;
case 'o':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxoff = value;
+ start_mxoff = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxoff) /* overflow */
+ !StartMultiXactOffsetIsValid(start_mxoff))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -303,15 +299,13 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
break;
case 'x':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_xid = value;
+ start_xid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_xid) /* overflow */
+ !StartTransactionIdIsValid(start_xid))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 5b49cc5a09..694c2be546 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -159,8 +159,8 @@ static const FormData_pg_attribute a2 = {
.attnum = MinTransactionIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
- .attbyval = true,
- .attalign = TYPALIGN_INT,
+ .attbyval = FLOAT8PASSBYVAL,
+ .attalign = TYPALIGN_XID,
.attstorage = TYPSTORAGE_PLAIN,
.attnotnull = true,
.attislocal = true,
@@ -187,8 +187,8 @@ static const FormData_pg_attribute a4 = {
.attnum = MaxTransactionIdAttributeNumber,
.attcacheoff = -1,
.atttypmod = -1,
- .attbyval = true,
- .attalign = TYPALIGN_INT,
+ .attbyval = FLOAT8PASSBYVAL,
+ .attalign = TYPALIGN_XID,
.attstorage = TYPSTORAGE_PLAIN,
.attnotnull = true,
.attislocal = true,
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c
index 92afbc2f25..3a1eda413f 100644
--- a/src/backend/catalog/pg_inherits.c
+++ b/src/backend/catalog/pg_inherits.c
@@ -146,7 +146,7 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
TransactionId xmin;
Snapshot snap;
- xmin = HeapTupleHeaderGetXmin(inheritsTuple->t_data);
+ xmin = HeapTupleGetXmin(inheritsTuple);
snap = GetActiveSnapshot();
if (!XidInMVCCSnapshot(xmin, snap))
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 056dca8e47..56295b9aa6 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -187,7 +187,7 @@ typedef struct AsyncQueueEntry
} AsyncQueueEntry;
/* Currently, no field of AsyncQueueEntry requires more than int alignment */
-#define QUEUEALIGN(len) INTALIGN(len)
+#define QUEUEALIGN(len) TYPEALIGN(8, len)
#define AsyncQueueEntryEmptySize (offsetof(AsyncQueueEntry, data) + 2)
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 96b46cbc02..44fd9efb23 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -130,7 +130,8 @@ static void CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid, Oid src_tsid
static List *ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath);
static List *ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid,
Oid dbid, char *srcpath,
- List *rlocatorlist, Snapshot snapshot);
+ List *rlocatorlist, Snapshot snapshot,
+ bool is_toast);
static CreateDBRelInfo *ScanSourceDatabasePgClassTuple(HeapTupleData *tuple,
Oid tbid, Oid dbid,
char *srcpath);
@@ -308,9 +309,10 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
}
/* Append relevant pg_class tuples for current page to rlocatorlist. */
+ /* No toast is expected in sys tables */
rlocatorlist = ScanSourceDatabasePgClassPage(page, buf, tbid, dbid,
srcpath, rlocatorlist,
- snapshot);
+ snapshot, false);
UnlockReleaseBuffer(buf);
}
@@ -328,7 +330,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
static List *
ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
char *srcpath, List *rlocatorlist,
- Snapshot snapshot)
+ Snapshot snapshot, bool is_toast)
{
BlockNumber blkno = BufferGetBlockNumber(buf);
OffsetNumber offnum;
@@ -358,6 +360,7 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid);
tuple.t_tableOid = RelationRelationId;
+ HeapTupleCopyBaseFromPage(buf, &tuple, page, is_toast);
/* Skip tuples that are not visible to this snapshot. */
if (HeapTupleSatisfiesVisibility(&tuple, snapshot, buf))
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index fd56066c13..f3b19cf188 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1656,7 +1656,7 @@ DefineIndex(Oid relationId,
set_indexsafe_procflags();
/* We should now definitely not be advertising any xmin. */
- Assert(MyProc->xmin == InvalidTransactionId);
+ Assert(pg_atomic_read_u64(&MyProc->xmin) == InvalidTransactionId);
/*
* The index is now valid in the sense that it contains all currently
@@ -4339,8 +4339,8 @@ set_indexsafe_procflags(void)
* This should only be called before installing xid or xmin in MyProc;
* otherwise, concurrent processes could see an Xmin that moves backwards.
*/
- Assert(MyProc->xid == InvalidTransactionId &&
- MyProc->xmin == InvalidTransactionId);
+ Assert(pg_atomic_read_u64(&MyProc->xid) == InvalidTransactionId &&
+ pg_atomic_read_u64(&MyProc->xmin) == InvalidTransactionId);
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
MyProc->statusFlags |= PROC_IN_SAFE_IC;
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 99c9f91cba..c72cab394f 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -48,6 +48,23 @@
#include "utils/syscache.h"
#include "utils/varlena.h"
+static inline void
+SeqTupleHeaderSetXmin(HeapTupleHeader htup, TransactionId xid)
+{
+ htup->t_choice.t_heap.t_xmin = xid;
+}
+
+static inline void
+SeqTupleHeaderSetXmax(HeapTupleHeader htup, TransactionId xid)
+{
+ htup->t_choice.t_heap.t_xmax = xid;
+}
+
+static inline TransactionId
+SeqTupleHeaderGetRawXmax(HeapTupleHeader htup)
+{
+ return htup->t_choice.t_heap.t_xmax;
+}
/*
* We don't want to log each fetching of a value from a sequence,
@@ -397,10 +414,10 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum)
* because if the current transaction aborts, no other xact will ever
* examine the sequence tuple anyway.
*/
- HeapTupleHeaderSetXmin(tuple->t_data, FrozenTransactionId);
+ SeqTupleHeaderSetXmin(tuple->t_data, FrozenTransactionId);
HeapTupleHeaderSetXminFrozen(tuple->t_data);
HeapTupleHeaderSetCmin(tuple->t_data, FirstCommandId);
- HeapTupleHeaderSetXmax(tuple->t_data, InvalidTransactionId);
+ SeqTupleHeaderSetXmax(tuple->t_data, InvalidTransactionId);
tuple->t_data->t_infomask |= HEAP_XMAX_INVALID;
ItemPointerSet(&tuple->t_data->t_ctid, 0, FirstOffsetNumber);
@@ -1232,9 +1249,9 @@ read_seq_tuple(Relation rel, Buffer *buf, HeapTuple seqdatatuple)
* this again if the update gets lost.
*/
Assert(!(seqdatatuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI));
- if (HeapTupleHeaderGetRawXmax(seqdatatuple->t_data) != InvalidTransactionId)
+ if (SeqTupleHeaderGetRawXmax(seqdatatuple->t_data) != InvalidTransactionId)
{
- HeapTupleHeaderSetXmax(seqdatatuple->t_data, InvalidTransactionId);
+ SeqTupleHeaderSetXmax(seqdatatuple->t_data, InvalidTransactionId);
seqdatatuple->t_data->t_infomask &= ~HEAP_XMAX_COMMITTED;
seqdatatuple->t_data->t_infomask |= HEAP_XMAX_INVALID;
MarkBufferDirtyHint(*buf, true);
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7ccde07de9..c3d7ae61a9 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -63,13 +63,12 @@
/*
* GUC parameters
*/
-int vacuum_freeze_min_age;
-int vacuum_freeze_table_age;
-int vacuum_multixact_freeze_min_age;
-int vacuum_multixact_freeze_table_age;
-int vacuum_failsafe_age;
-int vacuum_multixact_failsafe_age;
-
+int64 vacuum_freeze_min_age;
+int64 vacuum_freeze_table_age;
+int64 vacuum_multixact_freeze_min_age;
+int64 vacuum_multixact_freeze_table_age;
+int64 vacuum_failsafe_age;
+int64 vacuum_multixact_failsafe_age;
/* A few variables that don't seem worth passing around as parameters */
static MemoryContext vac_context = NULL;
@@ -955,10 +954,10 @@ get_all_vacuum_rels(int options)
*/
bool
vacuum_set_xid_limits(Relation rel,
- int freeze_min_age,
- int multixact_freeze_min_age,
- int freeze_table_age,
- int multixact_freeze_table_age,
+ int64 freeze_min_age,
+ int64 multixact_freeze_min_age,
+ int64 freeze_table_age,
+ int64 multixact_freeze_table_age,
TransactionId *oldestXmin,
MultiXactId *oldestMxact,
TransactionId *freezeLimit,
@@ -970,7 +969,7 @@ vacuum_set_xid_limits(Relation rel,
MultiXactId nextMXID,
safeOldestMxact,
aggressiveMXIDCutoff;
- int effective_multixact_freeze_max_age;
+ int64 effective_multixact_freeze_max_age;
/*
* Acquire oldestXmin.
@@ -1038,7 +1037,7 @@ vacuum_set_xid_limits(Relation rel,
* normally autovacuum_multixact_freeze_max_age, but may be less if we are
* short of multixact member space.
*/
- effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
+ effective_multixact_freeze_max_age = autovacuum_multixact_freeze_max_age;
/*
* Determine the minimum multixact freeze age to use: as specified by
@@ -1065,11 +1064,13 @@ vacuum_set_xid_limits(Relation rel,
* held back to an unsafe degree in passing
*/
safeOldestXmin = nextXID - autovacuum_freeze_max_age;
- if (!TransactionIdIsNormal(safeOldestXmin))
+ if (nextXID > FirstNormalTransactionId + autovacuum_freeze_max_age)
safeOldestXmin = FirstNormalTransactionId;
+
safeOldestMxact = nextMXID - effective_multixact_freeze_max_age;
if (safeOldestMxact < FirstMultiXactId)
safeOldestMxact = FirstMultiXactId;
+
if (TransactionIdPrecedes(*oldestXmin, safeOldestXmin))
ereport(WARNING,
(errmsg("cutoff for removing and freezing tuples is far in the past"),
@@ -1378,6 +1379,9 @@ vac_update_relstats(Relation relation,
futurexid = false;
if (frozenxid_updated)
*frozenxid_updated = false;
+
+ Assert(TransactionIdPrecedesOrEquals(frozenxid, ReadNextTransactionId()));
+
if (TransactionIdIsNormal(frozenxid) && oldfrozenxid != frozenxid)
{
bool update = false;
@@ -1401,6 +1405,9 @@ vac_update_relstats(Relation relation,
futuremxid = false;
if (minmulti_updated)
*minmulti_updated = false;
+
+ Assert(MultiXactIdPrecedesOrEquals(minmulti, ReadNextMultiXactId()));
+
if (MultiXactIdIsValid(minmulti) && oldminmulti != minmulti)
{
bool update = false;
@@ -1428,14 +1435,16 @@ vac_update_relstats(Relation relation,
if (futurexid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relfrozenxid value %u with new value %u for table \"%s\"",
- oldfrozenxid, frozenxid,
+ errmsg_internal("overwrote invalid relfrozenxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldfrozenxid,
+ (unsigned long long) frozenxid,
RelationGetRelationName(relation))));
if (futuremxid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relminmxid value %u with new value %u for table \"%s\"",
- oldminmulti, minmulti,
+ errmsg_internal("overwrote invalid relminmxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldminmulti,
+ (unsigned long long) minmulti,
RelationGetRelationName(relation))));
}
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 9b9bbf00a9..2f37cfed60 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -3180,6 +3180,7 @@ ExecEvalFieldStoreDeForm(ExprState *state, ExprEvalStep *op, ExprContext *econte
tmptup.t_len = HeapTupleHeaderGetDatumLength(tuphdr);
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tmptup);
tmptup.t_data = tuphdr;
heap_deform_tuple(&tmptup, tupDesc,
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 9df1f81ea8..d8c92f4846 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -1070,6 +1070,7 @@ GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple);
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tmptup);
tmptup.t_data = tuple;
result = heap_getattr(&tmptup,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 04454ad6e6..bbb060fdb6 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -3678,6 +3678,7 @@ ExecModifyTable(PlanState *pstate)
HeapTupleHeaderGetDatumLength(oldtupdata.t_data);
ItemPointerSetInvalid(&(oldtupdata.t_self));
/* Historically, view triggers see invalid t_tableOid. */
+ HeapTupleCopyHeaderXids(&oldtupdata);
oldtupdata.t_tableOid =
(relkind == RELKIND_VIEW) ? InvalidOid :
RelationGetRelid(resultRelInfo->ri_RelationDesc);
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index fd5796f1b9..26b60cc77e 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1154,6 +1154,7 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
mtuple->t_data->t_ctid = tuple->t_data->t_ctid;
mtuple->t_self = tuple->t_self;
mtuple->t_tableOid = tuple->t_tableOid;
+ HeapTupleCopyBase(mtuple, tuple);
}
else
{
diff --git a/src/backend/nodes/gen_node_support.pl b/src/backend/nodes/gen_node_support.pl
index 81b8c184a9..39cf494372 100644
--- a/src/backend/nodes/gen_node_support.pl
+++ b/src/backend/nodes/gen_node_support.pl
@@ -955,13 +955,13 @@ _read${n}(void)
|| $t eq 'bits32'
|| $t eq 'AclMode'
|| $t eq 'BlockNumber'
- || $t eq 'Index'
- || $t eq 'SubTransactionId')
+ || $t eq 'Index')
{
print $off "\tWRITE_UINT_FIELD($f);\n";
print $rff "\tREAD_UINT_FIELD($f);\n" unless $no_read;
}
- elsif ($t eq 'uint64')
+ elsif ($t eq 'uint64'
+ || $t eq 'SubTransactionId')
{
print $off "\tWRITE_UINT64_FIELD($f);\n";
print $rff "\tREAD_UINT64_FIELD($f);\n" unless $no_read;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 27e5cdee6f..59f2be3be9 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -817,7 +817,6 @@ _outConstraint(StringInfo str, const Constraint *node)
}
}
-
/*
* outNode -
* converts a Node into ascii string and append it to 'str'
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 6d5718ee4c..54697ed00d 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -229,7 +229,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
* src/backend/access/heap/README.HOT for discussion.
*/
if (index->indcheckxmin &&
- !TransactionIdPrecedes(HeapTupleHeaderGetXmin(indexRelation->rd_indextuple->t_data),
+ !TransactionIdPrecedes(HeapTupleGetXmin(indexRelation->rd_indextuple),
TransactionXmin))
{
root->glob->transientPlan = true;
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 1e90b72b74..1cbdadf792 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -123,8 +123,8 @@ int autovacuum_vac_ins_thresh;
double autovacuum_vac_ins_scale;
int autovacuum_anl_thresh;
double autovacuum_anl_scale;
-int autovacuum_freeze_max_age;
-int autovacuum_multixact_freeze_max_age;
+int64 autovacuum_freeze_max_age;
+int64 autovacuum_multixact_freeze_max_age;
double autovacuum_vac_cost_delay;
int autovacuum_vac_cost_limit;
@@ -147,10 +147,10 @@ static TransactionId recentXid;
static MultiXactId recentMulti;
/* Default freeze ages to use for autovacuum (varies by database) */
-static int default_freeze_min_age;
-static int default_freeze_table_age;
-static int default_multixact_freeze_min_age;
-static int default_multixact_freeze_table_age;
+static int64 default_freeze_min_age;
+static int64 default_freeze_table_age;
+static int64 default_multixact_freeze_min_age;
+static int64 default_multixact_freeze_table_age;
/* Memory context for long-lived data */
static MemoryContext AutovacMemCxt;
@@ -326,15 +326,15 @@ static void FreeWorkerInfo(int code, Datum arg);
static autovac_table *table_recheck_autovac(Oid relid, HTAB *table_toast_map,
TupleDesc pg_class_desc,
- int effective_multixact_freeze_max_age);
+ int64 effective_multixact_freeze_max_age);
static void recheck_relation_needs_vacanalyze(Oid relid, AutoVacOpts *avopts,
Form_pg_class classForm,
- int effective_multixact_freeze_max_age,
+ int64 effective_multixact_freeze_max_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void relation_needs_vacanalyze(Oid relid, AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
- int effective_multixact_freeze_max_age,
+ int64 effective_multixact_freeze_max_age,
bool *dovacuum, bool *doanalyze, bool *wraparound);
static void autovacuum_do_vac_analyze(autovac_table *tab,
@@ -1150,6 +1150,7 @@ do_start_worker(void)
ListCell *cell;
TransactionId xidForceLimit;
MultiXactId multiForceLimit;
+ int64 multiMembersThreshold;
bool for_xid_wrap;
bool for_multi_wrap;
avw_dbase *avdb;
@@ -1186,17 +1187,18 @@ do_start_worker(void)
* particular tables, but not loosened.)
*/
recentXid = ReadNextTransactionId();
- xidForceLimit = recentXid - autovacuum_freeze_max_age;
- /* ensure it's a "normal" XID, else TransactionIdPrecedes misbehaves */
- /* this can cause the limit to go backwards by 3, but that's OK */
- if (xidForceLimit < FirstNormalTransactionId)
- xidForceLimit -= FirstNormalTransactionId;
+ if (recentXid > FirstNormalTransactionId + autovacuum_freeze_max_age)
+ xidForceLimit = recentXid - autovacuum_freeze_max_age;
+ else
+ xidForceLimit = FirstNormalTransactionId;
/* Also determine the oldest datminmxid we will consider. */
recentMulti = ReadNextMultiXactId();
- multiForceLimit = recentMulti - MultiXactMemberFreezeThreshold();
- if (multiForceLimit < FirstMultiXactId)
- multiForceLimit -= FirstMultiXactId;
+ multiMembersThreshold = autovacuum_multixact_freeze_max_age;
+ if (recentMulti > FirstMultiXactId + multiMembersThreshold)
+ multiForceLimit = recentMulti - multiMembersThreshold;
+ else
+ multiForceLimit = FirstMultiXactId;
/*
* Choose a database to connect to. We pick the database that was least
@@ -1969,7 +1971,7 @@ do_autovacuum(void)
BufferAccessStrategy bstrategy;
ScanKeyData key;
TupleDesc pg_class_desc;
- int effective_multixact_freeze_max_age;
+ int64 effective_multixact_freeze_max_age;
bool did_vacuum = false;
bool found_concurrent_worker = false;
int i;
@@ -1992,7 +1994,7 @@ do_autovacuum(void)
* normally autovacuum_multixact_freeze_max_age, but may be less if we are
* short of multixact member space.
*/
- effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
+ effective_multixact_freeze_max_age = autovacuum_multixact_freeze_max_age;
/*
* Find the pg_database entry and select the default freeze ages. We use
@@ -2758,7 +2760,7 @@ extract_autovac_opts(HeapTuple tup, TupleDesc pg_class_desc)
static autovac_table *
table_recheck_autovac(Oid relid, HTAB *table_toast_map,
TupleDesc pg_class_desc,
- int effective_multixact_freeze_max_age)
+ int64 effective_multixact_freeze_max_age)
{
Form_pg_class classForm;
HeapTuple classTup;
@@ -2797,10 +2799,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
/* OK, it needs something done */
if (doanalyze || dovacuum)
{
- int freeze_min_age;
- int freeze_table_age;
- int multixact_freeze_min_age;
- int multixact_freeze_table_age;
+ int64 freeze_min_age;
+ int64 freeze_table_age;
+ int64 multixact_freeze_min_age;
+ int64 multixact_freeze_table_age;
int vac_cost_limit;
double vac_cost_delay;
int log_min_duration;
@@ -2905,7 +2907,7 @@ static void
recheck_relation_needs_vacanalyze(Oid relid,
AutoVacOpts *avopts,
Form_pg_class classForm,
- int effective_multixact_freeze_max_age,
+ int64 effective_multixact_freeze_max_age,
bool *dovacuum,
bool *doanalyze,
bool *wraparound)
@@ -2967,7 +2969,7 @@ relation_needs_vacanalyze(Oid relid,
AutoVacOpts *relopts,
Form_pg_class classForm,
PgStat_StatTabEntry *tabentry,
- int effective_multixact_freeze_max_age,
+ int64 effective_multixact_freeze_max_age,
/* output params below */
bool *dovacuum,
bool *doanalyze,
@@ -2996,8 +2998,8 @@ relation_needs_vacanalyze(Oid relid,
anltuples;
/* freeze parameters */
- int freeze_max_age;
- int multixact_freeze_max_age;
+ int64 freeze_max_age;
+ int64 multixact_freeze_max_age;
TransactionId xidForceLimit;
MultiXactId multiForceLimit;
@@ -3047,17 +3049,19 @@ relation_needs_vacanalyze(Oid relid,
av_enabled = (relopts ? relopts->enabled : true);
/* Force vacuum if table is at risk of wraparound */
- xidForceLimit = recentXid - freeze_max_age;
- if (xidForceLimit < FirstNormalTransactionId)
- xidForceLimit -= FirstNormalTransactionId;
+ if (recentXid > FirstNormalTransactionId + freeze_max_age)
+ xidForceLimit = recentXid - freeze_max_age;
+ else
+ xidForceLimit = FirstNormalTransactionId;
force_vacuum = (TransactionIdIsNormal(classForm->relfrozenxid) &&
TransactionIdPrecedes(classForm->relfrozenxid,
xidForceLimit));
if (!force_vacuum)
{
- multiForceLimit = recentMulti - multixact_freeze_max_age;
- if (multiForceLimit < FirstMultiXactId)
- multiForceLimit -= FirstMultiXactId;
+ if (recentMulti > FirstMultiXactId + multixact_freeze_max_age)
+ multiForceLimit = recentMulti - multixact_freeze_max_age;
+ else
+ multiForceLimit = FirstMultiXactId;
force_vacuum = MultiXactIdIsValid(classForm->relminmxid) &&
MultiXactIdPrecedes(classForm->relminmxid, multiForceLimit);
}
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index 2cc0ac9eb0..dd41f54049 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -847,8 +847,12 @@ DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
xl_heap_insert *xlrec;
ReorderBufferChange *change;
RelFileLocator target_locator;
+ bool isinit = (XLogRecGetInfo(r) & XLOG_HEAP_INIT_PAGE) != 0;
+ Pointer rec_data = (Pointer) XLogRecGetData(r);
- xlrec = (xl_heap_insert *) XLogRecGetData(r);
+ if (isinit)
+ rec_data += sizeof(TransactionId);
+ xlrec = (xl_heap_insert *) rec_data;
/*
* Ignore insert records without new tuples (this does happen when
@@ -904,8 +908,12 @@ DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
ReorderBufferChange *change;
char *data;
RelFileLocator target_locator;
+ bool isinit = (XLogRecGetInfo(r) & XLOG_HEAP_INIT_PAGE) != 0;
+ Pointer rec_data = (Pointer) XLogRecGetData(r);
- xlrec = (xl_heap_update *) XLogRecGetData(r);
+ if (isinit)
+ rec_data += sizeof(TransactionId);
+ xlrec = (xl_heap_update *) rec_data;
/* only interested in our database */
XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
@@ -1065,8 +1073,12 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
char *tupledata;
Size tuplelen;
RelFileLocator rlocator;
+ bool isinit = (XLogRecGetInfo(r) & XLOG_HEAP_INIT_PAGE) != 0;
+ Pointer rec_data = (Pointer) XLogRecGetData(r);
- xlrec = (xl_heap_multi_insert *) XLogRecGetData(r);
+ if (isinit)
+ rec_data += sizeof(TransactionId);
+ xlrec = (xl_heap_multi_insert *) rec_data;
/*
* Ignore insert records without new tuples. This happens when a
diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c
index ff8513e2d2..c1c4adad9d 100644
--- a/src/backend/replication/logical/proto.c
+++ b/src/backend/replication/logical/proto.c
@@ -64,7 +64,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_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
}
/*
@@ -78,7 +78,7 @@ logicalrep_read_begin(StringInfo in, LogicalRepBeginData *begin_data)
if (begin_data->final_lsn == InvalidXLogRecPtr)
elog(ERROR, "final_lsn not set in begin message");
begin_data->committime = pq_getmsgint64(in);
- begin_data->xid = pq_getmsgint(in, 4);
+ begin_data->xid = pq_getmsgint64(in);
}
@@ -132,7 +132,7 @@ logicalrep_write_begin_prepare(StringInfo out, ReorderBufferTXN *txn)
pq_sendint64(out, txn->final_lsn);
pq_sendint64(out, txn->end_lsn);
pq_sendint64(out, txn->xact_time.prepare_time);
- pq_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
/* send gid */
pq_sendstring(out, txn->gid);
@@ -152,7 +152,7 @@ logicalrep_read_begin_prepare(StringInfo in, LogicalRepPreparedTxnData *begin_da
if (begin_data->end_lsn == InvalidXLogRecPtr)
elog(ERROR, "end_lsn not set in begin prepare message");
begin_data->prepare_time = pq_getmsgint64(in);
- begin_data->xid = pq_getmsgint(in, 4);
+ begin_data->xid = pq_getmsgint64(in);
/* read gid (copy it into a pre-allocated buffer) */
strlcpy(begin_data->gid, pq_getmsgstring(in), sizeof(begin_data->gid));
@@ -185,7 +185,7 @@ logicalrep_write_prepare_common(StringInfo out, LogicalRepMsgType type,
pq_sendint64(out, prepare_lsn);
pq_sendint64(out, txn->end_lsn);
pq_sendint64(out, txn->xact_time.prepare_time);
- pq_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
/* send gid */
pq_sendstring(out, txn->gid);
@@ -224,7 +224,7 @@ logicalrep_read_prepare_common(StringInfo in, char *msgtype,
if (prepare_data->end_lsn == InvalidXLogRecPtr)
elog(ERROR, "end_lsn is not set in %s message", msgtype);
prepare_data->prepare_time = pq_getmsgint64(in);
- prepare_data->xid = pq_getmsgint(in, 4);
+ prepare_data->xid = pq_getmsgint64(in);
if (prepare_data->xid == InvalidTransactionId)
elog(ERROR, "invalid two-phase transaction ID in %s message", msgtype);
@@ -265,7 +265,7 @@ logicalrep_write_commit_prepared(StringInfo out, ReorderBufferTXN *txn,
pq_sendint64(out, commit_lsn);
pq_sendint64(out, txn->end_lsn);
pq_sendint64(out, txn->xact_time.commit_time);
- pq_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
/* send gid */
pq_sendstring(out, txn->gid);
@@ -291,7 +291,7 @@ logicalrep_read_commit_prepared(StringInfo in, LogicalRepCommitPreparedTxnData *
if (prepare_data->end_lsn == InvalidXLogRecPtr)
elog(ERROR, "end_lsn is not set in commit prepared message");
prepare_data->commit_time = pq_getmsgint64(in);
- prepare_data->xid = pq_getmsgint(in, 4);
+ prepare_data->xid = pq_getmsgint64(in);
/* read gid (copy it into a pre-allocated buffer) */
strlcpy(prepare_data->gid, pq_getmsgstring(in), sizeof(prepare_data->gid));
@@ -323,7 +323,7 @@ logicalrep_write_rollback_prepared(StringInfo out, ReorderBufferTXN *txn,
pq_sendint64(out, txn->end_lsn);
pq_sendint64(out, prepare_time);
pq_sendint64(out, txn->xact_time.commit_time);
- pq_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
/* send gid */
pq_sendstring(out, txn->gid);
@@ -351,7 +351,7 @@ logicalrep_read_rollback_prepared(StringInfo in,
elog(ERROR, "rollback_end_lsn is not set in rollback prepared message");
rollback_data->prepare_time = pq_getmsgint64(in);
rollback_data->rollback_time = pq_getmsgint64(in);
- rollback_data->xid = pq_getmsgint(in, 4);
+ rollback_data->xid = pq_getmsgint64(in);
/* read gid (copy it into a pre-allocated buffer) */
strlcpy(rollback_data->gid, pq_getmsgstring(in), sizeof(rollback_data->gid));
@@ -418,7 +418,7 @@ logicalrep_write_insert(StringInfo out, TransactionId xid, Relation rel,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
/* use Oid as relation identifier */
pq_sendint32(out, RelationGetRelid(rel));
@@ -467,7 +467,7 @@ logicalrep_write_update(StringInfo out, TransactionId xid, Relation rel,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
/* use Oid as relation identifier */
pq_sendint32(out, RelationGetRelid(rel));
@@ -541,7 +541,7 @@ logicalrep_write_delete(StringInfo out, TransactionId xid, Relation rel,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
/* use Oid as relation identifier */
pq_sendint32(out, RelationGetRelid(rel));
@@ -595,7 +595,7 @@ logicalrep_write_truncate(StringInfo out,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
pq_sendint32(out, nrelids);
@@ -653,7 +653,7 @@ logicalrep_write_message(StringInfo out, TransactionId xid, XLogRecPtr lsn,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
pq_sendint8(out, flags);
pq_sendint64(out, lsn);
@@ -675,7 +675,7 @@ logicalrep_write_rel(StringInfo out, TransactionId xid, Relation rel,
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
/* use Oid as relation identifier */
pq_sendint32(out, RelationGetRelid(rel));
@@ -731,7 +731,7 @@ logicalrep_write_typ(StringInfo out, TransactionId xid, Oid typoid)
/* transaction ID (if not valid, we're not streaming) */
if (TransactionIdIsValid(xid))
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(basetypoid));
if (!HeapTupleIsValid(tup))
@@ -1079,7 +1079,7 @@ logicalrep_write_stream_start(StringInfo out,
Assert(TransactionIdIsValid(xid));
/* transaction ID (we're starting to stream, so must be valid) */
- pq_sendint32(out, xid);
+ pq_sendint64(out, xid);
/* 1 if this is the first streaming segment for this xid */
pq_sendbyte(out, first_segment ? 1 : 0);
@@ -1095,7 +1095,7 @@ logicalrep_read_stream_start(StringInfo in, bool *first_segment)
Assert(first_segment);
- xid = pq_getmsgint(in, 4);
+ xid = pq_getmsgint64(in);
*first_segment = (pq_getmsgbyte(in) == 1);
return xid;
@@ -1124,7 +1124,7 @@ logicalrep_write_stream_commit(StringInfo out, ReorderBufferTXN *txn,
Assert(TransactionIdIsValid(txn->xid));
/* transaction ID */
- pq_sendint32(out, txn->xid);
+ pq_sendint64(out, txn->xid);
/* send the flags field (unused for now) */
pq_sendbyte(out, flags);
@@ -1144,7 +1144,7 @@ logicalrep_read_stream_commit(StringInfo in, LogicalRepCommitData *commit_data)
TransactionId xid;
uint8 flags;
- xid = pq_getmsgint(in, 4);
+ xid = pq_getmsgint64(in);
/* read flags (unused for now) */
flags = pq_getmsgbyte(in);
@@ -1173,8 +1173,8 @@ logicalrep_write_stream_abort(StringInfo out, TransactionId xid,
Assert(TransactionIdIsValid(xid) && TransactionIdIsValid(subxid));
/* transaction ID */
- pq_sendint32(out, xid);
- pq_sendint32(out, subxid);
+ pq_sendint64(out, xid);
+ pq_sendint64(out, subxid);
}
/*
@@ -1186,8 +1186,8 @@ logicalrep_read_stream_abort(StringInfo in, TransactionId *xid,
{
Assert(xid && subxid);
- *xid = pq_getmsgint(in, 4);
- *subxid = pq_getmsgint(in, 4);
+ *xid = pq_getmsgint64(in);
+ *subxid = pq_getmsgint64(in);
}
/*
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 9b20e158eb..e0259aaa33 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5094,8 +5094,12 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
TransactionId f_mapped_xid;
TransactionId f_create_xid;
XLogRecPtr f_lsn;
- uint32 f_hi,
- f_lo;
+ uint32 f_lsn_hi,
+ f_lsn_lo,
+ f_mapped_xid_hi,
+ f_mapped_xid_lo,
+ f_create_xid_hi,
+ f_create_xid_lo;
RewriteMappingFile *f;
if (strcmp(mapping_de->d_name, ".") == 0 ||
@@ -5107,11 +5111,14 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
continue;
if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT,
- &f_dboid, &f_relid, &f_hi, &f_lo,
- &f_mapped_xid, &f_create_xid) != 6)
+ &f_dboid, &f_relid, &f_lsn_hi, &f_lsn_lo,
+ &f_mapped_xid_hi, &f_mapped_xid_lo,
+ &f_create_xid_hi, &f_create_xid_lo) != 8)
elog(ERROR, "could not parse filename \"%s\"", mapping_de->d_name);
- f_lsn = ((uint64) f_hi) << 32 | f_lo;
+ f_lsn = ((uint64) f_lsn_hi) << 32 | f_lsn_lo;
+ f_mapped_xid = ((uint64) f_mapped_xid_hi) << 32 | f_mapped_xid_lo;
+ f_create_xid = ((uint64) f_create_xid_hi) << 32 | f_create_xid_lo;
/* mapping for another database */
if (f_dboid != dboid)
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index d518746ddd..f0adcb4dd1 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -579,7 +579,7 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
elog(ERROR, "cannot build an initial slot snapshot, not all transactions are monitored anymore");
/* so we don't overwrite the existing value */
- if (TransactionIdIsValid(MyProc->xmin))
+ if (TransactionIdIsValid(pg_atomic_read_u64(&MyProc->xmin)))
elog(ERROR, "cannot build an initial slot snapshot when MyProc->xmin already is valid");
snap = SnapBuildBuildSnapshot(builder);
@@ -601,7 +601,7 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
}
#endif
- MyProc->xmin = snap->xmin;
+ pg_atomic_write_u64(&MyProc->xmin, snap->xmin);
/* allocate in transaction context */
newxip = (TransactionId *)
@@ -999,9 +999,10 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
builder->catchange.xip = NULL;
}
- elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %u, xmax: %u",
+ elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %llu, xmax: %llu",
(uint32) builder->catchange.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax);
builder->catchange.xcnt = surviving_xids;
}
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index e62de43e09..4e01565fca 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -450,7 +450,7 @@ handle_streamed_transaction(LogicalRepMsgType action, StringInfo s)
* We should have received XID of the subxact as the first part of the
* message, so extract it.
*/
- xid = pq_getmsgint(s, 4);
+ xid = pq_getmsgint64(s);
if (!TransactionIdIsValid(xid))
ereport(ERROR,
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 2ecaa5b907..e7d2593cef 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -584,7 +584,8 @@ pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
if (!sent_begin_txn)
{
- elog(DEBUG1, "skipped replication of an empty transaction with XID: %u", txn->xid);
+ elog(DEBUG1, "skipped replication of an empty transaction with XID: %llu",
+ (unsigned long long) txn->xid);
return;
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 927fd2dbe5..d53bc09a14 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1143,10 +1143,6 @@ static void
XLogWalRcvSendHSFeedback(bool immed)
{
TimestampTz now;
- FullTransactionId nextFullXid;
- TransactionId nextXid;
- uint32 xmin_epoch,
- catalog_xmin_epoch;
TransactionId xmin,
catalog_xmin;
static TimestampTz sendTime = 0;
@@ -1203,31 +1199,15 @@ XLogWalRcvSendHSFeedback(bool immed)
catalog_xmin = InvalidTransactionId;
}
- /*
- * Get epoch and adjust if nextXid and oldestXmin are different sides of
- * the epoch boundary.
- */
- nextFullXid = ReadNextFullTransactionId();
- nextXid = XidFromFullTransactionId(nextFullXid);
- xmin_epoch = EpochFromFullTransactionId(nextFullXid);
- catalog_xmin_epoch = xmin_epoch;
- if (nextXid < xmin)
- xmin_epoch--;
- if (nextXid < catalog_xmin)
- catalog_xmin_epoch--;
-
- elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
- (unsigned long long) xmin, xmin_epoch,
- (unsigned long long) catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu catalog_xmin %llu",
+ (unsigned long long) xmin, (unsigned long long) catalog_xmin);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
pq_sendbyte(&reply_message, 'h');
pq_sendint64(&reply_message, GetCurrentTimestamp());
- pq_sendint32(&reply_message, xmin);
- pq_sendint32(&reply_message, xmin_epoch);
- pq_sendint32(&reply_message, catalog_xmin);
- pq_sendint32(&reply_message, catalog_xmin_epoch);
+ pq_sendint64(&reply_message, xmin);
+ pq_sendint64(&reply_message, catalog_xmin);
walrcv_send(wrconn, reply_message.data, reply_message.len);
if (TransactionIdIsValid(xmin) || TransactionIdIsValid(catalog_xmin))
primary_has_standby_xmin = true;
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 66cbec488c..d0a9bbb6c1 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -255,7 +255,6 @@ static void WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, Tr
static XLogRecPtr WalSndWaitForWal(XLogRecPtr loc);
static void LagTrackerWrite(XLogRecPtr lsn, TimestampTz local_flush_time);
static TimeOffset LagTrackerRead(int head, XLogRecPtr lsn, TimestampTz now);
-static bool TransactionIdInRecentPast(TransactionId xid, uint32 epoch);
static void WalSndSegmentOpen(XLogReaderState *state, XLogSegNo nextSegNo,
TimeLineID *tli_p);
@@ -293,7 +292,7 @@ InitWalSender(void)
*/
if (MyDatabaseId == InvalidOid)
{
- Assert(MyProc->xmin == InvalidTransactionId);
+ Assert(pg_atomic_read_u64(&MyProc->xmin) == InvalidTransactionId);
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
MyProc->statusFlags |= PROC_AFFECTS_ALL_HORIZONS;
ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
@@ -2166,7 +2165,7 @@ PhysicalReplicationSlotNewXmin(TransactionId feedbackXmin, TransactionId feedbac
ReplicationSlot *slot = MyReplicationSlot;
SpinLockAcquire(&slot->mutex);
- MyProc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&MyProc->xmin, InvalidTransactionId);
/*
* For physical replication we don't need the interlock provided by xmin
@@ -2198,44 +2197,6 @@ PhysicalReplicationSlotNewXmin(TransactionId feedbackXmin, TransactionId feedbac
}
}
-/*
- * Check that the provided xmin/epoch are sane, that is, not in the future
- * and not so far back as to be already wrapped around.
- *
- * Epoch of nextXid should be same as standby, or if the counter has
- * wrapped, then one greater than standby.
- *
- * This check doesn't care about whether clog exists for these xids
- * at all.
- */
-static bool
-TransactionIdInRecentPast(TransactionId xid, uint32 epoch)
-{
- FullTransactionId nextFullXid;
- TransactionId nextXid;
- uint32 nextEpoch;
-
- nextFullXid = ReadNextFullTransactionId();
- nextXid = XidFromFullTransactionId(nextFullXid);
- nextEpoch = EpochFromFullTransactionId(nextFullXid);
-
- if (xid <= nextXid)
- {
- if (epoch != nextEpoch)
- return false;
- }
- else
- {
- if (epoch + 1 != nextEpoch)
- return false;
- }
-
- if (!TransactionIdPrecedesOrEquals(xid, nextXid))
- return false; /* epoch OK, but it's wrapped around */
-
- return true;
-}
-
/*
* Hot Standby feedback
*/
@@ -2243,9 +2204,7 @@ static void
ProcessStandbyHSFeedbackMessage(void)
{
TransactionId feedbackXmin;
- uint32 feedbackEpoch;
TransactionId feedbackCatalogXmin;
- uint32 feedbackCatalogEpoch;
TimestampTz replyTime;
/*
@@ -2254,10 +2213,8 @@ ProcessStandbyHSFeedbackMessage(void)
* of this message.
*/
replyTime = pq_getmsgint64(&reply_message);
- feedbackXmin = pq_getmsgint(&reply_message, 4);
- feedbackEpoch = pq_getmsgint(&reply_message, 4);
- feedbackCatalogXmin = pq_getmsgint(&reply_message, 4);
- feedbackCatalogEpoch = pq_getmsgint(&reply_message, 4);
+ feedbackXmin = pq_getmsgint64(&reply_message);
+ feedbackCatalogXmin = pq_getmsgint64(&reply_message);
if (message_level_is_interesting(DEBUG2))
{
@@ -2266,11 +2223,9 @@ ProcessStandbyHSFeedbackMessage(void)
/* Copy because timestamptz_to_str returns a static buffer */
replyTimeStr = pstrdup(timestamptz_to_str(replyTime));
- elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ elog(DEBUG2, "hot standby feedback xmin %llu, catalog_xmin %llu reply_time %s",
(unsigned long long) feedbackXmin,
- feedbackEpoch,
(unsigned long long) feedbackCatalogXmin,
- feedbackCatalogEpoch,
replyTimeStr);
pfree(replyTimeStr);
@@ -2295,24 +2250,12 @@ ProcessStandbyHSFeedbackMessage(void)
if (!TransactionIdIsNormal(feedbackXmin)
&& !TransactionIdIsNormal(feedbackCatalogXmin))
{
- MyProc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&MyProc->xmin, InvalidTransactionId);
if (MyReplicationSlot != NULL)
PhysicalReplicationSlotNewXmin(feedbackXmin, feedbackCatalogXmin);
return;
}
- /*
- * Check that the provided xmin/epoch are sane, that is, not in the future
- * and not so far back as to be already wrapped around. Ignore if not.
- */
- if (TransactionIdIsNormal(feedbackXmin) &&
- !TransactionIdInRecentPast(feedbackXmin, feedbackEpoch))
- return;
-
- if (TransactionIdIsNormal(feedbackCatalogXmin) &&
- !TransactionIdInRecentPast(feedbackCatalogXmin, feedbackCatalogEpoch))
- return;
-
/*
* Set the WalSender's xmin equal to the standby's requested xmin, so that
* the xmin will be taken into account by GetSnapshotData() /
@@ -2350,9 +2293,9 @@ ProcessStandbyHSFeedbackMessage(void)
{
if (TransactionIdIsNormal(feedbackCatalogXmin)
&& TransactionIdPrecedes(feedbackCatalogXmin, feedbackXmin))
- MyProc->xmin = feedbackCatalogXmin;
+ pg_atomic_write_u64(&MyProc->xmin, feedbackCatalogXmin);
else
- MyProc->xmin = feedbackXmin;
+ pg_atomic_write_u64(&MyProc->xmin, feedbackXmin);
}
}
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index ab97e71dd7..118ff24d1c 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -2481,6 +2481,7 @@ statext_expressions_load(Oid stxoid, bool inh, int idx)
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
tmptup.t_data = td;
+ HeapTupleCopyHeaderXids(&tmptup);
tup = heap_copytuple(&tmptup);
diff --git a/src/backend/storage/buffer/Makefile b/src/backend/storage/buffer/Makefile
index fd7c40dcb0..ffcc0fc290 100644
--- a/src/backend/storage/buffer/Makefile
+++ b/src/backend/storage/buffer/Makefile
@@ -17,6 +17,7 @@ OBJS = \
buf_table.o \
bufmgr.o \
freelist.o \
- localbuf.o
+ localbuf.o \
+ heap_convert.o
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 6b95381481..ba5611b008 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -459,7 +459,8 @@ ForgetPrivateRefCountEntry(PrivateRefCountEntry *ref)
)
-static Buffer ReadBuffer_common(SMgrRelation smgr, char relpersistence,
+static Buffer ReadBuffer_common(Relation reln,
+ SMgrRelation smgr, char relpersistence,
ForkNumber forkNum, BlockNumber blockNum,
ReadBufferMode mode, BufferAccessStrategy strategy,
bool *hit);
@@ -777,7 +778,8 @@ ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum,
* miss.
*/
pgstat_count_buffer_read(reln);
- buf = ReadBuffer_common(RelationGetSmgr(reln), reln->rd_rel->relpersistence,
+ buf = ReadBuffer_common(reln,
+ RelationGetSmgr(reln), reln->rd_rel->relpersistence,
forkNum, blockNum, mode, strategy, &hit);
if (hit)
pgstat_count_buffer_hit(reln);
@@ -804,7 +806,7 @@ ReadBufferWithoutRelcache(RelFileLocator rlocator, ForkNumber forkNum,
SMgrRelation smgr = smgropen(rlocator, InvalidBackendId);
- return ReadBuffer_common(smgr, permanent ? RELPERSISTENCE_PERMANENT :
+ return ReadBuffer_common(NULL, smgr, permanent ? RELPERSISTENCE_PERMANENT :
RELPERSISTENCE_UNLOGGED, forkNum, blockNum,
mode, strategy, &hit);
}
@@ -816,7 +818,8 @@ ReadBufferWithoutRelcache(RelFileLocator rlocator, ForkNumber forkNum,
* *hit is set to true if the request was satisfied from shared buffer cache.
*/
static Buffer
-ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
+ReadBuffer_common(Relation reln,
+ SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
BlockNumber blockNum, ReadBufferMode mode,
BufferAccessStrategy strategy, bool *hit)
{
@@ -1048,6 +1051,30 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
blockNum,
relpath(smgr->smgr_rlocator, forkNum))));
}
+
+ if (PageGetPageLayoutVersion(bufBlock) != PG_PAGE_LAYOUT_VERSION &&
+ !PageIsNew((Page) bufBlock))
+ {
+ Buffer buf = BufferDescriptorGetBuffer(bufHdr);
+
+ /*
+ * All the forks but MAIN_FORKNUM should be converted to the
+ * actual page layout version in pg_upgrade.
+ */
+ if (forkNum != MAIN_FORKNUM)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg("invalid fork type (%d) in block %u of relation %s",
+ forkNum, blockNum,
+ relpath(smgr->smgr_rlocator, forkNum))));
+
+ LWLockAcquire(BufferDescriptorGetContentLock(bufHdr), LW_EXCLUSIVE);
+ /* Check for no concurrent changes */
+ if (PageGetPageLayoutVersion(bufBlock) != PG_PAGE_LAYOUT_VERSION)
+ convert_page(reln, bufBlock, buf, blockNum);
+
+ LWLockRelease(BufferDescriptorGetContentLock(bufHdr));
+ }
}
}
@@ -4131,6 +4158,64 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
}
}
+/*
+ * Mark buffer as converted - ie its format is changed without logical changes.
+ *
+ * It will override `full_page_write` GUC setting in XLogRecordAssemble.
+ */
+void
+MarkBufferConverted(Buffer buffer, bool converted)
+{
+ BufferDesc *bufHdr;
+ uint32 buf_state;
+ bool has_mark;
+
+ if (!BufferIsValid(buffer))
+ elog(ERROR, "bad buffer ID: %d", buffer);
+
+ Assert(!BufferIsLocal(buffer));
+
+ bufHdr = GetBufferDescriptor(buffer - 1);
+
+ Assert(GetPrivateRefCount(buffer) > 0);
+ if (converted)
+ {
+ /* here, either share or exclusive lock is OK */
+ Assert(LWLockHeldByMe(BufferDescriptorGetContentLock(bufHdr)));
+ }
+
+ buf_state = pg_atomic_read_u32(&bufHdr->state);
+ has_mark = (buf_state & BM_CONVERTED) != 0;
+ if (converted == has_mark)
+ return;
+
+ buf_state = LockBufHdr(bufHdr);
+ buf_state &= ~BM_CONVERTED;
+ if (converted)
+ buf_state |= BM_CONVERTED;
+ UnlockBufHdr(bufHdr, buf_state);
+}
+
+bool
+IsBufferConverted(Buffer buffer)
+{
+
+ BufferDesc *bufHdr;
+ uint32 buf_state;
+
+ if (!BufferIsValid(buffer))
+ elog(ERROR, "bad buffer ID: %d", buffer);
+
+ Assert(!BufferIsLocal(buffer));
+
+ bufHdr = GetBufferDescriptor(buffer - 1);
+
+ Assert(GetPrivateRefCount(buffer) > 0);
+
+ buf_state = pg_atomic_read_u32(&bufHdr->state);
+ return (buf_state & BM_CONVERTED) != 0;
+}
+
/*
* Release buffer content locks for shared buffers.
*
@@ -4165,6 +4250,47 @@ UnlockBuffers(void)
}
}
+/*
+ * Is shared buffer is locked?
+ */
+bool
+IsBufferLocked(Buffer buffer)
+{
+ BufferDesc *buf;
+
+ if (buffer == InvalidBuffer)
+ return true;
+
+ Assert(BufferIsPinned(buffer));
+ if (BufferIsLocal(buffer))
+ return true; /* local buffers need no lock */
+
+ buf = GetBufferDescriptor(buffer - 1);
+
+ return LWLockHeldByMe(BufferDescriptorGetContentLock(buf));
+}
+
+/*
+ * Is shared buffer is locked exclusive?
+ */
+bool
+IsBufferLockedExclusive(Buffer buffer)
+{
+ BufferDesc *buf;
+
+ if (buffer == InvalidBuffer)
+ return true;
+
+ Assert(BufferIsPinned(buffer));
+ if (BufferIsLocal(buffer))
+ return true; /* local buffers need no lock */
+
+ buf = GetBufferDescriptor(buffer - 1);
+
+ return LWLockHeldByMeInMode(BufferDescriptorGetContentLock(buf),
+ LW_EXCLUSIVE);
+}
+
/*
* Acquire or release the content_lock for the buffer.
*/
diff --git a/src/backend/storage/buffer/heap_convert.c b/src/backend/storage/buffer/heap_convert.c
new file mode 100644
index 0000000000..e6abac9760
--- /dev/null
+++ b/src/backend/storage/buffer/heap_convert.c
@@ -0,0 +1,546 @@
+/*-------------------------------------------------------------------------
+ *
+ * heap_convert.c
+ * Heap page converter from 32bit to 64bit xid format
+ *
+ * Copyright (c) 2015-2022, Postgres Professional
+ *
+ * IDENTIFICATION
+ * src/backend/storage/buffer/heap_convert.c
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "access/generic_xlog.h"
+#include "access/heapam.h"
+#include "access/multixact.h"
+#include "catalog/catalog.h"
+#include "storage/bufmgr.h"
+#include "storage/checksum.h"
+
+static void repack_heap_tuples(Relation rel, Page page, Buffer buf,
+ BlockNumber blkno, bool double_xmax);
+
+/*
+ * itemoffcompare
+ * Sorting support for repack_tuples()
+ */
+int
+itemoffcompare(const void *item1, const void *item2)
+{
+ /* Sort in decreasing itemoff order */
+ return ((ItemIdCompactData *) item2)->itemoff -
+ ((ItemIdCompactData *) item1)->itemoff;
+}
+
+/*
+ * Lazy page conversion from 32-bit to 64-bit XID at first read.
+ */
+void
+convert_page(Relation rel, Page page, Buffer buf, BlockNumber blkno)
+{
+ static unsigned logcnt = 0;
+ bool logit;
+ PageHeader hdr = (PageHeader) page;
+ GenericXLogState *state = NULL;
+ uint16 checksum;
+ bool try_double_xmax;
+
+ /* Not during XLog replaying */
+ Assert(rel != NULL);
+
+ /* Verify checksum */
+ if (hdr->pd_checksum)
+ {
+ checksum = pg_checksum_page((char *) page, blkno);
+ if (checksum != hdr->pd_checksum)
+ ereport(ERROR,
+ (errcode(ERRCODE_INDEX_CORRUPTED),
+ errmsg("page verification failed, calculated checksum %u but expected %u",
+ checksum, hdr->pd_checksum)));
+ }
+
+ /*
+ * We occasionally force logging of page conversion, so never-changed
+ * pages are converted in the end. FORCE_LOG_EVERY is chosen arbitrarily
+ * to log neither too much nor too little.
+ */
+#define FORCE_LOG_EVERY 128
+ logit = !RecoveryInProgress() && XLogIsNeeded() && RelationNeedsWAL(rel);
+ logit = logit && (++logcnt % FORCE_LOG_EVERY) == 0;
+ if (logit)
+ {
+ state = GenericXLogStart(rel);
+ page = GenericXLogRegisterBuffer(state, buf,
+ GENERIC_XLOG_FULL_IMAGE);
+ hdr = (PageHeader) page;
+ }
+#ifdef USE_ASSERT_CHECKING
+ else
+ {
+ /* Not already converted */
+ Assert(PageGetPageLayoutVersion(page) != PG_PAGE_LAYOUT_VERSION);
+ /* Page in 32-bit xid format should not have PageSpecial. */
+ Assert(PageGetSpecialSize(page) == 0);
+ }
+#endif
+
+ switch (rel->rd_rel->relkind)
+ {
+ case 't':
+ try_double_xmax = hdr->pd_upper - hdr->pd_lower <
+ MAXALIGN(sizeof(ToastPageSpecialData));
+ repack_heap_tuples(rel, page, buf, blkno, try_double_xmax);
+ break;
+ case 'r':
+ case 'p':
+ case 'm':
+ try_double_xmax = hdr->pd_upper - hdr->pd_lower <
+ MAXALIGN(sizeof(HeapPageSpecialData));
+ repack_heap_tuples(rel, page, buf, blkno, try_double_xmax);
+ break;
+ case 'i':
+ /* no need to convert index */
+ case 'S':
+ /* no real need to convert sequences */
+ break;
+ default:
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("conversion for relation \"%s\" cannot be done",
+ RelationGetRelationName(rel)),
+ errdetail_relkind_not_supported(rel->rd_rel->relkind)));
+ }
+
+ hdr->pd_checksum = pg_checksum_page((char *) page, blkno);
+
+ PageSetPageSizeAndVersion(page, PageGetPageSize(page),
+ PG_PAGE_LAYOUT_VERSION);
+
+ if (logit)
+ {
+ /*
+ * Finish logging buffer conversion and mark buffer as dirty.
+ */
+ Assert(state != NULL);
+ MarkBufferDirty(buf);
+ GenericXLogFinish(state);
+ }
+ else
+ {
+ /*
+ * Otherwise, it will be logged with full-page-write record on first
+ * actual change.
+ */
+ MarkBufferConverted(buf, true);
+ }
+}
+
+/*
+ * Convert xmin and xmax in a tuple.
+ * This also considers special cases: "double xmax" page format and multixact
+ * in xmax.
+ */
+static void
+convert_heap_tuple_xids(HeapTupleHeader tuple, TransactionId xid_base,
+ MultiXactId multi_base, bool double_xmax)
+{
+ /* Convert xmin */
+ if (double_xmax)
+ {
+ /* Prepare tuple for "double xmax" page format */
+ tuple->t_infomask |= HEAP_XMIN_FROZEN;
+ tuple->t_choice.t_heap.t_xmin = 0;
+ }
+ else
+ {
+ TransactionId xmin = tuple->t_choice.t_heap.t_xmin;
+
+ if (TransactionIdIsNormal(xmin))
+ {
+ if (HeapTupleHeaderXminFrozen(tuple))
+ tuple->t_choice.t_heap.t_xmin = FrozenTransactionId;
+ else if (HeapTupleHeaderXminInvalid(tuple))
+ tuple->t_choice.t_heap.t_xmin = InvalidTransactionId;
+ else
+ {
+ Assert(xmin >= xid_base + FirstNormalTransactionId);
+ /* Subtract xid_base from normal xmin */
+ tuple->t_choice.t_heap.t_xmin = xmin - xid_base;
+ }
+ }
+ }
+
+ /* If tuple has multixact flag, handle mxid wraparound */
+ if ((tuple->t_infomask & HEAP_XMAX_IS_MULTI) &&
+ !(tuple->t_infomask & HEAP_XMAX_INVALID))
+ {
+ MultiXactId mxid = tuple->t_choice.t_heap.t_xmax;
+
+ /* Handle mxid wraparound */
+ if (mxid < multi_base)
+ {
+ mxid += ((MultiXactId) 1 << 32) - FirstMultiXactId;
+ Assert(mxid >= multi_base);
+ }
+
+ if (double_xmax)
+ {
+ /* Save converted mxid into "double xmax" format */
+ HeapTupleHeaderSetDoubleXmax(tuple, mxid);
+ }
+ else
+ {
+ /*
+ * Save converted mxid offset relative to (minmxid - 1), which
+ * will be page's mxid base.
+ */
+ Assert(mxid - multi_base + FirstMultiXactId <= PG_UINT32_MAX);
+ tuple->t_choice.t_heap.t_xmax =
+ (uint32) (mxid - multi_base + FirstMultiXactId);
+ }
+ }
+ /* Convert xmax */
+ else if (!(tuple->t_infomask & HEAP_XMAX_INVALID))
+ {
+ TransactionId xmax = tuple->t_choice.t_heap.t_xmax;
+
+ if (double_xmax)
+ {
+ /* Save converted xmax into "double xmax" format */
+ HeapTupleHeaderSetDoubleXmax(tuple, xmax);
+ }
+ else if (TransactionIdIsNormal(xmax))
+ {
+ /* Subtract xid_base from normal xmax */
+ Assert(xmax >= xid_base + FirstNormalTransactionId);
+ tuple->t_choice.t_heap.t_xmax = xmax - xid_base;
+ }
+ }
+ else
+ {
+ if (double_xmax)
+ HeapTupleHeaderSetDoubleXmax(tuple, InvalidTransactionId);
+ else
+ tuple->t_choice.t_heap.t_xmax = InvalidTransactionId;
+ }
+}
+
+/*
+ * Correct page xmin/xmax based on tuple xmin/xmax values.
+ */
+static void
+compute_xid_min_max(HeapTuple tuple, MultiXactId multi_base,
+ TransactionId *xid_min, TransactionId *xid_max,
+ MultiXactId *multi_min, MultiXactId *multi_max)
+{
+ /* xmin */
+ if (!HeapTupleHeaderXminInvalid(tuple->t_data) &&
+ !HeapTupleHeaderXminFrozen(tuple->t_data))
+ {
+ TransactionId xid = HeapTupleGetRawXmin(tuple);
+
+ if (TransactionIdIsNormal(xid))
+ {
+ *xid_max = Max(*xid_max, xid);
+ *xid_min = Min(*xid_min, xid);
+ }
+ }
+
+ /* xmax */
+ if (!(tuple->t_data->t_infomask & HEAP_XMAX_INVALID))
+ {
+ TransactionId xid;
+
+ if (tuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI)
+ {
+ MultiXactId mxid = HeapTupleGetRawXmax(tuple);
+
+ Assert(MultiXactIdIsValid(mxid));
+
+ /* Handle mxid wraparound */
+ if (mxid < multi_base)
+ {
+ mxid += ((MultiXactId) 1 << 32) - FirstMultiXactId;
+ Assert(mxid >= multi_base);
+ }
+
+ *multi_max = Max(*multi_max, mxid);
+ *multi_min = Min(*multi_min, mxid);
+
+ /*
+ * Also take into account hidden update xid, which can be
+ * extracted by the vacuum.
+ */
+ if (tuple->t_data->t_infomask & HEAP_XMAX_LOCK_ONLY)
+ xid = InvalidTransactionId;
+ else
+ xid = HeapTupleGetUpdateXid(tuple);
+ }
+ else
+ {
+ xid = HeapTupleGetRawXmax(tuple);
+ }
+
+ if (TransactionIdIsNormal(xid))
+ {
+ *xid_max = Max(*xid_max, xid);
+ *xid_min = Min(*xid_min, xid);
+ }
+ }
+}
+
+/*
+ * Returns true if both:
+ * - xid_max: an uppper boundary of xmin's and xmax'es of all tuples on a page
+ * - xid_min: a lower boundary of xmin's and xmax'es of all tuples on a page
+ * can be expressed by 32-bit number relative to page's xid_base/multi_base
+ * or invalid.
+ *
+ * True value effectively means that these tuples can be directly put on one
+ * page in 64-xid format.
+ */
+static inline bool
+xids_fit_page(TransactionId xid_min, TransactionId xid_max,
+ MultiXactId multi_min, MultiXactId multi_max)
+{
+ bool xid_max_fits = false;
+ bool multi_max_fits = false;
+
+ if (xid_max == InvalidTransactionId)
+ xid_max_fits = true;
+
+ if (xid_max - xid_min <= MaxShortTransactionId - FirstNormalTransactionId)
+ xid_max_fits = true;
+
+ if (multi_max == InvalidMultiXactId)
+ multi_max_fits = true;
+
+ if (multi_max - multi_min <= MaxShortTransactionId - FirstMultiXactId)
+ multi_max_fits = true;
+
+ return xid_max_fits && multi_max_fits;
+}
+
+/*
+ * Set "base" for page in 64-bit XID format.
+ *
+ * This should not be called for double xmax pages. They do not have place for
+ * page special.
+ */
+static inline void
+heap_page_set_base(Page page,
+ TransactionId xid_min, TransactionId xid_max,
+ MultiXactId multi_min, MultiXactId multi_max,
+ TransactionId *xid_base, MultiXactId *multi_base,
+ bool is_toast)
+{
+ PageHeader hdr = (PageHeader) page;
+
+ if (xid_max != InvalidTransactionId)
+ *xid_base = xid_min - FirstNormalTransactionId;
+ else
+ *xid_base = InvalidTransactionId;
+
+ if (multi_max != InvalidMultiXactId)
+ *multi_base = multi_min - FirstMultiXactId;
+ else
+ *multi_base = InvalidMultiXactId;
+
+ if (is_toast)
+ {
+ ToastPageSpecial special;
+
+ hdr->pd_special = BLCKSZ - MAXALIGN(sizeof(ToastPageSpecialData));
+ special = ToastPageGetSpecial(page);
+ special->pd_xid_base = *xid_base;
+ }
+ else
+ {
+ HeapPageSpecial special;
+
+ hdr->pd_special = BLCKSZ - MAXALIGN(sizeof(HeapPageSpecialData));
+ special = HeapPageGetSpecial(page);
+ special->pd_xid_base = *xid_base;
+ special->pd_multi_base = *multi_base;
+ }
+}
+
+/*
+ * repack_heap_tuples
+ * Convert heap page format reusing space of dead tuples
+ */
+static void
+repack_heap_tuples(Relation rel, Page page, Buffer buf, BlockNumber blkno,
+ bool try_double_xmax)
+{
+ ItemIdCompactData items[MaxHeapTuplesPerPage];
+ ItemIdCompact itemPtr = items;
+ int nitems = 0,
+ maxoff = PageGetMaxOffsetNumber(page),
+ idx,
+ occupied_space = 0;
+ Offset upper;
+ bool double_xmax,
+ special_fits,
+ toast;
+ PageHeader hdr = (PageHeader) page,
+ new_hdr;
+ char new_page[BLCKSZ] = {0};
+ MultiXactId multi_base = rel->rd_rel->relminmxid,
+ multi_min = MaxMultiXactId,
+ multi_max = InvalidMultiXactId;
+ TransactionId xid_base = rel->rd_rel->relfrozenxid,
+ xid_min = MaxTransactionId,
+ xid_max = InvalidTransactionId;
+
+ toast = IsToastRelation(rel);
+
+ if (TransactionIdIsNormal(hdr->pd_prune_xid))
+ xid_min = xid_max = hdr->pd_prune_xid;
+
+ for (idx = 0; idx < maxoff; idx++)
+ {
+ HeapTupleData tuple;
+ ItemId lp;
+
+ lp = PageGetItemId(page, idx + 1);
+
+ /* Skip redirects and items without storage */
+ if (!ItemIdHasStorage(lp))
+ continue;
+
+ /* Build in-memory tuple representation */
+ tuple.t_tableOid = 1; /* doesn't matter in this case */
+ tuple.t_data = (HeapTupleHeader) PageGetItem(page, lp);
+ HeapTupleCopyHeaderXids(&tuple);
+ tuple.t_len = ItemIdGetLength(lp);
+ ItemPointerSet(&(tuple.t_self), blkno, ItemIdGetOffset(lp));
+
+ /*
+ * This is only needed to determine whether tuple is HEAPTUPLE_DEAD or
+ * HEAPTUPLE_RECENTLY_DEAD. And since this is the first time we read
+ * page after pg_upgrade, it cannot be HEAPTUPLE_RECENTLY_DEAD. See
+ * HeapTupleSatisfiesVacuum() for details
+ */
+ if (try_double_xmax &&
+ HeapTupleSatisfiesVacuum(&tuple,
+ (TransactionId) 1 << 32, buf) == HEAPTUPLE_DEAD)
+ {
+ ItemIdSetDead(lp);
+ }
+
+ if (ItemIdIsNormal(lp) && ItemIdHasStorage(lp))
+ {
+ itemPtr->offsetindex = idx;
+ itemPtr->itemoff = ItemIdGetOffset(lp);
+ if (unlikely(itemPtr->itemoff < hdr->pd_upper ||
+ itemPtr->itemoff >= hdr->pd_special))
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_DATA_CORRUPTED),
+ errmsg("corrupted item pointer: %u",
+ itemPtr->itemoff)));
+ }
+
+ itemPtr->alignedlen = MAXALIGN(ItemIdGetLength(lp));
+ occupied_space += itemPtr->alignedlen;
+ nitems++;
+ itemPtr++;
+ if (try_double_xmax)
+ {
+ HeapTupleSetXmin(&tuple, FrozenTransactionId);
+ HeapTupleHeaderSetXminFrozen(tuple.t_data);
+ }
+
+ compute_xid_min_max(&tuple, multi_base,
+ &xid_min, &xid_max,
+ &multi_min, &multi_max);
+ }
+ }
+
+ /* Write new header */
+ new_hdr = (PageHeader) new_page;
+ *new_hdr = *hdr;
+ new_hdr->pd_lower = SizeOfPageHeaderData + maxoff * sizeof(ItemIdData);
+
+ if (toast)
+ special_fits = BLCKSZ - new_hdr->pd_lower - occupied_space >=
+ sizeof(ToastPageSpecialData);
+ else
+ special_fits = BLCKSZ - new_hdr->pd_lower - occupied_space >=
+ sizeof(HeapPageSpecialData);
+
+ double_xmax = !special_fits ||
+ !xids_fit_page(xid_min, xid_max, multi_min, multi_max);
+
+ if (!double_xmax)
+ {
+ Assert(xid_max == InvalidTransactionId || xid_max >= xid_min);
+ Assert(multi_max == InvalidMultiXactId || multi_max >= multi_min);
+
+ heap_page_set_base(new_page,
+ xid_min, xid_max,
+ multi_min, multi_max,
+ &xid_base, &multi_base,
+ toast);
+
+ HeapPageSetPruneXid(new_page, new_hdr->pd_prune_xid, toast);
+ }
+ else
+ {
+ /* No space for special area, switch to "double xmax" format */
+ elog(DEBUG2, "convert heap page %u of relation \"%s\" to double xmax format",
+ blkno, RelationGetRelationName(rel));
+
+ if (try_double_xmax)
+ {
+ xid_base = InvalidTransactionId;
+ multi_base = InvalidMultiXactId;
+ }
+ else
+ {
+ repack_heap_tuples(rel, page, buf, blkno, true);
+ return;
+ }
+ }
+
+ /* Copy ItemIds with an offset */
+ memcpy((char *) new_page + SizeOfPageHeaderData,
+ (char *) page + SizeOfPageHeaderData,
+ hdr->pd_lower - SizeOfPageHeaderData);
+
+ /* Move live tuples */
+ upper = new_hdr->pd_special;
+ for (idx = 0; idx < nitems; idx++)
+ {
+ HeapTupleHeader tuple;
+ ItemId lp;
+
+ itemPtr = &items[idx];
+ lp = PageGetItemId(new_page, itemPtr->offsetindex + 1);
+ upper -= itemPtr->alignedlen;
+ occupied_space -= itemPtr->alignedlen;
+
+ memcpy((char *) new_page + upper,
+ (char *) page + itemPtr->itemoff,
+ itemPtr->alignedlen);
+
+ tuple = (HeapTupleHeader) (((char *) new_page) + upper);
+
+ convert_heap_tuple_xids(tuple, xid_base, multi_base, double_xmax);
+
+ lp->lp_off = upper;
+ }
+
+ Assert(occupied_space == 0);
+
+ new_hdr->pd_upper = upper;
+ if (new_hdr->pd_lower > new_hdr->pd_upper)
+ elog(ERROR, "cannot convert block %u of relation \"%s\"",
+ blkno, RelationGetRelationName(rel));
+
+ memcpy(page, new_page, BLCKSZ);
+}
diff --git a/src/backend/storage/buffer/meson.build b/src/backend/storage/buffer/meson.build
index 56a59b5248..a099145872 100644
--- a/src/backend/storage/buffer/meson.build
+++ b/src/backend/storage/buffer/meson.build
@@ -3,5 +3,6 @@ backend_sources += files(
'buf_table.c',
'bufmgr.c',
'freelist.c',
+ 'heap_convert.c',
'localbuf.c',
)
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 67c159a492..47589ec53b 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -67,7 +67,7 @@
#include "utils/rel.h"
#include "utils/snapmgr.h"
-#define UINT32_ACCESS_ONCE(var) ((uint32)(*((volatile uint32 *)&(var))))
+#define UINT64_ACCESS_ONCE(var) ((uint64)(*((volatile uint64 *)&(var))))
/* Our shared memory area */
typedef struct ProcArrayStruct
@@ -356,9 +356,6 @@ static inline void ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId l
static void ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid);
static void MaintainLatestCompletedXid(TransactionId latestXid);
static void MaintainLatestCompletedXidRecovery(TransactionId latestXid);
-
-static inline FullTransactionId FullXidRelativeTo(FullTransactionId rel,
- TransactionId xid);
static void GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons);
/*
@@ -517,7 +514,8 @@ ProcArrayAdd(PGPROC *proc)
arrayP->pgprocnos[index] = proc->pgprocno;
proc->pgxactoff = index;
- ProcGlobal->xids[index] = proc->xid;
+ pg_atomic_write_u64(&ProcGlobal->xids[index],
+ pg_atomic_read_u64(&proc->xid));
ProcGlobal->subxidStates[index] = proc->subxidStatus;
ProcGlobal->statusFlags[index] = proc->statusFlags;
@@ -577,7 +575,7 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
if (TransactionIdIsValid(latestXid))
{
- Assert(TransactionIdIsValid(ProcGlobal->xids[myoff]));
+ Assert(TransactionIdIsValid(pg_atomic_read_u64(&ProcGlobal->xids[myoff])));
/* Advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -585,17 +583,17 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
/* Same with xactCompletionCount */
ShmemVariableCache->xactCompletionCount++;
- ProcGlobal->xids[myoff] = InvalidTransactionId;
+ pg_atomic_write_u64(&ProcGlobal->xids[myoff], InvalidTransactionId);
ProcGlobal->subxidStates[myoff].overflowed = false;
ProcGlobal->subxidStates[myoff].count = 0;
}
else
{
/* Shouldn't be trying to remove a live transaction here */
- Assert(!TransactionIdIsValid(ProcGlobal->xids[myoff]));
+ Assert(!TransactionIdIsValid(pg_atomic_read_u64(&(ProcGlobal->xids[myoff]))));
}
- Assert(!TransactionIdIsValid(ProcGlobal->xids[myoff]));
+ Assert(!TransactionIdIsValid(pg_atomic_read_u64(&(ProcGlobal->xids[myoff]))));
Assert(ProcGlobal->subxidStates[myoff].count == 0);
Assert(ProcGlobal->subxidStates[myoff].overflowed == false);
@@ -641,7 +639,6 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
LWLockRelease(ProcArrayLock);
}
-
/*
* ProcArrayEndTransaction -- mark a transaction as no longer running
*
@@ -666,7 +663,7 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
* else is taking a snapshot. See discussion in
* src/backend/access/transam/README.
*/
- Assert(TransactionIdIsValid(proc->xid));
+ Assert(TransactionIdIsValid(pg_atomic_read_u64(&proc->xid)));
/*
* If we can immediately acquire ProcArrayLock, we clear our own XID
@@ -688,12 +685,12 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
* anyone else's calculation of a snapshot. We might change their
* estimate of global xmin, but that's OK.
*/
- Assert(!TransactionIdIsValid(proc->xid));
+ Assert(!TransactionIdIsValid(pg_atomic_read_u64(&proc->xid)));
Assert(proc->subxidStatus.count == 0);
Assert(!proc->subxidStatus.overflowed);
proc->lxid = InvalidLocalTransactionId;
- proc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&proc->xmin, InvalidTransactionId);
/* be sure this is cleared in abort */
proc->delayChkptFlags = 0;
@@ -729,13 +726,14 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
* processes' PGPROC entries.
*/
Assert(LWLockHeldByMeInMode(ProcArrayLock, LW_EXCLUSIVE));
- Assert(TransactionIdIsValid(ProcGlobal->xids[pgxactoff]));
- Assert(ProcGlobal->xids[pgxactoff] == proc->xid);
+ Assert(TransactionIdIsValid(pg_atomic_read_u64(&ProcGlobal->xids[pgxactoff])));
+ Assert(pg_atomic_read_u64(&ProcGlobal->xids[pgxactoff]) ==
+ pg_atomic_read_u64(&proc->xid));
- ProcGlobal->xids[pgxactoff] = InvalidTransactionId;
- proc->xid = InvalidTransactionId;
+ pg_atomic_write_u64(&ProcGlobal->xids[pgxactoff], InvalidTransactionId);
+ pg_atomic_write_u64(&proc->xid, InvalidTransactionId);
proc->lxid = InvalidLocalTransactionId;
- proc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&proc->xmin, InvalidTransactionId);
/* be sure this is cleared in abort */
proc->delayChkptFlags = 0;
@@ -788,7 +786,7 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
uint32 wakeidx;
/* We should definitely have an XID to clear. */
- Assert(TransactionIdIsValid(proc->xid));
+ Assert(TransactionIdIsValid(pg_atomic_read_u64(&proc->xid)));
/* Add ourselves to the list of processes needing a group XID clear. */
proc->procArrayGroupMember = true;
@@ -917,11 +915,11 @@ ProcArrayClearTransaction(PGPROC *proc)
pgxactoff = proc->pgxactoff;
- ProcGlobal->xids[pgxactoff] = InvalidTransactionId;
- proc->xid = InvalidTransactionId;
+ pg_atomic_write_u64(&ProcGlobal->xids[pgxactoff], InvalidTransactionId);
+ pg_atomic_write_u64(&proc->xid, InvalidTransactionId);
proc->lxid = InvalidLocalTransactionId;
- proc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&proc->xmin, InvalidTransactionId);
proc->recoveryConflictPending = false;
Assert(!(proc->statusFlags & PROC_VACUUM_STATE_MASK));
@@ -965,8 +963,7 @@ MaintainLatestCompletedXid(TransactionId latestXid)
if (TransactionIdPrecedes(XidFromFullTransactionId(cur_latest), latestXid))
{
- ShmemVariableCache->latestCompletedXid =
- FullXidRelativeTo(cur_latest, latestXid);
+ ShmemVariableCache->latestCompletedXid = FullTransactionIdFromXid(latestXid);
}
Assert(IsBootstrapProcessingMode() ||
@@ -980,7 +977,6 @@ static void
MaintainLatestCompletedXidRecovery(TransactionId latestXid)
{
FullTransactionId cur_latest = ShmemVariableCache->latestCompletedXid;
- FullTransactionId rel;
Assert(AmStartupProcess() || !IsUnderPostmaster);
Assert(LWLockHeldByMe(ProcArrayLock));
@@ -990,14 +986,12 @@ MaintainLatestCompletedXidRecovery(TransactionId latestXid)
* latestCompletedXid to be initialized in recovery. But in recovery it's
* safe to access nextXid without a lock for the startup process.
*/
- rel = ShmemVariableCache->nextXid;
Assert(FullTransactionIdIsValid(ShmemVariableCache->nextXid));
if (!FullTransactionIdIsValid(cur_latest) ||
TransactionIdPrecedes(XidFromFullTransactionId(cur_latest), latestXid))
{
- ShmemVariableCache->latestCompletedXid =
- FullXidRelativeTo(rel, latestXid);
+ ShmemVariableCache->latestCompletedXid = FullTransactionIdFromXid(latestXid);
}
Assert(FullTransactionIdIsNormal(ShmemVariableCache->latestCompletedXid));
@@ -1375,7 +1369,7 @@ bool
TransactionIdIsInProgress(TransactionId xid)
{
static TransactionId *xids = NULL;
- static TransactionId *other_xids;
+ static pg_atomic_uint64 *other_xids;
XidCacheStatus *other_subxidstates;
int nxids = 0;
ProcArrayStruct *arrayP = procArray;
@@ -1471,7 +1465,7 @@ TransactionIdIsInProgress(TransactionId xid)
continue;
/* Fetch xid just once - see GetNewTransactionId */
- pxid = UINT32_ACCESS_ONCE(other_xids[pgxactoff]);
+ pxid = pg_atomic_read_u64(&(other_xids[pgxactoff]));
if (!TransactionIdIsValid(pxid))
continue;
@@ -1503,7 +1497,7 @@ TransactionIdIsInProgress(TransactionId xid)
for (j = pxids - 1; j >= 0; j--)
{
/* Fetch xid just once - see GetNewTransactionId */
- TransactionId cxid = UINT32_ACCESS_ONCE(proc->subxids.xids[j]);
+ TransactionId cxid = UINT64_ACCESS_ONCE(proc->subxids.xids[j]);
if (TransactionIdEquals(cxid, xid))
{
@@ -1588,7 +1582,7 @@ TransactionIdIsInProgress(TransactionId xid)
topxid = SubTransGetTopmostTransaction(xid);
Assert(TransactionIdIsValid(topxid));
if (!TransactionIdEquals(topxid, xid) &&
- pg_lfind32(topxid, xids, nxids))
+ pg_lfind64(topxid, xids, nxids))
return true;
cachedXidIsNotInProgress = xid;
@@ -1608,7 +1602,7 @@ TransactionIdIsActive(TransactionId xid)
{
bool result = false;
ProcArrayStruct *arrayP = procArray;
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
int i;
/*
@@ -1627,7 +1621,7 @@ TransactionIdIsActive(TransactionId xid)
TransactionId pxid;
/* Fetch xid just once - see GetNewTransactionId */
- pxid = UINT32_ACCESS_ONCE(other_xids[i]);
+ pxid = pg_atomic_read_u64(&(other_xids[i]));
if (!TransactionIdIsValid(pxid))
continue;
@@ -1713,7 +1707,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
ProcArrayStruct *arrayP = procArray;
TransactionId kaxmin;
bool in_recovery = RecoveryInProgress();
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
/* inferred after ProcArrayLock is released */
h->catalog_oldest_nonremovable = InvalidTransactionId;
@@ -1729,7 +1723,8 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
* additions.
*/
{
- TransactionId initial;
+ TransactionId initial,
+ xid;
initial = XidFromFullTransactionId(h->latest_completed);
Assert(TransactionIdIsValid(initial));
@@ -1751,8 +1746,9 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
* definition, can't be any newer changes in the temp table than
* latestCompletedXid.
*/
- if (TransactionIdIsValid(MyProc->xid))
- h->temp_oldest_nonremovable = MyProc->xid;
+ xid = pg_atomic_read_u64(&MyProc->xid);
+ if (TransactionIdIsValid(xid))
+ h->temp_oldest_nonremovable = xid;
else
h->temp_oldest_nonremovable = initial;
}
@@ -1774,8 +1770,8 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
TransactionId xmin;
/* Fetch xid just once - see GetNewTransactionId */
- xid = UINT32_ACCESS_ONCE(other_xids[index]);
- xmin = UINT32_ACCESS_ONCE(proc->xmin);
+ xid = pg_atomic_read_u64(&(other_xids[index]));
+ xmin = pg_atomic_read_u64(&proc->xmin);
/*
* Consider both the transaction's Xmin, and its Xid.
@@ -2150,8 +2146,8 @@ GetSnapshotDataReuse(Snapshot snapshot)
* requirement that concurrent GetSnapshotData() calls yield the same
* xmin.
*/
- if (!TransactionIdIsValid(MyProc->xmin))
- MyProc->xmin = TransactionXmin = snapshot->xmin;
+ if (!TransactionIdIsValid(pg_atomic_read_u64(&MyProc->xmin)))
+ pg_atomic_write_u64(&MyProc->xmin, TransactionXmin = snapshot->xmin);
RecentXmin = snapshot->xmin;
Assert(TransactionIdPrecedesOrEquals(TransactionXmin, RecentXmin));
@@ -2203,7 +2199,7 @@ Snapshot
GetSnapshotData(Snapshot snapshot)
{
ProcArrayStruct *arrayP = procArray;
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
TransactionId xmin;
TransactionId xmax;
int count = 0;
@@ -2266,8 +2262,8 @@ GetSnapshotData(Snapshot snapshot)
latest_completed = ShmemVariableCache->latestCompletedXid;
mypgxactoff = MyProc->pgxactoff;
- myxid = other_xids[mypgxactoff];
- Assert(myxid == MyProc->xid);
+ myxid = pg_atomic_read_u64(&other_xids[mypgxactoff]);
+ Assert(myxid == pg_atomic_read_u64(&MyProc->xid));
oldestxid = ShmemVariableCache->oldestXid;
curXactCompletionCount = ShmemVariableCache->xactCompletionCount;
@@ -2301,7 +2297,7 @@ GetSnapshotData(Snapshot snapshot)
for (int pgxactoff = 0; pgxactoff < numProcs; pgxactoff++)
{
/* Fetch xid just once - see GetNewTransactionId */
- TransactionId xid = UINT32_ACCESS_ONCE(other_xids[pgxactoff]);
+ TransactionId xid = pg_atomic_read_u64(&(other_xids[pgxactoff]));
uint8 statusFlags;
Assert(allProcs[arrayP->pgprocnos[pgxactoff]].pgxactoff == pgxactoff);
@@ -2438,8 +2434,8 @@ GetSnapshotData(Snapshot snapshot)
replication_slot_xmin = procArray->replication_slot_xmin;
replication_slot_catalog_xmin = procArray->replication_slot_catalog_xmin;
- if (!TransactionIdIsValid(MyProc->xmin))
- MyProc->xmin = TransactionXmin = xmin;
+ if (!TransactionIdIsValid(pg_atomic_read_u64(&MyProc->xmin)))
+ pg_atomic_write_u64(&MyProc->xmin, TransactionXmin = xmin);
LWLockRelease(ProcArrayLock);
@@ -2451,12 +2447,7 @@ GetSnapshotData(Snapshot snapshot)
FullTransactionId def_vis_fxid_data;
FullTransactionId oldestfxid;
- /*
- * Converting oldestXid is only safe when xid horizon cannot advance,
- * i.e. holding locks. While we don't hold the lock anymore, all the
- * necessary data has been gathered with lock held.
- */
- oldestfxid = FullXidRelativeTo(latest_completed, oldestxid);
+ oldestfxid = FullTransactionIdFromXid(oldestxid);
/* apply vacuum_defer_cleanup_age */
def_vis_xid_data =
@@ -2479,8 +2470,8 @@ GetSnapshotData(Snapshot snapshot)
def_vis_xid =
TransactionIdOlder(replication_slot_catalog_xmin, def_vis_xid);
- def_vis_fxid = FullXidRelativeTo(latest_completed, def_vis_xid);
- def_vis_fxid_data = FullXidRelativeTo(latest_completed, def_vis_xid_data);
+ def_vis_fxid = FullTransactionIdFromXid(def_vis_xid);
+ def_vis_fxid_data = FullTransactionIdFromXid(def_vis_xid_data);
/*
* Check if we can increase upper bound. As a previous
@@ -2499,7 +2490,7 @@ GetSnapshotData(Snapshot snapshot)
/* See temp_oldest_nonremovable computation in ComputeXidHorizons() */
if (TransactionIdIsNormal(myxid))
GlobalVisTempRels.definitely_needed =
- FullXidRelativeTo(latest_completed, myxid);
+ FullTransactionIdFromXid(myxid);
else
{
GlobalVisTempRels.definitely_needed = latest_completed;
@@ -2606,7 +2597,7 @@ ProcArrayInstallImportedXmin(TransactionId xmin,
/*
* Likewise, let's just make real sure its xmin does cover us.
*/
- xid = UINT32_ACCESS_ONCE(proc->xmin);
+ xid = pg_atomic_read_u64(&proc->xmin);
if (!TransactionIdIsNormal(xid) ||
!TransactionIdPrecedesOrEquals(xid, xmin))
continue;
@@ -2617,7 +2608,7 @@ ProcArrayInstallImportedXmin(TransactionId xmin,
* GetSnapshotData first, we'll be overwriting a valid xmin here, so
* we don't check that.)
*/
- MyProc->xmin = TransactionXmin = xmin;
+ pg_atomic_write_u64(&MyProc->xmin, TransactionXmin = xmin);
result = true;
break;
@@ -2661,7 +2652,7 @@ ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc)
* can't go backwards. Also, make sure it's running in the same database,
* so that the per-database xmin cannot go backwards.
*/
- xid = UINT32_ACCESS_ONCE(proc->xmin);
+ xid = pg_atomic_read_u64(&proc->xmin);
if (proc->databaseId == MyDatabaseId &&
TransactionIdIsNormal(xid) &&
TransactionIdPrecedesOrEquals(xid, xmin))
@@ -2670,7 +2661,7 @@ ProcArrayInstallRestoredXmin(TransactionId xmin, PGPROC *proc)
* Install xmin and propagate the statusFlags that affect how the
* value is interpreted by vacuum.
*/
- MyProc->xmin = TransactionXmin = xmin;
+ pg_atomic_write_u64(&MyProc->xmin, TransactionXmin = xmin);
MyProc->statusFlags = (MyProc->statusFlags & ~PROC_XMIN_FLAGS) |
(proc->statusFlags & PROC_XMIN_FLAGS);
ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
@@ -2721,7 +2712,7 @@ GetRunningTransactionData(void)
static RunningTransactionsData CurrentRunningXactsData;
ProcArrayStruct *arrayP = procArray;
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
RunningTransactions CurrentRunningXacts = &CurrentRunningXactsData;
TransactionId latestCompletedXid;
TransactionId oldestRunningXid;
@@ -2780,7 +2771,7 @@ GetRunningTransactionData(void)
TransactionId xid;
/* Fetch xid just once - see GetNewTransactionId */
- xid = UINT32_ACCESS_ONCE(other_xids[index]);
+ xid = pg_atomic_read_u64(&(other_xids[index]));
/*
* We don't need to store transactions that don't have a TransactionId
@@ -2893,7 +2884,7 @@ TransactionId
GetOldestActiveTransactionId(void)
{
ProcArrayStruct *arrayP = procArray;
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
TransactionId oldestRunningXid;
int index;
@@ -2919,7 +2910,7 @@ GetOldestActiveTransactionId(void)
TransactionId xid;
/* Fetch xid just once - see GetNewTransactionId */
- xid = UINT32_ACCESS_ONCE(other_xids[index]);
+ xid = pg_atomic_read_u64(&(other_xids[index]));
if (!TransactionIdIsNormal(xid))
continue;
@@ -3007,7 +2998,7 @@ GetOldestSafeDecodingTransactionId(bool catalogOnly)
*/
if (!recovery_in_progress)
{
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
/*
* Spin over procArray collecting min(ProcGlobal->xids[i])
@@ -3017,7 +3008,7 @@ GetOldestSafeDecodingTransactionId(bool catalogOnly)
TransactionId xid;
/* Fetch xid just once - see GetNewTransactionId */
- xid = UINT32_ACCESS_ONCE(other_xids[index]);
+ xid = pg_atomic_read_u64(&(other_xids[index]));
if (!TransactionIdIsNormal(xid))
continue;
@@ -3212,7 +3203,7 @@ BackendXidGetPid(TransactionId xid)
{
int result = 0;
ProcArrayStruct *arrayP = procArray;
- TransactionId *other_xids = ProcGlobal->xids;
+ pg_atomic_uint64 *other_xids = ProcGlobal->xids;
int index;
if (xid == InvalidTransactionId) /* never match invalid xid */
@@ -3225,7 +3216,7 @@ BackendXidGetPid(TransactionId xid)
int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno];
- if (other_xids[index] == xid)
+ if (pg_atomic_read_u64(&other_xids[index]) == xid)
{
result = proc->pid;
break;
@@ -3306,7 +3297,7 @@ GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0,
if (allDbs || proc->databaseId == MyDatabaseId)
{
/* Fetch xmin just once - might change on us */
- TransactionId pxmin = UINT32_ACCESS_ONCE(proc->xmin);
+ TransactionId pxmin = pg_atomic_read_u64(&proc->xmin);
if (excludeXmin0 && !TransactionIdIsValid(pxmin))
continue;
@@ -3401,7 +3392,7 @@ GetConflictingVirtualXIDs(TransactionId limitXmin, Oid dbOid)
proc->databaseId == dbOid)
{
/* Fetch xmin just once - can't change on us, but good coding */
- TransactionId pxmin = UINT32_ACCESS_ONCE(proc->xmin);
+ TransactionId pxmin = pg_atomic_read_u64(&proc->xmin);
/*
* We ignore an invalid pxmin because this means that backend has
@@ -3528,7 +3519,7 @@ MinimumActiveBackends(int min)
continue; /* do not count deleted entries */
if (proc == MyProc)
continue; /* do not count myself */
- if (proc->xid == InvalidTransactionId)
+ if (pg_atomic_read_u64(&proc->xid) == InvalidTransactionId)
continue; /* do not count if no XID assigned */
if (proc->pid == 0)
continue; /* do not count prepared xacts */
@@ -4108,17 +4099,13 @@ static void
GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons)
{
GlobalVisSharedRels.maybe_needed =
- FullXidRelativeTo(horizons->latest_completed,
- horizons->shared_oldest_nonremovable);
+ FullTransactionIdFromXid(horizons->shared_oldest_nonremovable);
GlobalVisCatalogRels.maybe_needed =
- FullXidRelativeTo(horizons->latest_completed,
- horizons->catalog_oldest_nonremovable);
+ FullTransactionIdFromXid(horizons->catalog_oldest_nonremovable);
GlobalVisDataRels.maybe_needed =
- FullXidRelativeTo(horizons->latest_completed,
- horizons->data_oldest_nonremovable);
+ FullTransactionIdFromXid(horizons->data_oldest_nonremovable);
GlobalVisTempRels.maybe_needed =
- FullXidRelativeTo(horizons->latest_completed,
- horizons->temp_oldest_nonremovable);
+ FullTransactionIdFromXid(horizons->temp_oldest_nonremovable);
/*
* In longer running transactions it's possible that transactions we
@@ -4207,15 +4194,7 @@ GlobalVisTestIsRemovableXid(GlobalVisState *state, TransactionId xid)
{
FullTransactionId fxid;
- /*
- * Convert 32 bit argument to FullTransactionId. We can do so safely
- * because we know the xid has to, at the very least, be between
- * [oldestXid, nextXid), i.e. within 2 billion of xid. To avoid taking a
- * lock to determine either, we can just compare with
- * state->definitely_needed, which was based on those value at the time
- * the current snapshot was built.
- */
- fxid = FullXidRelativeTo(state->definitely_needed, xid);
+ fxid = FullTransactionIdFromXid(xid);
return GlobalVisTestIsRemovableFullXid(state, fxid);
}
@@ -4278,32 +4257,6 @@ GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
return GlobalVisTestIsRemovableXid(state, xid);
}
-/*
- * Convert a 32 bit transaction id into 64 bit transaction id, by assuming it
- * is within MaxTransactionId / 2 of XidFromFullTransactionId(rel).
- *
- * Be very careful about when to use this function. It can only safely be used
- * when there is a guarantee that xid is within MaxTransactionId / 2 xids of
- * rel. That e.g. can be guaranteed if the caller assures a snapshot is
- * held by the backend and xid is from a table (where vacuum/freezing ensures
- * the xid has to be within that range), or if xid is from the procarray and
- * prevents xid wraparound that way.
- */
-static inline FullTransactionId
-FullXidRelativeTo(FullTransactionId rel, TransactionId xid)
-{
- TransactionId rel_xid = XidFromFullTransactionId(rel);
-
- Assert(TransactionIdIsValid(xid));
- Assert(TransactionIdIsValid(rel_xid));
-
- /* not guaranteed to find issues, but likely to catch mistakes */
- AssertTransactionIdInAllowableRange(xid);
-
- return FullTransactionIdFromU64(U64FromFullTransactionId(rel)
- + (int32) (xid - rel_xid));
-}
-
/* ----------------------------------------------
* KnownAssignedTransactionIds sub-module
diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c
index 59310b708f..bf712ba7ee 100644
--- a/src/backend/storage/ipc/sinvaladt.c
+++ b/src/backend/storage/ipc/sinvaladt.c
@@ -426,8 +426,8 @@ BackendIdGetTransactionIds(int backendID, TransactionId *xid, TransactionId *xmi
if (proc != NULL)
{
- *xid = proc->xid;
- *xmin = proc->xmin;
+ *xid = pg_atomic_read_u64(&proc->xid);
+ *xmin = pg_atomic_read_u64(&proc->xmin);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 99341c3e87..5f1bed8b56 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -37,7 +37,7 @@
#include "utils/timestamp.h"
/* User-settable GUC parameters */
-int vacuum_defer_cleanup_age;
+int64 vacuum_defer_cleanup_age;
int max_standby_archive_delay = 30 * 1000;
int max_standby_streaming_delay = 30 * 1000;
bool log_recovery_conflict_waits = false;
@@ -486,8 +486,8 @@ ResolveRecoveryConflictWithSnapshotFullXid(FullTransactionId latestRemovedFullXi
FullTransactionId nextXid = ReadNextFullTransactionId();
uint64 diff;
- diff = U64FromFullTransactionId(nextXid) -
- U64FromFullTransactionId(latestRemovedFullXid);
+ diff = XidFromFullTransactionId(nextXid) -
+ XidFromFullTransactionId(latestRemovedFullXid);
if (diff < MaxTransactionId / 2)
{
TransactionId latestRemovedXid;
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index 1043068bac..0aa3ae79ac 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -1163,10 +1163,18 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
tag->locktag_field1);
break;
case LOCKTAG_TRANSACTION:
- appendStringInfo(buf,
- _("transaction %u"),
- tag->locktag_field1);
- break;
+ {
+ char xid_str[32];
+
+ /* make translatable string */
+ snprintf(xid_str, sizeof(xid_str), "%llu",
+ (unsigned long long)
+ (TransactionId) tag->locktag_field1 |
+ ((TransactionId) tag->locktag_field2 << 32));
+
+ appendStringInfo(buf, _("transaction %s"), xid_str);
+ break;
+ }
case LOCKTAG_VIRTUALTRANSACTION:
appendStringInfo(buf,
_("virtual transaction %d/%u"),
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 3d1049cf75..68ce82ddf8 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -4060,7 +4060,7 @@ GetRunningTransactionLocks(int *nlocks)
{
PGPROC *proc = proclock->tag.myProc;
LOCK *lock = proclock->tag.myLock;
- TransactionId xid = proc->xid;
+ TransactionId xid = pg_atomic_read_u64(&proc->xid);
/*
* Don't record locks for transactions if we know they have
@@ -4689,7 +4689,7 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
* so we won't save an XID of a different VXID. It doesn't matter whether
* we save this before or after setting up the primary lock table entry.
*/
- xid = proc->xid;
+ xid = pg_atomic_read_u64(&proc->xid);
/* Done with proc->fpLockBits */
LWLockRelease(&proc->fpInfoLock);
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index b71a60952d..529e01eb8f 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -334,9 +334,9 @@ static SlruCtlData SerialSlruCtlData;
#define SerialValue(slotno, xid) (*((SerCommitSeqNo *) \
(SerialSlruCtl->shared->page_buffer[slotno] + \
- ((((uint32) (xid)) % SERIAL_ENTRIESPERPAGE) * SERIAL_ENTRYSIZE))))
+ ((((uint64) (xid)) % SERIAL_ENTRIESPERPAGE) * SERIAL_ENTRYSIZE))))
-#define SerialPage(xid) (((uint32) (xid)) / SERIAL_ENTRIESPERPAGE)
+#define SerialPage(xid) ((int64) (((uint64) (xid)) / SERIAL_ENTRIESPERPAGE))
typedef struct SerialControlData
{
@@ -4078,7 +4078,7 @@ XidIsConcurrent(TransactionId xid)
if (TransactionIdFollowsOrEquals(xid, snap->xmax))
return true;
- return pg_lfind32(xid, snap->xip, snap->xcnt);
+ return pg_lfind64(xid, snap->xip, snap->xcnt);
}
bool
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 13fa07b0ff..7c81b1aa6a 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -205,7 +205,7 @@ InitProcGlobal(void)
* how hotly they are accessed.
*/
ProcGlobal->xids =
- (TransactionId *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->xids));
+ (pg_atomic_uint64 *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->xids));
MemSet(ProcGlobal->xids, 0, TotalProcs * sizeof(*ProcGlobal->xids));
ProcGlobal->subxidStates = (XidCacheStatus *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->subxidStates));
MemSet(ProcGlobal->subxidStates, 0, TotalProcs * sizeof(*ProcGlobal->subxidStates));
@@ -214,6 +214,7 @@ InitProcGlobal(void)
for (i = 0; i < TotalProcs; i++)
{
+ pg_atomic_init_u64(&ProcGlobal->xids[i], 0);
/* Common initialization for all PGPROCs, regardless of type. */
/*
@@ -383,8 +384,8 @@ InitProcess(void)
MyProc->lxid = InvalidLocalTransactionId;
MyProc->fpVXIDLock = false;
MyProc->fpLocalTransactionId = InvalidLocalTransactionId;
- MyProc->xid = InvalidTransactionId;
- MyProc->xmin = InvalidTransactionId;
+ pg_atomic_init_u64(&MyProc->xid, InvalidTransactionId);
+ pg_atomic_init_u64(&MyProc->xmin, InvalidTransactionId);
MyProc->pid = MyProcPid;
/* backendId, databaseId and roleId will be filled in later */
MyProc->backendId = InvalidBackendId;
@@ -570,8 +571,8 @@ InitAuxiliaryProcess(void)
MyProc->lxid = InvalidLocalTransactionId;
MyProc->fpVXIDLock = false;
MyProc->fpLocalTransactionId = InvalidLocalTransactionId;
- MyProc->xid = InvalidTransactionId;
- MyProc->xmin = InvalidTransactionId;
+ pg_atomic_init_u64(&MyProc->xid, InvalidTransactionId);
+ pg_atomic_init_u64(&MyProc->xmin, InvalidTransactionId);
MyProc->backendId = InvalidBackendId;
MyProc->databaseId = InvalidOid;
MyProc->roleId = InvalidOid;
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index 8b617c7e79..198fdb87e6 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -21,11 +21,31 @@
#include "storage/checksum.h"
#include "utils/memdebug.h"
#include "utils/memutils.h"
+#include "utils/snapmgr.h"
/* GUC variable */
bool ignore_checksum_failure = false;
+/*
+ * HeapPageSpecialData used when pd_special == BLCKSZ. This is special format
+ * used when page with 32-bit xids doesn't fit HeapPageSpecialData. Then
+ * all xmin's are frozen (can do this for all live tuples after pg_upgrade),
+ * while 64-bit xmax is stored in both t_heap.t_xmin and t_heap.t_xmax.
+ * This is so-called "double xmax" format.
+ */
+static HeapPageSpecialData heapDoubleXmaxSpecialData =
+{
+ .pd_xid_base = MaxTransactionId,
+ .pd_multi_base = MaxTransactionId
+};
+HeapPageSpecial heapDoubleXmaxSpecial = &heapDoubleXmaxSpecialData;
+
+static ToastPageSpecialData toastDoubleXmaxSpecialData =
+{
+ .pd_xid_base = MaxTransactionId
+};
+ToastPageSpecial toastDoubleXmaxSpecial = &toastDoubleXmaxSpecialData;
/* ----------------------------------------------------------------
* Page support functions
@@ -432,15 +452,144 @@ PageRestoreTempPage(Page tempPage, Page oldPage)
}
/*
- * Tuple defrag support for PageRepairFragmentation and PageIndexMultiDelete
+ * Get minimum and maximum values of xid and multixact on "double xmax" page.
*/
-typedef struct itemIdCompactData
+static void
+heap_page_double_xmax_get_min_max(Page page,
+ TransactionId *xid_min,
+ TransactionId *xid_max,
+ MultiXactId *multi_min,
+ MultiXactId *multi_max)
{
- uint16 offsetindex; /* linp array index */
- int16 itemoff; /* page offset of item data */
- uint16 alignedlen; /* MAXALIGN(item data len) */
-} itemIdCompactData;
-typedef itemIdCompactData *itemIdCompact;
+ bool xid_found = false,
+ multi_found = false;
+ OffsetNumber offnum,
+ maxoff;
+
+ maxoff = PageGetMaxOffsetNumber(page);
+
+ for (offnum = FirstOffsetNumber;
+ offnum <= maxoff;
+ offnum = OffsetNumberNext(offnum))
+ {
+ ItemId itemid;
+ HeapTupleHeader htup;
+ TransactionId xmax;
+
+ itemid = PageGetItemId(page, offnum);
+
+ if (!ItemIdIsNormal(itemid))
+ continue;
+
+ htup = (HeapTupleHeader) PageGetItem(page, itemid);
+
+ xmax = HeapTupleHeaderGetDoubleXmax(htup);
+
+ if (!TransactionIdIsNormal(xmax))
+ continue;
+
+ if (!(htup->t_infomask & HEAP_XMAX_IS_MULTI))
+ {
+ if (!xid_found)
+ {
+ *xid_min = *xid_max = xmax;
+ xid_found = true;
+ }
+ else
+ {
+ *xid_min = Min(*xid_min, xmax);
+ *xid_max = Max(*xid_max, xmax);
+ }
+ }
+ else
+ {
+ if (!multi_found)
+ {
+ *multi_min = *multi_max = xmax;
+ multi_found = true;
+ }
+ else
+ {
+ *multi_min = Min(*multi_min, xmax);
+ *multi_max = Max(*multi_max, xmax);
+ }
+ }
+ }
+}
+
+/*
+ * Add special area to heap page, so convert from "double xmax" to normal
+ * format.
+ */
+static void
+heap_page_add_special_area(ItemIdCompact itemidbase, int nitems, Page page,
+ TransactionId xid_base, MultiXactId multi_base,
+ bool is_toast)
+{
+ char newPage[BLCKSZ];
+ PageHeader phdr = (PageHeader) page;
+ PageHeader new_phdr = (PageHeader) newPage;
+ Offset upper;
+ int i;
+
+ memcpy(newPage, page, phdr->pd_lower);
+
+ /* Add special area */
+ if (is_toast)
+ {
+ ToastPageSpecial special;
+
+ new_phdr->pd_special = PageGetPageSize(newPage) - sizeof(ToastPageSpecialData);
+ special = (ToastPageSpecial) ((Pointer) (newPage) + new_phdr->pd_special);
+ special->pd_xid_base = xid_base;
+ }
+ else
+ {
+ HeapPageSpecial special;
+
+ new_phdr->pd_special = PageGetPageSize(newPage) - sizeof(HeapPageSpecialData);
+ special = (HeapPageSpecial) ((Pointer) (newPage) + new_phdr->pd_special);
+ special->pd_xid_base = xid_base;
+ special->pd_multi_base = multi_base;
+ }
+
+ /* sort itemIdSortData array into decreasing itemoff order */
+ qsort((char *) itemidbase, nitems, sizeof(ItemIdCompactData),
+ itemoffcompare);
+
+ upper = new_phdr->pd_special;
+ for (i = 0; i < nitems; i++)
+ {
+ ItemIdCompact itemidptr = &itemidbase[i];
+ ItemId lp;
+ HeapTupleHeader old_htup;
+ HeapTupleHeader new_htup;
+ TransactionId xmax;
+
+ lp = PageGetItemId(page, itemidptr->offsetindex + 1);
+ old_htup = (HeapTupleHeader) PageGetItem(page, lp);
+ upper -= itemidptr->alignedlen;
+ memcpy((Pointer) newPage + upper,
+ (Pointer) page + itemidptr->itemoff,
+ itemidptr->alignedlen);
+ lp = PageGetItemId(newPage, itemidptr->offsetindex + 1);
+ lp->lp_off = upper;
+ new_htup = (HeapTupleHeader) PageGetItem(newPage, lp);
+
+ /* Convert xmax value */
+ new_htup->t_choice.t_heap.t_xmin = FrozenTransactionId;
+ xmax = HeapTupleHeaderGetDoubleXmax(old_htup);
+ if (!(new_htup->t_infomask & HEAP_XMAX_IS_MULTI))
+ new_htup->t_choice.t_heap.t_xmax = NormalTransactionIdToShort(xid_base, xmax);
+ else
+ new_htup->t_choice.t_heap.t_xmax = NormalTransactionIdToShort(multi_base, xmax);
+ }
+
+ new_phdr->pd_upper = upper;
+
+ memcpy(page, newPage, PageGetPageSize(newPage));
+ elog(DEBUG2, "convert heap page from double xmax to normal format");
+}
/*
* After removing or marking some line pointers unused, move the tuples to
@@ -471,21 +620,47 @@ typedef itemIdCompactData *itemIdCompact;
* Callers must ensure that nitems is > 0
*/
static void
-compactify_tuples(itemIdCompact itemidbase, int nitems, Page page, bool presorted)
+compactify_tuples(ItemIdCompact itemidbase, int nitems, Page page,
+ bool presorted, bool addspecial, bool is_toast)
{
PageHeader phdr = (PageHeader) page;
Offset upper;
Offset copy_tail;
Offset copy_head;
- itemIdCompact itemidptr;
+ ItemIdCompact itemidptr;
int i;
/* Code within will not work correctly if nitems == 0 */
Assert(nitems > 0);
- if (presorted)
+ /* Add special area to the heap page if possible */
+ if (addspecial)
{
+ TransactionId xid_min = FirstNormalTransactionId,
+ xid_max = FirstNormalTransactionId;
+ MultiXactId multi_min = FirstNormalTransactionId,
+ multi_max = FirstNormalTransactionId;
+ Assert(phdr->pd_special == PageGetPageSize(page));
+
+ heap_page_double_xmax_get_min_max(page, &xid_min, &xid_max,
+ &multi_min, &multi_max);
+
+ if (xid_max - xid_min < (TransactionId) (MaxShortTransactionId - FirstNormalTransactionId) &&
+ multi_max - multi_min < (TransactionId) (MaxShortTransactionId - FirstNormalTransactionId))
+ {
+ Assert(xid_min >= FirstNormalTransactionId);
+ Assert(multi_min >= FirstNormalTransactionId);
+ heap_page_add_special_area(itemidbase, nitems, page,
+ xid_min - FirstNormalTransactionId,
+ multi_min - FirstNormalTransactionId,
+ is_toast);
+ return;
+ }
+ }
+
+ if (presorted)
+ {
#ifdef USE_ASSERT_CHECKING
{
/*
@@ -696,14 +871,14 @@ compactify_tuples(itemIdCompact itemidbase, int nitems, Page page, bool presorte
* the line pointer array following array truncation.
*/
void
-PageRepairFragmentation(Page page)
+PageRepairFragmentation(Page page, bool is_toast)
{
Offset pd_lower = ((PageHeader) page)->pd_lower;
Offset pd_upper = ((PageHeader) page)->pd_upper;
Offset pd_special = ((PageHeader) page)->pd_special;
Offset last_offset;
- itemIdCompactData itemidbase[MaxHeapTuplesPerPage];
- itemIdCompact itemidptr;
+ ItemIdCompactData itemidbase[MaxHeapTuplesPerPage];
+ ItemIdCompact itemidptr;
ItemId lp;
int nline,
nstorage,
@@ -777,11 +952,30 @@ PageRepairFragmentation(Page page)
nstorage = itemidptr - itemidbase;
if (nstorage == 0)
{
+ if (pd_special == PageGetPageSize(page))
+ {
+ if (is_toast)
+ {
+ pd_special = PageGetPageSize(page) - sizeof(ToastPageSpecialData);
+ ((PageHeader) page)->pd_special = pd_special;
+ ToastPageGetSpecial(page)->pd_xid_base = 0;
+ }
+ else
+ {
+ pd_special = PageGetPageSize(page) - sizeof(HeapPageSpecialData);
+ ((PageHeader) page)->pd_special = pd_special;
+ HeapPageGetSpecial(page)->pd_xid_base = 0;
+ HeapPageGetSpecial(page)->pd_multi_base = 0;
+ }
+ }
+
/* Page is completely empty, so just reset it quickly */
((PageHeader) page)->pd_upper = pd_special;
}
else
{
+ bool addspecial = false;
+
/* Need to compact the page the hard way */
if (totallen > (Size) (pd_special - pd_lower))
ereport(ERROR,
@@ -789,7 +983,25 @@ PageRepairFragmentation(Page page)
errmsg("corrupted item lengths: total %u, available space %u",
(unsigned int) totallen, pd_special - pd_lower)));
- compactify_tuples(itemidbase, nstorage, page, presorted);
+ /*
+ * Try to add special area to the heap page if it has enough of free
+ * space.
+ */
+ if (pd_special == PageGetPageSize(page))
+ {
+ Size special_size,
+ actual_size;
+
+ special_size = is_toast ? sizeof(ToastPageSpecialData) :
+ sizeof(HeapPageSpecialData);
+ actual_size = (Size) (pd_special - pd_lower) - totallen;
+
+ if (actual_size >= special_size)
+ addspecial = true;
+ }
+
+ compactify_tuples(itemidbase, nstorage, page, presorted, addspecial,
+ is_toast);
}
if (finalusedlp != nline)
@@ -992,6 +1204,9 @@ PageGetHeapFreeSpace(Page page)
{
Size space;
+ if (HeapPageIsDoubleXmax(page))
+ return 0;
+
space = PageGetFreeSpace(page);
if (space > 0)
{
@@ -1165,9 +1380,9 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems)
Offset pd_upper = phdr->pd_upper;
Offset pd_special = phdr->pd_special;
Offset last_offset;
- itemIdCompactData itemidbase[MaxIndexTuplesPerPage];
+ ItemIdCompactData itemidbase[MaxIndexTuplesPerPage];
ItemIdData newitemids[MaxIndexTuplesPerPage];
- itemIdCompact itemidptr;
+ ItemIdCompact itemidptr;
ItemId lp;
int nline,
nused;
@@ -1275,7 +1490,12 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems)
/* and compactify the tuple data */
if (nused > 0)
- compactify_tuples(itemidbase, nused, page, presorted);
+ {
+ bool is_toast;
+
+ is_toast = BLCKSZ - pd_special == sizeof(ToastPageSpecialData);
+ compactify_tuples(itemidbase, nused, page, presorted, false, is_toast);
+ }
else
phdr->pd_upper = pd_special;
}
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 662b5b50db..9eebbe1d25 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3786,15 +3786,13 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
case 'm':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxid = value;
+ start_mxid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxid) /* overflow */
+ !StartMultiXactIdIsValid(start_mxid))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -3817,15 +3815,13 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
case 'o':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxoff = value;
+ start_mxoff = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxoff) /* overflow */
+ !StartMultiXactOffsetIsValid(start_mxoff))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -3890,15 +3886,13 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
case 'x':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_xid = value;
+ start_xid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_xid) /* overflow */
+ !StartTransactionIdIsValid(start_xid))
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -4085,7 +4079,6 @@ PostgresSingleUserMain(int argc, char *argv[],
PostgresMain(dbname, username);
}
-
/* ----------------------------------------------------------------
* PostgresMain
* postgres main loop -- all backends, interactive or otherwise loop here
diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c
index 0cc7a6d8ad..04ca6ff16e 100644
--- a/src/backend/utils/adt/enum.c
+++ b/src/backend/utils/adt/enum.c
@@ -76,7 +76,7 @@ check_safe_enum_use(HeapTuple enumval_tup)
* Usually, a row would get hinted as committed when it's read or loaded
* into syscache; but just in case not, let's check the xmin directly.
*/
- xmin = HeapTupleHeaderGetXmin(enumval_tup->t_data);
+ xmin = HeapTupleGetXmin(enumval_tup);
if (!TransactionIdIsInProgress(xmin) &&
TransactionIdDidCommit(xmin))
return;
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index fd0d355789..78ffef1071 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -3661,6 +3661,7 @@ populate_recordset_record(PopulateRecordsetState *state, JsObject *obj)
tuple.t_len = HeapTupleHeaderGetDatumLength(tuphead);
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tuple);
tuple.t_data = tuphead;
tuplestore_puttuple(state->tuple_store, &tuple);
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index 14151bc81c..6fbdfdfb82 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -77,7 +77,7 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
* The representation is "<bid>/<lxid>", decimal and unsigned decimal
* respectively. Note that elog.c also knows how to format a vxid.
*/
- char vxidstr[32];
+ char vxidstr[64];
snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
(unsigned long long) lxid);
@@ -291,7 +291,9 @@ pg_lock_status(PG_FUNCTION_ARGS)
break;
case LOCKTAG_TRANSACTION:
values[6] =
- TransactionIdGetDatum(instance->locktag.locktag_field1);
+ TransactionIdGetDatum(
+ (TransactionId) instance->locktag.locktag_field1 |
+ ((TransactionId) instance->locktag.locktag_field2 << 32));
nulls[1] = true;
nulls[2] = true;
nulls[3] = true;
@@ -303,7 +305,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
break;
case LOCKTAG_VIRTUALTRANSACTION:
values[5] = VXIDGetDatum(instance->locktag.locktag_field1,
- instance->locktag.locktag_field2);
+ (TransactionId) instance->locktag.locktag_field2 |
+ ((TransactionId) instance->locktag.locktag_field3 << 32));
nulls[1] = true;
nulls[2] = true;
nulls[3] = true;
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index eadd8464ff..2f89562dc4 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -15,6 +15,7 @@
#include "postgres.h"
#include "access/htup_details.h"
+#include "access/xact.h"
#include "access/xlog.h"
#include "access/xlogprefetcher.h"
#include "catalog/pg_authid.h"
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index db843a0fbf..5e08d02d64 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -327,6 +327,7 @@ record_out(PG_FUNCTION_ARGS)
tuple.t_len = HeapTupleHeaderGetDatumLength(rec);
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tuple);
tuple.t_data = rec;
/*
@@ -694,6 +695,7 @@ record_send(PG_FUNCTION_ARGS)
tuple.t_len = HeapTupleHeaderGetDatumLength(rec);
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tuple);
tuple.t_data = rec;
/*
@@ -844,10 +846,12 @@ record_cmp(FunctionCallInfo fcinfo)
tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
ItemPointerSetInvalid(&(tuple1.t_self));
tuple1.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tuple1);
tuple1.t_data = record1;
tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
ItemPointerSetInvalid(&(tuple2.t_self));
tuple2.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tuple2);
tuple2.t_data = record2;
/*
@@ -1089,10 +1093,12 @@ record_eq(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple1.t_self));
tuple1.t_tableOid = InvalidOid;
tuple1.t_data = record1;
+ HeapTupleSetZeroBase(&tuple1);
tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
ItemPointerSetInvalid(&(tuple2.t_self));
tuple2.t_tableOid = InvalidOid;
tuple2.t_data = record2;
+ HeapTupleSetZeroBase(&tuple2);
/*
* We arrange to look up the needed comparison info just once per series
@@ -1351,10 +1357,12 @@ record_image_cmp(FunctionCallInfo fcinfo)
ItemPointerSetInvalid(&(tuple1.t_self));
tuple1.t_tableOid = InvalidOid;
tuple1.t_data = record1;
+ HeapTupleSetZeroBase(&tuple1);
tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
ItemPointerSetInvalid(&(tuple2.t_self));
tuple2.t_tableOid = InvalidOid;
tuple2.t_data = record2;
+ HeapTupleSetZeroBase(&tuple2);
/*
* We arrange to look up the needed comparison info just once per series
@@ -1597,10 +1605,12 @@ record_image_eq(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple1.t_self));
tuple1.t_tableOid = InvalidOid;
tuple1.t_data = record1;
+ HeapTupleSetZeroBase(&tuple1);
tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
ItemPointerSetInvalid(&(tuple2.t_self));
tuple2.t_tableOid = InvalidOid;
tuple2.t_data = record2;
+ HeapTupleSetZeroBase(&tuple2);
/*
* We arrange to look up the needed comparison info just once per series
@@ -1800,6 +1810,7 @@ hash_record(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
tuple.t_data = record;
+ HeapTupleSetZeroBase(&tuple);
/*
* We arrange to look up the needed hashing info just once per series of
@@ -1921,6 +1932,7 @@ hash_record_extended(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&(tuple.t_self));
tuple.t_tableOid = InvalidOid;
tuple.t_data = record;
+ HeapTupleSetZeroBase(&tuple);
/*
* We arrange to look up the needed hashing info just once per series of
diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c
index e4b4952a28..056752cfaf 100644
--- a/src/backend/utils/adt/xid.c
+++ b/src/backend/utils/adt/xid.c
@@ -32,16 +32,16 @@ xidin(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
- PG_RETURN_TRANSACTIONID((TransactionId) strtoul(str, NULL, 0));
+ PG_RETURN_TRANSACTIONID((TransactionId) strtou64(str, NULL, 0));
}
Datum
xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
- char *result = (char *) palloc(16);
+ char *result = (char *) palloc(32);
- snprintf(result, 16, "%lu", (unsigned long) transactionId);
+ snprintf(result, 32, "%llu", (unsigned long long) transactionId);
PG_RETURN_CSTRING(result);
}
@@ -52,8 +52,13 @@ Datum
xidrecv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
+ uint32 lo,
+ hi;
+
+ lo = (uint32) pq_getmsgint(buf, sizeof(TransactionId));
+ hi = (uint32) pq_getmsgint(buf, sizeof(TransactionId));
- PG_RETURN_TRANSACTIONID((TransactionId) pq_getmsgint(buf, sizeof(TransactionId)));
+ PG_RETURN_TRANSACTIONID((uint64) lo + ((uint64) hi << 32));
}
/*
@@ -64,9 +69,15 @@ xidsend(PG_FUNCTION_ARGS)
{
TransactionId arg1 = PG_GETARG_TRANSACTIONID(0);
StringInfoData buf;
+ uint32 lo,
+ hi;
+
+ lo = (uint32) (arg1 & 0xFFFFFFFF);
+ hi = (uint32) (arg1 >> 32);
pq_begintypsend(&buf);
- pq_sendint32(&buf, arg1);
+ pq_sendint(&buf, lo, sizeof(lo));
+ pq_sendint(&buf, hi, sizeof(hi));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -105,9 +116,9 @@ xid_age(PG_FUNCTION_ARGS)
/* Permanent XIDs are always infinitely old */
if (!TransactionIdIsNormal(xid))
- PG_RETURN_INT32(INT_MAX);
+ PG_RETURN_INT64(PG_INT8_MAX);
- PG_RETURN_INT32((int32) (now - xid));
+ PG_RETURN_INT64((int64) (now - xid));
}
/*
@@ -120,9 +131,9 @@ mxid_age(PG_FUNCTION_ARGS)
MultiXactId now = ReadNextMultiXactId();
if (!MultiXactIdIsValid(xid))
- PG_RETURN_INT32(INT_MAX);
+ PG_RETURN_INT64(PG_INT8_MAX);
- PG_RETURN_INT32((int32) (now - xid));
+ PG_RETURN_INT64((int64) (now - xid));
}
/*
@@ -184,7 +195,7 @@ xid8in(PG_FUNCTION_ARGS)
{
char *str = PG_GETARG_CSTRING(0);
- PG_RETURN_FULLTRANSACTIONID(FullTransactionIdFromU64(strtou64(str, NULL, 0)));
+ PG_RETURN_FULLTRANSACTIONID(FullTransactionIdFromXid(strtou64(str, NULL, 0)));
}
Datum
@@ -193,7 +204,7 @@ xid8out(PG_FUNCTION_ARGS)
FullTransactionId fxid = PG_GETARG_FULLTRANSACTIONID(0);
char *result = (char *) palloc(21);
- snprintf(result, 21, UINT64_FORMAT, U64FromFullTransactionId(fxid));
+ snprintf(result, 21, UINT64_FORMAT, XidFromFullTransactionId(fxid));
PG_RETURN_CSTRING(result);
}
@@ -204,7 +215,7 @@ xid8recv(PG_FUNCTION_ARGS)
uint64 value;
value = (uint64) pq_getmsgint64(buf);
- PG_RETURN_FULLTRANSACTIONID(FullTransactionIdFromU64(value));
+ PG_RETURN_FULLTRANSACTIONID(FullTransactionIdFromXid(value));
}
Datum
@@ -214,7 +225,7 @@ xid8send(PG_FUNCTION_ARGS)
StringInfoData buf;
pq_begintypsend(&buf);
- pq_sendint64(&buf, (uint64) U64FromFullTransactionId(arg1));
+ pq_sendint64(&buf, (uint64) XidFromFullTransactionId(arg1));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
diff --git a/src/backend/utils/adt/xid8funcs.c b/src/backend/utils/adt/xid8funcs.c
index d8e40b3b96..6257d985d6 100644
--- a/src/backend/utils/adt/xid8funcs.c
+++ b/src/backend/utils/adt/xid8funcs.c
@@ -80,8 +80,7 @@ typedef struct
* It is an ERROR if the xid is in the future. Otherwise, returns true if
* the transaction is still new enough that we can determine whether it
* committed and false otherwise. If *extracted_xid is not NULL, it is set
- * to the low 32 bits of the transaction ID (i.e. the actual XID, without the
- * epoch).
+ * to the actual transaction ID.
*
* The caller must hold XactTruncationLock since it's dealing with arbitrary
* XIDs, and must continue to hold it until it's done with any clog lookups
@@ -90,15 +89,10 @@ typedef struct
static bool
TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
{
- uint32 xid_epoch = EpochFromFullTransactionId(fxid);
TransactionId xid = XidFromFullTransactionId(fxid);
- uint32 now_epoch;
- TransactionId now_epoch_next_xid;
FullTransactionId now_fullxid;
now_fullxid = ReadNextFullTransactionId();
- now_epoch_next_xid = XidFromFullTransactionId(now_fullxid);
- now_epoch = EpochFromFullTransactionId(now_fullxid);
if (extracted_xid != NULL)
*extracted_xid = xid;
@@ -115,7 +109,7 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("transaction ID %llu is in the future",
- (unsigned long long) U64FromFullTransactionId(fxid))));
+ (unsigned long long) XidFromFullTransactionId(fxid))));
/*
* ShmemVariableCache->oldestClogXid is protected by XactTruncationLock,
@@ -127,48 +121,15 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
Assert(LWLockHeldByMe(XactTruncationLock));
/*
- * If the transaction ID has wrapped around, it's definitely too old to
- * determine the commit status. Otherwise, we can compare it to
- * ShmemVariableCache->oldestClogXid to determine whether the relevant
- * CLOG entry is guaranteed to still exist.
+ * We compare xid to ShmemVariableCache->oldestClogXid to determine
+ * whether the relevant CLOG entry is guaranteed to still exist.
*/
- if (xid_epoch + 1 < now_epoch
- || (xid_epoch + 1 == now_epoch && xid < now_epoch_next_xid)
- || TransactionIdPrecedes(xid, ShmemVariableCache->oldestClogXid))
+ if (TransactionIdPrecedes(xid, ShmemVariableCache->oldestClogXid))
return false;
return true;
}
-/*
- * Convert a TransactionId obtained from a snapshot held by the caller to a
- * FullTransactionId. Use next_fxid as a reference FullTransactionId, so that
- * we can compute the high order bits. It must have been obtained by the
- * caller with ReadNextFullTransactionId() after the snapshot was created.
- */
-static FullTransactionId
-widen_snapshot_xid(TransactionId xid, FullTransactionId next_fxid)
-{
- TransactionId next_xid = XidFromFullTransactionId(next_fxid);
- uint32 epoch = EpochFromFullTransactionId(next_fxid);
-
- /* Special transaction ID. */
- if (!TransactionIdIsNormal(xid))
- return FullTransactionIdFromEpochAndXid(0, xid);
-
- /*
- * The 64 bit result must be <= next_fxid, since next_fxid hadn't been
- * issued yet when the snapshot was created. Every TransactionId in the
- * snapshot must therefore be from the same epoch as next_fxid, or the
- * epoch before. We know this because next_fxid is never allow to get
- * more than one epoch ahead of the TransactionIds in any snapshot.
- */
- if (xid > next_xid)
- epoch--;
-
- return FullTransactionIdFromEpochAndXid(epoch, xid);
-}
-
/*
* txid comparator for qsort/bsearch
*/
@@ -295,12 +256,12 @@ parse_snapshot(const char *str)
char *endp;
StringInfo buf;
- xmin = FullTransactionIdFromU64(strtou64(str, &endp, 10));
+ xmin = FullTransactionIdFromXid(strtou64(str, &endp, 10));
if (*endp != ':')
goto bad_format;
str = endp + 1;
- xmax = FullTransactionIdFromU64(strtou64(str, &endp, 10));
+ xmax = FullTransactionIdFromXid(strtou64(str, &endp, 10));
if (*endp != ':')
goto bad_format;
str = endp + 1;
@@ -318,7 +279,7 @@ parse_snapshot(const char *str)
while (*str != '\0')
{
/* read next value */
- val = FullTransactionIdFromU64(strtou64(str, &endp, 10));
+ val = FullTransactionIdFromXid(strtou64(str, &endp, 10));
str = endp;
/* require the input to be in order */
@@ -397,7 +358,6 @@ pg_current_snapshot(PG_FUNCTION_ARGS)
uint32 nxip,
i;
Snapshot cur;
- FullTransactionId next_fxid = ReadNextFullTransactionId();
cur = GetActiveSnapshot();
if (cur == NULL)
@@ -415,11 +375,11 @@ pg_current_snapshot(PG_FUNCTION_ARGS)
snap = palloc(PG_SNAPSHOT_SIZE(nxip));
/* fill */
- snap->xmin = widen_snapshot_xid(cur->xmin, next_fxid);
- snap->xmax = widen_snapshot_xid(cur->xmax, next_fxid);
+ snap->xmin = FullTransactionIdFromXid(cur->xmin);
+ snap->xmax = FullTransactionIdFromXid(cur->xmax);
snap->nxip = nxip;
for (i = 0; i < nxip; i++)
- snap->xip[i] = widen_snapshot_xid(cur->xip[i], next_fxid);
+ snap->xip[i] = FullTransactionIdFromXid(cur->xip[i]);
/*
* We want them guaranteed to be in ascending order. This also removes
@@ -467,16 +427,16 @@ pg_snapshot_out(PG_FUNCTION_ARGS)
initStringInfo(&str);
appendStringInfo(&str, UINT64_FORMAT ":",
- U64FromFullTransactionId(snap->xmin));
+ XidFromFullTransactionId(snap->xmin));
appendStringInfo(&str, UINT64_FORMAT ":",
- U64FromFullTransactionId(snap->xmax));
+ XidFromFullTransactionId(snap->xmax));
for (i = 0; i < snap->nxip; i++)
{
if (i > 0)
appendStringInfoChar(&str, ',');
appendStringInfo(&str, UINT64_FORMAT,
- U64FromFullTransactionId(snap->xip[i]));
+ XidFromFullTransactionId(snap->xip[i]));
}
PG_RETURN_CSTRING(str.data);
@@ -505,8 +465,8 @@ pg_snapshot_recv(PG_FUNCTION_ARGS)
if (nxip < 0 || nxip > PG_SNAPSHOT_MAX_NXIP)
goto bad_format;
- xmin = FullTransactionIdFromU64((uint64) pq_getmsgint64(buf));
- xmax = FullTransactionIdFromU64((uint64) pq_getmsgint64(buf));
+ xmin = FullTransactionIdFromXid((uint64) pq_getmsgint64(buf));
+ xmax = FullTransactionIdFromXid((uint64) pq_getmsgint64(buf));
if (!FullTransactionIdIsValid(xmin) ||
!FullTransactionIdIsValid(xmax) ||
FullTransactionIdPrecedes(xmax, xmin))
@@ -519,7 +479,7 @@ pg_snapshot_recv(PG_FUNCTION_ARGS)
for (i = 0; i < nxip; i++)
{
FullTransactionId cur =
- FullTransactionIdFromU64((uint64) pq_getmsgint64(buf));
+ FullTransactionIdFromXid((uint64) pq_getmsgint64(buf));
if (FullTransactionIdPrecedes(cur, last) ||
FullTransactionIdPrecedes(cur, xmin) ||
@@ -564,10 +524,10 @@ pg_snapshot_send(PG_FUNCTION_ARGS)
pq_begintypsend(&buf);
pq_sendint32(&buf, snap->nxip);
- pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xmin));
- pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xmax));
+ pq_sendint64(&buf, (int64) XidFromFullTransactionId(snap->xmin));
+ pq_sendint64(&buf, (int64) XidFromFullTransactionId(snap->xmax));
for (i = 0; i < snap->nxip; i++)
- pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xip[i]));
+ pq_sendint64(&buf, (int64) XidFromFullTransactionId(snap->xip[i]));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
@@ -655,8 +615,7 @@ pg_snapshot_xip(PG_FUNCTION_ARGS)
* Report the status of a recent transaction ID, or null for wrapped,
* truncated away or otherwise too old XIDs.
*
- * The passed epoch-qualified xid is treated as a normal xid, not a
- * multixact id.
+ * The passed xid is treated as a normal xid, not a multixact id.
*
* If it points to a committed subxact the result is the subxact status even
* though the parent xact may still be in progress or may have aborted.
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 38e943fab2..b69aa01cf9 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -1839,6 +1839,7 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, Datum *arguments,
memcpy((char *) ct->tuple.t_data,
(const char *) dtp->t_data,
dtp->t_len);
+ HeapTupleCopyBase(&ct->tuple, dtp);
MemoryContextSwitchTo(oldcxt);
if (dtp != ntp)
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 00dc0f2403..233530cf35 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2307,8 +2307,7 @@ RelationReloadIndexInfo(Relation relation)
relation->rd_index->indislive = index->indislive;
/* Copy xmin too, as that is needed to make sense of indcheckxmin */
- HeapTupleHeaderSetXmin(relation->rd_indextuple->t_data,
- HeapTupleHeaderGetXmin(tuple->t_data));
+ HeapTupleSetXmin(relation->rd_indextuple, HeapTupleGetXmin(tuple));
ReleaseSysCache(tuple);
}
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index a9dd068095..34fe6bea83 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -540,7 +540,7 @@ lookup_C_func(HeapTuple procedureTuple)
NULL);
if (entry == NULL)
return NULL; /* no such entry */
- if (entry->fn_xmin == HeapTupleHeaderGetRawXmin(procedureTuple->t_data) &&
+ if (entry->fn_xmin == HeapTupleGetRawXmin(procedureTuple) &&
ItemPointerEquals(&entry->fn_tid, &procedureTuple->t_self))
return entry; /* OK */
return NULL; /* entry is out of date */
@@ -576,7 +576,7 @@ record_C_func(HeapTuple procedureTuple,
HASH_ENTER,
&found);
/* OID is already filled in */
- entry->fn_xmin = HeapTupleHeaderGetRawXmin(procedureTuple->t_data);
+ entry->fn_xmin = HeapTupleGetRawXmin(procedureTuple);
entry->fn_tid = procedureTuple->t_self;
entry->user_fn = user_fn;
entry->inforec = inforec;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 12a1f30f7c..1414b1aef2 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -857,6 +857,14 @@ build_guc_variables(void)
num_vars++;
}
+ for (i = 0; ConfigureNamesInt64[i].gen.name; i++)
+ {
+ struct config_int64 *conf = &ConfigureNamesInt64[i];
+
+ conf->gen.vartype = PGC_INT64;
+ num_vars++;
+ }
+
for (i = 0; ConfigureNamesReal[i].gen.name; i++)
{
struct config_real *conf = &ConfigureNamesReal[i];
@@ -897,6 +905,9 @@ build_guc_variables(void)
for (i = 0; ConfigureNamesInt[i].gen.name; i++)
guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
+ for (i = 0; ConfigureNamesInt64[i].gen.name; i++)
+ guc_vars[num_vars++] = &ConfigureNamesInt64[i].gen;
+
for (i = 0; ConfigureNamesReal[i].gen.name; i++)
guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8869eb4112..5a7ef089f4 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2438,74 +2438,6 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
- {
- {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Minimum age at which VACUUM should freeze a table row."),
- NULL
- },
- &vacuum_freeze_min_age,
- 50000000, 0, 1000000000,
- NULL, NULL, NULL
- },
-
- {
- {"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
- NULL
- },
- &vacuum_freeze_table_age,
- 150000000, 0, 2000000000,
- NULL, NULL, NULL
- },
-
- {
- {"vacuum_multixact_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Minimum age at which VACUUM should freeze a MultiXactId in a table row."),
- NULL
- },
- &vacuum_multixact_freeze_min_age,
- 5000000, 0, 1000000000,
- NULL, NULL, NULL
- },
-
- {
- {"vacuum_multixact_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Multixact age at which VACUUM should scan whole table to freeze tuples."),
- NULL
- },
- &vacuum_multixact_freeze_table_age,
- 150000000, 0, 2000000000,
- NULL, NULL, NULL
- },
-
- {
- {"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_PRIMARY,
- gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."),
- NULL
- },
- &vacuum_defer_cleanup_age,
- 0, 0, 1000000, /* see ComputeXidHorizons */
- NULL, NULL, NULL
- },
- {
- {"vacuum_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
- NULL
- },
- &vacuum_failsafe_age,
- 1600000000, 0, 2100000000,
- NULL, NULL, NULL
- },
- {
- {"vacuum_multixact_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
- gettext_noop("Multixact age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
- NULL
- },
- &vacuum_multixact_failsafe_age,
- 1600000000, 0, 2100000000,
- NULL, NULL, NULL
- },
-
/*
* See also CheckRequiredParameterValues() if this parameter changes
*/
@@ -3116,28 +3048,6 @@ struct config_int ConfigureNamesInt[] =
50, 0, INT_MAX,
NULL, NULL, NULL
},
- {
- /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
- {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
- gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
- NULL
- },
- &autovacuum_freeze_max_age,
-
- /* see vacuum_failsafe_age if you change the upper-limit value. */
- 200000000, 100000, 2000000000,
- NULL, NULL, NULL
- },
- {
- /* see multixact.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
- {"autovacuum_multixact_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
- gettext_noop("Multixact age at which to autovacuum a table to prevent multixact wraparound."),
- NULL
- },
- &autovacuum_multixact_freeze_max_age,
- 400000000, 10000, 2000000000,
- NULL, NULL, NULL
- },
{
/* see max_connections */
{"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM,
@@ -3415,6 +3325,96 @@ struct config_int ConfigureNamesInt[] =
struct config_int64 ConfigureNamesInt64[] =
{
+ {
+ {"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Minimum age at which VACUUM should freeze a table row."),
+ NULL
+ },
+ &vacuum_freeze_min_age,
+ INT64CONST(50000000), INT64CONST(0), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+
+ {
+ {"vacuum_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Age at which VACUUM should scan whole table to freeze tuples."),
+ NULL
+ },
+ &vacuum_freeze_table_age,
+ INT64CONST(150000000), INT64CONST(0), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+
+ {
+ {"vacuum_multixact_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Minimum age at which VACUUM should freeze a MultiXactId in a table row."),
+ NULL
+ },
+ &vacuum_multixact_freeze_min_age,
+ INT64CONST(5000000), INT64CONST(0), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+
+ {
+ {"vacuum_multixact_freeze_table_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Multixact age at which VACUUM should scan whole table to freeze tuples."),
+ NULL
+ },
+ &vacuum_multixact_freeze_table_age,
+ INT64CONST(150000000), INT64CONST(0), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+
+ {
+ {"vacuum_defer_cleanup_age", PGC_SIGHUP, REPLICATION_PRIMARY,
+ gettext_noop("Number of transactions by which VACUUM and HOT cleanup should be deferred, if any."),
+ NULL
+ },
+ &vacuum_defer_cleanup_age,
+ INT64CONST(0), INT64CONST(0), INT64CONST(1000000), /* see ComputeXidHorizons */
+ NULL, NULL, NULL
+ },
+ {
+ {"vacuum_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
+ NULL
+ },
+ &vacuum_failsafe_age,
+ INT64CONST(1600000000), INT64CONST(0), INT64CONST(2100000000),
+ NULL, NULL, NULL
+ },
+ {
+ {"vacuum_multixact_failsafe_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ gettext_noop("Multixact age at which VACUUM should trigger failsafe to avoid a wraparound outage."),
+ NULL
+ },
+ &vacuum_multixact_failsafe_age,
+ INT64CONST(1600000000), INT64CONST(0), INT64CONST(2100000000),
+ NULL, NULL, NULL
+ },
+ {
+ /* see varsup.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
+ {"autovacuum_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
+ gettext_noop("Age at which to autovacuum a table to prevent transaction ID wraparound."),
+ NULL
+ },
+ &autovacuum_freeze_max_age,
+
+ /* see vacuum_failsafe_age if you change the upper-limit value. */
+ INT64CONST(10000000000), INT64CONST(100000), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+ {
+ /* see multixact.c for why this is PGC_POSTMASTER not PGC_SIGHUP */
+ {"autovacuum_multixact_freeze_max_age", PGC_POSTMASTER, AUTOVACUUM,
+ gettext_noop("Multixact age at which to autovacuum a table to prevent multixact wraparound."),
+ NULL
+ },
+ &autovacuum_multixact_freeze_max_age,
+ INT64CONST(20000000000), INT64CONST(10000), INT64CONST(0x7FFFFFFFFFFFFFFF),
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c
index 61c83f3590..19a316ec99 100644
--- a/src/backend/utils/misc/help_config.c
+++ b/src/backend/utils/misc/help_config.c
@@ -33,6 +33,7 @@ typedef union
struct config_bool _bool;
struct config_real real;
struct config_int integer;
+ struct config_int64 integer8;
struct config_string string;
struct config_enum _enum;
} mixedStruct;
@@ -107,7 +108,12 @@ printMixedStruct(mixedStruct *structToPrint)
structToPrint->integer.min,
structToPrint->integer.max);
break;
-
+ case PGC_INT64:
+ printf("INT64\t%lld\t%lld\t%lld\t",
+ (long long) structToPrint->integer8.reset_val,
+ (long long) structToPrint->integer8.min,
+ (long long) structToPrint->integer8.max);
+ break;
case PGC_REAL:
printf("REAL\t%g\t%g\t%g\t",
structToPrint->real.reset_val,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 4ab4a0a701..ffffdeccbb 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -165,7 +165,7 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
nulls[5] = false;
values[6] = CStringGetTextDatum(psprintf("%llu",
- (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 868d21c351..d51f1d1863 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -647,9 +647,9 @@
#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table
# size before insert vacuum
#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
-#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
+#autovacuum_freeze_max_age = 10000000000 # maximum XID age before forced vacuum
# (change requires restart)
-#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age
+#autovacuum_multixact_freeze_max_age = 20000000000 # maximum multixact age
# before forced vacuum
# (change requires restart)
#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index afa5bdbf04..3ee2d869e6 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -1163,11 +1163,16 @@ writetup_cluster(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
{
TuplesortPublic *base = TuplesortstateGetPublic(state);
HeapTuple tuple = (HeapTuple) stup->tuple;
- unsigned int tuplen = tuple->t_len + sizeof(ItemPointerData) + sizeof(int);
+ unsigned int tuplen = tuple->t_len +
+ sizeof(ItemPointerData) +
+ 2 * sizeof(TransactionId) + /* tuple xmin, xmax */
+ sizeof(int);
/* We need to store t_self, but not other fields of HeapTupleData */
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
LogicalTapeWrite(tape, &tuple->t_self, sizeof(ItemPointerData));
+ LogicalTapeWrite(tape, &tuple->t_xmin, sizeof(TransactionId));
+ LogicalTapeWrite(tape, &tuple->t_xmax, sizeof(TransactionId));
LogicalTapeWrite(tape, tuple->t_data, tuple->t_len);
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
@@ -1179,7 +1184,10 @@ readtup_cluster(Tuplesortstate *state, SortTuple *stup,
{
TuplesortPublic *base = TuplesortstateGetPublic(state);
TuplesortClusterArg *arg = (TuplesortClusterArg *) base->arg;
- unsigned int t_len = tuplen - sizeof(ItemPointerData) - sizeof(int);
+ unsigned int t_len = tuplen -
+ sizeof(ItemPointerData) -
+ 2 * sizeof(TransactionId) - /* tuple xmin, xmax */
+ sizeof(int);
HeapTuple tuple = (HeapTuple) tuplesort_readtup_alloc(state,
t_len + HEAPTUPLESIZE);
@@ -1187,6 +1195,8 @@ readtup_cluster(Tuplesortstate *state, SortTuple *stup,
tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
tuple->t_len = t_len;
LogicalTapeReadExact(tape, &tuple->t_self, sizeof(ItemPointerData));
+ LogicalTapeReadExact(tape, &tuple->t_xmin, sizeof(TransactionId));
+ LogicalTapeReadExact(tape, &tuple->t_xmax, sizeof(TransactionId));
/* We don't currently bother to reconstruct t_tableOid */
tuple->t_tableOid = InvalidOid;
/* Read in the tuple body */
diff --git a/src/backend/utils/time/combocid.c b/src/backend/utils/time/combocid.c
index 6613dc0534..f673624f68 100644
--- a/src/backend/utils/time/combocid.c
+++ b/src/backend/utils/time/combocid.c
@@ -101,12 +101,13 @@ static CommandId GetRealCmax(CommandId combocid);
*/
CommandId
-HeapTupleHeaderGetCmin(HeapTupleHeader tup)
+HeapTupleGetCmin(HeapTuple tuple)
{
+ HeapTupleHeader tup = tuple->t_data;
CommandId cid = HeapTupleHeaderGetRawCommandId(tup);
Assert(!(tup->t_infomask & HEAP_MOVED));
- Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tup)));
+ Assert(TransactionIdIsCurrentTransactionId(HeapTupleGetXmin(tuple)));
if (tup->t_infomask & HEAP_COMBOCID)
return GetRealCmin(cid);
@@ -115,8 +116,9 @@ HeapTupleHeaderGetCmin(HeapTupleHeader tup)
}
CommandId
-HeapTupleHeaderGetCmax(HeapTupleHeader tup)
+HeapTupleGetCmax(HeapTuple tuple)
{
+ HeapTupleHeader tup = tuple->t_data;
CommandId cid = HeapTupleHeaderGetRawCommandId(tup);
Assert(!(tup->t_infomask & HEAP_MOVED));
@@ -128,7 +130,7 @@ HeapTupleHeaderGetCmax(HeapTupleHeader tup)
* things too much.
*/
Assert(CritSectionCount > 0 ||
- TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetUpdateXid(tup)));
+ TransactionIdIsCurrentTransactionId(HeapTupleGetUpdateXidAny(tuple)));
if (tup->t_infomask & HEAP_COMBOCID)
return GetRealCmax(cid);
@@ -150,7 +152,7 @@ HeapTupleHeaderGetCmax(HeapTupleHeader tup)
* changes the tuple in shared buffers.
*/
void
-HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
+HeapTupleHeaderAdjustCmax(HeapTuple tup,
CommandId *cmax,
bool *iscombo)
{
@@ -160,10 +162,10 @@ HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
* Test for HeapTupleHeaderXminCommitted() first, because it's cheaper
* than a TransactionIdIsCurrentTransactionId call.
*/
- if (!HeapTupleHeaderXminCommitted(tup) &&
- TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tup)))
+ if (!HeapTupleHeaderXminCommitted(tup->t_data) &&
+ TransactionIdIsCurrentTransactionId(HeapTupleGetRawXmin(tup)))
{
- CommandId cmin = HeapTupleHeaderGetCmin(tup);
+ CommandId cmin = HeapTupleGetCmin(tup);
*cmax = GetComboCommandId(cmin, *cmax);
*iscombo = true;
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f76bab65cb..2be450529f 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -950,15 +950,15 @@ SnapshotResetXmin(void)
if (pairingheap_is_empty(&RegisteredSnapshots))
{
- MyProc->xmin = InvalidTransactionId;
+ pg_atomic_write_u64(&MyProc->xmin, InvalidTransactionId);
return;
}
minSnapshot = pairingheap_container(SnapshotData, ph_node,
pairingheap_first(&RegisteredSnapshots));
- if (TransactionIdPrecedes(MyProc->xmin, minSnapshot->xmin))
- MyProc->xmin = minSnapshot->xmin;
+ if (TransactionIdPrecedes(pg_atomic_read_u64(&MyProc->xmin), minSnapshot->xmin))
+ pg_atomic_write_u64(&MyProc->xmin, minSnapshot->xmin);
}
/*
@@ -1111,7 +1111,7 @@ AtEOXact_Snapshot(bool isCommit, bool resetXmin)
if (resetXmin)
SnapshotResetXmin();
- Assert(resetXmin || MyProc->xmin == 0);
+ Assert(resetXmin || pg_atomic_read_u64(&MyProc->xmin) == 0);
}
@@ -1176,8 +1176,9 @@ ExportSnapshot(Snapshot snapshot)
* Generate file path for the snapshot. We start numbering of snapshots
* inside the transaction from 1.
*/
- snprintf(path, sizeof(path), SNAPSHOT_EXPORT_DIR "/%08X-%08X-%d",
- MyProc->backendId, MyProc->lxid, list_length(exportedSnapshots) + 1);
+ snprintf(path, sizeof(path), SNAPSHOT_EXPORT_DIR "/%08X-%08X%08X-%d",
+ MyProc->backendId, (uint32) (MyProc->lxid >> 32),
+ (uint32) MyProc->lxid, list_length(exportedSnapshots) + 1);
/*
* Copy the snapshot into TopTransactionContext, add it to the
@@ -1353,7 +1354,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, "%" INT64_MODIFIER "u", &val) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid snapshot data in file \"%s\"", filename)));
@@ -1378,7 +1379,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/%" INT64_MODIFIER "u", &vxid->backendId, &vxid->localTransactionId) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid snapshot data in file \"%s\"", filename)));
@@ -1837,7 +1838,7 @@ TransactionIdLimitedForOldSnapshots(TransactionId recentXmin,
*/
if (old_snapshot_threshold == 0)
{
- if (TransactionIdPrecedes(latest_xmin, MyProc->xmin)
+ if (TransactionIdPrecedes(latest_xmin, pg_atomic_read_u64(&MyProc->xmin))
&& TransactionIdFollows(latest_xmin, xlimit))
xlimit = latest_xmin;
@@ -2321,7 +2322,7 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
if (!snapshot->suboverflowed)
{
/* we have full data, so search subxip */
- if (pg_lfind32(xid, snapshot->subxip, snapshot->subxcnt))
+ if (pg_lfind64(xid, snapshot->subxip, snapshot->subxcnt))
return true;
/* not there, fall through to search xip[] */
@@ -2343,7 +2344,7 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
return false;
}
- if (pg_lfind32(xid, snapshot->xip, snapshot->xcnt))
+ if (pg_lfind64(xid, snapshot->xip, snapshot->xcnt))
return true;
}
else
@@ -2377,7 +2378,7 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
* indeterminate xid. We don't know whether it's top level or subxact
* but it doesn't matter. If it's present, the xid is visible.
*/
- if (pg_lfind32(xid, snapshot->subxip, snapshot->subxcnt))
+ if (pg_lfind64(xid, snapshot->subxip, snapshot->subxcnt))
return true;
}
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index c56e1ac86c..f2812e1a1e 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1305,7 +1305,7 @@ bootstrap_template1(void)
escape_quotes_bki(username));
/* relfrozenxid must not be less than FirstNormalTransactionId */
- sprintf(buf, "%u", Max(start_xid, 3));
+ sprintf(buf, "%llu", (unsigned long long) Max(start_xid, 3));
bki_lines = replace_token(bki_lines, "RECENTXMIN",
buf);
@@ -1328,13 +1328,13 @@ bootstrap_template1(void)
unsetenv("PGCLIENTENCODING");
snprintf(cmd, sizeof(cmd),
- "\"%s\" --boot -X %d %s %s %u %s %u %s %u %s %s %s",
+ "\"%s\" --boot -X %d %s %s %llu %s %llu %s %llu %s %s %s",
backend_exec,
wal_segment_size_mb * (1024 * 1024),
data_checksums ? "-k" : "",
- "-m", start_mxid,
- "-o", start_mxoff,
- "-x", start_xid,
+ "-m", (unsigned long long) start_mxid,
+ "-o", (unsigned long long) start_mxoff,
+ "-x", (unsigned long long) start_xid,
boot_options, extra_options,
debug ? "-d 5" : "");
@@ -2177,15 +2177,18 @@ usage(const char *progname)
printf(_(" --discard-caches set debug_discard_caches=1\n"));
printf(_(" -L DIRECTORY where to find the input files\n"));
printf(_(" -m, --multixact-id=START_MXID\n"
- " set initial database cluster multixact id\n"));
+ " set initial database cluster multixact id\n"
+ " max value is 2^62-1\n"));
printf(_(" -n, --no-clean do not clean up after errors\n"));
printf(_(" -N, --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" --no-instructions do not print instructions for next steps\n"));
printf(_(" -o, --multixact-offset=START_MXOFF\n"
- " set initial database cluster multixact offset\n"));
+ " set initial database cluster multixact offset\n"
+ " max value is 2^62-1"));
printf(_(" -s, --show show internal settings\n"));
printf(_(" -S, --sync-only only sync database files to disk, then exit\n"));
- printf(_(" -x, --xid=START_XID set initial database cluster xid\n"));
+ printf(_(" -x, --xid=START_XID set initial database cluster xid\n"
+ " max value is 2^62-1\n"));
printf(_("\nOther options:\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
@@ -2723,13 +2726,16 @@ initialize_data_directory(void)
setup_config();
if (start_mxid != 0)
- printf(_("selecting initial multixact id ... %u\n"), start_mxid);
+ printf(_("selecting initial multixact id ... %llu\n"),
+ (unsigned long long) start_mxid);
if (start_mxoff != 0)
- printf(_("selecting initial multixact offset ... %u\n"), start_mxoff);
+ printf(_("selecting initial multixact offset ... %llu\n"),
+ (unsigned long long) start_mxoff);
if (start_xid != 0)
- printf(_("selecting initial xid ... %u\n"), start_xid);
+ printf(_("selecting initial xid ... %llu\n"),
+ (unsigned long long) start_xid);
/* Bootstrap template1 */
bootstrap_template1();
@@ -2747,11 +2753,11 @@ initialize_data_directory(void)
fflush(stdout);
snprintf(cmd, sizeof(cmd),
- "\"%s\" %s %s %s %u %s %u %s %u template1 >%s",
+ "\"%s\" %s %s %s %llu %s %llu %s %llu template1 >%s",
backend_exec, backend_options, extra_options,
- "-m", start_mxid,
- "-o", start_mxoff,
- "-x", start_xid,
+ "-m", (unsigned long long) start_mxid,
+ "-o", (unsigned long long) start_mxoff,
+ "-x", (unsigned long long) start_xid,
DEVNULL);
PG_CMD_OPEN;
@@ -2918,15 +2924,13 @@ main(int argc, char *argv[])
break;
case 'm':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxid = value;
+ start_mxid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxid) /* overflow */
+ !StartMultiXactIdIsValid(start_mxid))
{
pg_log_error("invalid initial database cluster multixact id");
exit(1);
@@ -2951,15 +2955,13 @@ main(int argc, char *argv[])
break;
case 'o':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_mxoff = value;
+ start_mxoff = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_mxoff) /* overflow */
+ !StartMultiXactOffsetIsValid(start_mxoff))
{
pg_log_error("invalid initial database cluster multixact offset");
exit(1);
@@ -3038,15 +3040,13 @@ main(int argc, char *argv[])
break;
case 'x':
{
- unsigned long value;
- char *endptr;
+ char *endptr;
errno = 0;
- value = strtoul(optarg, &endptr, 0);
- start_xid = value;
+ start_xid = strtoull(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0 ||
- value != start_xid) /* overflow */
+ !StartTransactionIdIsValid(start_xid))
{
pg_log_error("invalid value for initial database cluster xid");
exit(1);
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl
index 57a68091d4..d595e45bd3 100644
--- a/src/bin/initdb/t/001_initdb.pl
+++ b/src/bin/initdb/t/001_initdb.pl
@@ -149,28 +149,28 @@ command_fails(
# Set non-standard initial mxid/mxoff/xid.
command_fails_like(
- [ 'initdb', '-m', '4294967296', $datadir ],
+ [ 'initdb', '-m', '9223372036854775807', $datadir ],
qr/initdb: error: invalid initial database cluster multixact id/,
'fails for invalid initial database cluster multixact id');
command_fails_like(
- [ 'initdb', '-o', '4294967296', $datadir ],
+ [ 'initdb', '-o', '9223372036854775807', $datadir ],
qr/initdb: error: invalid initial database cluster multixact offset/,
'fails for invalid initial database cluster multixact offset');
command_fails_like(
- [ 'initdb', '-x', '4294967296', $datadir ],
+ [ 'initdb', '-x', '9223372036854775807', $datadir ],
qr/initdb: error: invalid value for initial database cluster xid/,
'fails for invalid initial database cluster xid');
command_fails_like(
- [ 'initdb', '-m', '0x100000000', $datadir ],
+ [ 'initdb', '-m', '0x10000000000000000', $datadir ],
qr/initdb: error: invalid initial database cluster multixact id/,
'fails for invalid initial database cluster multixact id');
command_fails_like(
- [ 'initdb', '-o', '0x100000000', $datadir ],
+ [ 'initdb', '-o', '0x10000000000000000', $datadir ],
qr/initdb: error: invalid initial database cluster multixact offset/,
'fails for invalid initial database cluster multixact offset');
command_fails_like(
- [ 'initdb', '-x', '0x100000000', $datadir ],
+ [ 'initdb', '-x', '0x10000000000000000', $datadir ],
qr/initdb: error: invalid value for initial database cluster xid/,
'fails for invalid initial database cluster xid');
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 8050811105..6563eb798b 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -9,6 +9,8 @@ use PostgreSQL::Test::Utils;
use Test::More;
+use Data::Dumper;
+
# This regression test demonstrates that the pg_amcheck binary correctly
# identifies specific kinds of corruption within pages. To test this, we need
# a mechanism to create corrupt pages with predictable, repeatable corruption.
@@ -85,6 +87,62 @@ use Test::More;
use constant HEAPTUPLE_PACK_CODE => 'LLLSSSSSCCLLCCCCCCCCCCllLL';
use constant HEAPTUPLE_PACK_LENGTH => 58; # Total size
+use constant HEAPPAGE_SPECIAL_PACK_CODE => 'QQ';
+use constant HEAPPAGE_SPECIAL_PACK_LENGTH => 16;
+use constant HEAPPAGE_SIZE => 8192;
+
+# Some #define constants from access/htup_details.h for use while corrupting.
+use constant HEAP_HASNULL => 0x0001;
+use constant HEAP_XMAX_LOCK_ONLY => 0x0080;
+use constant HEAP_XMIN_COMMITTED => 0x0100;
+use constant HEAP_XMIN_INVALID => 0x0200;
+use constant HEAP_XMAX_COMMITTED => 0x0400;
+use constant HEAP_XMAX_INVALID => 0x0800;
+use constant HEAP_NATTS_MASK => 0x07FF;
+use constant HEAP_XMAX_IS_MULTI => 0x1000;
+use constant HEAP_KEYS_UPDATED => 0x2000;
+
+use constant FIRST_NORMAL_TRANSACTION_ID => 3;
+
+# Read page special data
+sub read_special_data
+{
+ my ($fh, $offset) = @_;
+ my ($buffer, %special);
+
+ $offset -= $offset % HEAPPAGE_SIZE;
+ $offset += HEAPPAGE_SIZE - HEAPPAGE_SPECIAL_PACK_LENGTH;
+
+ sysseek($fh, $offset, 0)
+ or BAIL_OUT("sysseek failed: $!");
+ defined(sysread($fh, $buffer, HEAPPAGE_SPECIAL_PACK_LENGTH))
+ or BAIL_OUT("sysread failed: $!");
+
+ @_ = unpack(HEAPPAGE_SPECIAL_PACK_CODE, $buffer);
+ %special = (
+ pd_xid_base => shift,
+ pd_multi_base => shift);
+ return \%special;
+}
+
+# Write page special data
+sub write_special_data
+{
+ my ($fh, $offset, $special) = @_;
+
+ $offset -= $offset % HEAPPAGE_SIZE;
+ $offset += HEAPPAGE_SIZE - HEAPPAGE_SPECIAL_PACK_LENGTH;
+
+ my $buffer = pack(
+ HEAPPAGE_SPECIAL_PACK_CODE,
+ $special->{pd_xid_base}, $special->{pd_multi_base});
+
+ sysseek($fh, $offset, 0)
+ or BAIL_OUT("sysseek failed: $!");
+ defined(syswrite($fh, $buffer, HEAPPAGE_SPECIAL_PACK_LENGTH))
+ or BAIL_OUT("syswrite failed: $!");
+ return;
+}
# Read a tuple of our table from a heap page.
#
@@ -96,8 +154,9 @@ use constant HEAPTUPLE_PACK_LENGTH => 58; # Total size
#
sub read_tuple
{
- my ($fh, $offset) = @_;
+ my ($fh, $offset, $raw) = @_;
my ($buffer, %tup);
+
sysseek($fh, $offset, 0)
or BAIL_OUT("sysseek failed: $!");
defined(sysread($fh, $buffer, HEAPTUPLE_PACK_LENGTH))
@@ -133,6 +192,18 @@ sub read_tuple
c_va_toastrelid => shift);
# Stitch together the text for column 'b'
$tup{b} = join('', map { chr($tup{"b_body$_"}) } (1 .. 7));
+
+ if (!$raw)
+ {
+ my $special = read_special_data($fh, $offset);
+
+ $tup{t_xmin} += $special->{pd_xid_base};
+ my $is_multi = $tup{t_infomask} & HEAP_XMAX_IS_MULTI;
+ $tup{t_xmax} += !$is_multi ?
+ $special->{pd_xid_base} :
+ $special->{pd_multi_base};
+ }
+
return \%tup;
}
@@ -148,7 +219,33 @@ sub read_tuple
#
sub write_tuple
{
- my ($fh, $offset, $tup) = @_;
+ my ($fh, $offset, $tup, $raw) = @_;
+
+ if (!$raw)
+ {
+ my $special = read_special_data($fh, $offset);
+
+ my $xmin = $tup->{t_xmin} - $special->{pd_xid_base};
+ die "tuple x_min $tup->{t_xmin} is too smal for pd_xid_base $special->{pd_xid_base}"
+ if $xmin < 3;
+ $tup->{t_xmin} = $xmin;
+
+ if (($tup->{t_infomask} & HEAP_XMAX_IS_MULTI) == 0)
+ {
+ my $xmax = $tup->{t_xmax} - $special->{pd_xid_base};
+ die "tuple x_max $tup->{t_xmax} is too smal for pd_xid_base $special->{pd_xid_base}"
+ if $xmax < 3;
+ $tup->{t_xmax} = $xmax;
+ }
+ else
+ {
+ my $xmax = $tup->{t_xmax} - $special->{pd_multi_base};
+ die "tuple multi x_max $tup->{t_xmax} is too smal for pd_multi_base $special->{pd_multi_base}"
+ if $xmax < 3;
+ $tup->{t_xmax} = $xmax;
+ }
+ }
+
my $buffer = pack(
HEAPTUPLE_PACK_CODE,
$tup->{t_xmin}, $tup->{t_xmax},
@@ -171,6 +268,41 @@ sub write_tuple
return;
}
+# move pd_xid_base and pd_multi_base to more suitable position for tests.
+sub fixup_page
+{
+ my ($fh, $page, $xid_base, $multi_base, $lp_off) = @_;
+ my $offset = $page * HEAPPAGE_SIZE;
+ my $special = read_special_data($fh, $offset);
+
+ die "xid_base $xid_base should be lesser than existed $special->{pd_xid_base}"
+ if ($xid_base > $special->{pd_xid_base});
+ die "multi_base $multi_base should be lesser than existed $special->{pd_multi_base}"
+ if ($multi_base > $special->{pd_multi_base} && $special->{pd_multi_base} != 0);
+ return if ($xid_base == $special->{pd_xid_base} &&
+ $multi_base == $special->{pd_multi_base});
+
+ my $xid_delta = $special->{pd_xid_base} - $xid_base;
+ my $multi_delta = $special->{pd_multi_base} - $multi_base;
+
+ for my $off (@$lp_off)
+ {
+ # change only tuples on this page.
+ next if ($off < $offset && $off > $offset + HEAPPAGE_SIZE);
+
+ my $tup = read_tuple($fh, $off, 1);
+ $tup->{t_xmin} += $xid_delta;
+ my $is_multi = $tup->{t_infomask} & HEAP_XMAX_IS_MULTI;
+ $tup->{t_xmax} += !$is_multi ? $xid_delta : $multi_delta;
+ write_tuple($fh, $off, $tup, 1);
+ }
+
+ $special->{pd_xid_base} = $xid_base;
+ $special->{pd_multi_base} = $multi_base;
+
+ write_special_data($fh, $offset, $special);
+}
+
# Set umask so test directories and files are created with default permissions
umask(0077);
@@ -233,6 +365,10 @@ my $relfrozenxid = $node->safe_psql('postgres',
q(select relfrozenxid from pg_class where relname = 'test'));
my $datfrozenxid = $node->safe_psql('postgres',
q(select datfrozenxid from pg_database where datname = 'postgres'));
+my $datminmxid = $node->safe_psql('postgres',
+ q(select datminmxid from pg_database where datname = 'postgres'));
+my $txid_current = $node->safe_psql('postgres',
+ q(select txid_current()));
# Sanity check that our 'test' table has a relfrozenxid newer than the
# datfrozenxid for the database, and that the datfrozenxid is greater than the
@@ -263,7 +399,7 @@ select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
$node->stop;
my $file;
open($file, '+<', $relpath)
- or BAIL_OUT("open failed: $!");
+ or BAIL_OUT("open failed: $!");
binmode $file;
my $ENDIANNESS;
@@ -291,8 +427,13 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Determine endianness of current platform from the 1-byte varlena header
$ENDIANNESS = $tup->{b_header} == 0x11 ? "little" : "big";
}
+
+# Set 64bit xid bases a bit in the past therefore we can set xmin/xmax a bit
+# in the past
+fixup_page($file, 0, $datfrozenxid - 100, $datminmxid - 100, \@lp_off);
+
close($file)
- or BAIL_OUT("close failed: $!");
+ or BAIL_OUT("close failed: $!");
$node->start;
# Ok, Xids and page layout look ok. We can run corruption tests.
@@ -308,17 +449,6 @@ $node->command_ok([ 'pg_amcheck', '-p', $port, 'postgres' ],
$node->stop;
-# Some #define constants from access/htup_details.h for use while corrupting.
-use constant HEAP_HASNULL => 0x0001;
-use constant HEAP_XMAX_LOCK_ONLY => 0x0080;
-use constant HEAP_XMIN_COMMITTED => 0x0100;
-use constant HEAP_XMIN_INVALID => 0x0200;
-use constant HEAP_XMAX_COMMITTED => 0x0400;
-use constant HEAP_XMAX_INVALID => 0x0800;
-use constant HEAP_NATTS_MASK => 0x07FF;
-use constant HEAP_XMAX_IS_MULTI => 0x1000;
-use constant HEAP_KEYS_UPDATED => 0x2000;
-
# Helper function to generate a regular expression matching the header we
# expect verify_heapam() to return given which fields we expect to be non-null.
sub header
@@ -342,7 +472,7 @@ sub header
#
my @expected;
open($file, '+<', $relpath)
- or BAIL_OUT("open failed: $!");
+ or BAIL_OUT("open failed: $!");
binmode $file;
for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
@@ -367,7 +497,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
if ($offnum == 2)
{
# Corruptly set xmin < datfrozenxid
- my $xmin = 3;
+ my $xmin = $datfrozenxid - 12;
$tup->{t_xmin} = $xmin;
$tup->{t_infomask} &= ~HEAP_XMIN_COMMITTED;
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
@@ -377,24 +507,24 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
}
elsif ($offnum == 3)
{
- # Corruptly set xmin < datfrozenxid, further back, noting circularity
- # of xid comparison. For a new cluster with epoch = 0, the corrupt
- # xmin will be interpreted as in the future
- $tup->{t_xmin} = 4026531839;
+ # Corruptly set xmin > next transaction id.
+ my $xmin = $relfrozenxid + 1000000;
+ $tup->{t_xmin} = $xmin;
$tup->{t_infomask} &= ~HEAP_XMIN_COMMITTED;
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
+ qr/${$header}xmin $xmin equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
- # Corruptly set xmax < relminmxid;
- $tup->{t_xmax} = 4026531839;
+ # Corruptly set xmax > next transaction id.
+ my $xmax = $relfrozenxid + 1000000;
+ $tup->{t_xmax} = $xmax;
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
+ qr/${$header}xmax $xmax equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
@@ -402,8 +532,8 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} += 128;
push @expected,
- qr/${$header}data begins at offset 152 beyond the tuple length 58/,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 152 \(3 attributes, no nulls\)/;
+ qr/${$header}data begins at offset 152 beyond the tuple length 58/,
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 152 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 6)
{
@@ -411,7 +541,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} += 3;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 27 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 27 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 7)
{
@@ -419,7 +549,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} -= 8;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 16 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 16 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 8)
{
@@ -427,7 +557,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} -= 3;
push @expected,
- qr/${$header}tuple data should begin at byte 24, but actually begins at byte 21 \(3 attributes, no nulls\)/;
+ qr/${$header}tuple data should begin at byte 24, but actually begins at byte 21 \(3 attributes, no nulls\)/;
}
elsif ($offnum == 9)
{
@@ -435,7 +565,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask2} |= HEAP_NATTS_MASK;
push @expected,
- qr/${$header}number of attributes 2047 exceeds maximum expected for table 3/;
+ qr/${$header}number of attributes 2047 exceeds maximum expected for table 3/;
}
elsif ($offnum == 10)
{
@@ -447,7 +577,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_bits} = 0xAA;
push @expected,
- qr/${$header}tuple data should begin at byte 280, but actually begins at byte 24 \(2047 attributes, has nulls\)/;
+ qr/${$header}tuple data should begin at byte 280, but actually begins at byte 24 \(2047 attributes, has nulls\)/;
}
elsif ($offnum == 11)
{
@@ -458,7 +588,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_hoff} = 32;
push @expected,
- qr/${$header}number of attributes 67 exceeds maximum expected for table 3/;
+ qr/${$header}number of attributes 67 exceeds maximum expected for table 3/;
}
elsif ($offnum == 12)
{
@@ -482,7 +612,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$header = header(0, $offnum, 1);
push @expected,
- qr/${header}attribute with length \d+ ends at offset \d+ beyond total tuple length \d+/;
+ qr/${header}attribute with length \d+ ends at offset \d+ beyond total tuple length \d+/;
}
elsif ($offnum == 13)
{
@@ -497,25 +627,27 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Set both HEAP_XMAX_COMMITTED and HEAP_XMAX_IS_MULTI
$tup->{t_infomask} |= HEAP_XMAX_COMMITTED;
$tup->{t_infomask} |= HEAP_XMAX_IS_MULTI;
- $tup->{t_xmax} = 4;
+ my $xmax = $datminmxid + 1000000;
+ $tup->{t_xmax} = $xmax;
push @expected,
- qr/${header}multitransaction ID 4 equals or exceeds next valid multitransaction ID 1/;
+ qr/${header}multitransaction ID $xmax equals or exceeds next valid multitransaction ID \d+/;
}
elsif ($offnum == 15) # Last offnum must equal ROWCOUNT
{
# Set both HEAP_XMAX_COMMITTED and HEAP_XMAX_IS_MULTI
$tup->{t_infomask} |= HEAP_XMAX_COMMITTED;
$tup->{t_infomask} |= HEAP_XMAX_IS_MULTI;
- $tup->{t_xmax} = 4000000000;
+ my $xmax = $datminmxid - 10;
+ $tup->{t_xmax} = $xmax;
push @expected,
- qr/${header}multitransaction ID 4000000000 precedes relation minimum multitransaction ID threshold 1/;
+ qr/${header}multitransaction ID $xmax precedes relation minimum multitransaction ID threshold \d+/;
}
write_tuple($file, $offset, $tup);
}
close($file)
- or BAIL_OUT("close failed: $!");
+ or BAIL_OUT("close failed: $!");
$node->start;
# Run pg_amcheck against the corrupt table with epoch=0, comparing actual
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index a8a46d5bf0..ffc89b3184 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -248,7 +248,7 @@ main(int argc, char *argv[])
printf(_("Latest checkpoint's full_page_writes: %s\n"),
ControlFile->checkPointCopy.fullPageWrites ? _("on") : _("off"));
printf(_("Latest checkpoint's NextXID: %llu\n"),
- (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index dcb3b11d57..bab5773b2e 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -41,6 +41,7 @@
#include "access/attnum.h"
#include "access/sysattr.h"
#include "access/transam.h"
+#include "c.h"
#include "catalog/pg_aggregate_d.h"
#include "catalog/pg_am_d.h"
#include "catalog/pg_attribute_d.h"
@@ -2830,7 +2831,7 @@ dumpDatabase(Archive *fout)
*datistemplate,
*datconnlimit,
*tablespace;
- uint32 frozenxid,
+ uint64 frozenxid,
minmxid;
char *qdatname;
@@ -2891,8 +2892,8 @@ dumpDatabase(Archive *fout)
iculocale = PQgetvalue(res, 0, i_daticulocale);
else
iculocale = NULL;
- frozenxid = atooid(PQgetvalue(res, 0, i_frozenxid));
- minmxid = atooid(PQgetvalue(res, 0, i_minmxid));
+ frozenxid = strtou64(PQgetvalue(res, 0, i_frozenxid), NULL, 0);
+ minmxid = strtou64(PQgetvalue(res, 0, i_minmxid), NULL, 0);
dbdacl.acl = PQgetvalue(res, 0, i_datacl);
dbdacl.acldefault = PQgetvalue(res, 0, i_acldefault);
datistemplate = PQgetvalue(res, 0, i_datistemplate);
@@ -3178,10 +3179,16 @@ dumpDatabase(Archive *fout)
RelFileNumber relfilenumber;
appendPQExpBuffer(loHorizonQry, "UPDATE pg_catalog.pg_class\n"
- "SET relfrozenxid = '%u', relminmxid = '%u'\n"
+ "SET relfrozenxid = '%llu', relminmxid = '%llu'\n"
"WHERE oid = %u;\n",
- atooid(PQgetvalue(lo_res, i, ii_relfrozenxid)),
- atooid(PQgetvalue(lo_res, i, ii_relminmxid)),
+ (unsigned long long) strtou64(PQgetvalue(lo_res,
+ i,
+ ii_relfrozenxid),
+ NULL, 0),
+ (unsigned long long) strtou64(PQgetvalue(lo_res,
+ i,
+ ii_relminmxid),
+ NULL, 0),
atooid(PQgetvalue(lo_res, i, ii_oid)));
oid = atooid(PQgetvalue(lo_res, i, ii_oid));
@@ -6461,11 +6468,11 @@ getTables(Archive *fout, int *numTables)
tblinfo[i].relreplident = *(PQgetvalue(res, i, i_relreplident));
tblinfo[i].rowsec = (strcmp(PQgetvalue(res, i, i_relrowsec), "t") == 0);
tblinfo[i].forcerowsec = (strcmp(PQgetvalue(res, i, i_relforcerowsec), "t") == 0);
- tblinfo[i].frozenxid = atooid(PQgetvalue(res, i, i_relfrozenxid));
- tblinfo[i].toast_frozenxid = atooid(PQgetvalue(res, i, i_toastfrozenxid));
+ tblinfo[i].frozenxid = strtou64(PQgetvalue(res, i, i_relfrozenxid), NULL, 0);
+ tblinfo[i].toast_frozenxid = strtou64(PQgetvalue(res, i, i_toastfrozenxid), NULL, 0);
tblinfo[i].toast_oid = atooid(PQgetvalue(res, i, i_toastoid));
- tblinfo[i].minmxid = atooid(PQgetvalue(res, i, i_relminmxid));
- tblinfo[i].toast_minmxid = atooid(PQgetvalue(res, i, i_toastminmxid));
+ tblinfo[i].minmxid = strtou64(PQgetvalue(res, i, i_relminmxid), NULL, 0);
+ tblinfo[i].toast_minmxid = strtou64(PQgetvalue(res, i, i_toastminmxid), NULL, 0);
tblinfo[i].reloptions = pg_strdup(PQgetvalue(res, i, i_reloptions));
if (PQgetisnull(res, i, i_checkoption))
tblinfo[i].checkoption = NULL;
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 427f5d45f6..f47a403b15 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -298,11 +298,11 @@ typedef struct _tableInfo
bool rowsec; /* is row security enabled? */
bool forcerowsec; /* is row security forced? */
bool hasoids; /* does it have OIDs? */
- uint32 frozenxid; /* table's relfrozenxid */
- uint32 minmxid; /* table's relminmxid */
+ uint64 frozenxid; /* table's relfrozenxid */
+ uint64 minmxid; /* table's relminmxid */
Oid toast_oid; /* toast table's OID, or 0 if none */
- uint32 toast_frozenxid; /* toast table's relfrozenxid, if any */
- uint32 toast_minmxid; /* toast table's relminmxid */
+ uint64 toast_frozenxid; /* toast table's relfrozenxid, if any */
+ uint64 toast_minmxid; /* toast table's relminmxid */
int ncheck; /* # of CHECK expressions */
Oid reltype; /* OID of table's composite type, if any */
Oid reloftype; /* underlying type for typed table */
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index 977491b875..24967f4e71 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -63,7 +63,6 @@ static ControlFileData ControlFile; /* pg_control values */
static XLogSegNo newXlogSegNo; /* new XLOG segment # */
static bool guessed = false; /* T if we had to guess at any values */
static const char *progname;
-static uint32 set_xid_epoch = (uint32) -1;
static TransactionId set_oldest_xid = 0;
static TransactionId set_xid = 0;
static TransactionId set_oldest_commit_ts_xid = 0;
@@ -95,7 +94,6 @@ main(int argc, char *argv[])
static struct option long_options[] = {
{"commit-timestamp-ids", required_argument, NULL, 'c'},
{"pgdata", required_argument, NULL, 'D'},
- {"epoch", required_argument, NULL, 'e'},
{"force", no_argument, NULL, 'f'},
{"next-wal-file", required_argument, NULL, 'l'},
{"multixact-ids", required_argument, NULL, 'm'},
@@ -137,7 +135,7 @@ main(int argc, char *argv[])
}
- while ((c = getopt_long(argc, argv, "c:D:e:fl:m:no:O:u:x:", long_options, NULL)) != -1)
+ while ((c = getopt_long(argc, argv, "c:D:fl:m:no:O:u:x:", long_options, NULL)) != -1)
{
switch (c)
{
@@ -153,24 +151,9 @@ main(int argc, char *argv[])
noupdate = true;
break;
- case 'e':
- errno = 0;
- set_xid_epoch = strtoul(optarg, &endptr, 0);
- if (endptr == optarg || *endptr != '\0' || errno != 0)
- {
- /*------
- translator: the second %s is a command line argument (-e, etc) */
- pg_log_error("invalid argument for option %s", "-e");
- pg_log_error_hint("Try \"%s --help\" for more information.", progname);
- exit(1);
- }
- if (set_xid_epoch == -1)
- pg_fatal("transaction ID epoch (-e) must not be -1");
- break;
-
case 'u':
errno = 0;
- set_oldest_xid = strtoul(optarg, &endptr, 0);
+ set_oldest_xid = strtou64(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-u");
@@ -184,7 +167,7 @@ main(int argc, char *argv[])
case 'x':
errno = 0;
- set_xid = strtoul(optarg, &endptr, 0);
+ set_xid = strtou64(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-x");
@@ -198,14 +181,14 @@ main(int argc, char *argv[])
case 'c':
errno = 0;
- set_oldest_commit_ts_xid = strtoul(optarg, &endptr, 0);
+ set_oldest_commit_ts_xid = strtou64(optarg, &endptr, 0);
if (endptr == optarg || *endptr != ',' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-c");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit(1);
}
- set_newest_commit_ts_xid = strtoul(endptr + 1, &endptr2, 0);
+ set_newest_commit_ts_xid = strtou64(endptr + 1, &endptr2, 0);
if (endptr2 == endptr + 1 || *endptr2 != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-c");
@@ -237,7 +220,7 @@ main(int argc, char *argv[])
case 'm':
errno = 0;
- set_mxid = strtoul(optarg, &endptr, 0);
+ set_mxid = strtou64(optarg, &endptr, 0);
if (endptr == optarg || *endptr != ',' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-m");
@@ -245,7 +228,7 @@ main(int argc, char *argv[])
exit(1);
}
- set_oldestmxid = strtoul(endptr + 1, &endptr2, 0);
+ set_oldestmxid = strtou64(endptr + 1, &endptr2, 0);
if (endptr2 == endptr + 1 || *endptr2 != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-m");
@@ -265,7 +248,7 @@ main(int argc, char *argv[])
case 'O':
errno = 0;
- set_mxoff = strtoul(optarg, &endptr, 0);
+ set_mxoff = strtou64(optarg, &endptr, 0);
if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid argument for option %s", "-O");
@@ -408,11 +391,6 @@ main(int argc, char *argv[])
* Adjust fields if required by switches. (Do this now so that printout,
* if any, includes these values.)
*/
- if (set_xid_epoch != -1)
- ControlFile.checkPointCopy.nextXid =
- FullTransactionIdFromEpochAndXid(set_xid_epoch,
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
-
if (set_oldest_xid != 0)
{
ControlFile.checkPointCopy.oldestXid = set_oldest_xid;
@@ -420,9 +398,7 @@ main(int argc, char *argv[])
}
if (set_xid != 0)
- ControlFile.checkPointCopy.nextXid =
- FullTransactionIdFromEpochAndXid(EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- set_xid);
+ ControlFile.checkPointCopy.nextXid = FullTransactionIdFromXid(set_xid);
if (set_oldest_commit_ts_xid != 0)
ControlFile.checkPointCopy.oldestCommitTsXid = set_oldest_commit_ts_xid;
@@ -655,7 +631,7 @@ GuessControlValues(void)
ControlFile.checkPointCopy.PrevTimeLineID = 1;
ControlFile.checkPointCopy.fullPageWrites = false;
ControlFile.checkPointCopy.nextXid =
- FullTransactionIdFromEpochAndXid(0, FirstNormalTransactionId);
+ FullTransactionIdFromXid(FirstNormalTransactionId);
ControlFile.checkPointCopy.nextOid = FirstGenbkiObjectId;
ControlFile.checkPointCopy.nextMulti = FirstMultiXactId;
ControlFile.checkPointCopy.nextMultiOffset = 0;
@@ -706,6 +682,8 @@ GuessControlValues(void)
*
* NB: this display should be just those fields that will not be
* reset by RewriteControlFile().
+ *
+ * Special macros help to make translatable strings.
*/
static void
PrintControlValues(bool guessed)
@@ -725,8 +703,7 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
printf(_("Latest checkpoint's full_page_writes: %s\n"),
ControlFile.checkPointCopy.fullPageWrites ? _("on") : _("off"));
- printf(_("Latest checkpoint's NextXID: %u:%llu\n"),
- EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
(unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
@@ -824,12 +801,6 @@ PrintNewControlValues(void)
ControlFile.checkPointCopy.oldestXidDB);
}
- if (set_xid_epoch != -1)
- {
- printf(_("NextXID epoch: %u\n"),
- EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- }
-
if (set_oldest_commit_ts_xid != 0)
{
printf(_("oldestCommitTsXid: %llu\n"),
@@ -1133,7 +1104,6 @@ usage(void)
" set oldest and newest transactions bearing\n"
" commit timestamp (zero means no change)\n"));
printf(_(" [-D, --pgdata=]DATADIR data directory\n"));
- printf(_(" -e, --epoch=XIDEPOCH set next transaction ID epoch\n"));
printf(_(" -f, --force force update to be done\n"));
printf(_(" -l, --next-wal-file=WALFILE set minimum starting location for new WAL\n"));
printf(_(" -m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID\n"));
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 7f8042f34a..1d47abd975 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -20,6 +20,7 @@ OBJS = \
parallel.o \
pg_upgrade.o \
relfilenumber.o \
+ segresize.o \
server.o \
tablespace.o \
util.o \
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index f1bc1e6886..3ff1951185 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -33,6 +33,8 @@ static void check_for_pg_role_prefix(ClusterInfo *cluster);
static void check_for_new_tablespace_dir(ClusterInfo *new_cluster);
static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
static char *get_canonical_locale_name(int category, const char *locale);
+static void check_for_32bit_xid_usage(ClusterInfo *cluster);
+static bool is_xid_wraparound(ClusterInfo *cluster);
/*
@@ -82,7 +84,7 @@ output_check_banner(bool live_check)
void
-check_and_dump_old_cluster(bool live_check)
+check_and_dump_old_cluster(bool live_check, bool *is_wraparound)
{
/* -- OLD -- */
@@ -168,6 +170,17 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 903)
old_9_3_check_for_line_data_type_usage(&old_cluster);
+ /* Prepare for 64bit xid */
+ if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER)
+ {
+ /* Check if 32-bit xid type is used in tables */
+ check_for_32bit_xid_usage(&old_cluster);
+ /* Check indexes to be upgraded */
+ invalidate_spgist_indexes(&old_cluster, true);
+ invalidate_gin_indexes(&old_cluster, true);
+ invalidate_external_indexes(&old_cluster, true);
+ }
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -175,6 +188,8 @@ check_and_dump_old_cluster(bool live_check)
if (!user_opts.check)
generate_old_dump();
+ *is_wraparound = is_xid_wraparound(&old_cluster);
+
if (!live_check)
stop_postmaster(false);
}
@@ -244,6 +259,17 @@ issue_warnings_and_set_wal_level(void)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 906)
old_9_6_invalidate_hash_indexes(&new_cluster, false);
+ /* Raindex for 64bit xid */
+ if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER)
+ {
+ /* Check if 32-bit xid type is used in tables */
+ check_for_32bit_xid_usage(&old_cluster);
+ /* Check indexes to be upgraded */
+ invalidate_spgist_indexes(&old_cluster, true);
+ invalidate_gin_indexes(&old_cluster, true);
+ invalidate_external_indexes(&old_cluster, true);
+ }
+
report_extension_updates(&new_cluster);
stop_postmaster(false);
@@ -1502,3 +1528,124 @@ get_canonical_locale_name(int category, const char *locale)
return res;
}
+
+/*
+ * check_for_32bit_xid_usage()
+ *
+ * Postgres Pro Enterprise changes xid storage format to 64-bit. Check if
+ * xid type is used in tables.
+ */
+static void
+check_for_32bit_xid_usage(ClusterInfo *cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ bool found = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for incompatible \"xid\" data type");
+
+ snprintf(output_path, sizeof(output_path), "tables_using_xid.txt");
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ PGresult *res;
+ bool db_used = false;
+ int ntups;
+ int rowno;
+ int i_nspname,
+ i_relname,
+ i_attname;
+ DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, active_db->db_name);
+
+ /*
+ * While several relkinds don't store any data, e.g. views, they can
+ * be used to define data types of other columns, so we check all
+ * relkinds.
+ */
+ res = executeQueryOrDie(conn,
+ "SELECT n.nspname, c.relname, a.attname "
+ "FROM pg_catalog.pg_class c, "
+ " pg_catalog.pg_namespace n, "
+ " pg_catalog.pg_attribute a "
+ "WHERE c.oid = a.attrelid AND "
+ " a.attnum >= 1 AND "
+ " a.atttypid = 'pg_catalog.xid'::pg_catalog.regtype AND "
+ " c.relnamespace = n.oid AND "
+ /* exclude possible orphaned temp tables */
+ " n.nspname !~ '^pg_temp_' AND "
+ " n.nspname NOT IN ('pg_catalog', 'information_schema')");
+
+ ntups = PQntuples(res);
+ i_nspname = PQfnumber(res, "nspname");
+ i_relname = PQfnumber(res, "relname");
+ i_attname = PQfnumber(res, "attname");
+ for (rowno = 0; rowno < ntups; rowno++)
+ {
+ found = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ fprintf(script, "Database: %s\n", active_db->db_name);
+ db_used = true;
+ }
+ fprintf(script, " %s.%s.%s\n",
+ PQgetvalue(res, rowno, i_nspname),
+ PQgetvalue(res, rowno, i_relname),
+ PQgetvalue(res, rowno, i_attname));
+ }
+
+ PQclear(res);
+
+ PQfinish(conn);
+ }
+
+ if (script)
+ fclose(script);
+
+ if (found)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains the \"xid\" data type in user tables.\n"
+ "The internal format of \"xid\" changed in Postgres Pro Enterprise so this cluster\n"
+ "cannot currently be upgraded. Note that even dropped attributes cause a problem.\n"
+ "You can remove the problem tables and restart the upgrade.\n"
+ "A list of the problem columns is in the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+}
+
+/*
+ * is_xid_wraparound()
+ *
+ * Return true if 32-xid cluster had wraparound.
+ */
+static bool
+is_xid_wraparound(ClusterInfo *cluster)
+{
+ PGconn *conn;
+ PGresult *res;
+ bool is_wraparound;
+
+ conn = connectToServer(cluster, "template1");
+
+ /*
+ * txid_current is extended with an "epoch" counter, so to check
+ * wraparound in old 32-xid cluster we cut epoch by casting to int4.
+ */
+ res = executeQueryOrDie(conn,
+ "SELECT 1 "
+ "FROM pg_catalog.pg_database, txid_current() tx "
+ "WHERE (tx %% 4294967295)::bigint <= datfrozenxid::text::bigint "
+ "LIMIT 1");
+ is_wraparound = PQntuples(res) ? true : false;
+ PQclear(res);
+ PQfinish(conn);
+
+ return is_wraparound;
+}
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index a5b4a77570..5021f0112b 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -284,6 +284,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
xid.value = strtou64(p, NULL, 10);
/*
+ * Try to read 32-bit XID format 'epoch:xid'.
+ *
* Delimiter changed from '/' to ':' in 9.6. We don't test for
* the catalog version of the change because the catalog version
* is pulled from pg_controldata too, and it isn't worth adding an
@@ -299,8 +301,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
if (p == NULL)
{
/* FullTransactionId representation */
- cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
- cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtxid = xid.value;
}
else
{
@@ -309,8 +310,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
/* Epoch:Xid representation */
p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
- cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtxid = (XidFromFullTransactionId(xid)) << 32 |
+ (TransactionId) str2uint(p);
}
got_xid = true;
@@ -334,7 +335,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtmulti = str2uint(p);
+ cluster->controldata.chkpnt_nxtmulti = strtou64(p, NULL, 10);
got_multi = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's oldestXID:")) != NULL)
@@ -345,7 +346,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_oldstxid = str2uint(p);
+ cluster->controldata.chkpnt_oldstxid = strtou64(p, NULL, 10);
got_oldestxid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's oldestMultiXid:")) != NULL)
@@ -356,7 +357,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_oldstMulti = str2uint(p);
+ cluster->controldata.chkpnt_oldstMulti = strtou64(p, NULL, 10);
got_oldestmulti = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextMultiOffset:")) != NULL)
@@ -367,7 +368,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtmxoff = str2uint(p);
+ cluster->controldata.chkpnt_nxtmxoff = strtou64(p, NULL, 10);
got_mxoff = true;
}
else if ((p = strstr(bufin, "First log segment after reset:")) != NULL)
diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c
index 079fbda838..dedd8ad2b7 100644
--- a/src/bin/pg_upgrade/file.c
+++ b/src/bin/pg_upgrade/file.c
@@ -174,7 +174,8 @@ linkFile(const char *src, const char *dst,
*/
void
rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName)
+ const char *schemaName, const char *relName,
+ bool update_version)
{
int src_fd;
int dst_fd;
@@ -290,6 +291,11 @@ rewriteVisibilityMap(const char *fromfile, const char *tofile,
if (old_lastpart && empty)
break;
+ if (update_version)
+ PageSetPageSizeAndVersion((Page) new_vmbuf.data,
+ PageGetPageSize((Page) new_vmbuf.data),
+ PG_PAGE_LAYOUT_VERSION);
+
/* Set new checksum for visibility map page, if enabled */
if (new_cluster.controldata.data_checksum_version != 0)
((PageHeader) new_vmbuf.data)->pd_checksum =
@@ -316,6 +322,97 @@ rewriteVisibilityMap(const char *fromfile, const char *tofile,
close(src_fd);
}
+/*
+ * updateSegmentVersion()
+ *
+ * Transform a segment file, copying from src to dst.
+ * schemaName/relName are relation's SQL name (used for error messages only).
+ *
+ * Read segment pages one by one and set version to PG_PAGE_LAYOUT_VERSION.
+ *
+ * Although FSM and MV formats does not change while switch to 64-bit XIDs, we
+ * must upgrade pages version in order to avoid lazy conversion on first read.
+ */
+void
+updateSegmentPagesVersion(const char *fromfile, const char *tofile,
+ const char *schemaName, const char *relName)
+{
+ int src_fd;
+ int dst_fd;
+ struct stat statbuf;
+ ssize_t src_filesize;
+ ssize_t totalBytesRead;
+ ssize_t bytesRead;
+ BlockNumber blkno;
+ PGAlignedBlock buf;
+
+ if ((src_fd = open(fromfile, O_RDONLY | PG_BINARY, 0)) < 0)
+ pg_fatal("error while copying relation \"%s.%s\": could not open file \"%s\": %s",
+ schemaName, relName, fromfile, strerror(errno));
+
+ if (fstat(src_fd, &statbuf) != 0)
+ pg_fatal("error while copying relation \"%s.%s\": could not stat file \"%s\": %s",
+ schemaName, relName, fromfile, strerror(errno));
+
+ if ((dst_fd = open(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
+ pg_file_create_mode)) < 0)
+ pg_fatal("error while copying relation \"%s.%s\": could not create file \"%s\": %s",
+ schemaName, relName, tofile, strerror(errno));
+
+ /* Save old file size */
+ src_filesize = statbuf.st_size;
+ totalBytesRead = 0;
+ blkno = 0;
+
+ while (totalBytesRead < src_filesize)
+ {
+ errno = 0;
+ if ((bytesRead = read(src_fd, buf.data, BLCKSZ)) != BLCKSZ)
+ {
+ if (bytesRead < 0)
+ pg_fatal("error while copying relation \"%s.%s\": could not read file \"%s\": %s",
+ schemaName, relName, fromfile, strerror(errno));
+ else
+ pg_fatal("error while copying relation \"%s.%s\": partial page found in file \"%s\"",
+ schemaName, relName, fromfile);
+ }
+
+ totalBytesRead += BLCKSZ;
+ PageSetPageSizeAndVersion((Page) buf.data,
+ PageGetPageSize((Page) buf.data),
+ PG_PAGE_LAYOUT_VERSION);
+
+ /* Set new checksum for page, if enabled */
+ if (new_cluster.controldata.data_checksum_version != 0)
+ ((PageHeader) buf.data)->pd_checksum =
+ pg_checksum_page(buf.data, blkno);
+
+ /*
+ * We dealing here only with FSM and VM pages.
+ */
+ if (((PageHeader) buf.data)->pd_lower != SizeOfPageHeaderData ||
+ ((PageHeader) buf.data)->pd_upper != BLCKSZ)
+ pg_fatal("error while copying relation \"%s.%s\": unknown page format found in file \"%s\"",
+ schemaName, relName, fromfile);
+
+ errno = 0;
+ if (write(dst_fd, buf.data, BLCKSZ) != BLCKSZ)
+ {
+ /* if write didn't set errno, assume problem is no disk space */
+ if (errno == 0)
+ errno = ENOSPC;
+ pg_fatal("error while copying relation \"%s.%s\": could not write file \"%s\": %s",
+ schemaName, relName, tofile, strerror(errno));
+ }
+
+ blkno++;
+ }
+
+ /* Clean up */
+ close(dst_fd);
+ close(src_fd);
+}
+
void
check_file_clone(void)
{
diff --git a/src/bin/pg_upgrade/meson.build b/src/bin/pg_upgrade/meson.build
index 02f030e0cc..8822377e07 100644
--- a/src/bin/pg_upgrade/meson.build
+++ b/src/bin/pg_upgrade/meson.build
@@ -10,6 +10,7 @@ pg_upgrade_sources = files(
'parallel.c',
'pg_upgrade.c',
'relfilenumber.c',
+ 'segresize.c',
'server.c',
'tablespace.c',
'util.c',
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index a8b1e0ed84..326dc9c8d5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -44,6 +44,9 @@
#include <langinfo.h>
#endif
+#include "access/multixact.h"
+#include "access/transam.h"
+#include "access/xlog_internal.h"
#include "catalog/pg_class_d.h"
#include "common/file_perm.h"
#include "common/logging.h"
@@ -53,7 +56,7 @@
static void prepare_new_cluster(void);
static void prepare_new_globals(void);
-static void create_new_objects(void);
+static void create_new_objects(bool is_wraparound);
static void copy_xact_xlog_xid(void);
static void set_frozenxids(bool minmxid_only);
static void make_outputdirs(char *pgdata);
@@ -80,6 +83,7 @@ main(int argc, char **argv)
{
char *deletion_script_file_name = NULL;
bool live_check = false;
+ bool is_wraparound = false;
/*
* pg_upgrade doesn't currently use common/logging.c, but initialize it
@@ -125,7 +129,7 @@ main(int argc, char **argv)
check_cluster_compatibility(live_check);
- check_and_dump_old_cluster(live_check);
+ check_and_dump_old_cluster(live_check, &is_wraparound);
/* -- NEW -- */
@@ -156,7 +160,7 @@ main(int argc, char **argv)
prepare_new_globals();
- create_new_objects();
+ create_new_objects(is_wraparound);
stop_postmaster(false);
@@ -365,7 +369,6 @@ setup(char *argv0, bool *live_check)
}
}
-
static void
prepare_new_cluster(void)
{
@@ -419,7 +422,7 @@ prepare_new_globals(void)
static void
-create_new_objects(void)
+create_new_objects(bool is_wraparound)
{
int dbnum;
@@ -511,11 +514,23 @@ create_new_objects(void)
check_ok();
/*
- * We don't have minmxids for databases or relations in pre-9.3 clusters,
- * so set those after we have restored the schema.
+ * Refix datfrozenxid and datminmxid
*/
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 902)
set_frozenxids(true);
+ else if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER &&
+ new_cluster.controldata.cat_ver >= XID_FORMATCHANGE_CAT_VER)
+ {
+ /*
+ * During upgrade from 32-bit to 64-bit xids save relfrozenxids if
+ * there was no wraparound in old cluster. Otherwise, reset them to
+ * FirstNormalTransactionId value.
+ */
+ if (is_wraparound)
+ set_frozenxids(false);
+ else
+ set_frozenxids(true);
+ }
/* update new_cluster info now that we have objects in the databases */
get_db_and_rel_infos(&new_cluster);
@@ -569,14 +584,37 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
static void
copy_xact_xlog_xid(void)
{
- /*
- * Copy old commit logs to new data dir. pg_clog has been renamed to
- * pg_xact in post-10 clusters.
- */
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ TransactionId next_xid;
+
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+
+ /* Set next xid to 2^32 if we're upgrading from 32 bit postgres */
+ if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER &&
+ new_cluster.controldata.cat_ver >= XID_FORMATCHANGE_CAT_VER)
+ next_xid = ((TransactionId) 1 << 32);
+ else
+ next_xid = old_cluster.controldata.chkpnt_nxtxid;
+
+ if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER &&
+ new_cluster.controldata.cat_ver >= XID_FORMATCHANGE_CAT_VER)
+ {
+ /* Convert commit logs and copy to the new data dir */
+ prep_status("Transforming commit log segments");
+ convert_xact(psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster)),
+ psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster)));
+ check_ok();
+ }
+ else
+ {
+ /*
+ * Copy old commit logs to new data dir. pg_clog has been renamed to
+ * pg_xact in post-10 clusters.
+ */
+ prep_status("Copying commit log segments");
+ copy_subdir_files(GetClogDirName(old_cluster), GetClogDirName(new_cluster));
+ check_ok();
+ }
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
@@ -590,19 +628,20 @@ copy_xact_xlog_xid(void)
prep_status("Setting next transaction ID and epoch for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -x %llu \"%s\"",
- new_cluster.bindir,
- (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ new_cluster.bindir, (unsigned long long) next_xid,
new_cluster.pgdata);
+#ifdef NOT_USED
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
new_cluster.bindir, old_cluster.controldata.chkpnt_nxtepoch,
new_cluster.pgdata);
+#endif
/* must reset commit timestamp limits also */
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -c %llu,%llu \"%s\"",
new_cluster.bindir,
- (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
- (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) next_xid,
+ (unsigned long long) next_xid,
new_cluster.pgdata);
check_ok();
@@ -615,8 +654,48 @@ copy_xact_xlog_xid(void)
if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER &&
new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
{
- copy_subdir_files("pg_multixact/offsets", "pg_multixact/offsets");
- copy_subdir_files("pg_multixact/members", "pg_multixact/members");
+ uint64 oldest_mxid = old_cluster.controldata.chkpnt_oldstMulti;
+ uint64 next_mxid = old_cluster.controldata.chkpnt_nxtmulti;
+ uint64 next_mxoff = old_cluster.controldata.chkpnt_nxtmxoff;
+
+ if (old_cluster.controldata.cat_ver >= XID_FORMATCHANGE_CAT_VER)
+ {
+ copy_subdir_files("pg_multixact/offsets", "pg_multixact/offsets");
+ copy_subdir_files("pg_multixact/members", "pg_multixact/members");
+ }
+ else
+ {
+ MultiXactOffset oldest_mxoff;
+
+ remove_new_subdir("pg_multixact/offsets", false);
+ oldest_mxoff = convert_multixact_offsets("pg_multixact/offsets", "pg_multixact/offsets");
+
+ remove_new_subdir("pg_multixact/members", false);
+ convert_multixact_members("pg_multixact/members", "pg_multixact/members", oldest_mxoff);
+
+ /*
+ * Handle wraparound if we're upgrading from 32 bit postgres.
+ * Invalid 0 mxids/offsets are skipped, so 1 becomes 2^32.
+ */
+ if (oldest_mxoff)
+ {
+ if (next_mxid < oldest_mxid)
+ next_mxid += ((MultiXactId) 1 << 32) - FirstMultiXactId;
+
+ if (next_mxoff < oldest_mxoff)
+ next_mxoff += ((MultiXactOffset) 1 << 32) - 1;
+
+ /* Offsets and members were rewritten, oldest_mxoff = 1 */
+ next_mxoff -= oldest_mxoff - 1;
+ oldest_mxoff = 1;
+
+ /*
+ * Save converted next_mxid for possible usage in
+ * set_frozenxids()
+ */
+ old_cluster.controldata.chkpnt_nxtmulti = next_mxid;
+ }
+ }
prep_status("Setting next multixact ID and offset for new cluster");
@@ -627,9 +706,9 @@ copy_xact_xlog_xid(void)
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -O %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
- (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
- (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) next_mxoff,
+ (unsigned long long) next_mxid,
+ (unsigned long long) oldest_mxid,
new_cluster.pgdata);
check_ok();
}
@@ -703,6 +782,8 @@ set_frozenxids(bool minmxid_only)
int ntups;
int i_datname;
int i_datallowconn;
+ TransactionId frozen_xid;
+ MultiXactId minmxid;
if (!minmxid_only)
prep_status("Setting frozenxid and minmxid counters in new cluster");
@@ -711,18 +792,26 @@ set_frozenxids(bool minmxid_only)
conn_template1 = connectToServer(&new_cluster, "template1");
+ if (old_cluster.controldata.cat_ver < XID_FORMATCHANGE_CAT_VER &&
+ new_cluster.controldata.cat_ver >= XID_FORMATCHANGE_CAT_VER)
+ frozen_xid = FirstNormalTransactionId;
+ else
+ frozen_xid = old_cluster.controldata.chkpnt_nxtxid;
+
+ minmxid = old_cluster.controldata.chkpnt_nxtmulti;
+
if (!minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
"SET datfrozenxid = '%llu'",
- (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) frozen_xid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
"SET datminmxid = '%llu'",
- (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) minmxid));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -762,7 +851,7 @@ set_frozenxids(bool minmxid_only)
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) frozen_xid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
@@ -773,7 +862,7 @@ set_frozenxids(bool minmxid_only)
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) minmxid));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 31589b0fdc..538994d5e5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -115,6 +115,11 @@ extern char *output_files[];
*/
#define MULTIXACT_FORMATCHANGE_CAT_VER 201301231
+/*
+ * xid format changed from 32-bit to 64-bit.
+ */
+#define XID_FORMATCHANGE_CAT_VER 999999999
+
/*
* large object chunk size added to pg_controldata,
* commit 5f93c37805e7485488480916b4585e098d3cc883
@@ -199,13 +204,13 @@ typedef struct
uint32 ctrl_ver;
uint32 cat_ver;
char nextxlogfile[25];
- uint32 chkpnt_nxtxid;
- uint32 chkpnt_nxtepoch;
+ uint64 chkpnt_nxtxid;
+ uint32 chkpnt_nxtepoch; /* for 32bit xids only */
uint32 chkpnt_nxtoid;
- uint32 chkpnt_nxtmulti;
- uint32 chkpnt_nxtmxoff;
- uint32 chkpnt_oldstMulti;
- uint32 chkpnt_oldstxid;
+ uint64 chkpnt_nxtmulti;
+ uint64 chkpnt_nxtmxoff;
+ uint64 chkpnt_oldstMulti;
+ uint64 chkpnt_oldstxid;
uint32 align;
uint32 blocksz;
uint32 largesz;
@@ -333,7 +338,7 @@ extern OSInfo os_info;
/* check.c */
void output_check_banner(bool live_check);
-void check_and_dump_old_cluster(bool live_check);
+void check_and_dump_old_cluster(bool live_check, bool *is_wraparound);
void check_new_cluster(void);
void report_clusters_compatible(void);
void issue_warnings_and_set_wal_level(void);
@@ -374,7 +379,10 @@ void copyFile(const char *src, const char *dst,
void linkFile(const char *src, const char *dst,
const char *schemaName, const char *relName);
void rewriteVisibilityMap(const char *fromfile, const char *tofile,
- const char *schemaName, const char *relName);
+ const char *schemaName, const char *relName,
+ bool update_version);
+void updateSegmentPagesVersion(const char *fromfile, const char *tofile,
+ const char *schemaName, const char *relName);
void check_file_clone(void);
void check_hard_link(void);
@@ -456,6 +464,10 @@ void old_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
void old_11_check_for_sql_identifier_data_type_usage(ClusterInfo *cluster);
void report_extension_updates(ClusterInfo *cluster);
+void invalidate_spgist_indexes(ClusterInfo *cluster, bool check_mode);
+void invalidate_gin_indexes(ClusterInfo *cluster, bool check_mode);
+void invalidate_external_indexes(ClusterInfo *cluster, bool check_mode);
+
/* parallel.c */
void parallel_exec_prog(const char *log_file, const char *opt_log_file,
const char *fmt,...) pg_attribute_printf(3, 4);
@@ -463,3 +475,9 @@ void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr
char *old_pgdata, char *new_pgdata,
char *old_tablespace);
bool reap_child(bool wait_for_child);
+
+/* segresize.c */
+void convert_xact(const char *olddir, const char *newdir);
+MultiXactOffset convert_multixact_offsets(const char *olddir, const char *newdir);
+void convert_multixact_members(const char *olddir, const char *newdir,
+ MultiXactOffset oldest_mxoff);
diff --git a/src/bin/pg_upgrade/relfilenumber.c b/src/bin/pg_upgrade/relfilenumber.c
index c3f3d6bc0a..678e74051e 100644
--- a/src/bin/pg_upgrade/relfilenumber.c
+++ b/src/bin/pg_upgrade/relfilenumber.c
@@ -16,7 +16,8 @@
#include "pg_upgrade.h"
static void transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace);
-static void transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit);
+static void transfer_relfile(FileNameMap *map, const char *type_suffix,
+ bool vm_must_add_frozenbit, bool update_version);
/*
@@ -136,6 +137,7 @@ transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace)
{
int mapnum;
bool vm_must_add_frozenbit = false;
+ bool update_version = false;
/*
* Do we need to rewrite visibilitymap?
@@ -144,19 +146,28 @@ transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace)
new_cluster.controldata.cat_ver >= VISIBILITY_MAP_FROZEN_BIT_CAT_VER)
vm_must_add_frozenbit = true;
+ /*
+ * Need to update FSM and VM pages version to avoid lazy conversion.
+ */
+ if (old_cluster.controldata.cat_ver < new_cluster.controldata.cat_ver)
+ update_version = true;
+
for (mapnum = 0; mapnum < size; mapnum++)
{
if (old_tablespace == NULL ||
strcmp(maps[mapnum].old_tablespace, old_tablespace) == 0)
{
/* transfer primary file */
- transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "", vm_must_add_frozenbit,
+ update_version);
/*
* Copy/link any fsm and vm files, if they exist
*/
- transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit);
- transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit);
+ transfer_relfile(&maps[mapnum], "_fsm", vm_must_add_frozenbit,
+ update_version);
+ transfer_relfile(&maps[mapnum], "_vm", vm_must_add_frozenbit,
+ update_version);
}
}
}
@@ -170,7 +181,8 @@ transfer_single_new_db(FileNameMap *maps, int size, char *old_tablespace)
* mode.
*/
static void
-transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_frozenbit)
+transfer_relfile(FileNameMap *map, const char *type_suffix,
+ bool vm_must_add_frozenbit, bool update_version)
{
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
@@ -235,7 +247,17 @@ transfer_relfile(FileNameMap *map, const char *type_suffix, bool vm_must_add_fro
/* Need to rewrite visibility map format */
pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
old_file, new_file);
- rewriteVisibilityMap(old_file, new_file, map->nspname, map->relname);
+ rewriteVisibilityMap(old_file, new_file, map->nspname,
+ map->relname, update_version);
+ }
+ else if ((update_version && strcmp(type_suffix, "_vm") == 0) ||
+ (update_version && strcmp(type_suffix, "_fsm") == 0))
+ {
+ /* Need to update pages version */
+ pg_log(PG_VERBOSE, "rewriting \"%s\" to \"%s\"",
+ old_file, new_file);
+ updateSegmentPagesVersion(old_file, new_file, map->nspname,
+ map->relname);
}
else
switch (user_opts.transfer_mode)
diff --git a/src/bin/pg_upgrade/segresize.c b/src/bin/pg_upgrade/segresize.c
new file mode 100644
index 0000000000..99e2c5ecde
--- /dev/null
+++ b/src/bin/pg_upgrade/segresize.c
@@ -0,0 +1,586 @@
+/*-------------------------------------------------------------------------
+ *
+ * segresize.c
+ * SLRU segment resize utility from 32bit to 64bit xid format
+ *
+ * Copyright (c) 2015-2022, Postgres Professional
+ *
+ * IDENTIFICATION
+ * src/bin/pg_upgrade/segresize.c
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres_fe.h"
+
+#include "pg_upgrade.h"
+#include "access/multixact.h"
+#include "access/transam.h"
+
+#define SLRU_PAGES_PER_SEGMENT_OLD 32
+#define SLRU_PAGES_PER_SEGMENT 32 /* Should be equal to value from slru.h */
+
+#define CLOG_BITS_PER_XACT 2
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+
+typedef uint32 MultiXactId32;
+typedef uint32 MultiXactOffset32;
+typedef uint32 TransactionId32;
+
+#define MaxTransactionId32 ((TransactionId32) 0xFFFFFFFF)
+#define MaxMultiXactId32 ((MultiXactId32) 0xFFFFFFFF)
+#define MaxMultiXactOffset32 ((MultiXactOffset32) 0xFFFFFFFF)
+
+#define MULTIXACT_OFFSETS_PER_PAGE_OLD (BLCKSZ / sizeof(MultiXactOffset32))
+#define MULTIXACT_OFFSETS_PER_PAGE (BLCKSZ / sizeof(MultiXactOffset))
+
+#define MXACT_MEMBER_FLAGS_PER_BYTE 1
+
+/* 64xid */
+#define MULTIXACT_FLAGBYTES_PER_GROUP 8
+#define MULTIXACT_MEMBERS_PER_MEMBERGROUP \
+ (MULTIXACT_FLAGBYTES_PER_GROUP * MXACT_MEMBER_FLAGS_PER_BYTE)
+/* size in bytes of a complete group */
+#define MULTIXACT_MEMBERGROUP_SIZE \
+ (sizeof(TransactionId) * MULTIXACT_MEMBERS_PER_MEMBERGROUP + MULTIXACT_FLAGBYTES_PER_GROUP)
+#define MULTIXACT_MEMBERGROUPS_PER_PAGE (BLCKSZ / MULTIXACT_MEMBERGROUP_SIZE)
+
+/* 32xid */
+#define MULTIXACT_FLAGBYTES_PER_GROUP_OLD 4
+#define MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD \
+ (MULTIXACT_FLAGBYTES_PER_GROUP_OLD * MXACT_MEMBER_FLAGS_PER_BYTE)
+/* size in bytes of a complete group */
+#define MULTIXACT_MEMBERGROUP_SIZE_OLD \
+ (sizeof(TransactionId32) * MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD + MULTIXACT_FLAGBYTES_PER_GROUP_OLD)
+#define MULTIXACT_MEMBERGROUPS_PER_PAGE_OLD (BLCKSZ / MULTIXACT_MEMBERGROUP_SIZE_OLD)
+#define MULTIXACT_MEMBERS_PER_PAGE_OLD \
+ (MULTIXACT_MEMBERGROUPS_PER_PAGE_OLD * MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD)
+
+typedef struct SLRUSegmentState
+{
+ const char *dir;
+ FILE *file;
+ int64 segno;
+ int64 pageno;
+ bool is_empty_segment;
+} SLRUSegmentState;
+
+static char *
+slru_filename_old(const char *path, int64 segno)
+{
+ Assert(segno <= PG_INT32_MAX);
+ return psprintf("%s/%04X", path, (int) segno);
+}
+
+static char *
+slru_filename_new(const char *path, int64 segno)
+{
+ return psprintf("%s/%012llX", path, (long long) segno);
+}
+
+static inline FILE *
+open_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno),
+ char *mode, char *fatal_msg)
+{
+ char *filename = filename_fn(state->dir, state->segno);
+ FILE *fd = fopen(filename, mode);
+
+ if (!fd)
+ pg_fatal(fatal_msg, filename);
+
+ pfree(filename);
+
+ return fd;
+}
+
+static void
+close_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno))
+{
+ if (state->file != NULL)
+ {
+ if (fclose(state->file) != 0)
+ pg_fatal("could not close file \"%s\": %m",
+ filename_fn(state->dir, state->segno));
+ state->file = NULL;
+ }
+}
+
+static inline int
+read_file(SLRUSegmentState *state, void *buf)
+{
+ size_t n = fread(buf, sizeof(char), BLCKSZ, state->file);
+
+ if (n != 0)
+ return n;
+
+ if (ferror(state->file))
+ pg_fatal("could not read file \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ if (!feof(state->file))
+ pg_fatal("unknown file read state \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ close_file(state, slru_filename_old);
+
+ return 0;
+}
+
+static int
+read_old_segment_page(SLRUSegmentState *state, void *buf, bool *is_empty)
+{
+ int n;
+
+ /* Open next segment file, if needed */
+ if (!state->file)
+ {
+ state->file = open_file(state, slru_filename_old, "rb",
+ "could not open source file \"%s\": %m");
+
+ /* Set position to the needed page */
+ if (fseek(state->file, state->pageno * BLCKSZ, SEEK_SET))
+ close_file(state, slru_filename_old);
+
+ /*
+ * Skip segment conversion if segment file doesn't exist.
+ * First segment file should exist in any case.
+ */
+ if (state->segno != 0)
+ state->is_empty_segment = true;
+ }
+
+ if (state->file)
+ {
+ /* Segment file does exist, read page from it */
+ state->is_empty_segment = false;
+
+ /* Try to read BLCKSZ bytes */
+ n = read_file(state, buf);
+ *is_empty = (n == 0);
+
+ /* Zeroing buf tail if needed */
+ if (n)
+ memset((char *) buf + n, 0, BLCKSZ - n);
+ }
+ else
+ {
+ n = state->is_empty_segment ?
+ BLCKSZ : /* Skip empty block at the end of segment */
+ 0; /* We reached the last segment */
+ *is_empty = true;
+
+ if (n)
+ memset((char *) buf, 0, BLCKSZ);
+ }
+
+ state->pageno++;
+
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT_OLD)
+ {
+ /* Start new segment */
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_old);
+ }
+
+ return n;
+}
+
+static void
+write_new_segment_page(SLRUSegmentState *state, void *buf, bool is_empty)
+{
+ /*
+ * Create a new segment file if we still didn't. Creation is postponed
+ * until the first non-empty page is found. This helps not to create
+ * completely empty segments.
+ */
+ if (!state->file && !is_empty)
+ {
+ state->file = open_file(state, slru_filename_new, "wb",
+ "could not open target file \"%s\": %m");
+
+ /* Write zeroes to the previously skipped prefix */
+ if (state->pageno > 0)
+ {
+ char zerobuf[BLCKSZ] = {0};
+
+ for (int64 i = 0; i < state->pageno; i++)
+ {
+ if (fwrite(zerobuf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+ }
+
+ }
+
+ /* Write page to the new segment (if it was created) */
+ if (state->file)
+ {
+ if (fwrite(buf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+
+ state->pageno++;
+
+ /*
+ * Did we reach the maximum page number? Then close segment file and
+ * create a new one on the next iteration
+ */
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_new);
+ }
+}
+
+/*
+ * Convert pg_xact segments.
+ */
+void
+convert_xact(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg = {0};
+ SLRUSegmentState newseg = {0};
+ TransactionId oldest_xid = old_cluster.controldata.chkpnt_oldstxid;
+ TransactionId next_xid = old_cluster.controldata.chkpnt_nxtxid;
+ TransactionId xid;
+ int64 pageno;
+ char buf[BLCKSZ] = {0};
+
+ oldseg.dir = old_subdir;
+ newseg.dir = new_subdir;
+
+ pageno = oldest_xid / CLOG_XACTS_PER_PAGE;
+
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT_OLD;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT_OLD;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ if (next_xid < oldest_xid)
+ next_xid += (TransactionId) 1 << 32; /* wraparound */
+
+ /* Copy xid flags reading only needed segment pages */
+ for (xid = oldest_xid & ~(CLOG_XACTS_PER_PAGE - 1);
+ xid <= ((next_xid - 1) & ~(CLOG_XACTS_PER_PAGE - 1));
+ xid += CLOG_XACTS_PER_PAGE)
+ {
+ bool is_empty;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxTransactionId32 / CLOG_XACTS_PER_PAGE / SLRU_PAGES_PER_SEGMENT_OLD)
+ {
+ pageno = (MaxTransactionId32 + 1) / CLOG_XACTS_PER_PAGE;
+
+ Assert(oldseg.segno == pageno / SLRU_PAGES_PER_SEGMENT_OLD);
+ Assert(!oldseg.pageno);
+ Assert(!oldseg.file);
+ oldseg.segno = 0;
+
+ Assert(newseg.segno == pageno / SLRU_PAGES_PER_SEGMENT);
+ Assert(!newseg.pageno);
+ Assert(!newseg.file);
+ newseg.segno = 0;
+ }
+
+ read_old_segment_page(&oldseg, buf, &is_empty);
+ write_new_segment_page(&newseg, buf, is_empty);
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+}
+
+static inline SLRUSegmentState
+create_slru_segment_state(MultiXactId mxid,
+ int offsets_per_page,
+ int pages_per_segment,
+ char *dir)
+{
+ SLRUSegmentState seg = {0};
+ int64 n;
+
+ n = mxid / offsets_per_page;
+ seg.pageno = n % pages_per_segment;
+ seg.segno = n / pages_per_segment;
+ seg.dir = dir;
+
+ return seg;
+}
+
+/*
+ * Convert pg_multixact/offsets segments and return oldest mxid offset.
+ */
+MultiXactOffset
+convert_multixact_offsets(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg,
+ newseg;
+ MultiXactOffset32 oldbuf[MULTIXACT_OFFSETS_PER_PAGE_OLD] = {0};
+ MultiXactOffset newbuf[MULTIXACT_OFFSETS_PER_PAGE] = {0};
+ MultiXactOffset32 oldest_mxoff = 0;
+ MultiXactId oldest_mxid,
+ next_mxid,
+ mxid;
+ uint64 old_entry,
+ new_entry;
+ bool oldest_mxoff_known = false;
+
+ StaticAssertStmt((sizeof(oldbuf) == BLCKSZ && sizeof(newbuf) == BLCKSZ),
+ "buf should be BLCKSZ");
+
+ oldest_mxid = old_cluster.controldata.chkpnt_oldstMulti;
+
+ oldseg = create_slru_segment_state(oldest_mxid,
+ MULTIXACT_OFFSETS_PER_PAGE_OLD,
+ SLRU_PAGES_PER_SEGMENT_OLD,
+ psprintf("%s/%s", old_cluster.pgdata,
+ old_subdir));
+
+ newseg = create_slru_segment_state(oldest_mxid,
+ MULTIXACT_OFFSETS_PER_PAGE,
+ SLRU_PAGES_PER_SEGMENT,
+ psprintf("%s/%s", new_cluster.pgdata,
+ new_subdir));
+
+ old_entry = oldest_mxid % MULTIXACT_OFFSETS_PER_PAGE_OLD;
+ new_entry = oldest_mxid % MULTIXACT_OFFSETS_PER_PAGE;
+
+ next_mxid = old_cluster.controldata.chkpnt_nxtmulti;
+ if (next_mxid < oldest_mxid)
+ next_mxid += (MultiXactId) 1 << 32; /* wraparound */
+
+ prep_status("Converting old %s to new format", old_subdir);
+
+ /* Copy mxid offsets reading only needed segment pages */
+ for (mxid = oldest_mxid; mxid < next_mxid; old_entry = 0)
+ {
+ int oldlen;
+ bool is_empty;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxMultiXactId32 / MULTIXACT_OFFSETS_PER_PAGE_OLD / SLRU_PAGES_PER_SEGMENT_OLD) /* 0xFFFF */
+ oldseg.segno = 0;
+
+ oldlen = read_old_segment_page(&oldseg, oldbuf, &is_empty);
+
+ if (oldlen == 0 || is_empty)
+ pg_fatal("cannot read page %lld from segment: %s\n",
+ (long long) oldseg.pageno,
+ slru_filename_old(oldseg.dir, oldseg.segno));
+
+ /* Save oldest mxid offset */
+ if (!oldest_mxoff_known)
+ {
+ oldest_mxoff = oldbuf[old_entry];
+ oldest_mxoff_known = true;
+ }
+
+ /* Skip wrapped-around invalid MultiXactIds */
+ if (mxid == (MultiXactId) 1 << 32)
+ {
+ Assert(oldseg.segno == 0);
+ Assert(oldseg.pageno == 1);
+ Assert(old_entry == 0);
+ mxid += FirstMultiXactId;
+ old_entry = FirstMultiXactId;
+ }
+
+ /* Copy entries to the new page */
+ for (; mxid < next_mxid && old_entry < MULTIXACT_OFFSETS_PER_PAGE_OLD;
+ mxid++, old_entry++)
+ {
+ MultiXactOffset mxoff = oldbuf[old_entry];
+
+ /* Handle possible offset wraparound (1 becomes 2^32) */
+ if (mxoff < oldest_mxoff)
+ mxoff += ((MultiXactOffset) 1 << 32) - 1;
+
+ /* Subtract oldest_mxoff, so new offsets will start from 1 */
+ newbuf[new_entry++] = mxoff - oldest_mxoff + 1;
+
+ if (new_entry >= MULTIXACT_OFFSETS_PER_PAGE)
+ {
+ /* Write new page */
+ write_new_segment_page(&newseg, newbuf, false);
+ new_entry = 0;
+ }
+ }
+ }
+
+ /* Write the last incomplete page */
+ if (new_entry > 0 || oldest_mxid == next_mxid)
+ {
+ memset(&newbuf[new_entry], 0,
+ sizeof(newbuf[0]) * (MULTIXACT_OFFSETS_PER_PAGE - new_entry));
+ write_new_segment_page(&newseg, newbuf, false);
+ }
+
+ /* Use next_mxoff as oldest_mxoff, if oldest_mxid == next_mxid */
+ if (!oldest_mxoff_known)
+ {
+ Assert(oldest_mxid == next_mxid);
+ oldest_mxoff = (MultiXactOffset) old_cluster.controldata.chkpnt_nxtmxoff;
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+
+ pfree((char *) oldseg.dir);
+ pfree((char *) newseg.dir);
+
+ check_ok();
+
+ return oldest_mxoff;
+}
+
+/*
+ * Convert pg_multixact/members segments, offsets will start from 1.
+ */
+void
+convert_multixact_members(const char *old_subdir, const char *new_subdir,
+ MultiXactOffset oldest_mxoff)
+{
+ MultiXactOffset next_mxoff,
+ mxoff;
+ SLRUSegmentState oldseg,
+ newseg;
+ char oldbuf[BLCKSZ] = {0},
+ newbuf[BLCKSZ] = {0};
+ int newgroup,
+ newmember;
+ char *newflag = newbuf;
+ TransactionId *newxid;
+ int oldidx,
+ newidx;
+
+ prep_status("Converting old %s to new format", old_subdir);
+
+ next_mxoff = (MultiXactOffset) old_cluster.controldata.chkpnt_nxtmxoff;
+ if (next_mxoff < oldest_mxoff)
+ next_mxoff += (MultiXactOffset) 1 << 32;
+
+ newxid = (TransactionId *) (newflag + MXACT_MEMBER_FLAGS_PER_BYTE * MULTIXACT_MEMBERS_PER_MEMBERGROUP);
+
+ /* Initialize old starting position */
+ oldidx = oldest_mxoff % MULTIXACT_MEMBERS_PER_PAGE_OLD;
+ oldseg = create_slru_segment_state(oldest_mxoff,
+ MULTIXACT_MEMBERS_PER_PAGE_OLD,
+ SLRU_PAGES_PER_SEGMENT_OLD,
+ psprintf("%s/%s", old_cluster.pgdata,
+ old_subdir));
+
+ /* Initialize empty new segment */
+ newseg = create_slru_segment_state(0, 1, 1,
+ psprintf("%s/%s", new_cluster.pgdata,
+ new_subdir));
+
+ /* Initialize new starting position (skip invalid zero offset) */
+ newgroup = 0;
+ newidx = 1;
+ newmember = 1;
+ newflag++;
+ newxid++;
+
+ /* Iterate through the original directory */
+ for (mxoff = oldest_mxoff; mxoff < next_mxoff; oldidx = 0)
+ {
+ bool old_is_empty;
+ int oldlen;
+ int ngroups;
+ int oldgroup;
+ int oldmember;
+
+ oldlen = read_old_segment_page(&oldseg, oldbuf, &old_is_empty);
+
+ if (oldlen == 0 || old_is_empty)
+ pg_fatal("cannot read page %lld from segment: %s\n",
+ (long long) oldseg.pageno,
+ slru_filename_old(oldseg.dir, oldseg.segno));
+
+ ngroups = oldlen / MULTIXACT_MEMBERGROUP_SIZE_OLD;
+
+ /* Iterate through old member groups */
+ for (oldgroup = oldidx / MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD,
+ oldmember = oldidx % MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD;
+ oldgroup < ngroups && mxoff < next_mxoff;
+ oldgroup++, oldmember = 0)
+ {
+ char *oldflag = (char *) oldbuf + oldgroup * MULTIXACT_MEMBERGROUP_SIZE_OLD;
+ TransactionId32 *oldxid = (TransactionId32 *) (oldflag + MULTIXACT_FLAGBYTES_PER_GROUP_OLD);
+
+ oldxid += oldmember;
+ oldflag += oldmember;
+
+ /* Iterate through old members */
+ for (int i = 0;
+ i < MULTIXACT_MEMBERS_PER_MEMBERGROUP_OLD && mxoff < next_mxoff;
+ i++)
+ {
+ /* Copy member's xid and flags to the new page */
+ *newflag++ = *oldflag++;
+ *newxid++ = (TransactionId) * oldxid++;
+
+ newidx++;
+ oldidx++;
+ mxoff++;
+
+ if (++newmember >= MULTIXACT_MEMBERS_PER_MEMBERGROUP)
+ {
+ /* Start next member group */
+ newmember = 0;
+
+ if (++newgroup >= MULTIXACT_MEMBERGROUPS_PER_PAGE)
+ {
+ /* Write current page and start new */
+ newgroup = 0;
+ newidx = 0;
+ write_new_segment_page(&newseg, newbuf, false);
+ memset(newbuf, 0, BLCKSZ);
+ }
+
+ newflag = (char *) newbuf + newgroup * MULTIXACT_MEMBERGROUP_SIZE;
+ newxid = (TransactionId *) (newflag + MXACT_MEMBER_FLAGS_PER_BYTE * MULTIXACT_MEMBERS_PER_MEMBERGROUP);
+ }
+
+ /* Handle offset wraparound */
+ if (mxoff > MaxMultiXactOffset32)
+ {
+ Assert(mxoff == (MultiXactOffset) 1 << 32);
+ Assert(oldseg.segno == MaxMultiXactOffset32 / MULTIXACT_MEMBERS_PER_PAGE_OLD / SLRU_PAGES_PER_SEGMENT_OLD);
+ Assert(oldseg.pageno == MaxMultiXactOffset32 / MULTIXACT_MEMBERS_PER_PAGE_OLD % SLRU_PAGES_PER_SEGMENT_OLD);
+ Assert(oldmember == MaxMultiXactOffset32 % MULTIXACT_MEMBERS_PER_PAGE_OLD);
+
+ /* Switch to segment 0000 */
+ close_file(&oldseg, slru_filename_old);
+ oldseg.segno = 0;
+ oldseg.pageno = 0;
+
+ oldidx = 1; /* skip invalid zero mxid offset */
+ }
+ }
+ }
+ }
+
+ /* Write last page, unless it is empty */
+ if (newflag > (char *) newbuf || oldest_mxoff == next_mxoff)
+ write_new_segment_page(&newseg, newbuf, false);
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+
+ pfree((char *) oldseg.dir);
+ pfree((char *) newseg.dir);
+
+ check_ok();
+}
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index add6ea9c34..9ebb8d1063 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -84,7 +84,7 @@ my $oldnode =
# increasing test runtime, run these tests with a custom setting.
# --allow-group-access and --wal-segsize have been added in v11.
my %node_params = ();
-$node_params{extra} = [ '--wal-segsize', '1', '--allow-group-access' ]
+$node_params{extra} = [ '--wal-segsize', '1', '--allow-group-access', '-x', '21000000000' ]
if $oldnode->pg_version >= 11;
$oldnode->init(%node_params);
$oldnode->start;
@@ -178,6 +178,14 @@ if (defined($ENV{oldinstall}))
'ran adapt script');
}
+$oldnode->safe_psql('regression',
+ "CREATE TABLE t1 (id SERIAL NOT NULL PRIMARY KEY, plt text, pln NUMERIC(8, 4));
+ INSERT INTO t1 (plt, pln) SELECT md5(random()::text), random() * 9999 FROM generate_series(1, 1000);");
+my $relfrozenxid = $oldnode->safe_psql('regression',
+ "SELECT relfrozenxid FROM pg_class WHERE relname = 't1';");
+my $relminmxid = $oldnode->safe_psql('regression',
+ "SELECT relminmxid FROM pg_class WHERE relname = 't1';");
+
# Take a dump before performing the upgrade as a base comparison. Note
# that we need to use pg_dumpall from the new node here.
my @dump_command = (
@@ -290,6 +298,16 @@ ok( !-d $newnode->data_dir . "/pg_upgrade_output.d",
$newnode->start;
+my $relfrozenxid_new = $newnode->safe_psql('regression',
+ "SELECT relfrozenxid FROM pg_class WHERE relname = 't1';");
+
+is($relfrozenxid_new, $relfrozenxid, 'old and new relfrozenxid match after pg_upgrade');
+
+my $relminmxid_new = $newnode->safe_psql('regression',
+ "SELECT relminmxid FROM pg_class WHERE relname = 't1';");
+
+is($relminmxid_new, $relminmxid, 'old and new relminmxid match after pg_upgrade');
+
# Check if there are any logs coming from pg_upgrade, that would only be
# retained on failure.
my $log_path = $newnode->data_dir . "/pg_upgrade_output.d";
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index dc19fc6ec8..20763af6d2 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -9,6 +9,7 @@
#include "postgres_fe.h"
+#include "access/transam.h"
#include "catalog/pg_class_d.h"
#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
@@ -242,19 +243,21 @@ old_9_6_check_for_unknown_data_type_usage(ClusterInfo *cluster)
}
/*
- * old_9_6_invalidate_hash_indexes()
- * 9.6 -> 10
- * Hash index binary format has changed from 9.6->10.0
+ * invalidate_indexes()
+ * Invalidates all indexes satisfying given predicate.
*/
-void
-old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
+static void
+invalidate_indexes(ClusterInfo *cluster, bool check_mode,
+ const char *name, const char *pred)
{
int dbnum;
FILE *script = NULL;
bool found = false;
- char *output_path = "reindex_hash.sql";
+ char output_path[MAXPGPATH];
+
+ snprintf(output_path, sizeof(output_path), "reindex_%s.sql", name);
- prep_status("Checking for hash indexes");
+ prep_status("Checking for %s indexes", name);
for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
{
@@ -267,9 +270,16 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
DbInfo *active_db = &cluster->dbarr.dbs[dbnum];
PGconn *conn = connectToServer(cluster, active_db->db_name);
- /* find hash indexes */
- res = executeQueryOrDie(conn,
- "SELECT n.nspname, c.relname "
+
+ /*
+ * Find indexes satisfying predicate.
+ *
+ * System indexes (with oids < FirstNormalObjectId) are excluded from
+ * the search as they are recreated in the new cluster during initdb.
+ */
+ res = executeQueryOrDie(
+ conn,
+ "SELECT n.nspname, c.relname, i.indexrelid "
"FROM pg_catalog.pg_class c, "
" pg_catalog.pg_index i, "
" pg_catalog.pg_am a, "
@@ -277,8 +287,11 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
"WHERE i.indexrelid = c.oid AND "
" c.relam = a.oid AND "
" c.relnamespace = n.oid AND "
- " a.amname = 'hash'"
- );
+ " i.indexrelid >= '%u'::pg_catalog.oid AND "
+ " %s "
+ "ORDER BY i.indexrelid ASC",
+ FirstNormalObjectId,
+ pred);
ntups = PQntuples(res);
i_nspname = PQfnumber(res, "nspname");
@@ -311,8 +324,14 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
if (!check_mode && db_used)
{
- /* mark hash indexes as invalid */
- PQclear(executeQueryOrDie(conn,
+ /*
+ * Mark indexes satisfying predicate as invalid.
+ *
+ * System indexes (with oids < FirstNormalObjectId) are excluded
+ * from the search (see above).
+ */
+ PQclear(executeQueryOrDie(
+ conn,
"UPDATE pg_catalog.pg_index i "
"SET indisvalid = false "
"FROM pg_catalog.pg_class c, "
@@ -321,7 +340,10 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
"WHERE i.indexrelid = c.oid AND "
" c.relam = a.oid AND "
" c.relnamespace = n.oid AND "
- " a.amname = 'hash'"));
+ " i.indexrelid >= '%u'::pg_catalog.oid AND "
+ " %s",
+ FirstNormalObjectId,
+ pred));
}
PQfinish(conn);
@@ -335,24 +357,37 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
report_status(PG_WARNING, "warning");
if (check_mode)
pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
+ "Your installation contains %s indexes. These indexes have different\n"
"internal formats between your old and new clusters, so they must be\n"
"reindexed with the REINDEX command. After upgrading, you will be given\n"
- "REINDEX instructions.");
+ "REINDEX instructions.",
+ name);
else
pg_log(PG_WARNING, "\n"
- "Your installation contains hash indexes. These indexes have different\n"
+ "Your installation contains %s indexes. These indexes have different\n"
"internal formats between your old and new clusters, so they must be\n"
"reindexed with the REINDEX command. The file\n"
" %s\n"
"when executed by psql by the database superuser will recreate all invalid\n"
"indexes; until then, none of these indexes will be used.",
+ name,
output_path);
}
else
check_ok();
}
+/*
+ * old_9_6_invalidate_hash_indexes()
+ * 9.6 -> 10
+ * Hash index binary format has changed from 9.6->10.0
+ */
+void
+old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
+{
+ invalidate_indexes(cluster, check_mode, "hash", "a.amname = 'hash'");
+}
+
/*
* old_11_check_for_sql_identifier_data_type_usage()
* 11 -> 12
@@ -459,3 +494,36 @@ report_extension_updates(ClusterInfo *cluster)
else
check_ok();
}
+
+/*
+ * invalidate_spgist_indexes()
+ * 32bit -> 64bit
+ * SP-GIST contains xids.
+ */
+void
+invalidate_spgist_indexes(ClusterInfo *cluster, bool check_mode)
+{
+ invalidate_indexes(cluster, check_mode, "spgist", "a.amname = 'spgist'");
+}
+
+/*
+ * invalidate_gin_indexes()
+ * 32bit -> 64bit
+ * Gin indexes contains xids in deleted pages.
+ */
+void
+invalidate_gin_indexes(ClusterInfo *cluster, bool check_mode)
+{
+ invalidate_indexes(cluster, check_mode, "gin", "a.amname = 'gin'");
+}
+
+/*
+ * invalidate_external_indexes()
+ * Generate script to REINDEX non standard external indexes (like RUM etc)
+ */
+void
+invalidate_external_indexes(ClusterInfo *cluster, bool check_mode)
+{
+ invalidate_indexes(cluster, check_mode, "external",
+ "NOT a.amname IN ('btree', 'hash', 'gist', 'gin', 'spgist', 'brin')");
+}
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index f1ceb4a4bd..f4109471ac 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/000000000000";
+ my $pathname = "$backup_path/pg_xact/000000123000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 5a82cfdab2..cb11ca27f5 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -919,7 +919,7 @@ main(int argc, char **argv)
config.filter_by_fpw = true;
break;
case 'x':
- if (sscanf(optarg, "%u", &config.filter_by_xid) != 1)
+ if (sscanf(optarg, "%" INT64_MODIFIER "u", &config.filter_by_xid) != 1)
{
pg_log_error("invalid transaction ID specification: \"%s\"",
optarg);
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 543f2e2643..73bc172309 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/ginblock.h b/src/include/access/ginblock.h
index 9347f464f3..4db042c319 100644
--- a/src/include/access/ginblock.h
+++ b/src/include/access/ginblock.h
@@ -133,8 +133,15 @@ typedef struct GinMetaPageData
* We should reclaim deleted page only once every transaction started before
* its deletion is over.
*/
-#define GinPageGetDeleteXid(page) ( ((PageHeader) (page))->pd_prune_xid )
-#define GinPageSetDeleteXid(page, xid) ( ((PageHeader) (page))->pd_prune_xid = xid)
+#define GinPageGetDeleteXid(page) ( \
+ (((PageHeader) (page))->pd_upper == BLCKSZ - sizeof(GinPageOpaqueData) - sizeof(TransactionId)) ? \
+ *((TransactionId *) ((char *) (page) + BLCKSZ - sizeof(GinPageOpaqueData) - sizeof(TransactionId))) : \
+ InvalidTransactionId )
+#define GinPageSetDeleteXid(page, xid) \
+ do { \
+ ((PageHeader) (page))->pd_upper = BLCKSZ - sizeof(GinPageOpaqueData) - sizeof(TransactionId); \
+ *((TransactionId *) ((char *) (page) + BLCKSZ - sizeof(GinPageOpaqueData) - sizeof(TransactionId))) = xid; \
+ } while (false)
extern bool GinPageIsRecyclable(Page page);
/*
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index a3337627b8..41de3052fd 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -223,7 +223,7 @@ GistPageGetDeleteXid(Page page)
return ((GISTDeletedPageContents *) PageGetContents(page))->deleteXid;
}
else
- return FullTransactionIdFromEpochAndXid(0, FirstNormalTransactionId);
+ return FullTransactionIdFromXid(FirstNormalTransactionId);
}
/*
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index 9dab35551e..ed1e7e44f3 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -146,6 +146,8 @@ extern void ReleaseBulkInsertStatePin(BulkInsertState bistate);
extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
int options, BulkInsertState bistate);
+extern void rewrite_page_prepare_for_xid(Page page, HeapTuple tup,
+ bool is_toast);
extern void heap_multi_insert(Relation relation, struct TupleTableSlot **slots,
int ntuples, CommandId cid, int options,
BulkInsertState bistate);
@@ -164,14 +166,14 @@ extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
Buffer *buffer, struct TM_FailureData *tmfd);
extern void heap_inplace_update(Relation relation, HeapTuple tuple);
-extern bool heap_freeze_tuple(HeapTupleHeader tuple,
+extern bool heap_freeze_tuple(HeapTuple tuple,
TransactionId relfrozenxid, TransactionId relminmxid,
TransactionId cutoff_xid, TransactionId cutoff_multi);
-extern bool heap_tuple_would_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
+extern bool heap_tuple_would_freeze(HeapTuple htup, TransactionId cutoff_xid,
MultiXactId cutoff_multi,
TransactionId *relfrozenxid_out,
MultiXactId *relminmxid_out);
-extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
+extern bool heap_tuple_needs_eventual_freeze(HeapTuple htup);
extern void simple_heap_insert(Relation relation, HeapTuple tup);
extern void simple_heap_delete(Relation relation, ItemPointer tid);
@@ -189,12 +191,16 @@ extern int heap_page_prune(Relation relation, Buffer buffer,
TransactionId old_snap_xmin,
TimestampTz old_snap_ts,
int *nnewlpdead,
- OffsetNumber *off_loc);
+ OffsetNumber *off_loc,
+ bool repairFragmentation);
extern void heap_page_prune_execute(Buffer buffer,
OffsetNumber *redirected, int nredirected,
OffsetNumber *nowdead, int ndead,
- OffsetNumber *nowunused, int nunused);
-extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
+ OffsetNumber *nowunused, int nunused,
+ bool repairFragmentation,
+ bool is_toast);
+extern void heap_get_root_tuples(Relation relation, Buffer buffer, Page page,
+ OffsetNumber *root_offsets);
/* in heap/vacuumlazy.c */
struct VacuumParams;
@@ -212,7 +218,7 @@ extern HTSV_Result HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer
TransactionId *dead_after);
extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
uint16 infomask, TransactionId xid);
-extern bool HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple);
+extern bool HeapTupleIsOnlyLocked(HeapTuple htup);
extern bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot);
extern bool HeapTupleIsSurelyDead(HeapTuple htup,
struct GlobalVisState *vistest);
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index 34220d93cf..54e3e3759a 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -59,6 +59,8 @@
#define XLOG_HEAP2_LOCK_UPDATED 0x60
#define XLOG_HEAP2_NEW_CID 0x70
+#define XLOG_HEAP3_BASE_SHIFT 0x00
+
/*
* xl_heap_insert/xl_heap_multi_insert flag values, 8 bits are available.
*/
@@ -98,6 +100,7 @@
#define XLH_DELETE_CONTAINS_OLD_KEY (1<<2)
#define XLH_DELETE_IS_SUPER (1<<3)
#define XLH_DELETE_IS_PARTITION_MOVE (1<<4)
+#define XLH_DELETE_PAGE_ON_TOAST_RELATION (1<<5)
/* convenience macro for checking whether any form of old tuple was logged */
#define XLH_DELETE_CONTAINS_OLD \
@@ -240,15 +243,19 @@ typedef struct xl_heap_update
*
* Acquires a full cleanup lock.
*/
+#define XLH_PRUNE_ON_TOAST_RELATION 0x01
+#define XLH_PRUNE_REPAIR_FRAGMENTATION 0x02
+
typedef struct xl_heap_prune
{
TransactionId latestRemovedXid;
uint16 nredirected;
uint16 ndead;
+ uint8 flags;
/* OFFSET NUMBERS are in the block reference 0 */
} xl_heap_prune;
-#define SizeOfHeapPrune (offsetof(xl_heap_prune, ndead) + sizeof(uint16))
+#define SizeOfHeapPrune (offsetof(xl_heap_prune, flags) + sizeof(uint8))
/*
* The vacuum page record is similar to the prune record, but can only mark
@@ -336,13 +343,16 @@ typedef struct xl_heap_freeze_tuple
* Backup block 0's data contains an array of xl_heap_freeze_tuple structs,
* one for each tuple.
*/
+#define XLH_FREEZE_PAGE_ON_TOAST_RELATION 0x01
+
typedef struct xl_heap_freeze_page
{
TransactionId cutoff_xid;
uint16 ntuples;
+ uint8 flags;
} xl_heap_freeze_page;
-#define SizeOfHeapFreezePage (offsetof(xl_heap_freeze_page, ntuples) + sizeof(uint16))
+#define SizeOfHeapFreezePage (offsetof(xl_heap_freeze_page, flags) + sizeof(uint8))
/*
* This is what we need to know about setting a visibility map bit
@@ -389,7 +399,19 @@ typedef struct xl_heap_rewrite_mapping
XLogRecPtr start_lsn; /* Insert LSN at begin of rewrite */
} xl_heap_rewrite_mapping;
-extern void HeapTupleHeaderAdvanceLatestRemovedXid(HeapTupleHeader tuple,
+#define XLH_BASE_SHIFT_ON_TOAST_RELATION 0x01
+
+/* shift the base of xids on heap page */
+typedef struct xl_heap_base_shift
+{
+ int64 delta; /* delta value to shift the base */
+ bool multi; /* true to shift multixact base */
+ uint8 flags;
+} xl_heap_base_shift;
+
+#define SizeOfHeapBaseShift (offsetof(xl_heap_base_shift, flags) + sizeof(uint8))
+
+extern void HeapTupleHeaderAdvanceLatestRemovedXid(HeapTuple tuple,
TransactionId *latestRemovedXid);
extern void heap_redo(XLogReaderState *record);
@@ -399,12 +421,15 @@ extern void heap_mask(char *pagedata, BlockNumber blkno);
extern void heap2_redo(XLogReaderState *record);
extern void heap2_desc(StringInfo buf, XLogReaderState *record);
extern const char *heap2_identify(uint8 info);
+extern void heap3_redo(XLogReaderState *record);
+extern void heap3_desc(StringInfo buf, XLogReaderState *record);
+extern const char *heap3_identify(uint8 info);
extern void heap_xlog_logical_rewrite(XLogReaderState *r);
extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
TransactionId cutoff_xid, xl_heap_freeze_tuple *tuples,
int ntuples);
-extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple,
+extern bool heap_prepare_freeze_tuple(HeapTuple htup,
TransactionId relfrozenxid,
TransactionId relminmxid,
TransactionId cutoff_xid,
@@ -413,8 +438,11 @@ extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple,
bool *totally_frozen,
TransactionId *relfrozenxid_out,
MultiXactId *relminmxid_out);
-extern void heap_execute_freeze_tuple(HeapTupleHeader tuple,
+extern void heap_execute_freeze_tuple(HeapTuple tuple,
xl_heap_freeze_tuple *frz);
+extern void heap_execute_freeze_tuple_page(Page page, HeapTupleHeader htup,
+ xl_heap_freeze_tuple *xlrec_tp,
+ bool is_toast);
extern XLogRecPtr log_heap_visible(RelFileLocator rlocator, Buffer heap_buffer,
Buffer vm_buffer, TransactionId cutoff_xid, uint8 vmflags);
diff --git a/src/include/access/heaptoast.h b/src/include/access/heaptoast.h
index a75699054a..3916a5f05e 100644
--- a/src/include/access/heaptoast.h
+++ b/src/include/access/heaptoast.h
@@ -20,10 +20,19 @@
/*
* Find the maximum size of a tuple if there are to be N tuples per page.
*/
+#if MAXIMUM_ALIGNOF == 8
#define MaximumBytesPerTuple(tuplesPerPage) \
MAXALIGN_DOWN((BLCKSZ - \
- MAXALIGN(SizeOfPageHeaderData + (tuplesPerPage) * sizeof(ItemIdData))) \
+ MAXALIGN(SizeOfPageHeaderData + (tuplesPerPage) * sizeof(ItemIdData)) - MAXALIGN(sizeof(HeapPageSpecialData))) \
/ (tuplesPerPage))
+#elif MAXIMUM_ALIGNOF == 4
+#define MaximumBytesPerTuple(tuplesPerPage) \
+ MAXALIGN_DOWN((BLCKSZ - \
+ MAXALIGN(SizeOfPageHeaderData + (tuplesPerPage) * sizeof(ItemIdData)) - MAXALIGN(sizeof(ToastPageSpecialData))) \
+ / (tuplesPerPage))
+#else
+#error "unknown arch bitness"
+#endif
/*
* These symbols control toaster activation. If a tuple is larger than
diff --git a/src/include/access/htup.h b/src/include/access/htup.h
index a4bc7256ed..ae61f92471 100644
--- a/src/include/access/htup.h
+++ b/src/include/access/htup.h
@@ -54,6 +54,12 @@ typedef MinimalTupleData *MinimalTuple;
* this can't be told apart from case #1 by inspection; code setting up
* or destroying this representation has to know what it's doing.
*
+ * t_xmin and t_xmax are TransactionId values stored in heap tuple header.
+ * Normally they are calculated from ShortTransactionId-sized on-disk tuple
+ * xmin/xmax representation:
+ * t_data->t_choice.t_heap.t_xmin/t_data->t_choice.t_heap.t_xmin
+ * and pd_xid_base and pd_multi_base commmon values for all tuples on a page.
+ *
* t_len should always be valid, except in the pointer-to-nothing case.
* t_self and t_tableOid should be valid if the HeapTupleData points to
* a disk buffer, or if it represents a copy of a tuple on disk. They
@@ -61,10 +67,12 @@ typedef MinimalTupleData *MinimalTuple;
*/
typedef struct HeapTupleData
{
+ TransactionId t_xmin; /* calculated tuple xmin */
+ TransactionId t_xmax; /* calculated tuple xmax */
uint32 t_len; /* length of *t_data */
ItemPointerData t_self; /* SelfItemPointer */
Oid t_tableOid; /* table the tuple came from */
-#define FIELDNO_HEAPTUPLEDATA_DATA 3
+#define FIELDNO_HEAPTUPLEDATA_DATA 5
HeapTupleHeader t_data; /* -> tuple header and data */
} HeapTupleData;
@@ -78,12 +86,12 @@ typedef HeapTupleData *HeapTuple;
#define HeapTupleIsValid(tuple) PointerIsValid(tuple)
/* HeapTupleHeader functions implemented in utils/time/combocid.c */
-extern CommandId HeapTupleHeaderGetCmin(HeapTupleHeader tup);
-extern CommandId HeapTupleHeaderGetCmax(HeapTupleHeader tup);
-extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
+extern CommandId HeapTupleGetCmin(HeapTuple tup);
+extern CommandId HeapTupleGetCmax(HeapTuple tup);
+extern void HeapTupleHeaderAdjustCmax(HeapTuple tup,
CommandId *cmax, bool *iscombo);
/* Prototype for HeapTupleHeader accessors in heapam.c */
-extern TransactionId HeapTupleGetUpdateXid(HeapTupleHeader tuple);
+extern TransactionId HeapTupleGetUpdateXid(HeapTuple tuple);
#endif /* HTUP_H */
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 9561c835f2..8bd9cfb82c 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -19,6 +19,7 @@
#include "access/tupdesc.h"
#include "access/tupmacs.h"
#include "storage/bufpage.h"
+#include "storage/bufmgr.h"
/*
* MaxTupleAttributeNumber limits the number of (user) columns in a tuple.
@@ -120,13 +121,13 @@
typedef struct HeapTupleFields
{
- TransactionId t_xmin; /* inserting xact ID */
- TransactionId t_xmax; /* deleting or locking xact ID */
+ ShortTransactionId t_xmin; /* inserting xact ID */
+ ShortTransactionId t_xmax; /* deleting or locking xact ID */
union
{
CommandId t_cid; /* inserting or deleting command ID, or both */
- TransactionId t_xvac; /* old-style VACUUM FULL xact ID */
+ ShortTransactionId t_xvac; /* old-style VACUUM FULL xact ID */
} t_field3;
} HeapTupleFields;
@@ -222,7 +223,7 @@ struct HeapTupleHeaderData
* HEAP_XMAX_LOCK_ONLY bit is set; or, for pg_upgrade's sake, if the Xmax is
* not a multi and the EXCL_LOCK bit is set.
*
- * See also HeapTupleHeaderIsOnlyLocked, which also checks for a possible
+ * See also HeapTupleIsOnlyLocked, which also checks for a possible
* aborted updater transaction.
*
* Beware of multiple evaluations of the argument.
@@ -298,27 +299,85 @@ struct HeapTupleHeaderData
*/
/*
- * HeapTupleHeaderGetRawXmin returns the "raw" xmin field, which is the xid
+ * Copy base values for xid and multixacts from one heap tuple to heap tuple.
+ * Should be called on tuple copy or making desc tuple on the base on src tuple
+ * saving visibility information.
+ */
+#define HeapTupleCopyBase(dest, src) \
+{ \
+ (dest)->t_xmin = (src)->t_xmin; \
+ (dest)->t_xmax = (src)->t_xmax; \
+}
+
+/*
+ * Set base values for tuple xids/multixacts to zero. Used when visibility
+ * infromation is negligible or will be set later.
+ */
+#define HeapTupleSetZeroBase(tup) \
+{ \
+ (tup)->t_xmin = 0; \
+ (tup)->t_xmax = 0; \
+}
+
+/*
+ * Copy HeapTupleHeader xmin/xmax in raw way ???
+ */
+#define HeapTupleCopyHeaderXids(tup) \
+{ \
+ (tup)->t_xmin = (tup)->t_data->t_choice.t_heap.t_xmin; \
+ (tup)->t_xmax = (tup)->t_data->t_choice.t_heap.t_xmax; \
+}
+
+/*
+ * Macros for accessing "double xmax". On pg_upgraded instances, it might
+ * happend that we can't fit new special area to the page. But we still
+ * might neep to write xmax of tuples for updates and deletes. The trick is
+ * that we actually don't need xmin field. After pg_upgrade (wich implies
+ * restart) no insertions went to this page yet (otherwise special area could
+ * fit). So, if tuple is visible (othewise it would be deleted), then it's
+ * visible for everybody. Thus, t_xmin isn't needed. Therefore, we can use
+ * both t_xmin and t_xmax to store 64-bit xmax.
+ *
+ * See heap_convert.c for details.
+ */
+#define HeapTupleHeaderGetDoubleXmax(tup) \
+ ((TransactionId)(tup)->t_choice.t_heap.t_xmax + \
+ ((TransactionId)(tup)->t_choice.t_heap.t_xmin << 32))
+
+#define HeapTupleHeaderSetDoubleXmax(tup, xid) \
+do { \
+ (tup)->t_choice.t_heap.t_xmax = (TransactionId) (xid) & 0xFFFFFFFF; \
+ (tup)->t_choice.t_heap.t_xmin = ((TransactionId) (xid) >> 32) & 0xFFFFFFFF; \
+} while (0)
+
+/*
+ * HeapTupleGetRawXmin returns the "raw" xmin field, which is the xid
* originally used to insert the tuple. However, the tuple might actually
* be frozen (via HeapTupleHeaderSetXminFrozen) in which case the tuple's xmin
* is visible to every snapshot. Prior to PostgreSQL 9.4, we actually changed
* the xmin to FrozenTransactionId, and that value may still be encountered
* on disk.
*/
-#define HeapTupleHeaderGetRawXmin(tup) \
+#define HeapTupleGetRawXmin(tup) ((tup)->t_xmin)
+
+#define HeapTupleGetXmin(tup) \
( \
- (tup)->t_choice.t_heap.t_xmin \
+ HeapTupleHeaderXminFrozen((tup)->t_data) ? \
+ FrozenTransactionId : HeapTupleGetRawXmin(tup) \
)
-#define HeapTupleHeaderGetXmin(tup) \
+#define HeapTupleSetXmin(tup, xid) ((tup)->t_xmin = (xid))
+
+#define HeapTupleHeaderSetXmin(page, tup) \
( \
- HeapTupleHeaderXminFrozen(tup) ? \
- FrozenTransactionId : HeapTupleHeaderGetRawXmin(tup) \
+ AssertMacro(!HeapPageIsDoubleXmax(page)), \
+ (tup)->t_data->t_choice.t_heap.t_xmin = NormalTransactionIdToShort(HeapPageGetSpecial(page)->pd_xid_base, (tup)->t_xmin) \
)
-#define HeapTupleHeaderSetXmin(tup, xid) \
+#define ToastTupleHeaderSetXmin(page, tup) \
( \
- (tup)->t_choice.t_heap.t_xmin = (xid) \
+ AssertMacro(!HeapPageIsDoubleXmax(page)), \
+ (tup)->t_data->t_choice.t_heap.t_xmin = NormalTransactionIdToShort(ToastPageGetSpecial(page)->pd_xid_base, (tup)->t_xmin) \
)
#define HeapTupleHeaderXminCommitted(tup) \
@@ -337,18 +396,6 @@ struct HeapTupleHeaderData
((tup)->t_infomask & (HEAP_XMIN_FROZEN)) == HEAP_XMIN_FROZEN \
)
-#define HeapTupleHeaderSetXminCommitted(tup) \
-( \
- AssertMacro(!HeapTupleHeaderXminInvalid(tup)), \
- ((tup)->t_infomask |= HEAP_XMIN_COMMITTED) \
-)
-
-#define HeapTupleHeaderSetXminInvalid(tup) \
-( \
- AssertMacro(!HeapTupleHeaderXminCommitted(tup)), \
- ((tup)->t_infomask |= HEAP_XMIN_INVALID) \
-)
-
#define HeapTupleHeaderSetXminFrozen(tup) \
( \
AssertMacro(!HeapTupleHeaderXminInvalid(tup)), \
@@ -362,30 +409,67 @@ struct HeapTupleHeaderData
* to resolve the MultiXactId if necessary. This might involve multixact I/O,
* so it should only be used if absolutely necessary.
*/
-#define HeapTupleHeaderGetUpdateXid(tup) \
+#define HeapTupleGetUpdateXidAny(tup) \
( \
- (!((tup)->t_infomask & HEAP_XMAX_INVALID) && \
- ((tup)->t_infomask & HEAP_XMAX_IS_MULTI) && \
- !((tup)->t_infomask & HEAP_XMAX_LOCK_ONLY)) ? \
+ (!((tup)->t_data->t_infomask & HEAP_XMAX_INVALID) && \
+ ((tup)->t_data->t_infomask & HEAP_XMAX_IS_MULTI) && \
+ !((tup)->t_data->t_infomask & HEAP_XMAX_LOCK_ONLY)) ? \
HeapTupleGetUpdateXid(tup) \
: \
- HeapTupleHeaderGetRawXmax(tup) \
+ HeapTupleGetRawXmax(tup) \
)
-#define HeapTupleHeaderGetRawXmax(tup) \
+#define HeapTupleGetRawXmax(tup) ((tup)->t_xmax)
+
+#define HeapTupleHeaderGetRawXmax(page, tup) \
( \
- (tup)->t_choice.t_heap.t_xmax \
+ HeapPageIsDoubleXmax(page) ? \
+ HeapTupleHeaderGetDoubleXmax(tup) : \
+ ShortTransactionIdToNormal( \
+ ((tup)->t_infomask & HEAP_XMAX_IS_MULTI) ? HeapPageGetSpecial(page)->pd_multi_base : HeapPageGetSpecial(page)->pd_xid_base, \
+ (tup)->t_choice.t_heap.t_xmax) \
)
-#define HeapTupleHeaderSetXmax(tup, xid) \
+#define ToastTupleHeaderGetRawXmax(page, tup) \
( \
- (tup)->t_choice.t_heap.t_xmax = (xid) \
+ HeapPageIsDoubleXmax(page) ? \
+ HeapTupleHeaderGetDoubleXmax(tup) : \
+ ShortTransactionIdToNormal( \
+ ToastPageGetSpecial(page)->pd_xid_base, \
+ (tup)->t_choice.t_heap.t_xmax) \
)
+#define HeapTupleSetXmax(tup, xid) \
+do { \
+ (tup)->t_xmax = (xid); \
+} while (0)
+
+#define HeapTupleHeaderSetXmax(page, tup) \
+do { \
+ if (HeapPageIsDoubleXmax(page)) \
+ HeapTupleHeaderSetDoubleXmax((tup)->t_data, (tup)->t_xmax); \
+ else \
+ (tup)->t_data->t_choice.t_heap.t_xmax = \
+ NormalTransactionIdToShort( \
+ ((tup)->t_data->t_infomask & HEAP_XMAX_IS_MULTI) ? HeapPageGetSpecial(page)->pd_multi_base : HeapPageGetSpecial(page)->pd_xid_base, \
+ ((tup)->t_xmax)); \
+} while (0)
+
+#define ToastTupleHeaderSetXmax(page, tup) \
+do { \
+ if (HeapPageIsDoubleXmax(page)) \
+ HeapTupleHeaderSetDoubleXmax((tup)->t_data, (tup)->t_xmax); \
+ else \
+ (tup)->t_data->t_choice.t_heap.t_xmax = \
+ NormalTransactionIdToShort( \
+ ToastPageGetSpecial(page)->pd_xid_base, \
+ ((tup)->t_xmax)); \
+} while (0)
+
/*
* HeapTupleHeaderGetRawCommandId will give you what's in the header whether
- * it is useful or not. Most code should use HeapTupleHeaderGetCmin or
- * HeapTupleHeaderGetCmax instead, but note that those Assert that you can
+ * it is useful or not. Most code should use HeapTupleGetCmin or
+ * HeapTupleGetCmax instead, but note that those Assert that you can
* get a legitimate result, ie you are in the originating transaction!
*/
#define HeapTupleHeaderGetRawCommandId(tup) \
@@ -555,8 +639,16 @@ do { \
* an otherwise-empty page can indeed hold a tuple of this size. Because
* ItemIds and tuples have different alignment requirements, don't assume that
* you can, say, fit 2 tuples of size MaxHeapTupleSize/2 on the same page.
+ *
+ * On shift to 64-bit XIDs MaxHeapTupleSize decreased by sizeof(HeapPageSpecialData).
+ * Extant tuples with length over new MaxHeapTupleSize are inherited on DoubleXmax
+ * pages. They could be read, but can not be updated unless their length decreases
+ * to fit MaxHeapTupleSize. Vacuum full will also copy these double xmax pages
+ * without change.
*/
-#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)))
+
+#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)) - MAXALIGN(sizeof(HeapPageSpecialData)))
+#define MaxHeapTupleSize_32 (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData)))
#define MinHeapTupleSize MAXALIGN(SizeofHeapTupleHeader)
/*
@@ -690,6 +782,79 @@ struct MinimalTupleData
#define HeapTupleClearHeapOnly(tuple) \
HeapTupleHeaderClearHeapOnly((tuple)->t_data)
+static inline void
+HeapTupleCopyXminFromPage(HeapTuple tup, Page page, bool is_toast)
+{
+ TransactionId base;
+ ShortTransactionId xmin; /* short xmin from tuple header */
+
+ if (HeapTupleHeaderXminFrozen(tup->t_data))
+ {
+ tup->t_xmin = FrozenTransactionId;
+ return;
+ }
+
+ xmin = tup->t_data->t_choice.t_heap.t_xmin;
+
+ if (!TransactionIdIsNormal(xmin))
+ base = 0;
+ else if (is_toast)
+ base = ToastPageGetSpecial(page)->pd_xid_base;
+ else
+ base = HeapPageGetSpecial(page)->pd_xid_base;
+
+ tup->t_xmin = ShortTransactionIdToNormal(base, xmin);
+}
+
+static inline void
+HeapTupleCopyXmaxFromPage(HeapTuple tup, Page page, bool is_toast)
+{
+ TransactionId base;
+ ShortTransactionId xmax; /* short xmax from tuple header */
+
+ xmax = tup->t_data->t_choice.t_heap.t_xmax;
+
+ if (!TransactionIdIsNormal(xmax))
+ base = 0;
+ else if (is_toast)
+ /*
+ * Toast page is not expected to have multixacts in chunks and
+ * has shorter special.
+ */
+ base = ToastPageGetSpecial(page)->pd_xid_base;
+ else if (tup->t_data->t_infomask & HEAP_XMAX_IS_MULTI)
+ base = HeapPageGetSpecial(page)->pd_multi_base;
+ else
+ base = HeapPageGetSpecial(page)->pd_xid_base;
+
+ tup->t_xmax = ShortTransactionIdToNormal(base, xmax);
+}
+
+/*
+ * Copy base values for xid and multixacts from page to heap tuple. Should be
+ * called each time tuple is read from page. Otherwise, it would be impossible
+ * to correctly read tuple xmin and xmax.
+ */
+static inline void
+HeapTupleCopyBaseFromPage(Buffer buffer, HeapTuple tup, Page page,
+ bool is_toast)
+{
+ Assert(IsBufferLocked(buffer));
+
+ if (HeapPageIsDoubleXmax(page))
+ {
+ /*
+ * On double xmax pages, xmax is extracted from tuple header.
+ */
+ tup->t_xmin = FrozenTransactionId;
+ tup->t_xmax = HeapTupleHeaderGetDoubleXmax(tup->t_data);
+ return;
+ }
+
+ HeapTupleCopyXminFromPage(tup, page, is_toast);
+ HeapTupleCopyXmaxFromPage(tup, page, is_toast);
+}
+
/* prototypes for functions in common/heaptuple.c */
extern Size heap_compute_data_size(TupleDesc tupleDesc,
Datum *values, bool *isnull);
diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h
index 4cbe17de7b..980f8bb747 100644
--- a/src/include/access/multixact.h
+++ b/src/include/access/multixact.h
@@ -18,16 +18,16 @@
/*
* The first two MultiXactId values are reserved to store the truncation Xid
- * and epoch of the first segment, so we start assigning multixact values from
+ * and base of the first segment, so we start assigning multixact values from
* 2.
*/
-#define InvalidMultiXactId ((MultiXactId) 0)
-#define FirstMultiXactId ((MultiXactId) 1)
-#define MaxMultiXactId ((MultiXactId) 0xFFFFFFFF)
+#define InvalidMultiXactId UINT64CONST(0)
+#define FirstMultiXactId UINT64CONST(1)
+#define MaxMultiXactId UINT64CONST(0xFFFFFFFFFFFFFFFF)
#define MultiXactIdIsValid(multi) ((multi) != InvalidMultiXactId)
-#define MaxMultiXactOffset ((MultiXactOffset) 0xFFFFFFFF)
+#define MaxMultiXactOffset UINT64CONST(0xFFFFFFFFFFFFFFFF)
/* Number of SLRU buffers to use for multixact */
#define NUM_MULTIXACTOFFSET_BUFFERS 8
@@ -147,7 +147,6 @@ extern void MultiXactSetNextMXact(MultiXactId nextMulti,
extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
MultiXactOffset minMultiOffset);
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
-extern int MultiXactMemberFreezeThreshold(void);
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len);
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 8e4f6864e5..72b4ff5c52 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -62,8 +62,10 @@ typedef uint16 BTCycleId;
typedef struct BTPageOpaqueData
{
BlockNumber btpo_prev; /* left sibling, or P_NONE if leftmost */
+ /* ... or next transaction ID (lower part) */
BlockNumber btpo_next; /* right sibling, or P_NONE if rightmost */
uint32 btpo_level; /* tree level --- zero for leaf pages */
+ /* ... or next transaction ID (lower part) */
uint16 btpo_flags; /* flag bits, see below */
BTCycleId btpo_cycleid; /* vacuum cycle ID of latest split */
} BTPageOpaqueData;
@@ -92,6 +94,14 @@ typedef BTPageOpaqueData *BTPageOpaque;
*/
#define MAX_BT_CYCLE_ID 0xFF7F
+/* Macros for access xact */
+#define BTP_GET_XACT(opaque) (((uint64) ((BTPageOpaque) opaque)->btpo_prev << 32) | \
+ (uint64) ((BTPageOpaque) opaque)->btpo_level)
+#define BTP_SET_XACT(opaque, xact) \
+do { \
+ ((BTPageOpaque) opaque)->btpo_prev = (uint32) (xact >> 32); \
+ ((BTPageOpaque) opaque)->btpo_level = (uint32) xact; \
+} while (0)
/*
* The Meta page is always the first page in the btree index.
diff --git a/src/include/access/rewriteheap.h b/src/include/access/rewriteheap.h
index 5cc04756a5..cd7913858f 100644
--- a/src/include/access/rewriteheap.h
+++ b/src/include/access/rewriteheap.h
@@ -51,7 +51,7 @@ typedef struct LogicalRewriteMappingData
* 6) xid of the xact performing the mapping
* ---
*/
-#define LOGICAL_REWRITE_FORMAT "map-%x-%x-%X_%X-%x-%x"
-extern void CheckPointLogicalRewriteHeap(void);
+#define LOGICAL_REWRITE_FORMAT "map-%x-%x-%X_%X-%x_%x-%x_%x"
+extern void CheckPointLogicalRewriteHeap(void);
#endif /* REWRITE_HEAP_H */
diff --git a/src/include/access/rmgrlist.h b/src/include/access/rmgrlist.h
index 000bcbfdaf..8200ccff3e 100644
--- a/src/include/access/rmgrlist.h
+++ b/src/include/access/rmgrlist.h
@@ -47,3 +47,4 @@ PG_RMGR(RM_COMMIT_TS_ID, "CommitTs", commit_ts_redo, commit_ts_desc, commit_ts_i
PG_RMGR(RM_REPLORIGIN_ID, "ReplicationOrigin", replorigin_redo, replorigin_desc, replorigin_identify, NULL, NULL, NULL, NULL)
PG_RMGR(RM_GENERIC_ID, "Generic", generic_redo, generic_desc, generic_identify, NULL, NULL, generic_mask, NULL)
PG_RMGR(RM_LOGICALMSG_ID, "LogicalMessage", logicalmsg_redo, logicalmsg_desc, logicalmsg_identify, NULL, NULL, NULL, logicalmsg_decode)
+PG_RMGR(RM_HEAP3_ID, "Heap3", heap3_redo, heap3_desc, heap3_identify, NULL, NULL, heap_mask, NULL)
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 4f5a324da2..767854419d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -21,15 +21,7 @@
/*
* Define SLRU segment size. A page is the same BLCKSZ as is used everywhere
* else in Postgres. The segment size can be chosen somewhat arbitrarily;
- * we make it 32 pages by default, or 256Kb, i.e. 1M transactions for CLOG
- * or 64K transactions for SUBTRANS.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * page numbering also wraps around at 0xFFFFFFFF/xxxx_XACTS_PER_PAGE (where
- * xxxx is CLOG or SUBTRANS, respectively), and segment numbering at
- * 0xFFFFFFFF/xxxx_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need
- * take no explicit notice of that fact in slru.c, except when comparing
- * segment and page numbers in SimpleLruTruncate (see PagePrecedes()).
+ * we make it 32 pages by default.
*/
#define SLRU_PAGES_PER_SEGMENT 32
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index e45d73eae3..6f89426e57 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -118,7 +118,7 @@ typedef enum TM_Result
* cmax is the outdating command's CID, but only when the failure code is
* TM_SelfModified (i.e., something in the current transaction outdated the
* tuple); otherwise cmax is zero. (We make this restriction because
- * HeapTupleHeaderGetCmax doesn't work for tuples outdated in other
+ * HeapTupleGetCmax doesn't work for tuples outdated in other
* transactions.)
*/
typedef struct TM_FailureData
diff --git a/src/include/access/transam.h b/src/include/access/transam.h
index 775471d2a7..e7cf1206df 100644
--- a/src/include/access/transam.h
+++ b/src/include/access/transam.h
@@ -17,6 +17,10 @@
#include "access/xlogdefs.h"
+#ifndef FRONTEND
+#include "utils/elog.h"
+#endif
+
/* ----------------
* Special transaction ID values
*
@@ -28,11 +32,12 @@
* Note: if you need to change it, you must change pg_class.h as well.
* ----------------
*/
-#define InvalidTransactionId ((TransactionId) 0)
-#define BootstrapTransactionId ((TransactionId) 1)
-#define FrozenTransactionId ((TransactionId) 2)
-#define FirstNormalTransactionId ((TransactionId) 3)
-#define MaxTransactionId ((TransactionId) 0xFFFFFFFF)
+#define InvalidTransactionId UINT64CONST(0)
+#define BootstrapTransactionId UINT64CONST(1)
+#define FrozenTransactionId UINT64CONST(2)
+#define FirstNormalTransactionId UINT64CONST(3)
+#define MaxTransactionId UINT64CONST(0xFFFFFFFFFFFFFFFF)
+#define MaxShortTransactionId ((TransactionId) 0x7FFFFFFF)
/* ----------------
* transaction ID manipulation macros
@@ -44,17 +49,48 @@
#define TransactionIdStore(xid, dest) (*(dest) = (xid))
#define StoreInvalidTransactionId(dest) (*(dest) = InvalidTransactionId)
-#define EpochFromFullTransactionId(x) ((uint32) ((x).value >> 32))
-#define XidFromFullTransactionId(x) ((uint32) (x).value)
-#define U64FromFullTransactionId(x) ((x).value)
+/*
+ * Convert short xid from/to full xid. Assertion should fail if we full xid
+ * doesn't fit to xid base.
+ */
+static inline TransactionId
+ShortTransactionIdToNormal(TransactionId base, ShortTransactionId xid)
+{
+ if (!TransactionIdIsNormal(xid))
+ return (TransactionId) xid;
+
+#ifndef FRONTEND
+ /* xid + base should not overflow TransactionId */
+ Assert(xid + base >= base);
+#endif
+
+ return (TransactionId) (xid + base);
+}
+
+static inline ShortTransactionId
+NormalTransactionIdToShort(TransactionId base, TransactionId xid)
+{
+ if (!TransactionIdIsNormal(xid))
+ return (ShortTransactionId) (xid);
+
+#ifndef FRONTEND
+ /* xid should fit ShortTransactionId */
+ Assert(xid >= base + FirstNormalTransactionId &&
+ xid <= base + MaxShortTransactionId);
+#endif
+
+ return (ShortTransactionId) (xid - base);
+}
+
+#define XidFromFullTransactionId(x) ((x).value)
#define FullTransactionIdEquals(a, b) ((a).value == (b).value)
#define FullTransactionIdPrecedes(a, b) ((a).value < (b).value)
#define FullTransactionIdPrecedesOrEquals(a, b) ((a).value <= (b).value)
#define FullTransactionIdFollows(a, b) ((a).value > (b).value)
#define FullTransactionIdFollowsOrEquals(a, b) ((a).value >= (b).value)
#define FullTransactionIdIsValid(x) TransactionIdIsValid(XidFromFullTransactionId(x))
-#define InvalidFullTransactionId FullTransactionIdFromEpochAndXid(0, InvalidTransactionId)
-#define FirstNormalFullTransactionId FullTransactionIdFromEpochAndXid(0, FirstNormalTransactionId)
+#define InvalidFullTransactionId FullTransactionIdFromXid(InvalidTransactionId)
+#define FirstNormalFullTransactionId FullTransactionIdFromXid(FirstNormalTransactionId)
#define FullTransactionIdIsNormal(x) FullTransactionIdFollowsOrEquals(x, FirstNormalFullTransactionId)
/*
@@ -68,21 +104,11 @@ typedef struct FullTransactionId
} FullTransactionId;
static inline FullTransactionId
-FullTransactionIdFromEpochAndXid(uint32 epoch, TransactionId xid)
-{
- FullTransactionId result;
-
- result.value = ((uint64) epoch) << 32 | xid;
-
- return result;
-}
-
-static inline FullTransactionId
-FullTransactionIdFromU64(uint64 value)
+FullTransactionIdFromXid(TransactionId xid)
{
FullTransactionId result;
- result.value = value;
+ result.value = xid;
return result;
}
@@ -91,8 +117,7 @@ FullTransactionIdFromU64(uint64 value)
#define TransactionIdAdvance(dest) \
do { \
(dest)++; \
- if ((dest) < FirstNormalTransactionId) \
- (dest) = FirstNormalTransactionId; \
+ Assert(TransactionIdIsNormal(dest)); \
} while(0)
/*
@@ -140,18 +165,19 @@ FullTransactionIdAdvance(FullTransactionId *dest)
/* back up a transaction ID variable, handling wraparound correctly */
#define TransactionIdRetreat(dest) \
do { \
+ Assert(TransactionIdIsNormal(dest)); \
(dest)--; \
- } while ((dest) < FirstNormalTransactionId)
+ } while(0)
/* compare two XIDs already known to be normal; this is a macro for speed */
#define NormalTransactionIdPrecedes(id1, id2) \
(AssertMacro(TransactionIdIsNormal(id1) && TransactionIdIsNormal(id2)), \
- (int32) ((id1) - (id2)) < 0)
+ (int64) ((id1) - (id2)) < 0)
/* compare two XIDs already known to be normal; this is a macro for speed */
#define NormalTransactionIdFollows(id1, id2) \
(AssertMacro(TransactionIdIsNormal(id1) && TransactionIdIsNormal(id2)), \
- (int32) ((id1) - (id2)) > 0)
+ (int64) ((id1) - (id2)) > 0)
/* ----------
* Object ID (OID) zero is InvalidOid.
@@ -221,9 +247,6 @@ typedef struct VariableCacheData
TransactionId oldestXid; /* cluster-wide minimum datfrozenxid */
TransactionId xidVacLimit; /* start forcing autovacuums here */
- TransactionId xidWarnLimit; /* start complaining here */
- TransactionId xidStopLimit; /* refuse to advance nextXid beyond here */
- TransactionId xidWrapLimit; /* where the world ends */
Oid oldestXidDB; /* database with minimum datfrozenxid */
/*
@@ -276,10 +299,6 @@ extern bool TransactionIdDidAbort(TransactionId transactionId);
extern void TransactionIdCommitTree(TransactionId xid, int nxids, TransactionId *xids);
extern void TransactionIdAsyncCommitTree(TransactionId xid, int nxids, TransactionId *xids, XLogRecPtr lsn);
extern void TransactionIdAbortTree(TransactionId xid, int nxids, TransactionId *xids);
-extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);
-extern bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2);
-extern bool TransactionIdFollows(TransactionId id1, TransactionId id2);
-extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2);
extern TransactionId TransactionIdLatest(TransactionId mainxid,
int nxids, const TransactionId *xids);
extern XLogRecPtr TransactionIdGetCommitLSN(TransactionId xid);
@@ -319,7 +338,7 @@ ReadNextTransactionId(void)
/* return transaction ID backed up by amount, handling wraparound correctly */
static inline TransactionId
-TransactionIdRetreatedBy(TransactionId xid, uint32 amount)
+TransactionIdRetreatedBy(TransactionId xid, uint64 amount)
{
xid -= amount;
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index 8b24cd3658..db8dae182d 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -131,10 +131,11 @@ fetch_att(const void *T, bool attbyval, int attlen)
((attalign) == TYPALIGN_INT) ? INTALIGN(cur_offset) : \
(((attalign) == TYPALIGN_CHAR) ? (uintptr_t) (cur_offset) : \
(((attalign) == TYPALIGN_DOUBLE) ? DOUBLEALIGN(cur_offset) : \
+ (((attalign) == TYPALIGN_XID) ? MAXALIGN(cur_offset) : \
( \
AssertMacro((attalign) == TYPALIGN_SHORT), \
SHORTALIGN(cur_offset) \
- ))) \
+ )))) \
)
/*
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index c604ee11f8..3e39b01527 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -242,7 +242,7 @@ typedef struct xl_xact_xinfo
* Commit records can be large, so copying large portions isn't
* attractive.
*/
- uint32 xinfo;
+ uint64 xinfo;
} xl_xact_xinfo;
typedef struct xl_xact_dbinfo
@@ -295,7 +295,12 @@ typedef struct xl_xact_invals
typedef struct xl_xact_twophase
{
- TransactionId xid;
+ /*
+ * TransactionId is split into 32-bit parts because xl_xact_twophase is
+ * only int-aligned.
+ */
+ uint32 xid_lo;
+ uint32 xid_hi;
} xl_xact_twophase;
typedef struct xl_xact_origin
@@ -314,7 +319,7 @@ typedef struct xl_xact_commit
/* xl_xact_relfilelocators follows if XINFO_HAS_RELFILELOCATORS */
/* xl_xact_stats_items follows if XINFO_HAS_DROPPED_STATS */
/* xl_xact_invals follows if XINFO_HAS_INVALS */
- /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
+ /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE (xid is int-aligned!) */
/* twophase_gid follows if XINFO_HAS_GID. As a null-terminated string. */
/* xl_xact_origin follows if XINFO_HAS_ORIGIN, stored unaligned! */
} xl_xact_commit;
@@ -330,7 +335,7 @@ typedef struct xl_xact_abort
/* xl_xact_relfilelocators follows if XINFO_HAS_RELFILELOCATORS */
/* xl_xact_stats_items follows if XINFO_HAS_DROPPED_STATS */
/* No invalidation messages needed. */
- /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE */
+ /* xl_xact_twophase follows if XINFO_HAS_TWOPHASE (xid is int-aligned!) */
/* twophase_gid follows if XINFO_HAS_GID. As a null-terminated string. */
/* xl_xact_origin follows if XINFO_HAS_ORIGIN, stored unaligned! */
} xl_xact_abort;
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index 001ff2f521..6694551c71 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -37,6 +37,7 @@
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
+#define REGBUF_CONVERTED 0x20 /* buffer had format convertion */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index e87f91316a..222c15dc24 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -426,10 +426,6 @@ extern bool DecodeXLogRecord(XLogReaderState *state,
#define XLogRecBlockImageApply(decoder, block_id) \
((decoder)->record->blocks[block_id].apply_image)
-#ifndef FRONTEND
-extern FullTransactionId XLogRecGetFullXid(XLogReaderState *record);
-#endif
-
extern bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page);
extern char *XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len);
extern void XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id,
diff --git a/src/include/access/xlogrecord.h b/src/include/access/xlogrecord.h
index 835151ec92..9eab0f53eb 100644
--- a/src/include/access/xlogrecord.h
+++ b/src/include/access/xlogrecord.h
@@ -41,18 +41,17 @@
typedef struct XLogRecord
{
uint32 xl_tot_len; /* total len of entire record */
+ pg_crc32c xl_crc; /* CRC for this record */
TransactionId xl_xid; /* xact id */
XLogRecPtr xl_prev; /* ptr to previous record in log */
uint8 xl_info; /* flag bits, see below */
RmgrId xl_rmid; /* resource manager for this record */
- /* 2 bytes of padding here, initialize to zero */
- pg_crc32c xl_crc; /* CRC for this record */
/* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no padding */
} XLogRecord;
-#define SizeOfXLogRecord (offsetof(XLogRecord, xl_crc) + sizeof(pg_crc32c))
+#define SizeOfXLogRecord (offsetof(XLogRecord, xl_rmid) + sizeof(RmgrId))
/*
* The high 4 bits in xl_info may be used freely by rmgr. The
diff --git a/src/include/c.h b/src/include/c.h
index c8f72e44d8..2aea4dadb3 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -75,6 +75,10 @@
#include <libintl.h>
#endif
+#if HAVE_INTTYPES_H
+#include "inttypes.h"
+#endif
+
/* ----------------------------------------------------------------
* Section 1: compiler characteristics
@@ -585,19 +589,29 @@ typedef double float8;
typedef Oid regproc;
typedef regproc RegProcedure;
-typedef uint32 TransactionId;
+typedef uint64 TransactionId;
-typedef uint32 LocalTransactionId;
+extern bool TransactionIdPrecedes(TransactionId id1, TransactionId id2);
+extern bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2);
+extern bool TransactionIdFollows(TransactionId id1, TransactionId id2);
+extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2);
-typedef uint32 SubTransactionId;
+typedef uint32 ShortTransactionId;
+typedef uint64 LocalTransactionId;
+typedef uint64 SubTransactionId;
-#define InvalidSubTransactionId ((SubTransactionId) 0)
-#define TopSubTransactionId ((SubTransactionId) 1)
+#define InvalidSubTransactionId ((SubTransactionId) 0)
+#define TopSubTransactionId ((SubTransactionId) 1)
/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
typedef TransactionId MultiXactId;
-typedef uint32 MultiXactOffset;
+typedef uint64 MultiXactOffset;
+
+#define MAX_START_XID UINT64CONST(0x3FFFFFFFFFFFFFFF) /* 2^62 - 1 */
+#define StartTransactionIdIsValid(xid) ((xid) <= MAX_START_XID)
+#define StartMultiXactIdIsValid(mxid) ((mxid) <= MAX_START_XID)
+#define StartMultiXactOffsetIsValid(mxoff) ((mxoff) <= MAX_START_XID)
typedef uint32 CommandId;
@@ -771,7 +785,6 @@ typedef NameData *Name;
/* we don't currently need wider versions of the other ALIGN macros */
#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
-
/* ----------------------------------------------------------------
* Section 6: assertions
* ----------------------------------------------------------------
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index c1af6eaf5f..c89ba99071 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -57,6 +57,7 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202209291
+/* XXX: should de changed to actual version on commit */
+#define CATALOG_VERSION_NO 999999999
#endif
diff --git a/src/include/catalog/pg_amproc.dat b/src/include/catalog/pg_amproc.dat
index 4cc129bebd..4f20977635 100644
--- a/src/include/catalog/pg_amproc.dat
+++ b/src/include/catalog/pg_amproc.dat
@@ -403,9 +403,9 @@
amprocrighttype => 'bytea', amprocnum => '2',
amproc => 'hashvarlenaextended' },
{ amprocfamily => 'hash/xid_ops', amproclefttype => 'xid',
- amprocrighttype => 'xid', amprocnum => '1', amproc => 'hashint4' },
+ amprocrighttype => 'xid', amprocnum => '1', amproc => 'hashint8' },
{ amprocfamily => 'hash/xid_ops', amproclefttype => 'xid',
- amprocrighttype => 'xid', amprocnum => '2', amproc => 'hashint4extended' },
+ amprocrighttype => 'xid', amprocnum => '2', amproc => 'hashint8extended' },
{ amprocfamily => 'hash/xid8_ops', amproclefttype => 'xid8',
amprocrighttype => 'xid8', amprocnum => '1', amproc => 'hashint8' },
{ amprocfamily => 'hash/xid8_ops', amproclefttype => 'xid8',
diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h
index 06368e2366..ab02a0896f 100644
--- a/src/include/catalog/pg_control.h
+++ b/src/include/catalog/pg_control.h
@@ -247,4 +247,10 @@ typedef struct ControlFileData
*/
#define PG_CONTROL_FILE_SIZE 8192
+#define CONTROLFILE_GET_OLDEDITION(control) \
+ ((control)->pg_old_version >> 16)
+
+#define CONTROLFILE_SET_OLDEDITION(control, v) \
+ (control)->pg_old_version = ((v) << 16)
+
#endif /* PG_CONTROL_H */
diff --git a/src/include/catalog/pg_operator.dat b/src/include/catalog/pg_operator.dat
index bc5f8213f3..912ab48ecf 100644
--- a/src/include/catalog/pg_operator.dat
+++ b/src/include/catalog/pg_operator.dat
@@ -183,16 +183,16 @@
oprresult => 'bool', oprcom => '=(xid,xid)', oprnegate => '<>(xid,xid)',
oprcode => 'xideq', oprrest => 'eqsel', oprjoin => 'eqjoinsel' },
{ oid => '353', descr => 'equal',
- oprname => '=', oprleft => 'xid', oprright => 'int4', oprresult => 'bool',
- oprnegate => '<>(xid,int4)', oprcode => 'xideqint4', oprrest => 'eqsel',
+ oprname => '=', oprleft => 'xid', oprright => 'int8', oprresult => 'bool',
+ oprnegate => '<>(xid,int8)', oprcode => 'xideqint8', oprrest => 'eqsel',
oprjoin => 'eqjoinsel' },
{ oid => '3315', descr => 'not equal',
oprname => '<>', oprleft => 'xid', oprright => 'xid', oprresult => 'bool',
oprcom => '<>(xid,xid)', oprnegate => '=(xid,xid)', oprcode => 'xidneq',
oprrest => 'neqsel', oprjoin => 'neqjoinsel' },
{ oid => '3316', descr => 'not equal',
- oprname => '<>', oprleft => 'xid', oprright => 'int4', oprresult => 'bool',
- oprnegate => '=(xid,int4)', oprcode => 'xidneqint4', oprrest => 'neqsel',
+ oprname => '<>', oprleft => 'xid', oprright => 'int8', oprresult => 'bool',
+ oprnegate => '=(xid,int8)', oprcode => 'xidneqint8', oprrest => 'neqsel',
oprjoin => 'neqjoinsel' },
{ oid => '5068', descr => 'equal',
oprname => '=', oprcanmerge => 't', oprcanhash => 't', oprleft => 'xid8',
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 68bb032d3e..58e6ceb80a 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2369,10 +2369,10 @@
{ oid => '1181',
descr => 'age of a transaction ID, in transactions before current transaction',
proname => 'age', provolatile => 's', proparallel => 'r',
- prorettype => 'int4', proargtypes => 'xid', prosrc => 'xid_age' },
+ prorettype => 'int8', proargtypes => 'xid', prosrc => 'xid_age' },
{ oid => '3939',
descr => 'age of a multi-transaction ID, in multi-transactions before current multi-transaction',
- proname => 'mxid_age', provolatile => 's', prorettype => 'int4',
+ proname => 'mxid_age', provolatile => 's', prorettype => 'int8',
proargtypes => 'xid', prosrc => 'mxid_age' },
{ oid => '1188',
@@ -2707,11 +2707,11 @@
prosrc => 'bpcharlen' },
{ oid => '1319',
- proname => 'xideqint4', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'xid int4', prosrc => 'xideq' },
+ proname => 'xideqint8', proleakproof => 't', prorettype => 'bool',
+ proargtypes => 'xid int8', prosrc => 'xideq' },
{ oid => '3309',
- proname => 'xidneqint4', proleakproof => 't', prorettype => 'bool',
- proargtypes => 'xid int4', prosrc => 'xidneq' },
+ proname => 'xidneqint8', proleakproof => 't', prorettype => 'bool',
+ proargtypes => 'xid int8', prosrc => 'xidneq' },
{ oid => '1326',
proname => 'interval_div', prorettype => 'interval',
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index df45879463..9ecd608aa9 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -95,9 +95,9 @@
typinput => 'tidin', typoutput => 'tidout', typreceive => 'tidrecv',
typsend => 'tidsend', typalign => 's' },
{ oid => '28', array_type_oid => '1011', descr => 'transaction id',
- typname => 'xid', typlen => '4', typbyval => 't', typcategory => 'U',
+ typname => 'xid', typlen => '8', typbyval => 'FLOAT8PASSBYVAL', typcategory => 'U',
typinput => 'xidin', typoutput => 'xidout', typreceive => 'xidrecv',
- typsend => 'xidsend', typalign => 'i' },
+ typsend => 'xidsend', typalign => 'x' },
{ oid => '29', array_type_oid => '1012',
descr => 'command identifier type, sequence in transaction id',
typname => 'cid', typlen => '4', typbyval => 't', typcategory => 'U',
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 48a2559137..71f5f547f4 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -300,6 +300,11 @@ DECLARE_UNIQUE_INDEX(pg_type_typname_nsp_index, 2704, TypeNameNspIndexId, on pg_
#define TYPALIGN_SHORT 's' /* short alignment (typically 2 bytes) */
#define TYPALIGN_INT 'i' /* int alignment (typically 4 bytes) */
#define TYPALIGN_DOUBLE 'd' /* double alignment (often 8 bytes) */
+/*
+ * We need to use alignment sutable for 8-byte XID values.
+ * On system like AIX double alignment (4 bytes) is not enough.
+ */
+#define TYPALIGN_XID 'x'
#define TYPSTORAGE_PLAIN 'p' /* type not prepared for toasting */
#define TYPSTORAGE_EXTERNAL 'e' /* toastable, don't try to compress */
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 5d816ba7f4..7255b2eeda 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -213,12 +213,12 @@ typedef enum VacOptValue
*/
typedef struct VacuumParams
{
- bits32 options; /* bitmask of VACOPT_* */
- int freeze_min_age; /* min freeze age, -1 to use default */
- int freeze_table_age; /* age at which to scan whole table */
- int multixact_freeze_min_age; /* min multixact freeze age, -1 to
+ bits32 options; /* bitmask of VacuumOption */
+ int64 freeze_min_age; /* min freeze age, -1 to use default */
+ int64 freeze_table_age; /* age at which to scan whole table */
+ int64 multixact_freeze_min_age; /* min multixact freeze age, -1 to
* use default */
- int multixact_freeze_table_age; /* multixact age at which to scan
+ int64 multixact_freeze_table_age; /* multixact age at which to scan
* whole table */
bool is_wraparound; /* force a for-wraparound vacuum */
int log_min_duration; /* minimum execution threshold in ms at
@@ -252,12 +252,12 @@ typedef struct VacDeadItems
/* GUC parameters */
extern PGDLLIMPORT int default_statistics_target; /* PGDLLIMPORT for PostGIS */
-extern PGDLLIMPORT int vacuum_freeze_min_age;
-extern PGDLLIMPORT int vacuum_freeze_table_age;
-extern PGDLLIMPORT int vacuum_multixact_freeze_min_age;
-extern PGDLLIMPORT int vacuum_multixact_freeze_table_age;
-extern PGDLLIMPORT int vacuum_failsafe_age;
-extern PGDLLIMPORT int vacuum_multixact_failsafe_age;
+extern PGDLLIMPORT int64 vacuum_freeze_min_age;
+extern PGDLLIMPORT int64 vacuum_freeze_table_age;
+extern PGDLLIMPORT int64 vacuum_multixact_freeze_min_age;
+extern PGDLLIMPORT int64 vacuum_multixact_freeze_table_age;
+extern PGDLLIMPORT int64 vacuum_failsafe_age;
+extern PGDLLIMPORT int64 vacuum_multixact_failsafe_age;
/* Variables for cost-based parallel vacuum */
extern PGDLLIMPORT pg_atomic_uint32 *VacuumSharedCostBalance;
@@ -287,10 +287,10 @@ extern void vac_update_relstats(Relation relation,
bool *minmulti_updated,
bool in_outer_xact);
extern bool vacuum_set_xid_limits(Relation rel,
- int freeze_min_age,
- int multixact_freeze_min_age,
- int freeze_table_age,
- int multixact_freeze_table_age,
+ int64 freeze_min_age,
+ int64 multixact_freeze_min_age,
+ int64 freeze_table_age,
+ int64 multixact_freeze_table_age,
TransactionId *oldestXmin,
MultiXactId *oldestMxact,
TransactionId *freezeLimit,
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 380a82b9de..3711cac3da 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -281,6 +281,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
#define PG_GETARG_FLOAT4(n) DatumGetFloat4(PG_GETARG_DATUM(n))
#define PG_GETARG_FLOAT8(n) DatumGetFloat8(PG_GETARG_DATUM(n))
#define PG_GETARG_INT64(n) DatumGetInt64(PG_GETARG_DATUM(n))
+#define PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n))
/* use this if you want the raw, possibly-toasted input datum: */
#define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n))
/* use this if you want the input datum de-toasted: */
@@ -367,6 +368,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
#define PG_RETURN_FLOAT8(x) return Float8GetDatum(x)
#define PG_RETURN_INT64(x) return Int64GetDatum(x)
#define PG_RETURN_UINT64(x) return UInt64GetDatum(x)
+#define PG_RETURN_TRANSACTIONID(x) return TransactionIdGetDatum(x)
/* RETURN macros for other pass-by-ref types will typically look like this: */
#define PG_RETURN_BYTEA_P(x) PG_RETURN_POINTER(x)
#define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x)
diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h
index dc991626ba..78d4d08c4a 100644
--- a/src/include/nodes/pg_list.h
+++ b/src/include/nodes/pg_list.h
@@ -44,6 +44,7 @@ typedef union ListCell
{
void *ptr_value;
int int_value;
+ int64 int64_value;
Oid oid_value;
TransactionId xid_value;
} ListCell;
@@ -169,6 +170,7 @@ list_length(const List *l)
*/
#define lfirst(lc) ((lc)->ptr_value)
#define lfirst_int(lc) ((lc)->int_value)
+#define lfirst_int64(lc) ((lc)->int64_value)
#define lfirst_oid(lc) ((lc)->oid_value)
#define lfirst_xid(lc) ((lc)->xid_value)
#define lfirst_node(type,lc) castNode(type, lfirst(lc))
@@ -195,6 +197,7 @@ list_length(const List *l)
#define llast(l) lfirst(list_last_cell(l))
#define llast_int(l) lfirst_int(list_last_cell(l))
+#define llast_int64(l) lfirst_int64(list_last_cell(l))
#define llast_oid(l) lfirst_oid(list_last_cell(l))
#define llast_xid(l) lfirst_xid(list_last_cell(l))
#define llast_node(type,l) castNode(type, llast(l))
@@ -557,6 +560,7 @@ extern List *list_make5_impl(NodeTag t, ListCell datum1, ListCell datum2,
extern pg_nodiscard List *lappend(List *list, void *datum);
extern pg_nodiscard List *lappend_int(List *list, int datum);
+extern pg_nodiscard List *lappend_int64(List *list, int64 datum);
extern pg_nodiscard List *lappend_oid(List *list, Oid datum);
extern pg_nodiscard List *lappend_xid(List *list, TransactionId datum);
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index c5a80b829e..c1b49b018d 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -775,6 +775,9 @@
# endif
#endif
+/* Postgres Pro use 64bit xids */
+#undef XID_IS_64BIT
+
/* Size of a WAL file block. This need have no particular relation to BLCKSZ.
XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
diff --git a/src/include/port/pg_lfind.h b/src/include/port/pg_lfind.h
index 0625cac6b5..40e0b1bd78 100644
--- a/src/include/port/pg_lfind.h
+++ b/src/include/port/pg_lfind.h
@@ -81,35 +81,21 @@ pg_lfind8_le(uint8 key, uint8 *base, uint32 nelem)
}
/*
- * pg_lfind32
+ * pg_lfind64
*
* Return true if there is an element in 'base' that equals 'key', otherwise
* return false.
*/
static inline bool
-pg_lfind32(uint32 key, uint32 *base, uint32 nelem)
+pg_lfind64(uint64 key, uint64 *base, uint32 nelem)
{
- uint32 i = 0;
-
-#ifndef USE_NO_SIMD
-
- /*
- * For better instruction-level parallelism, each loop iteration operates
- * on a block of four registers. Testing for SSE2 has showed this is ~40%
- * faster than using a block of two registers.
- */
- const Vector32 keys = vector32_broadcast(key); /* load copies of key */
- const uint32 nelem_per_vector = sizeof(Vector32) / sizeof(uint32);
- const uint32 nelem_per_iteration = 4 * nelem_per_vector;
-
- /* round down to multiple of elements per iteration */
- const uint32 tail_idx = nelem & ~(nelem_per_iteration - 1);
-
+ uint32 i,
+ iterations;
#if defined(USE_ASSERT_CHECKING)
bool assert_result = false;
/* pre-compute the result for assert checking */
- for (i = 0; i < nelem; i++)
+ for (i = 0; i < nelem; ++i)
{
if (key == base[i])
{
@@ -119,62 +105,127 @@ pg_lfind32(uint32 key, uint32 *base, uint32 nelem)
}
#endif
- for (i = 0; i < tail_idx; i += nelem_per_iteration)
+#define UNROLL_FACTOR 8
+ StaticAssertStmt((UNROLL_FACTOR & (UNROLL_FACTOR - 1)) == 0,
+ "Loop unroll factor must be power of 2");
+ iterations = nelem & ~(UNROLL_FACTOR - 1);
+ for (i = 0; i < iterations; i += UNROLL_FACTOR)
{
- Vector32 vals1,
- vals2,
- vals3,
- vals4,
- result1,
- result2,
- result3,
- result4,
- tmp1,
- tmp2,
- result;
-
- /* load the next block into 4 registers */
- vector32_load(&vals1, &base[i]);
- vector32_load(&vals2, &base[i + nelem_per_vector]);
- vector32_load(&vals3, &base[i + nelem_per_vector * 2]);
- vector32_load(&vals4, &base[i + nelem_per_vector * 3]);
-
- /* compare each value to the key */
- result1 = vector32_eq(keys, vals1);
- result2 = vector32_eq(keys, vals2);
- result3 = vector32_eq(keys, vals3);
- result4 = vector32_eq(keys, vals4);
-
- /* combine the results into a single variable */
- tmp1 = vector32_or(result1, result2);
- tmp2 = vector32_or(result3, result4);
- result = vector32_or(tmp1, tmp2);
-
- /* see if there was a match */
- if (vector32_is_highbit_set(result))
+ if (base[0] == key || base[1] == key || base[2] == key ||
+ base[3] == key || base[4] == key || base[5] == key ||
+ base[6] == key || base[7] == key)
{
+#if defined(USE_ASSERT_CHECKING)
Assert(assert_result == true);
+#endif
return true;
}
+ base += UNROLL_FACTOR;
}
-#endif /* ! USE_NO_SIMD */
/* Process the remaining elements one at a time. */
- for (; i < nelem; i++)
+ iterations = nelem & (UNROLL_FACTOR - 1);
+ for (i = 0; i < iterations; ++i)
{
- if (key == base[i])
+ if (key == *base++)
{
-#ifndef USE_NO_SIMD
+#if defined(USE_ASSERT_CHECKING)
Assert(assert_result == true);
#endif
return true;
}
}
-#ifndef USE_NO_SIMD
+#if defined(USE_ASSERT_CHECKING)
Assert(assert_result == false);
#endif
return false;
+// uint32 i = 0;
+//
+//#ifndef USE_NO_SIMD
+//
+// /*
+// * For better instruction-level parallelism, each loop iteration operates
+// * on a block of four registers. Testing for SSE2 has showed this is ~40%
+// * faster than using a block of two registers.
+// */
+// const Vector32 keys = vector32_broadcast(key); /* load copies of key */
+// const uint32 nelem_per_vector = sizeof(Vector32) / sizeof(uint32);
+// const uint32 nelem_per_iteration = 4 * nelem_per_vector;
+//
+// /* round down to multiple of elements per iteration */
+// const uint32 tail_idx = nelem & ~(nelem_per_iteration - 1);
+//
+//#if defined(USE_ASSERT_CHECKING)
+// bool assert_result = false;
+//
+// /* pre-compute the result for assert checking */
+// for (i = 0; i < nelem; i++)
+// {
+// if (key == base[i])
+// {
+// assert_result = true;
+// break;
+// }
+// }
+//#endif
+//
+// for (i = 0; i < tail_idx; i += nelem_per_iteration)
+// {
+// Vector32 vals1,
+// vals2,
+// vals3,
+// vals4,
+// result1,
+// result2,
+// result3,
+// result4,
+// tmp1,
+// tmp2,
+// result;
+//
+// /* load the next block into 4 registers */
+// vector32_load(&vals1, &base[i]);
+// vector32_load(&vals2, &base[i + nelem_per_vector]);
+// vector32_load(&vals3, &base[i + nelem_per_vector * 2]);
+// vector32_load(&vals4, &base[i + nelem_per_vector * 3]);
+//
+// /* compare each value to the key */
+// result1 = vector32_eq(keys, vals1);
+// result2 = vector32_eq(keys, vals2);
+// result3 = vector32_eq(keys, vals3);
+// result4 = vector32_eq(keys, vals4);
+//
+// /* combine the results into a single variable */
+// tmp1 = vector32_or(result1, result2);
+// tmp2 = vector32_or(result3, result4);
+// result = vector32_or(tmp1, tmp2);
+//
+// /* see if there was a match */
+// if (vector32_is_highbit_set(result))
+// {
+// Assert(assert_result == true);
+// return true;
+// }
+// }
+//#endif /* ! USE_NO_SIMD */
+//
+// /* Process the remaining elements one at a time. */
+// for (; i < nelem; i++)
+// {
+// if (key == base[i])
+// {
+//#ifndef USE_NO_SIMD
+// Assert(assert_result == true);
+//#endif
+// return true;
+// }
+// }
+//
+//#ifndef USE_NO_SIMD
+// Assert(assert_result == false);
+//#endif
+// return false;
}
#endif /* PG_LFIND_H */
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 5f6a1e3d5a..cf46515829 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -428,6 +428,9 @@ typedef struct NullableDatum
#define SIZEOF_DATUM SIZEOF_VOID_P
+static uint64 DatumGetUInt64(Datum X);
+static Datum UInt64GetDatum(uint64 X);
+
/*
* DatumGetBool
* Returns boolean value of a datum.
@@ -609,7 +612,7 @@ ObjectIdGetDatum(Oid X)
static inline TransactionId
DatumGetTransactionId(Datum X)
{
- return (TransactionId) X;
+ return DatumGetUInt64(X);
}
/*
@@ -619,7 +622,7 @@ DatumGetTransactionId(Datum X)
static inline Datum
TransactionIdGetDatum(TransactionId X)
{
- return (Datum) X;
+ return UInt64GetDatum(X);
}
/*
@@ -629,7 +632,7 @@ TransactionIdGetDatum(TransactionId X)
static inline Datum
MultiXactIdGetDatum(MultiXactId X)
{
- return (Datum) X;
+ return UInt64GetDatum(X);
}
/*
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 9d40fd6d54..03024361ea 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -37,8 +37,8 @@ extern PGDLLIMPORT int autovacuum_vac_ins_thresh;
extern PGDLLIMPORT double autovacuum_vac_ins_scale;
extern PGDLLIMPORT int autovacuum_anl_thresh;
extern PGDLLIMPORT double autovacuum_anl_scale;
-extern PGDLLIMPORT int autovacuum_freeze_max_age;
-extern PGDLLIMPORT int autovacuum_multixact_freeze_max_age;
+extern PGDLLIMPORT int64 autovacuum_freeze_max_age;
+extern PGDLLIMPORT int64 autovacuum_multixact_freeze_max_age;
extern PGDLLIMPORT double autovacuum_vac_cost_delay;
extern PGDLLIMPORT int autovacuum_vac_cost_limit;
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index 406db6be78..df62ffa605 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -40,10 +40,10 @@
*/
#define BUF_REFCOUNT_ONE 1
#define BUF_REFCOUNT_MASK ((1U << 18) - 1)
-#define BUF_USAGECOUNT_MASK 0x003C0000U
+#define BUF_USAGECOUNT_MASK 0x001C0000U
#define BUF_USAGECOUNT_ONE (1U << 18)
#define BUF_USAGECOUNT_SHIFT 18
-#define BUF_FLAG_MASK 0xFFC00000U
+#define BUF_FLAG_MASK 0xFFE00000U
/* Get refcount and usagecount from buffer state */
#define BUF_STATE_GET_REFCOUNT(state) ((state) & BUF_REFCOUNT_MASK)
@@ -55,6 +55,7 @@
* Note: BM_TAG_VALID essentially means that there is a buffer hashtable
* entry associated with the buffer's tag.
*/
+#define BM_CONVERTED (1U << 21) /* buffer were converted to 64xid */
#define BM_LOCKED (1U << 22) /* buffer header is locked */
#define BM_DIRTY (1U << 23) /* data needs writing */
#define BM_VALID (1U << 24) /* data is valid */
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 6f4dfa0960..fc9d1af846 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -157,8 +157,12 @@ extern void BufferGetTag(Buffer buffer, RelFileLocator *rlocator,
ForkNumber *forknum, BlockNumber *blknum);
extern void MarkBufferDirtyHint(Buffer buffer, bool buffer_std);
+extern void MarkBufferConverted(Buffer buffer, bool converted);
+extern bool IsBufferConverted(Buffer buffer);
extern void UnlockBuffers(void);
+extern bool IsBufferLocked(Buffer buffer);
+extern bool IsBufferLockedExclusive(Buffer buffer);
extern void LockBuffer(Buffer buffer, int mode);
extern bool ConditionalLockBuffer(Buffer buffer);
extern void LockBufferForCleanup(Buffer buffer);
@@ -184,6 +188,8 @@ extern void AtProcExit_LocalBuffers(void);
extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype);
extern void FreeAccessStrategy(BufferAccessStrategy strategy);
+/* old tuple format support */
+extern void convert_page(Relation rel, Page orig_page, Buffer buf, BlockNumber blkno);
/* inline functions */
diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h
index 2708c4b683..87375bbf79 100644
--- a/src/include/storage/bufpage.h
+++ b/src/include/storage/bufpage.h
@@ -14,10 +14,13 @@
#ifndef BUFPAGE_H
#define BUFPAGE_H
+#include "access/transam.h"
#include "access/xlogdefs.h"
#include "storage/block.h"
#include "storage/item.h"
#include "storage/off.h"
+#include "postgres.h"
+#include "utils/rel.h"
/*
* A postgres disk page is an abstraction layered on top of a postgres
@@ -163,12 +166,41 @@ typedef struct PageHeaderData
LocationIndex pd_upper; /* offset to end of free space */
LocationIndex pd_special; /* offset to start of special space */
uint16 pd_pagesize_version;
- TransactionId pd_prune_xid; /* oldest prunable XID, or zero if none */
+ ShortTransactionId pd_prune_xid; /* oldest prunable XID, or zero if
+ * none */
ItemIdData pd_linp[FLEXIBLE_ARRAY_MEMBER]; /* line pointer array */
} PageHeaderData;
typedef PageHeaderData *PageHeader;
+
+/*
+ * HeapPageSpecialData -- data that stored at the end of each heap page.
+ *
+ * pd_xid_base - base value for transaction IDs on page
+ * pd_multi_base - base value for multixact IDs on page
+ *
+ * pd_xid_base and pd_multi_base are base values for calculation of transaction
+ * identifiers from t_xmin and t_xmax in each heap tuple header on the page.
+ */
+typedef struct HeapPageSpecialData
+{
+ TransactionId pd_xid_base; /* base value for transaction IDs on page */
+ TransactionId pd_multi_base; /* base value for multixact IDs on page */
+} HeapPageSpecialData;
+
+typedef HeapPageSpecialData *HeapPageSpecial;
+
+typedef struct ToastPageSpecialData
+{
+ TransactionId pd_xid_base; /* base value for transaction IDs on page */
+} ToastPageSpecialData;
+
+typedef ToastPageSpecialData *ToastPageSpecial;
+
+extern PGDLLIMPORT HeapPageSpecial heapDoubleXmaxSpecial;
+extern PGDLLIMPORT ToastPageSpecial toastDoubleXmaxSpecial;
+
/*
* pd_flags contains the following flag bits. Undefined bits are initialized
* to zero and may be used in the future.
@@ -200,7 +232,7 @@ typedef PageHeaderData *PageHeader;
* As of Release 9.3, the checksum version must also be considered when
* handling pages.
*/
-#define PG_PAGE_LAYOUT_VERSION 4
+#define PG_PAGE_LAYOUT_VERSION 5
#define PG_DATA_CHECKSUM_VERSION 1
/* ----------------------------------------------------------------
@@ -440,18 +472,177 @@ PageClearAllVisible(Page page)
}
/*
- * These two require "access/transam.h", so left as macros.
+ * Check if page is in "double xmax" format.
*/
-#define PageSetPrunable(page, xid) \
-do { \
- Assert(TransactionIdIsNormal(xid)); \
- if (!TransactionIdIsValid(((PageHeader) (page))->pd_prune_xid) || \
- TransactionIdPrecedes(xid, ((PageHeader) (page))->pd_prune_xid)) \
- ((PageHeader) (page))->pd_prune_xid = (xid); \
-} while (0)
-#define PageClearPrunable(page) \
- (((PageHeader) (page))->pd_prune_xid = InvalidTransactionId)
+static inline bool
+HeapPageIsDoubleXmax(Page page)
+{
+ return ((PageHeader) (page))->pd_special == BLCKSZ;
+}
+/*
+ * Get pointer to HeapPageSpecialData.
+ *
+ * Can be used for non-consistent reads from non-locked pages.
+ *
+ * Return doubleXmaxSpecial when pd_special == BLCKSZ (i.e. "double xmax"
+ * format).
+ */
+static inline HeapPageSpecial
+HeapPageGetSpecialNoAssert(Page page)
+{
+ if (HeapPageIsDoubleXmax(page))
+ return heapDoubleXmaxSpecial;
+
+ return (HeapPageSpecial) ((char *) page +
+ ((PageHeader) page)->pd_special);
+}
+
+/*
+ * Get pointer to ToastPageSpecialData.
+ *
+ * Can be used for non-consistent reads from non-locked pages.
+ *
+ * Return doubleXmaxSpecial when pd_special == BLCKSZ (i.e. "double xmax"
+ * format).
+ */
+static inline ToastPageSpecial
+ToastPageGetSpecialNoAssert(Page page)
+{
+ if (HeapPageIsDoubleXmax(page))
+ return toastDoubleXmaxSpecial;
+
+ return (ToastPageSpecial) ((char *) page +
+ ((PageHeader) page)->pd_special);
+}
+
+/*
+ * Wrapper for HeapPageGetSpecialNoAssert for general use.
+ */
+static inline HeapPageSpecial
+HeapPageGetSpecial(Page page)
+{
+ if (HeapPageIsDoubleXmax(page))
+ return heapDoubleXmaxSpecial;
+
+ Assert(((PageHeader) page)->pd_special ==
+ BLCKSZ - MAXALIGN(sizeof(HeapPageSpecialData)));
+
+ return (HeapPageSpecial) ((char *) page +
+ ((PageHeader) page)->pd_special);
+}
+
+/*
+ * Wrapper for ToastPageGetSpecialNoAssert for general use.
+ */
+static inline ToastPageSpecial
+ToastPageGetSpecial(Page page)
+{
+ if (HeapPageIsDoubleXmax(page))
+ return toastDoubleXmaxSpecial;
+
+ Assert(((PageHeader) page)->pd_special ==
+ BLCKSZ - MAXALIGN(sizeof(ToastPageSpecialData)));
+
+ return (ToastPageSpecial) ((char *) page +
+ ((PageHeader) page)->pd_special);
+}
+
+/*
+ * Set pd_prune_xid.
+ */
+static inline void
+HeapPageSetPruneXid(Page page, TransactionId xid, bool is_toast)
+{
+ TransactionId base;
+
+ if (HeapPageIsDoubleXmax(page))
+ return;
+
+ if (!TransactionIdIsNormal(xid))
+ {
+ ((PageHeader) (page))->pd_prune_xid = xid;
+ return;
+ }
+
+ base = is_toast ? ToastPageGetSpecial(page)->pd_xid_base :
+ HeapPageGetSpecial(page)->pd_xid_base;
+
+ ((PageHeader) (page))->pd_prune_xid = NormalTransactionIdToShort(base, xid);
+ Assert(((PageHeader) (page))->pd_prune_xid <= MaxShortTransactionId);
+}
+
+static inline void
+ToastPageSetPruneXid(Page page, TransactionId xid)
+{
+ if (HeapPageIsDoubleXmax(page))
+ return;
+
+ if (!TransactionIdIsNormal(xid))
+ {
+ ((PageHeader) (page))->pd_prune_xid = xid;
+ return;
+ }
+
+ ((PageHeader) (page))->pd_prune_xid =
+ NormalTransactionIdToShort(ToastPageGetSpecial(page)->pd_xid_base, (xid));
+
+ Assert(((PageHeader) (page))->pd_prune_xid <= MaxShortTransactionId);
+}
+
+/*
+ * Get pd_prune_xid from locked page.
+ */
+static inline TransactionId
+HeapPageGetPruneXid(Page page, bool is_toast)
+{
+ TransactionId base;
+
+ if (HeapPageIsDoubleXmax(page))
+ return ((PageHeader) (page))->pd_prune_xid;
+
+ base = is_toast ? ToastPageGetSpecial(page)->pd_xid_base :
+ HeapPageGetSpecial(page)->pd_xid_base;
+
+ return ShortTransactionIdToNormal(base,
+ ((PageHeader) (page))->pd_prune_xid);
+}
+
+static inline void
+PageSetPrunable(Page page, TransactionId xid, bool is_toast)
+{
+ TransactionId prune_xid;
+
+ Assert(TransactionIdIsNormal(xid));
+
+ if (HeapPageIsDoubleXmax(page))
+ return;
+
+ prune_xid = HeapPageGetPruneXid(page, is_toast);
+ if ((!TransactionIdIsValid(prune_xid) ||
+ TransactionIdPrecedes(xid, prune_xid)))
+ {
+ HeapPageSetPruneXid(page, xid, is_toast);
+ }
+}
+
+/*
+ * Get pd_prune_xid from non-locked page. May return invalid value, but doen't
+ * causes assert failures.
+ */
+static inline TransactionId
+HeapPageGetPruneXidNoAssert(Page page, bool is_toast)
+{
+ TransactionId base;
+
+ if (HeapPageIsDoubleXmax(page))
+ return ((PageHeader) (page))->pd_prune_xid;
+
+ base = is_toast ? ToastPageGetSpecialNoAssert(page)->pd_xid_base :
+ HeapPageGetSpecialNoAssert(page)->pd_xid_base;
+ return ShortTransactionIdToNormal(base,
+ ((PageHeader) (page))->pd_prune_xid);
+}
/* ----------------------------------------------------------------
* extern declarations
@@ -485,6 +676,21 @@ do { \
StaticAssertDecl(BLCKSZ == ((BLCKSZ / sizeof(size_t)) * sizeof(size_t)),
"BLCKSZ has to be a multiple of sizeof(size_t)");
+/*
+ * Tuple defrag support for PageRepairFragmentation and PageIndexMultiDelete
+ */
+typedef struct ItemIdCompactData
+{
+ uint16 offsetindex; /* linp array index */
+ int16 itemoff; /* page offset of item data */
+ uint16 alignedlen; /* MAXALIGN(item data len) */
+} ItemIdCompactData;
+
+typedef ItemIdCompactData *ItemIdCompact;
+typedef RelationData *Relation;
+
+extern int itemoffcompare(const void *item1, const void *item2);
+
extern void PageInit(Page page, Size pageSize, Size specialSize);
extern bool PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags);
extern OffsetNumber PageAddItemExtended(Page page, Item item, Size size,
@@ -493,7 +699,7 @@ extern Page PageGetTempPage(Page page);
extern Page PageGetTempPageCopy(Page page);
extern Page PageGetTempPageCopySpecial(Page page);
extern void PageRestoreTempPage(Page tempPage, Page oldPage);
-extern void PageRepairFragmentation(Page page);
+extern void PageRepairFragmentation(Page page, bool is_toast);
extern void PageTruncateLinePointerArray(Page page);
extern Size PageGetFreeSpace(Page page);
extern Size PageGetFreeSpaceForMultipleTuples(Page page, int ntups);
diff --git a/src/include/storage/itemid.h b/src/include/storage/itemid.h
index e33637ff21..442a72d658 100644
--- a/src/include/storage/itemid.h
+++ b/src/include/storage/itemid.h
@@ -78,6 +78,8 @@ typedef uint16 ItemLength;
#define ItemIdGetRedirect(itemId) \
((itemId)->lp_off)
+#define ItemIdGetTupleEnd(itemId) \
+ (MAXALIGN(ItemIdGetLength((itemId))) + ItemIdGetOffset((itemId)))
/*
* ItemIdIsValid
* True iff item identifier is valid.
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index e4e1495b24..0e0cd79bb0 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -227,8 +227,8 @@ typedef struct LOCKTAG
/* ID info for a transaction is its TransactionId */
#define SET_LOCKTAG_TRANSACTION(locktag,xid) \
- ((locktag).locktag_field1 = (xid), \
- (locktag).locktag_field2 = 0, \
+ ((locktag).locktag_field1 = (uint32)((xid) & 0xFFFFFFFF), \
+ (locktag).locktag_field2 = (uint32)((xid) >> 32), \
(locktag).locktag_field3 = 0, \
(locktag).locktag_field4 = 0, \
(locktag).locktag_type = LOCKTAG_TRANSACTION, \
@@ -237,8 +237,8 @@ typedef struct LOCKTAG
/* ID info for a virtual transaction is its VirtualTransactionId */
#define SET_LOCKTAG_VIRTUALTRANSACTION(locktag,vxid) \
((locktag).locktag_field1 = (vxid).backendId, \
- (locktag).locktag_field2 = (vxid).localTransactionId, \
- (locktag).locktag_field3 = 0, \
+ (locktag).locktag_field2 = (uint32)((vxid).localTransactionId & 0xFFFFFFFF), \
+ (locktag).locktag_field3 = (uint32)((vxid).localTransactionId >> 32), \
(locktag).locktag_field4 = 0, \
(locktag).locktag_type = LOCKTAG_VIRTUALTRANSACTION, \
(locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
@@ -248,9 +248,9 @@ typedef struct LOCKTAG
* its speculative insert counter.
*/
#define SET_LOCKTAG_SPECULATIVE_INSERTION(locktag,xid,token) \
- ((locktag).locktag_field1 = (xid), \
- (locktag).locktag_field2 = (token), \
- (locktag).locktag_field3 = 0, \
+ ((locktag).locktag_field1 = (uint32)((xid) & 0xFFFFFFFF), \
+ (locktag).locktag_field2 = (uint32)((xid) >> 32), \
+ (locktag).locktag_field3 = (token), \
(locktag).locktag_field4 = 0, \
(locktag).locktag_type = LOCKTAG_SPECULATIVE_TOKEN, \
(locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index fdc18f8180..4ff7353e8c 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -17,6 +17,7 @@
#include "access/clog.h"
#include "access/xlogdefs.h"
#include "lib/ilist.h"
+#include "port/atomics.h"
#include "storage/latch.h"
#include "storage/lock.h"
#include "storage/pg_sema.h"
@@ -176,12 +177,12 @@ struct PGPROC
Latch procLatch; /* generic latch for process */
- TransactionId xid; /* id of top-level transaction currently being
+ pg_atomic_uint64 xid; /* id of top-level transaction currently being
* executed by this proc, if running and XID
* is assigned; else InvalidTransactionId.
* mirrored in ProcGlobal->xids[pgxactoff] */
- TransactionId xmin; /* minimal running XID as it was when we were
+ pg_atomic_uint64 xmin; /* minimal running XID as it was when we were
* starting our xact, excluding LAZY VACUUM:
* vacuum must not remove tuples deleted by
* xid >= xmin ! */
@@ -364,7 +365,7 @@ typedef struct PROC_HDR
PGPROC *allProcs;
/* Array mirroring PGPROC.xid for each PGPROC currently in the procarray */
- TransactionId *xids;
+ pg_atomic_uint64 *xids;
/*
* Array mirroring PGPROC.subxidStatus for each PGPROC currently in the
diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h
index f5da98dc73..209615f3cc 100644
--- a/src/include/storage/standby.h
+++ b/src/include/storage/standby.h
@@ -21,7 +21,7 @@
#include "storage/standbydefs.h"
/* User-settable GUC parameters */
-extern PGDLLIMPORT int vacuum_defer_cleanup_age;
+extern PGDLLIMPORT int64 vacuum_defer_cleanup_age;
extern PGDLLIMPORT int max_standby_archive_delay;
extern PGDLLIMPORT int max_standby_streaming_delay;
extern PGDLLIMPORT bool log_recovery_conflict_waits;
diff --git a/src/include/utils/combocid.h b/src/include/utils/combocid.h
index 80fe6d2cea..8465768b6f 100644
--- a/src/include/utils/combocid.h
+++ b/src/include/utils/combocid.h
@@ -15,7 +15,7 @@
#define COMBOCID_H
/*
- * HeapTupleHeaderGetCmin and HeapTupleHeaderGetCmax function prototypes
+ * HeapTupleGetCmin and HeapTupleGetCmax function prototypes
* are in access/htup.h, because that's where the macro definitions that
* those functions replaced used to be.
*/
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 7dc401cf0d..3e1e5a5e4a 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -308,12 +308,12 @@ typedef struct AutoVacOpts
int vacuum_ins_threshold;
int analyze_threshold;
int vacuum_cost_limit;
- int freeze_min_age;
- int freeze_max_age;
- int freeze_table_age;
- int multixact_freeze_min_age;
- int multixact_freeze_max_age;
- int multixact_freeze_table_age;
+ int64 freeze_min_age;
+ int64 freeze_max_age;
+ int64 freeze_table_age;
+ int64 multixact_freeze_min_age;
+ int64 multixact_freeze_max_age;
+ int64 multixact_freeze_table_age;
int log_min_duration;
float8 vacuum_cost_delay;
float8 vacuum_scale_factor;
diff --git a/src/include/utils/xid8.h b/src/include/utils/xid8.h
index 9c5ce241db..1fdd1e86c1 100644
--- a/src/include/utils/xid8.h
+++ b/src/include/utils/xid8.h
@@ -17,13 +17,13 @@
static inline FullTransactionId
DatumGetFullTransactionId(Datum X)
{
- return FullTransactionIdFromU64(DatumGetUInt64(X));
+ return FullTransactionIdFromXid(DatumGetUInt64(X));
}
static inline Datum
FullTransactionIdGetDatum(FullTransactionId X)
{
- return UInt64GetDatum(U64FromFullTransactionId(X));
+ return UInt64GetDatum(XidFromFullTransactionId(X));
}
#define PG_GETARG_FULLTRANSACTIONID(X) DatumGetFullTransactionId(PG_GETARG_DATUM(X))
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 8f21e0d701..6772f8c360 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -2664,7 +2664,7 @@ validate_plperl_function(plperl_proc_ptr *proc_ptr, HeapTuple procTup)
* This is needed because CREATE OR REPLACE FUNCTION can modify the
* function's pg_proc entry without changing its OID.
************************************************************/
- uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetRawXmin(procTup->t_data) &&
+ uptodate = (prodesc->fn_xmin == HeapTupleGetRawXmin(procTup) &&
ItemPointerEquals(&prodesc->fn_tid, &procTup->t_self));
if (uptodate)
@@ -2788,7 +2788,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger, bool is_event_trigger)
MemoryContextSetIdentifier(proc_cxt, prodesc->proname);
prodesc->fn_cxt = proc_cxt;
prodesc->fn_refcount = 0;
- prodesc->fn_xmin = HeapTupleHeaderGetRawXmin(procTup->t_data);
+ prodesc->fn_xmin = HeapTupleGetRawXmin(procTup);
prodesc->fn_tid = procTup->t_self;
prodesc->nargs = procStruct->pronargs;
prodesc->arg_out_func = (FmgrInfo *) palloc0(prodesc->nargs * sizeof(FmgrInfo));
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index b286f2a50c..61db613c2f 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -171,7 +171,7 @@ recheck:
if (function)
{
/* We have a compiled function, but is it still valid? */
- if (function->fn_xmin == HeapTupleHeaderGetRawXmin(procTup->t_data) &&
+ if (function->fn_xmin == HeapTupleGetRawXmin(procTup) &&
ItemPointerEquals(&function->fn_tid, &procTup->t_self))
function_valid = true;
else
@@ -348,7 +348,7 @@ do_compile(FunctionCallInfo fcinfo,
function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
MemoryContextSetIdentifier(func_cxt, function->fn_signature);
function->fn_oid = fcinfo->flinfo->fn_oid;
- function->fn_xmin = HeapTupleHeaderGetRawXmin(procTup->t_data);
+ function->fn_xmin = HeapTupleGetRawXmin(procTup);
function->fn_tid = procTup->t_self;
function->fn_input_collation = fcinfo->fncollation;
function->fn_cxt = func_cxt;
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index a647342948..6763b6a4b7 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -7376,6 +7376,7 @@ deconstruct_composite_datum(Datum value, HeapTupleData *tmptup)
tmptup->t_len = HeapTupleHeaderGetDatumLength(td);
ItemPointerSetInvalid(&(tmptup->t_self));
tmptup->t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(tmptup);
tmptup->t_data = td;
/* Extract rowtype info and find a tupdesc */
@@ -7550,6 +7551,7 @@ exec_move_row_from_datum(PLpgSQL_execstate *estate,
tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
ItemPointerSetInvalid(&(tmptup.t_self));
tmptup.t_tableOid = InvalidOid;
+ HeapTupleSetZeroBase(&tmptup);
tmptup.t_data = td;
/* Extract rowtype info */
diff --git a/src/pl/plpython/plpy_procedure.c b/src/pl/plpython/plpy_procedure.c
index 494f109b32..9884f74fa7 100644
--- a/src/pl/plpython/plpy_procedure.c
+++ b/src/pl/plpython/plpy_procedure.c
@@ -178,7 +178,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
proc->proname = pstrdup(NameStr(procStruct->proname));
MemoryContextSetIdentifier(cxt, proc->proname);
proc->pyname = pstrdup(procName);
- proc->fn_xmin = HeapTupleHeaderGetRawXmin(procTup->t_data);
+ proc->fn_xmin = HeapTupleGetRawXmin(procTup);
proc->fn_tid = procTup->t_self;
proc->fn_readonly = (procStruct->provolatile != PROVOLATILE_VOLATILE);
proc->is_setof = procStruct->proretset;
@@ -419,7 +419,7 @@ PLy_procedure_valid(PLyProcedure *proc, HeapTuple procTup)
return false;
/* If the pg_proc tuple has changed, it's not valid */
- if (!(proc->fn_xmin == HeapTupleHeaderGetRawXmin(procTup->t_data) &&
+ if (!(proc->fn_xmin == HeapTupleGetRawXmin(procTup) &&
ItemPointerEquals(&proc->fn_tid, &procTup->t_self)))
return false;
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index eaa98d42c2..bd5b071c13 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -1428,7 +1428,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
* function's pg_proc entry without changing its OID.
************************************************************/
if (prodesc != NULL &&
- prodesc->fn_xmin == HeapTupleHeaderGetRawXmin(procTup->t_data) &&
+ prodesc->fn_xmin == HeapTupleGetRawXmin(procTup) &&
ItemPointerEquals(&prodesc->fn_tid, &procTup->t_self))
{
/* It's still up-to-date, so we can use it */
@@ -1495,7 +1495,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid,
prodesc->internal_proname = pstrdup(internal_proname);
prodesc->fn_cxt = proc_cxt;
prodesc->fn_refcount = 0;
- prodesc->fn_xmin = HeapTupleHeaderGetRawXmin(procTup->t_data);
+ prodesc->fn_xmin = HeapTupleGetRawXmin(procTup);
prodesc->fn_tid = procTup->t_self;
prodesc->nargs = procStruct->pronargs;
prodesc->arg_out_func = (FmgrInfo *) palloc0(prodesc->nargs * sizeof(FmgrInfo));
diff --git a/src/test/Makefile b/src/test/Makefile
index dbd3192874..8e0f39289e 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -12,7 +12,8 @@ subdir = src/test
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
-SUBDIRS = perl regress isolation modules authentication recovery subscription
+SUBDIRS = perl regress isolation modules authentication recovery subscription \
+ xid-64
ifeq ($(with_icu),yes)
SUBDIRS += icu
diff --git a/src/test/meson.build b/src/test/meson.build
index 241d9d48aa..650936bd66 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -5,6 +5,7 @@ subdir('authentication')
subdir('recovery')
subdir('subscription')
subdir('modules')
+subdir('xid-64')
if ssl.found()
subdir('ssl')
diff --git a/src/test/modules/test_lfind/test_lfind.c b/src/test/modules/test_lfind/test_lfind.c
index 82673d54c6..e4fd52c134 100644
--- a/src/test/modules/test_lfind/test_lfind.c
+++ b/src/test/modules/test_lfind/test_lfind.c
@@ -120,29 +120,29 @@ Datum
test_lfind32(PG_FUNCTION_ARGS)
{
#define TEST_ARRAY_SIZE 135
- uint32 test_array[TEST_ARRAY_SIZE] = {0};
+ uint64 test_array[TEST_ARRAY_SIZE] = {0};
test_array[8] = 1;
test_array[64] = 2;
test_array[TEST_ARRAY_SIZE - 1] = 3;
- if (pg_lfind32(1, test_array, 4))
- elog(ERROR, "pg_lfind32() found nonexistent element");
- if (!pg_lfind32(1, test_array, TEST_ARRAY_SIZE))
- elog(ERROR, "pg_lfind32() did not find existing element");
+ if (pg_lfind64(1, test_array, 4))
+ elog(ERROR, "pg_lfind64() found nonexistent element");
+ if (!pg_lfind64(1, test_array, TEST_ARRAY_SIZE))
+ elog(ERROR, "pg_lfind64() did not find existing element");
- if (pg_lfind32(2, test_array, 32))
- elog(ERROR, "pg_lfind32() found nonexistent element");
- if (!pg_lfind32(2, test_array, TEST_ARRAY_SIZE))
- elog(ERROR, "pg_lfind32() did not find existing element");
+ if (pg_lfind64(2, test_array, 32))
+ elog(ERROR, "pg_lfind64() found nonexistent element");
+ if (!pg_lfind64(2, test_array, TEST_ARRAY_SIZE))
+ elog(ERROR, "pg_lfind64() did not find existing element");
- if (pg_lfind32(3, test_array, 96))
- elog(ERROR, "pg_lfind32() found nonexistent element");
- if (!pg_lfind32(3, test_array, TEST_ARRAY_SIZE))
- elog(ERROR, "pg_lfind32() did not find existing element");
+ if (pg_lfind64(3, test_array, 96))
+ elog(ERROR, "pg_lfind64() found nonexistent element");
+ if (!pg_lfind64(3, test_array, TEST_ARRAY_SIZE))
+ elog(ERROR, "pg_lfind64() did not find existing element");
- if (pg_lfind32(4, test_array, TEST_ARRAY_SIZE))
- elog(ERROR, "pg_lfind32() found nonexistent element");
+ if (pg_lfind64(4, test_array, TEST_ARRAY_SIZE))
+ elog(ERROR, "pg_lfind64() found nonexistent element");
PG_RETURN_VOID();
}
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 4fef9c12e6..cb535c0906 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -476,7 +476,9 @@ sub init
mkdir $self->archive_dir;
PostgreSQL::Test::Utils::system_or_bail('initdb', '-D', $pgdata, '-A',
- 'trust', '-N', @{ $params{extra} });
+ 'trust', '-N',
+ '-x', '1249835483136', '-m', '2422361554944', '-o', '3594887626752',
+ @{ $params{extra} });
PostgreSQL::Test::Utils::system_or_bail($ENV{PG_REGRESS},
'--config-auth', $pgdata, @{ $params{auth_extra} });
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index e8e1a420bc..8329d2ff7e 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -57,7 +57,7 @@ $node_primary->init(has_archiving => 1, allows_streaming => 1);
# Bump the transaction ID epoch. This is useful to stress the portability
# of recovery_target_xid parsing.
-system_or_bail('pg_resetwal', '--epoch', '1', $node_primary->data_dir);
+system_or_bail('pg_resetwal', $node_primary->data_dir);
# Start it
$node_primary->start;
diff --git a/src/test/regress/expected/indirect_toast.out b/src/test/regress/expected/indirect_toast.out
index 44b54dc37f..313482b866 100644
--- a/src/test/regress/expected/indirect_toast.out
+++ b/src/test/regress/expected/indirect_toast.out
@@ -161,6 +161,14 @@ SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
("one-toasted,one-null, via indirect",0,1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
(5 rows)
+create or replace function random_string(len integer) returns text as $$
+select substr((select string_agg(r,'') from (select random()::text as r from generate_series(1,(len+15)/16)) s1), 1, len);
+$$ language sql;
+create table toasttest_main(t text);
+alter table toasttest_main alter column t set storage main;
+insert into toasttest_main (select random_string(len) from generate_series(7000,8000) len);
DROP TABLE indtoasttest;
+DROP TABLE toasttest_main;
DROP FUNCTION update_using_indirect();
+DROP FUNCTION random_string(integer);
RESET default_toast_compression;
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index dd4354fc7d..d52545b443 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -100,7 +100,7 @@ SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main'));
INSERT INTO large_tuple_test (select 3, NULL);
-- now this tuple won't fit on the second page, but the insert should
-- still succeed by extending the relation
-INSERT INTO large_tuple_test (select 4, repeat('a', 8126));
+INSERT INTO large_tuple_test (select 4, repeat('a', 8112));
DROP TABLE large_tuple_test;
--
-- check indirection (field/array assignment), cf bug #14265
@@ -980,3 +980,17 @@ insert into returningwrtest values (2, 'foo') returning returningwrtest;
(1 row)
drop table returningwrtest;
+-- Check for MaxHeapTupleSize
+create table maxheaptuplesize_test(value text);
+alter table maxheaptuplesize_test alter column value set storage external;
+insert into maxheaptuplesize_test values (repeat('x', 8104));
+insert into maxheaptuplesize_test values (repeat('x', 8112));
+insert into maxheaptuplesize_test values (repeat('x', 8120));
+insert into maxheaptuplesize_test values (repeat('x', 8128));
+insert into maxheaptuplesize_test values (repeat('x', 8136));
+insert into maxheaptuplesize_test values (repeat('x', 8144));
+insert into maxheaptuplesize_test values (repeat('x', 8152));
+insert into maxheaptuplesize_test values (repeat('x', 8160));
+insert into maxheaptuplesize_test values (repeat('x', 8168));
+insert into maxheaptuplesize_test values (repeat('x', 8176));
+drop table maxheaptuplesize_test;
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 330eb0f765..ce4a2ab432 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -197,7 +197,7 @@ WHERE p1.oid != p2.oid AND
ORDER BY 1, 2;
proargtypes | proargtypes
-----------------------------+--------------------------
- integer | xid
+ bigint | xid
timestamp without time zone | timestamp with time zone
bit | bit varying
txid_snapshot | pg_snapshot
@@ -705,7 +705,7 @@ int8(oid)
tideq(tid,tid)
timestamptz_cmp(timestamp with time zone,timestamp with time zone)
interval_cmp(interval,interval)
-xideqint4(xid,integer)
+xideqint8(xid,bigint)
timetz_eq(time with time zone,time with time zone)
timetz_ne(time with time zone,time with time zone)
timetz_lt(time with time zone,time with time zone)
@@ -819,7 +819,7 @@ pg_lsn_gt(pg_lsn,pg_lsn)
pg_lsn_ne(pg_lsn,pg_lsn)
pg_lsn_cmp(pg_lsn,pg_lsn)
xidneq(xid,xid)
-xidneqint4(xid,integer)
+xidneqint8(xid,bigint)
sha224(bytea)
sha256(bytea)
sha384(bytea)
diff --git a/src/test/regress/expected/select_views.out b/src/test/regress/expected/select_views.out
index 1aeed8452b..d3be84754c 100644
--- a/src/test/regress/expected/select_views.out
+++ b/src/test/regress/expected/select_views.out
@@ -2,9 +2,22 @@
-- SELECT_VIEWS
-- test the views defined in CREATE_VIEWS
--
-SELECT * FROM street;
+SELECT * FROM street ORDER BY name COLLATE "C", thepath::text COLLATE "C";
name | thepath | cname
------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------
+ 100th Ave | [(-122.1657,37.429),(-122.1647,37.432)] | Oakland
+ 107th Ave | [(-122.1555,37.403),(-122.1531,37.41)] | Oakland
+ 14th St | [(-122.299,37.147),(-122.3,37.148)] | Lafayette
+ 19th Ave | [(-122.2366,37.897),(-122.2359,37.905)] | Berkeley
+ 1st St | [(-121.75508,37.89294),(-121.753581,37.90031)] | Oakland
+ 5th St | [(-122.278,37),(-122.2792,37.005),(-122.2803,37.009)] | Lafayette
+ 5th St | [(-122.296,37.615),(-122.2953,37.598)] | Berkeley
+ 82nd Ave | [(-122.1695,37.596),(-122.1681,37.603)] | Berkeley
+ 85th Ave | [(-122.1877,37.466),(-122.186,37.476)] | Oakland
+ 89th Ave | [(-122.1822,37.459),(-122.1803,37.471)] | Oakland
+ 98th Ave | [(-122.1568,37.498),(-122.1558,37.502)] | Oakland
+ 98th Ave | [(-122.1693,37.438),(-122.1682,37.444)] | Oakland
+ 98th Ave | [(-122.2001,37.258),(-122.1974,37.27)] | Lafayette
Access Rd 25 | [(-121.9283,37.894),(-121.9283,37.9)] | Oakland
Ada St | [(-122.2487,37.398),(-122.2496,37.401)] | Lafayette
Agua Fria Creek | [(-121.9254,37.922),(-121.9281,37.889)] | Oakland
@@ -22,8 +35,8 @@ SELECT * FROM street;
Arroyo Las Positas | [(-121.7973,37.997),(-121.7957,37.005)] | Oakland
Arroyo Seco | [(-121.7073,37.766),(-121.6997,37.729)] | Oakland
Ash St | [(-122.0408,37.31),(-122.04,37.292)] | Oakland
- Avenue 134th | [(-122.1823,37.002),(-122.1851,37.992)] | Oakland
Avenue 134th | [(-122.1823,37.002),(-122.1851,37.992)] | Berkeley
+ Avenue 134th | [(-122.1823,37.002),(-122.1851,37.992)] | Oakland
Avenue 140th | [(-122.1656,37.003),(-122.1691,37.988)] | Oakland
Avenue 140th | [(-122.1656,37.003),(-122.1691,37.988)] | Berkeley
Avenue D | [(-122.298,37.848),(-122.3024,37.849)] | Berkeley
@@ -37,14 +50,14 @@ SELECT * FROM street;
Broadmore Ave | [(-122.095,37.522),(-122.0936,37.497)] | Oakland
Broadway | [(-122.2409,37.586),(-122.2395,37.601)] | Berkeley
Buckingham Blvd | [(-122.2231,37.59),(-122.2214,37.606)] | Berkeley
+ Butterfield Dr | [(-122.0838,37.002),(-122.0834,37.987)] | Berkeley
Butterfield Dr | [(-122.0838,37.002),(-122.0834,37.987)] | Oakland
Butterfield Dr | [(-122.0838,37.002),(-122.0834,37.987)] | Oakland
- Butterfield Dr | [(-122.0838,37.002),(-122.0834,37.987)] | Berkeley
C St | [(-122.1768,37.46),(-122.1749,37.435)] | Oakland
Calaveras Creek | [(-121.8203,37.035),(-121.8207,37.931)] | Oakland
Calaveras Creek | [(-121.8203,37.035),(-121.8207,37.931)] | Oakland
- California St | [(-122.2032,37.005),(-122.2016,37.996)] | Berkeley
California St | [(-122.2032,37.005),(-122.2016,37.996)] | Lafayette
+ California St | [(-122.2032,37.005),(-122.2016,37.996)] | Berkeley
Cameron Ave | [(-122.1316,37.502),(-122.1327,37.481)] | Oakland
Campus Dr | [(-122.1704,37.905),(-122.1678,37.868),(-122.1671,37.865)] | Berkeley
Capricorn Ave | [(-122.2176,37.404),(-122.2164,37.384)] | Lafayette
@@ -55,8 +68,8 @@ SELECT * FROM street;
Central Ave | [(-122.2343,37.602),(-122.2331,37.595)] | Berkeley
Chambers Dr | [(-122.2004,37.352),(-122.1972,37.368)] | Lafayette
Chambers Lane | [(-122.2001,37.359),(-122.1975,37.371)] | Lafayette
- Champion St | [(-122.214,37.991),(-122.2147,37.002)] | Berkeley
Champion St | [(-122.214,37.991),(-122.2147,37.002)] | Lafayette
+ Champion St | [(-122.214,37.991),(-122.2147,37.002)] | Berkeley
Chapman Dr | [(-122.0421,37.504),(-122.0414,37.498)] | Oakland
Charles St | [(-122.0255,37.505),(-122.0252,37.499)] | Oakland
Cherry St | [(-122.0437,37.42),(-122.0434,37.413)] | Oakland
@@ -77,9 +90,9 @@ SELECT * FROM street;
Cull Canyon Road | [(-122.0536,37.435),(-122.0499,37.315)] | Oakland
Cull Creek | [(-122.0624,37.875),(-122.0582,37.527)] | Berkeley
D St | [(-122.1811,37.505),(-122.1805,37.497)] | Oakland
+ Decoto Road | [(-122.0159,37.006),(-122.016,37.002),(-122.0164,37.993)] | Berkeley
Decoto Road | [(-122.0159,37.006),(-122.016,37.002),(-122.0164,37.993)] | Oakland
Decoto Road | [(-122.0159,37.006),(-122.016,37.002),(-122.0164,37.993)] | Oakland
- Decoto Road | [(-122.0159,37.006),(-122.016,37.002),(-122.0164,37.993)] | Berkeley
Deering St | [(-122.2146,37.904),(-122.2126,37.897)] | Berkeley
Dimond Ave | [(-122.2167,37.994),(-122.2162,37.006)] | Berkeley
Dimond Ave | [(-122.2167,37.994),(-122.2162,37.006)] | Lafayette
@@ -117,12 +130,12 @@ SELECT * FROM street;
I- 580 | [(-121.9322,37.989),(-121.9243,37.006),(-121.9217,37.014)] | Oakland
I- 580 | [(-122.018,37.019),(-122.0009,37.032),(-121.9787,37.983),(-121.958,37.984),(-121.9571,37.986)] | Oakland
I- 580 | [(-122.018,37.019),(-122.0009,37.032),(-121.9787,37.983),(-121.958,37.984),(-121.9571,37.986)] | Oakland
- I- 580 | [(-122.1108,37.023),(-122.1101,37.02),(-122.108103,37.00764),(-122.108,37.007),(-122.1069,37.998),(-122.1064,37.994),(-122.1053,37.982),(-122.1048,37.977),(-122.1032,37.958),(-122.1026,37.953),(-122.1013,37.938),(-122.0989,37.911),(-122.0984,37.91),(-122.098,37.908)] | Oakland
I- 580 | [(-122.1108,37.023),(-122.1101,37.02),(-122.108103,37.00764),(-122.108,37.007),(-122.1069,37.998),(-122.1064,37.994),(-122.1053,37.982),(-122.1048,37.977),(-122.1032,37.958),(-122.1026,37.953),(-122.1013,37.938),(-122.0989,37.911),(-122.0984,37.91),(-122.098,37.908)] | Berkeley
+ I- 580 | [(-122.1108,37.023),(-122.1101,37.02),(-122.108103,37.00764),(-122.108,37.007),(-122.1069,37.998),(-122.1064,37.994),(-122.1053,37.982),(-122.1048,37.977),(-122.1032,37.958),(-122.1026,37.953),(-122.1013,37.938),(-122.0989,37.911),(-122.0984,37.91),(-122.098,37.908)] | Oakland
I- 580 | [(-122.1543,37.703),(-122.1535,37.694),(-122.1512,37.655),(-122.1475,37.603),(-122.1468,37.583),(-122.1472,37.569),(-122.149044,37.54874),(-122.1493,37.546),(-122.1501,37.532),(-122.1506,37.509),(-122.1495,37.482),(-122.1487,37.467),(-122.1477,37.447),(-122.1414,37.383),(-122.1404,37.376),(-122.1398,37.372),(-122.139,37.356),(-122.1388,37.353),(-122.1385,37.34),(-122.1382,37.33),(-122.1378,37.316)] | Oakland
I- 580 | [(-122.1543,37.703),(-122.1535,37.694),(-122.1512,37.655),(-122.1475,37.603),(-122.1468,37.583),(-122.1472,37.569),(-122.149044,37.54874),(-122.1493,37.546),(-122.1501,37.532),(-122.1506,37.509),(-122.1495,37.482),(-122.1487,37.467),(-122.1477,37.447),(-122.1414,37.383),(-122.1404,37.376),(-122.1398,37.372),(-122.139,37.356),(-122.1388,37.353),(-122.1385,37.34),(-122.1382,37.33),(-122.1378,37.316)] | Berkeley
- I- 580 | [(-122.2197,37.99),(-122.22,37.99),(-122.222092,37.99523),(-122.2232,37.998),(-122.224146,37.99963),(-122.2261,37.003),(-122.2278,37.007),(-122.2302,37.026),(-122.2323,37.043),(-122.2344,37.059),(-122.235405,37.06427),(-122.2365,37.07)] | Berkeley
I- 580 | [(-122.2197,37.99),(-122.22,37.99),(-122.222092,37.99523),(-122.2232,37.998),(-122.224146,37.99963),(-122.2261,37.003),(-122.2278,37.007),(-122.2302,37.026),(-122.2323,37.043),(-122.2344,37.059),(-122.235405,37.06427),(-122.2365,37.07)] | Lafayette
+ I- 580 | [(-122.2197,37.99),(-122.22,37.99),(-122.222092,37.99523),(-122.2232,37.998),(-122.224146,37.99963),(-122.2261,37.003),(-122.2278,37.007),(-122.2302,37.026),(-122.2323,37.043),(-122.2344,37.059),(-122.235405,37.06427),(-122.2365,37.07)] | Berkeley
I- 580 Ramp | [(-121.8521,37.011),(-121.8479,37.999),(-121.8476,37.999),(-121.8456,37.01),(-121.8455,37.011)] | Oakland
I- 580 Ramp | [(-121.8521,37.011),(-121.8479,37.999),(-121.8476,37.999),(-121.8456,37.01),(-121.8455,37.011)] | Oakland
I- 580 Ramp | [(-121.8743,37.014),(-121.8722,37.999),(-121.8714,37.999)] | Oakland
@@ -136,8 +149,8 @@ SELECT * FROM street;
I- 580 Ramp | [(-122.0941,37.897),(-122.0943,37.902)] | Berkeley
I- 580 Ramp | [(-122.096,37.888),(-122.0962,37.891),(-122.0964,37.9)] | Berkeley
I- 580 Ramp | [(-122.101,37.898),(-122.1005,37.902),(-122.0989,37.911)] | Berkeley
- I- 580 Ramp | [(-122.1086,37.003),(-122.1068,37.993),(-122.1066,37.992),(-122.1053,37.982)] | Oakland
I- 580 Ramp | [(-122.1086,37.003),(-122.1068,37.993),(-122.1066,37.992),(-122.1053,37.982)] | Berkeley
+ I- 580 Ramp | [(-122.1086,37.003),(-122.1068,37.993),(-122.1066,37.992),(-122.1053,37.982)] | Oakland
I- 580 Ramp | [(-122.1414,37.383),(-122.1407,37.376),(-122.1403,37.372),(-122.139,37.356)] | Oakland
I- 580/I-680 Ramp | ((-121.9207,37.988),(-121.9192,37.016)) | Oakland
I- 580/I-680 Ramp | ((-121.9207,37.988),(-121.9192,37.016)) | Oakland
@@ -158,16 +171,16 @@ SELECT * FROM street;
I- 880 | ((-121.9669,37.075),(-121.9663,37.071),(-121.9656,37.065),(-121.9618,37.037),(-121.95689,37),(-121.948,37.933)) | Oakland
I- 880 | [(-121.948,37.933),(-121.9471,37.925),(-121.9467,37.923),(-121.946,37.918),(-121.9452,37.912),(-121.937,37.852)] | Oakland
I- 880 | [(-122.0219,37.466),(-122.0205,37.447),(-122.020331,37.44447),(-122.020008,37.43962),(-122.0195,37.432),(-122.0193,37.429),(-122.0164,37.393),(-122.010219,37.34771),(-122.0041,37.313)] | Oakland
- I- 880 | [(-122.0375,37.632),(-122.0359,37.619),(-122.0358,37.616),(-122.034514,37.60409),(-122.031876,37.57965),(-122.031193,37.57332),(-122.03016,37.56375),(-122.02943,37.55698),(-122.028689,37.54929),(-122.027833,37.53908),(-122.025979,37.51698),(-122.0238,37.491)] | Oakland
I- 880 | [(-122.0375,37.632),(-122.0359,37.619),(-122.0358,37.616),(-122.034514,37.60409),(-122.031876,37.57965),(-122.031193,37.57332),(-122.03016,37.56375),(-122.02943,37.55698),(-122.028689,37.54929),(-122.027833,37.53908),(-122.025979,37.51698),(-122.0238,37.491)] | Berkeley
- I- 880 | [(-122.0612,37.003),(-122.0604,37.991),(-122.0596,37.982),(-122.0585,37.967),(-122.0583,37.961),(-122.0553,37.918),(-122.053635,37.89475),(-122.050759,37.8546),(-122.05,37.844),(-122.0485,37.817),(-122.0483,37.813),(-122.0482,37.811)] | Oakland
+ I- 880 | [(-122.0375,37.632),(-122.0359,37.619),(-122.0358,37.616),(-122.034514,37.60409),(-122.031876,37.57965),(-122.031193,37.57332),(-122.03016,37.56375),(-122.02943,37.55698),(-122.028689,37.54929),(-122.027833,37.53908),(-122.025979,37.51698),(-122.0238,37.491)] | Oakland
I- 880 | [(-122.0612,37.003),(-122.0604,37.991),(-122.0596,37.982),(-122.0585,37.967),(-122.0583,37.961),(-122.0553,37.918),(-122.053635,37.89475),(-122.050759,37.8546),(-122.05,37.844),(-122.0485,37.817),(-122.0483,37.813),(-122.0482,37.811)] | Oakland
I- 880 | [(-122.0612,37.003),(-122.0604,37.991),(-122.0596,37.982),(-122.0585,37.967),(-122.0583,37.961),(-122.0553,37.918),(-122.053635,37.89475),(-122.050759,37.8546),(-122.05,37.844),(-122.0485,37.817),(-122.0483,37.813),(-122.0482,37.811)] | Berkeley
+ I- 880 | [(-122.0612,37.003),(-122.0604,37.991),(-122.0596,37.982),(-122.0585,37.967),(-122.0583,37.961),(-122.0553,37.918),(-122.053635,37.89475),(-122.050759,37.8546),(-122.05,37.844),(-122.0485,37.817),(-122.0483,37.813),(-122.0482,37.811)] | Oakland
I- 880 | [(-122.0831,37.312),(-122.0819,37.296),(-122.081,37.285),(-122.0786,37.248),(-122.078,37.24),(-122.077642,37.23496),(-122.076983,37.22567),(-122.076599,37.22026),(-122.076229,37.21505),(-122.0758,37.209)] | Oakland
I- 880 | [(-122.0978,37.528),(-122.096,37.496),(-122.0931,37.453),(-122.09277,37.4496),(-122.090189,37.41442),(-122.0896,37.405),(-122.085,37.34)] | Oakland
I- 880 | [(-122.1365,37.902),(-122.1358,37.898),(-122.1333,37.881),(-122.1323,37.874),(-122.1311,37.866),(-122.1308,37.865),(-122.1307,37.864),(-122.1289,37.851),(-122.1277,37.843),(-122.1264,37.834),(-122.1231,37.812),(-122.1165,37.766),(-122.1104,37.72),(-122.109695,37.71094),(-122.109,37.702),(-122.108312,37.69168),(-122.1076,37.681)] | Berkeley
- I- 880 | [(-122.1755,37.185),(-122.1747,37.178),(-122.1742,37.173),(-122.1692,37.126),(-122.167792,37.11594),(-122.16757,37.11435),(-122.1671,37.111),(-122.1655,37.1),(-122.165169,37.09811),(-122.1641,37.092),(-122.1596,37.061),(-122.158381,37.05275),(-122.155991,37.03657),(-122.1531,37.017),(-122.1478,37.98),(-122.1407,37.932),(-122.1394,37.924),(-122.1389,37.92),(-122.1376,37.91)] | Oakland
I- 880 | [(-122.1755,37.185),(-122.1747,37.178),(-122.1742,37.173),(-122.1692,37.126),(-122.167792,37.11594),(-122.16757,37.11435),(-122.1671,37.111),(-122.1655,37.1),(-122.165169,37.09811),(-122.1641,37.092),(-122.1596,37.061),(-122.158381,37.05275),(-122.155991,37.03657),(-122.1531,37.017),(-122.1478,37.98),(-122.1407,37.932),(-122.1394,37.924),(-122.1389,37.92),(-122.1376,37.91)] | Berkeley
+ I- 880 | [(-122.1755,37.185),(-122.1747,37.178),(-122.1742,37.173),(-122.1692,37.126),(-122.167792,37.11594),(-122.16757,37.11435),(-122.1671,37.111),(-122.1655,37.1),(-122.165169,37.09811),(-122.1641,37.092),(-122.1596,37.061),(-122.158381,37.05275),(-122.155991,37.03657),(-122.1531,37.017),(-122.1478,37.98),(-122.1407,37.932),(-122.1394,37.924),(-122.1389,37.92),(-122.1376,37.91)] | Oakland
I- 880 | [(-122.2214,37.711),(-122.2202,37.699),(-122.2199,37.695),(-122.219,37.682),(-122.2184,37.672),(-122.2173,37.652),(-122.2159,37.638),(-122.2144,37.616),(-122.2138,37.612),(-122.2135,37.609),(-122.212,37.592),(-122.2116,37.586),(-122.2111,37.581)] | Berkeley
I- 880 | [(-122.2707,37.975),(-122.2693,37.972),(-122.2681,37.966),(-122.267,37.962),(-122.2659,37.957),(-122.2648,37.952),(-122.2636,37.946),(-122.2625,37.935),(-122.2617,37.927),(-122.2607,37.921),(-122.2593,37.916),(-122.258,37.911),(-122.2536,37.898),(-122.2432,37.858),(-122.2408,37.845),(-122.2386,37.827),(-122.2374,37.811)] | Berkeley
I- 880 Ramp | [(-122.0019,37.301),(-122.002,37.293)] | Oakland
@@ -202,28 +215,28 @@ SELECT * FROM street;
Laguna Ave | [(-122.2099,37.989),(-122.2089,37)] | Berkeley
Laguna Ave | [(-122.2099,37.989),(-122.2089,37)] | Lafayette
Lakehurst Cir | [(-122.284729,37.89025),(-122.286096,37.90364)] | Berkeley
- Lakeshore Ave | [(-122.2586,37.99),(-122.2556,37.006)] | Berkeley
Lakeshore Ave | [(-122.2586,37.99),(-122.2556,37.006)] | Lafayette
+ Lakeshore Ave | [(-122.2586,37.99),(-122.2556,37.006)] | Berkeley
Las Positas Road | [(-121.764488,37.99199),(-121.75569,37.02022)] | Oakland
Las Positas Road | [(-121.764488,37.99199),(-121.75569,37.02022)] | Oakland
- Linden St | [(-122.2867,37.998),(-122.2864,37.008)] | Berkeley
Linden St | [(-122.2867,37.998),(-122.2864,37.008)] | Lafayette
+ Linden St | [(-122.2867,37.998),(-122.2864,37.008)] | Berkeley
Livermore Ave | [(-121.7687,37.448),(-121.769,37.375)] | Oakland
Livermore Ave | [(-121.7687,37.448),(-121.769,37.375)] | Oakland
Livermore Ave | [(-121.772719,37.99085),(-121.7728,37.001)] | Oakland
Livermore Ave | [(-121.772719,37.99085),(-121.7728,37.001)] | Oakland
- Locust St | [(-122.1606,37.007),(-122.1593,37.987)] | Oakland
Locust St | [(-122.1606,37.007),(-122.1593,37.987)] | Berkeley
+ Locust St | [(-122.1606,37.007),(-122.1593,37.987)] | Oakland
Logan Ct | [(-122.0053,37.492),(-122.0061,37.484)] | Oakland
Magnolia St | [(-122.0971,37.5),(-122.0962,37.484)] | Oakland
Mandalay Road | [(-122.2322,37.397),(-122.2321,37.403)] | Lafayette
Marin Ave | [(-122.2741,37.894),(-122.272,37.901)] | Berkeley
Martin Luther King Jr Way | [(-122.2712,37.608),(-122.2711,37.599)] | Berkeley
Mattos Dr | [(-122.0005,37.502),(-122.000898,37.49683)] | Oakland
- Maubert Ave | [(-122.1114,37.009),(-122.1096,37.995)] | Oakland
Maubert Ave | [(-122.1114,37.009),(-122.1096,37.995)] | Berkeley
- McClure Ave | [(-122.1431,37.001),(-122.1436,37.998)] | Oakland
+ Maubert Ave | [(-122.1114,37.009),(-122.1096,37.995)] | Oakland
McClure Ave | [(-122.1431,37.001),(-122.1436,37.998)] | Berkeley
+ McClure Ave | [(-122.1431,37.001),(-122.1436,37.998)] | Oakland
Medlar Dr | [(-122.0627,37.378),(-122.0625,37.375)] | Oakland
Mildred Ct | [(-122.0002,37.388),(-121.9998,37.386)] | Oakland
Miller Road | [(-122.0902,37.645),(-122.0865,37.545)] | Berkeley
@@ -242,8 +255,8 @@ SELECT * FROM street;
Parkridge Dr | [(-122.1438,37.884),(-122.1428,37.9)] | Berkeley
Parkside Dr | [(-122.0475,37.603),(-122.0443,37.596)] | Berkeley
Paseo Padre Pkwy | [(-121.9143,37.005),(-121.913522,37)] | Oakland
- Paseo Padre Pkwy | [(-122.0021,37.639),(-121.996,37.628)] | Oakland
Paseo Padre Pkwy | [(-122.0021,37.639),(-121.996,37.628)] | Berkeley
+ Paseo Padre Pkwy | [(-122.0021,37.639),(-121.996,37.628)] | Oakland
Pearl St | [(-122.2383,37.594),(-122.2366,37.615)] | Berkeley
Periwinkle Road | [(-122.0451,37.301),(-122.044758,37.29844)] | Oakland
Pimlico Dr | [(-121.8616,37.998),(-121.8618,37.008)] | Oakland
@@ -254,11 +267,11 @@ SELECT * FROM street;
Railroad Ave | [(-122.0245,37.013),(-122.0234,37.003),(-122.0223,37.993)] | Oakland
Railroad Ave | [(-122.0245,37.013),(-122.0234,37.003),(-122.0223,37.993)] | Berkeley
Ranspot Dr | [(-122.0972,37.999),(-122.0959,37)] | Oakland
- Ranspot Dr | [(-122.0972,37.999),(-122.0959,37)] | Oakland
Ranspot Dr | [(-122.0972,37.999),(-122.0959,37)] | Berkeley
+ Ranspot Dr | [(-122.0972,37.999),(-122.0959,37)] | Oakland
Redding St | [(-122.1978,37.901),(-122.1975,37.895)] | Berkeley
- Redwood Road | [(-122.1493,37.98),(-122.1437,37.001)] | Oakland
Redwood Road | [(-122.1493,37.98),(-122.1437,37.001)] | Berkeley
+ Redwood Road | [(-122.1493,37.98),(-122.1437,37.001)] | Oakland
Roca Dr | [(-122.0335,37.609),(-122.0314,37.599)] | Berkeley
Rosedale Ct | [(-121.9232,37.9),(-121.924,37.897)] | Oakland
Sacramento St | [(-122.2799,37.606),(-122.2797,37.597)] | Berkeley
@@ -266,8 +279,8 @@ SELECT * FROM street;
Saginaw Ct | [(-121.8803,37.898),(-121.8806,37.901)] | Oakland
San Andreas Dr | [(-122.0609,37.9),(-122.0614,37.895)] | Berkeley
Santa Maria Ave | [(-122.0773,37),(-122.0773,37.98)] | Oakland
- Santa Maria Ave | [(-122.0773,37),(-122.0773,37.98)] | Oakland
Santa Maria Ave | [(-122.0773,37),(-122.0773,37.98)] | Berkeley
+ Santa Maria Ave | [(-122.0773,37),(-122.0773,37.98)] | Oakland
Shattuck Ave | [(-122.2686,37.904),(-122.2686,37.897)] | Berkeley
Sheridan Road | [(-122.2279,37.425),(-122.2253,37.411),(-122.2223,37.377)] | Lafayette
Shoreline Dr | [(-122.2657,37.603),(-122.2648,37.6)] | Berkeley
@@ -317,27 +330,14 @@ SELECT * FROM street;
Welch Creek Road | [(-121.7695,37.386),(-121.7737,37.413)] | Oakland
West Loop Road | [(-122.0576,37.604),(-122.0602,37.586)] | Berkeley
Western Pacific Railroad Spur | [(-122.0394,37.018),(-122.0394,37.961)] | Oakland
- Western Pacific Railroad Spur | [(-122.0394,37.018),(-122.0394,37.961)] | Oakland
Western Pacific Railroad Spur | [(-122.0394,37.018),(-122.0394,37.961)] | Berkeley
+ Western Pacific Railroad Spur | [(-122.0394,37.018),(-122.0394,37.961)] | Oakland
Whitlock Creek | [(-121.74683,37.91276),(-121.733107,37)] | Oakland
Whitlock Creek | [(-121.74683,37.91276),(-121.733107,37)] | Oakland
Willimet Way | [(-122.0964,37.517),(-122.0949,37.493)] | Oakland
Wisconsin St | [(-122.1994,37.017),(-122.1975,37.998),(-122.1971,37.994)] | Oakland
Wisconsin St | [(-122.1994,37.017),(-122.1975,37.998),(-122.1971,37.994)] | Berkeley
Wp Railroad | [(-122.254,37.902),(-122.2506,37.891)] | Berkeley
- 100th Ave | [(-122.1657,37.429),(-122.1647,37.432)] | Oakland
- 107th Ave | [(-122.1555,37.403),(-122.1531,37.41)] | Oakland
- 14th St | [(-122.299,37.147),(-122.3,37.148)] | Lafayette
- 19th Ave | [(-122.2366,37.897),(-122.2359,37.905)] | Berkeley
- 1st St | [(-121.75508,37.89294),(-121.753581,37.90031)] | Oakland
- 5th St | [(-122.278,37),(-122.2792,37.005),(-122.2803,37.009)] | Lafayette
- 5th St | [(-122.296,37.615),(-122.2953,37.598)] | Berkeley
- 82nd Ave | [(-122.1695,37.596),(-122.1681,37.603)] | Berkeley
- 85th Ave | [(-122.1877,37.466),(-122.186,37.476)] | Oakland
- 89th Ave | [(-122.1822,37.459),(-122.1803,37.471)] | Oakland
- 98th Ave | [(-122.1568,37.498),(-122.1558,37.502)] | Oakland
- 98th Ave | [(-122.1693,37.438),(-122.1682,37.444)] | Oakland
- 98th Ave | [(-122.2001,37.258),(-122.1974,37.27)] | Lafayette
(333 rows)
SELECT name, #thepath FROM iexit ORDER BY name COLLATE "C", 2;
diff --git a/src/test/regress/expected/txid.out b/src/test/regress/expected/txid.out
index 95ba66e95e..2ea4434f51 100644
--- a/src/test/regress/expected/txid.out
+++ b/src/test/regress/expected/txid.out
@@ -238,9 +238,11 @@ SELECT txid_snapshot '1:9223372036854775807:3';
(1 row)
SELECT txid_snapshot '1:9223372036854775808:3';
-ERROR: invalid input syntax for type pg_snapshot: "1:9223372036854775808:3"
-LINE 1: SELECT txid_snapshot '1:9223372036854775808:3';
- ^
+ txid_snapshot
+-------------------------
+ 1:9223372036854775808:3
+(1 row)
+
-- test txid_current_if_assigned
BEGIN;
SELECT txid_current_if_assigned() IS NULL;
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index d3ac08c9ee..952019b2e2 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -19,7 +19,7 @@ WHERE t1.typnamespace = 0 OR
(t1.typlen <= 0 AND t1.typlen != -1 AND t1.typlen != -2) OR
(t1.typtype not in ('b', 'c', 'd', 'e', 'm', 'p', 'r')) OR
NOT t1.typisdefined OR
- (t1.typalign not in ('c', 's', 'i', 'd')) OR
+ (t1.typalign not in ('c', 's', 'i', 'd', 'x')) OR
(t1.typstorage not in ('p', 'x', 'e', 'm'));
oid | typname
-----+---------
@@ -32,7 +32,8 @@ WHERE t1.typbyval AND
(t1.typlen != 1 OR t1.typalign != 'c') AND
(t1.typlen != 2 OR t1.typalign != 's') AND
(t1.typlen != 4 OR t1.typalign != 'i') AND
- (t1.typlen != 8 OR t1.typalign != 'd');
+ (t1.typlen != 8 OR t1.typalign != 'd') AND
+ (t1.typlen != 8 OR t1.typalign != 'x');
oid | typname
-----+---------
(0 rows)
diff --git a/src/test/regress/expected/xid.out b/src/test/regress/expected/xid.out
index d8e76f3321..3252bdc28d 100644
--- a/src/test/regress/expected/xid.out
+++ b/src/test/regress/expected/xid.out
@@ -8,9 +8,9 @@ select '010'::xid,
'42'::xid8,
'0xffffffffffffffff'::xid8,
'-1'::xid8;
- xid | xid | xid | xid | xid8 | xid8 | xid8 | xid8
------+-----+------------+------------+------+------+----------------------+----------------------
- 8 | 42 | 4294967295 | 4294967295 | 8 | 42 | 18446744073709551615 | 18446744073709551615
+ xid | xid | xid | xid | xid8 | xid8 | xid8 | xid8
+-----+-----+------------+----------------------+------+------+----------------------+----------------------
+ 8 | 42 | 4294967295 | 18446744073709551615 | 8 | 42 | 18446744073709551615 | 18446744073709551615
(1 row)
-- garbage values are not yet rejected (perhaps they should be)
@@ -381,9 +381,11 @@ SELECT pg_snapshot '1:9223372036854775807:3';
(1 row)
SELECT pg_snapshot '1:9223372036854775808:3';
-ERROR: invalid input syntax for type pg_snapshot: "1:9223372036854775808:3"
-LINE 1: SELECT pg_snapshot '1:9223372036854775808:3';
- ^
+ pg_snapshot
+-------------------------
+ 1:9223372036854775808:3
+(1 row)
+
-- test pg_current_xact_id_if_assigned
BEGIN;
SELECT pg_current_xact_id_if_assigned() IS NULL;
diff --git a/src/test/regress/expected/xid64.out b/src/test/regress/expected/xid64.out
new file mode 100644
index 0000000000..c30c5b5739
--- /dev/null
+++ b/src/test/regress/expected/xid64.out
@@ -0,0 +1,92 @@
+---
+--- Unit test for xid64 functions
+---
+-- directory paths and dlsuffix are passed to us in environment variables
+\getenv libdir PG_LIBDIR
+\getenv dlsuffix PG_DLSUFFIX
+\set regresslib :libdir '/regress' :dlsuffix
+CREATE FUNCTION xid64_test_1(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_1' LANGUAGE C STRICT;
+CREATE FUNCTION xid64_test_2(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_2' LANGUAGE C STRICT;
+CREATE FUNCTION xid64_test_double_xmax(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_double_xmax' LANGUAGE C STRICT;
+---
+--- Check page consistency after conversion
+---
+CREATE UNLOGGED TABLE test_xid64_table(a int);
+ALTER TABLE test_xid64_table SET (autovacuum_enabled = false);
+INSERT INTO test_xid64_table(a) SELECT a FROM generate_series(1, 1000) AS a;
+SELECT xid64_test_1('test_xid64_table');
+INFO: test 1: page is converted to xid64 format
+ xid64_test_1
+--------------
+
+(1 row)
+
+DROP TABLE test_xid64_table;
+---
+--- Check tuples consistency after conversion
+---
+CREATE UNLOGGED TABLE test_xid64_table(s serial, i int, t text);
+ALTER TABLE test_xid64_table SET (autovacuum_enabled = false);
+DO $$
+BEGIN
+ FOR j IN 1..20 LOOP
+ INSERT INTO test_xid64_table(i, t) VALUES (random()::int, md5(random()::text));
+ COMMIT;
+ END LOOP;
+END $$;
+DO $$
+BEGIN
+ FOR j IN 1..10 LOOP
+ DELETE FROM test_xid64_table WHERE ctid IN (SELECT ctid FROM test_xid64_table TABLESAMPLE BERNOULLI (5));
+ COMMIT;
+ END LOOP;
+END $$;
+SELECT xid64_test_2('test_xid64_table');
+ xid64_test_2
+--------------
+
+(1 row)
+
+DROP TABLE test_xid64_table;
+---
+--- Check tuples consistency after conversion to double xmax (on full page)
+---
+CREATE UNLOGGED TABLE test_xid64_table(i int);
+DO $$
+BEGIN
+ FOR j IN 1..40 LOOP
+ INSERT INTO test_xid64_table SELECT i FROM generate_series(1, 100) AS i;
+ COMMIT;
+ END LOOP;
+END $$;
+SELECT xid64_test_2('test_xid64_table');
+ xid64_test_2
+--------------
+
+(1 row)
+
+DROP TABLE test_xid64_table;
+CREATE UNLOGGED TABLE test_xid64_table(i text);
+INSERT INTO test_xid64_table(i) VALUES ('NNBABCDSDFGHJKLP');
+DO $$
+BEGIN
+ FOR j IN 1..40 LOOP
+ INSERT INTO test_xid64_table(i) SELECT 'A' FROM generate_series(1, 100) AS i;
+ COMMIT;
+ END LOOP;
+END $$;
+SELECT xid64_test_double_xmax('test_xid64_table');
+INFO: test double xmax: page 0 is converted into double xmax format
+INFO: test double xmax: end
+ xid64_test_double_xmax
+------------------------
+
+(1 row)
+
+DROP TABLE test_xid64_table;
+DROP FUNCTION xid64_test_1(rel regclass);
+DROP FUNCTION xid64_test_2(rel regclass);
+DROP FUNCTION xid64_test_double_xmax(rel regclass);
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 9f644a0c1b..2344cb38b3 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -33,7 +33,7 @@ test: strings numerology point lseg line box path polygon circle date time timet
# geometry depends on point, lseg, line, box, path, polygon, circle
# horology depends on date, time, timetz, timestamp, timestamptz, interval
# ----------
-test: geometry horology tstypes regex type_sanity opr_sanity misc_sanity comments expressions unicode xid mvcc
+test: geometry horology tstypes regex type_sanity opr_sanity misc_sanity comments expressions unicode xid xid64 mvcc
# ----------
# Load huge amounts of data
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index dda076847a..b6ede1f800 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2252,7 +2252,7 @@ regression_main(int argc, char *argv[],
/* initdb */
header(_("initializing database system"));
snprintf(buf, sizeof(buf),
- "\"%s%sinitdb\" -D \"%s/data\" --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
+ "\"%s%sinitdb\" -D \"%s/data\" -x 1249835483136 -m 2422361554944 -o 3594887626752 --no-clean --no-sync%s%s > \"%s/log/initdb.log\" 2>&1",
bindir ? bindir : "",
bindir ? "/" : "",
temp_instance,
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index 548afb4438..fd6dd77ce5 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -23,6 +23,7 @@
#include "access/htup_details.h"
#include "access/transam.h"
#include "access/xact.h"
+#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_type.h"
@@ -1257,3 +1258,293 @@ get_columns_length(PG_FUNCTION_ARGS)
PG_RETURN_INT32(column_offset);
}
+
+#include "access/hio.h"
+#include "access/relation.h"
+#include "storage/bufmgr.h"
+#include "utils/rel.h"
+
+static void
+CheckNewPage(char *msg, Page page)
+{
+ uint16 size;
+
+ if (PageGetPageLayoutVersion(page) != PG_PAGE_LAYOUT_VERSION)
+ elog(ERROR, "%s: page version is %d, expected %d ",
+ msg, PageGetPageLayoutVersion(page), PG_PAGE_LAYOUT_VERSION);
+
+ size = PageGetSpecialSize(page);
+ if (size == MAXALIGN(sizeof(HeapPageSpecialData)))
+ elog(INFO, "%s: page is converted to xid64 format", msg);
+ else if (HeapPageIsDoubleXmax(page))
+ elog(INFO, "%s: page is converted into double xmax format", msg);
+ else
+ elog(ERROR, "%s: converted page has pageSpecial size %u, expected %llu",
+ msg, size,
+ (unsigned long long) MAXALIGN(sizeof(HeapPageSpecialData)));
+}
+
+/*
+ * Get page from relation.
+ * Make this page look like in 32-bit xid format.
+ * Convert it to 64-bit xid format.
+ * Run basic checks.
+ */
+PG_FUNCTION_INFO_V1(xid64_test_1);
+Datum
+xid64_test_1(PG_FUNCTION_ARGS)
+{
+ Oid relid;
+ Relation rel;
+ Buffer buf;
+ Page page;
+ PageHeader hdr;
+
+ relid = PG_GETARG_OID(0);
+ rel = relation_open(relid, AccessExclusiveLock);
+ buf = ReadBuffer(rel, 0);
+ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
+
+ page = BufferGetPage(buf);
+ hdr = (PageHeader) page;
+
+ if (PageGetSpecialSize(page) != MAXALIGN(sizeof(HeapPageSpecialData)))
+ elog(ERROR, "page expected in new format");
+
+ if (PageGetPageLayoutVersion(page) != PG_PAGE_LAYOUT_VERSION)
+ elog(ERROR, "unknown page version (%u)",
+ PageGetPageLayoutVersion(page));
+
+ hdr->pd_special = BLCKSZ;
+ PageSetPageSizeAndVersion(page, BLCKSZ, PG_PAGE_LAYOUT_VERSION - 1);
+
+ convert_page(rel, page, buf, 0);
+ CheckNewPage("test 1", page);
+
+ UnlockReleaseBuffer(buf);
+ relation_close(rel, AccessExclusiveLock);
+
+ PG_RETURN_VOID();
+}
+
+typedef struct TupleCheckValues
+{
+ TransactionId xmin;
+ TransactionId xmax;
+} TupleCheckValues;
+
+typedef struct RelCheckValues
+{
+ TupleCheckValues *tcv;
+ Size ntuples;
+} RelCheckValues;
+
+static RelCheckValues
+FillRelCheckValues(Relation rel, Buffer buffer, Page page)
+{
+ RelCheckValues set;
+ Size n;
+
+#define DEFAULT_SET_SIZE 64
+ n = DEFAULT_SET_SIZE;
+ set.ntuples = 0;
+ set.tcv = palloc(sizeof(set.tcv[0]) * n);
+
+ {
+ OffsetNumber maxoff,
+ offnum;
+ HeapTupleHeader tuphdr;
+ ItemId itemid;
+ HeapTupleData tuple;
+ TransactionId xmin,
+ xmax;
+
+ maxoff = PageGetMaxOffsetNumber(page);
+
+ for (offnum = FirstOffsetNumber;
+ offnum <= maxoff;
+ offnum = OffsetNumberNext(offnum))
+ {
+ itemid = PageGetItemId(page, offnum);
+ tuphdr = (HeapTupleHeader) PageGetItem(page, itemid);
+ tuple.t_data = tuphdr;
+ tuple.t_len = ItemIdGetLength(itemid);
+ tuple.t_tableOid = RelationGetRelid(rel);
+
+ if (HeapPageGetSpecial(page) == heapDoubleXmaxSpecial)
+ {
+ xmin = tuphdr->t_choice.t_heap.t_xmin;
+ xmax = tuphdr->t_choice.t_heap.t_xmax;
+ }
+ else
+ {
+ HeapTupleCopyBaseFromPage(buffer, &tuple, page,
+ IsToastRelation(rel));
+
+ xmin = HeapTupleGetRawXmin(&tuple);
+ xmax = HeapTupleGetRawXmax(&tuple);
+ }
+
+ if (set.ntuples == n)
+ {
+ n *= 2;
+ set.tcv = repalloc(set.tcv, sizeof(set.tcv[0]) * n);
+ }
+
+ set.tcv[set.ntuples].xmin = xmin;
+ set.tcv[set.ntuples].xmax = xmax;
+ set.ntuples++;
+ }
+ }
+
+ return set;
+}
+
+/*
+ * Test xmin/xmax invariant when converting page from 32bit xid to 64xid.
+ *
+ * Scenario:
+ * - enforce all relation pages to 32bit xid format, discarding pd_xid_base and
+ * pd_multi_base
+ * - store all xmin/xmax in array
+ * - convert all the pages from relation into 64xid format
+ * - store all new xmin/xmax in array
+ * - compare old and new xmin/xmax
+ *
+ * NOTE: inital xid value does not affect test as pd_xid_base/pd_multi_base
+ * discarded.
+ */
+PG_FUNCTION_INFO_V1(xid64_test_2);
+Datum
+xid64_test_2(PG_FUNCTION_ARGS)
+{
+ Oid relid;
+ Relation rel;
+ RelCheckValues before,
+ after;
+ BlockNumber pageno,
+ npages;
+ Size i;
+
+ relid = PG_GETARG_OID(0);
+ rel = relation_open(relid, AccessExclusiveLock);
+ npages = RelationGetNumberOfBlocks(rel);
+
+ for (pageno = 0; pageno != npages; ++pageno)
+ {
+ Buffer buf;
+ Page page;
+ PageHeader hdr;
+
+ /* get page */
+ buf = ReadBuffer(rel, pageno);
+ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
+ page = BufferGetPage(buf);
+ hdr = (PageHeader) page;
+
+ /* make page look like 32-bit xid page */
+ hdr->pd_special = BLCKSZ;
+ PageSetPageSizeAndVersion(page, BLCKSZ, PG_PAGE_LAYOUT_VERSION - 1);
+
+ before = FillRelCheckValues(rel, buf, page);
+ convert_page(rel, page, buf, pageno);
+ after = FillRelCheckValues(rel, buf, page);
+
+ /* check */
+ if (before.ntuples != after.ntuples)
+ elog(ERROR, "numer of tuples must be equal");
+
+ for (i = 0; i != before.ntuples; ++i)
+ {
+ if (before.tcv[i].xmin != after.tcv[i].xmin && after.tcv[i].xmin)
+ elog(ERROR, "old and new xmin does not match (%llu != %llu)",
+ (unsigned long long) before.tcv[i].xmin,
+ (unsigned long long) after.tcv[i].xmin);
+
+ if (before.tcv[i].xmax != after.tcv[i].xmax)
+ elog(ERROR, "old and new xmax does not match (%llu != %llu)",
+ (unsigned long long) before.tcv[i].xmax,
+ (unsigned long long) after.tcv[i].xmax);
+ }
+
+ Assert(npages != 0);
+ pfree(before.tcv);
+ pfree(after.tcv);
+
+ UnlockReleaseBuffer(buf);
+ }
+
+ relation_close(rel, AccessExclusiveLock);
+
+ PG_RETURN_VOID();
+}
+
+PG_FUNCTION_INFO_V1(xid64_test_double_xmax);
+Datum
+xid64_test_double_xmax(PG_FUNCTION_ARGS)
+{
+ Oid relid;
+ Relation rel;
+ BlockNumber pageno,
+ npages;
+ bool found;
+
+ relid = PG_GETARG_OID(0);
+ rel = relation_open(relid, AccessExclusiveLock);
+ npages = RelationGetNumberOfBlocks(rel);
+ found = false;
+
+ for (pageno = 0; pageno != npages; ++pageno)
+ {
+ Buffer buf;
+ Page page;
+ PageHeader hdr;
+ ItemId itemid;
+ OffsetNumber offnum;
+ HeapTupleHeader tuphdr;
+
+ buf = ReadBuffer(rel, pageno);
+ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
+ page = BufferGetPage(buf);
+ hdr = (PageHeader) page;
+
+ if (pageno == 0)
+ {
+ itemid = PageGetItemId(page, FirstOffsetNumber);
+ itemid->lp_len += 16; /* Move to overlap special */
+ }
+
+ for (offnum = FirstOffsetNumber;
+ offnum <= PageGetMaxOffsetNumber(page);
+ offnum = OffsetNumberNext(offnum))
+ {
+ itemid = PageGetItemId(page, offnum);
+ tuphdr = (HeapTupleHeader) PageGetItem(page, itemid);
+ tuphdr->t_infomask |= HEAP_XMIN_COMMITTED;
+ }
+
+ hdr->pd_special = BLCKSZ;
+ PageSetPageSizeAndVersion(page, BLCKSZ, PG_PAGE_LAYOUT_VERSION - 1);
+
+ convert_page(rel, page, buf, pageno);
+
+ if (HeapPageIsDoubleXmax(page))
+ {
+ found = true;
+ elog(INFO, "test double xmax: page %u is converted into double xmax format",
+ pageno);
+ }
+
+ UnlockReleaseBuffer(buf);
+ }
+
+ if (!found)
+ elog(ERROR, "test double xmax: failed, no double xmax");
+
+ Assert(npages != 0);
+ elog(INFO, "test double xmax: end");
+
+ relation_close(rel, AccessExclusiveLock);
+
+ PG_RETURN_VOID();
+}
diff --git a/src/test/regress/sql/indirect_toast.sql b/src/test/regress/sql/indirect_toast.sql
index 3e2f6c0237..ea087b5128 100644
--- a/src/test/regress/sql/indirect_toast.sql
+++ b/src/test/regress/sql/indirect_toast.sql
@@ -76,7 +76,18 @@ SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
VACUUM FREEZE indtoasttest;
SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
+create or replace function random_string(len integer) returns text as $$
+select substr((select string_agg(r,'') from (select random()::text as r from generate_series(1,(len+15)/16)) s1), 1, len);
+$$ language sql;
+
+create table toasttest_main(t text);
+alter table toasttest_main alter column t set storage main;
+
+insert into toasttest_main (select random_string(len) from generate_series(7000,8000) len);
+
DROP TABLE indtoasttest;
+DROP TABLE toasttest_main;
DROP FUNCTION update_using_indirect();
+DROP FUNCTION random_string(integer);
RESET default_toast_compression;
diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql
index bdcffd0314..7ada0801eb 100644
--- a/src/test/regress/sql/insert.sql
+++ b/src/test/regress/sql/insert.sql
@@ -55,7 +55,7 @@ INSERT INTO large_tuple_test (select 3, NULL);
-- now this tuple won't fit on the second page, but the insert should
-- still succeed by extending the relation
-INSERT INTO large_tuple_test (select 4, repeat('a', 8126));
+INSERT INTO large_tuple_test (select 4, repeat('a', 8112));
DROP TABLE large_tuple_test;
@@ -597,3 +597,18 @@ alter table returningwrtest2 drop c;
alter table returningwrtest attach partition returningwrtest2 for values in (2);
insert into returningwrtest values (2, 'foo') returning returningwrtest;
drop table returningwrtest;
+
+-- Check for MaxHeapTupleSize
+create table maxheaptuplesize_test(value text);
+alter table maxheaptuplesize_test alter column value set storage external;
+insert into maxheaptuplesize_test values (repeat('x', 8104));
+insert into maxheaptuplesize_test values (repeat('x', 8112));
+insert into maxheaptuplesize_test values (repeat('x', 8120));
+insert into maxheaptuplesize_test values (repeat('x', 8128));
+insert into maxheaptuplesize_test values (repeat('x', 8136));
+insert into maxheaptuplesize_test values (repeat('x', 8144));
+insert into maxheaptuplesize_test values (repeat('x', 8152));
+insert into maxheaptuplesize_test values (repeat('x', 8160));
+insert into maxheaptuplesize_test values (repeat('x', 8168));
+insert into maxheaptuplesize_test values (repeat('x', 8176));
+drop table maxheaptuplesize_test;
diff --git a/src/test/regress/sql/select_views.sql b/src/test/regress/sql/select_views.sql
index e742f13699..70e663e350 100644
--- a/src/test/regress/sql/select_views.sql
+++ b/src/test/regress/sql/select_views.sql
@@ -3,7 +3,7 @@
-- test the views defined in CREATE_VIEWS
--
-SELECT * FROM street;
+SELECT * FROM street ORDER BY name COLLATE "C", thepath::text COLLATE "C";
SELECT name, #thepath FROM iexit ORDER BY name COLLATE "C", 2;
diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql
index 5edc1f1f6e..2b6c4aff6c 100644
--- a/src/test/regress/sql/type_sanity.sql
+++ b/src/test/regress/sql/type_sanity.sql
@@ -22,7 +22,7 @@ WHERE t1.typnamespace = 0 OR
(t1.typlen <= 0 AND t1.typlen != -1 AND t1.typlen != -2) OR
(t1.typtype not in ('b', 'c', 'd', 'e', 'm', 'p', 'r')) OR
NOT t1.typisdefined OR
- (t1.typalign not in ('c', 's', 'i', 'd')) OR
+ (t1.typalign not in ('c', 's', 'i', 'd', 'x')) OR
(t1.typstorage not in ('p', 'x', 'e', 'm'));
-- Look for "pass by value" types that can't be passed by value.
@@ -33,7 +33,8 @@ WHERE t1.typbyval AND
(t1.typlen != 1 OR t1.typalign != 'c') AND
(t1.typlen != 2 OR t1.typalign != 's') AND
(t1.typlen != 4 OR t1.typalign != 'i') AND
- (t1.typlen != 8 OR t1.typalign != 'd');
+ (t1.typlen != 8 OR t1.typalign != 'd') AND
+ (t1.typlen != 8 OR t1.typalign != 'x');
-- Look for "toastable" types that aren't varlena.
diff --git a/src/test/regress/sql/xid64.sql b/src/test/regress/sql/xid64.sql
new file mode 100644
index 0000000000..caa97a0ed9
--- /dev/null
+++ b/src/test/regress/sql/xid64.sql
@@ -0,0 +1,84 @@
+---
+--- Unit test for xid64 functions
+---
+
+-- directory paths and dlsuffix are passed to us in environment variables
+\getenv libdir PG_LIBDIR
+\getenv dlsuffix PG_DLSUFFIX
+
+\set regresslib :libdir '/regress' :dlsuffix
+
+CREATE FUNCTION xid64_test_1(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_1' LANGUAGE C STRICT;
+CREATE FUNCTION xid64_test_2(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_2' LANGUAGE C STRICT;
+CREATE FUNCTION xid64_test_double_xmax(rel regclass) RETURNS VOID
+ AS :'regresslib', 'xid64_test_double_xmax' LANGUAGE C STRICT;
+
+---
+--- Check page consistency after conversion
+---
+CREATE UNLOGGED TABLE test_xid64_table(a int);
+ALTER TABLE test_xid64_table SET (autovacuum_enabled = false);
+INSERT INTO test_xid64_table(a) SELECT a FROM generate_series(1, 1000) AS a;
+SELECT xid64_test_1('test_xid64_table');
+DROP TABLE test_xid64_table;
+
+---
+--- Check tuples consistency after conversion
+---
+CREATE UNLOGGED TABLE test_xid64_table(s serial, i int, t text);
+ALTER TABLE test_xid64_table SET (autovacuum_enabled = false);
+
+DO $$
+BEGIN
+ FOR j IN 1..20 LOOP
+ INSERT INTO test_xid64_table(i, t) VALUES (random()::int, md5(random()::text));
+ COMMIT;
+ END LOOP;
+END $$;
+
+DO $$
+BEGIN
+ FOR j IN 1..10 LOOP
+ DELETE FROM test_xid64_table WHERE ctid IN (SELECT ctid FROM test_xid64_table TABLESAMPLE BERNOULLI (5));
+ COMMIT;
+ END LOOP;
+END $$;
+
+SELECT xid64_test_2('test_xid64_table');
+DROP TABLE test_xid64_table;
+
+---
+--- Check tuples consistency after conversion to double xmax (on full page)
+---
+CREATE UNLOGGED TABLE test_xid64_table(i int);
+
+DO $$
+BEGIN
+ FOR j IN 1..40 LOOP
+ INSERT INTO test_xid64_table SELECT i FROM generate_series(1, 100) AS i;
+ COMMIT;
+ END LOOP;
+END $$;
+
+SELECT xid64_test_2('test_xid64_table');
+DROP TABLE test_xid64_table;
+
+CREATE UNLOGGED TABLE test_xid64_table(i text);
+INSERT INTO test_xid64_table(i) VALUES ('NNBABCDSDFGHJKLP');
+
+DO $$
+BEGIN
+ FOR j IN 1..40 LOOP
+ INSERT INTO test_xid64_table(i) SELECT 'A' FROM generate_series(1, 100) AS i;
+ COMMIT;
+ END LOOP;
+END $$;
+
+SELECT xid64_test_double_xmax('test_xid64_table');
+DROP TABLE test_xid64_table;
+
+DROP FUNCTION xid64_test_1(rel regclass);
+DROP FUNCTION xid64_test_2(rel regclass);
+DROP FUNCTION xid64_test_double_xmax(rel regclass);
diff --git a/src/test/xid-64/Makefile b/src/test/xid-64/Makefile
new file mode 100644
index 0000000000..3b1e50dfc0
--- /dev/null
+++ b/src/test/xid-64/Makefile
@@ -0,0 +1,22 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for src/test/xid-64
+#
+# Copyright (c) 2018, Postgres Professional
+#
+# src/test/xid-64/Makefile
+#
+#-------------------------------------------------------------------------
+
+subdir = src/test/xid-64
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+check:
+ $(prove_check)
+
+installcheck:
+ $(prove_installcheck)
+
+clean distclean maintainer-clean:
+ rm -rf tmp_check
diff --git a/src/test/xid-64/README b/src/test/xid-64/README
new file mode 100644
index 0000000000..01c0a1a1f7
--- /dev/null
+++ b/src/test/xid-64/README
@@ -0,0 +1,16 @@
+src/test/xid-64/README
+
+Regression tests for 64-bit XIDs
+=============================================
+
+This directory contains a test suite for 64-bit xids.
+
+Running the tests
+=================
+
+ make check
+
+NOTE: This creates a temporary installation, and some tests may
+create one or multiple nodes.
+
+NOTE: This requires the --enable-tap-tests argument to configure.
diff --git a/src/test/xid-64/meson.build b/src/test/xid-64/meson.build
new file mode 100644
index 0000000000..f55ebdf41c
--- /dev/null
+++ b/src/test/xid-64/meson.build
@@ -0,0 +1,15 @@
+tests += {
+ 'name': 'xid-64',
+ 'sd': meson.current_source_dir(),
+ 'bd': meson.current_build_dir(),
+ 'tap': {
+ 'tests': [
+ 't/001_test_large_xids.pl',
+ 't/002_test_gucs.pl',
+ 't/003_test_integrity.pl',
+ 't/004_test_relminmxid.pl',
+ 't/005_stream_subxact.pl',
+ 't/006_zeropage.pl',
+ ],
+ },
+}
diff --git a/src/test/xid-64/t/001_test_large_xids.pl b/src/test/xid-64/t/001_test_large_xids.pl
new file mode 100644
index 0000000000..4c7dbc6cb1
--- /dev/null
+++ b/src/test/xid-64/t/001_test_large_xids.pl
@@ -0,0 +1,54 @@
+# Tests for large xid values
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+use bigint;
+
+sub command_output
+{
+ my ($cmd) = @_;
+ my ($stdout, $stderr);
+ print("# Running: " . join(" ", @{$cmd}) . "\n");
+ my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
+ ok($result, "@$cmd exit code 0");
+ is($stderr, '', "@$cmd no stderr");
+ return $stdout;
+}
+
+my $START_VAL = 2**32;
+my $MAX_VAL = 2**62;
+
+my $ixid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imxid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imoff = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+
+# Initialize master node with the random xid-related parameters
+my $node = PostgreSQL::Test::Cluster->new('master');
+$node->init(extra => [ "--xid=$ixid", "--multixact-id=$imxid", "--multixact-offset=$imoff" ]);
+$node->start;
+
+# Initialize master node and check the xid-related parameters
+my $pgcd_output = command_output(
+ [ 'pg_controldata', '-D', $node->data_dir ] );
+print($pgcd_output); print('\n');
+ok($pgcd_output =~ qr/Latest checkpoint's NextXID:\s*(\d+)/, "XID found");
+my ($nextxid) = ($1);
+ok($nextxid >= $ixid && $nextxid < $ixid + 1000,
+ "Latest checkpoint's NextXID ($nextxid) is close to the initial xid ($ixid).");
+ok($pgcd_output =~ qr/Latest checkpoint's NextMultiXactId:\s*(\d+)/, "MultiXactId found");
+my ($nextmxid) = ($1);
+ok($nextmxid >= $imxid && $nextmxid < $imxid + 1000,
+ "Latest checkpoint's NextMultiXactId ($nextmxid) is close to the initial multiXactId ($imxid).");
+ok($pgcd_output =~ qr/Latest checkpoint's NextMultiOffset:\s*(\d+)/, "MultiOffset found");
+my ($nextmoff) = ($1);
+ok($nextmoff >= $imoff && $nextmoff < $imoff + 1000,
+ "Latest checkpoint's NextMultiOffset ($nextmoff) is close to the initial multiOffset ($imoff).");
+
+# Run pgbench to check whether the database is working properly
+$node->command_ok(
+ [ qw(pgbench --initialize --no-vacuum --scale=10) ],
+ 'pgbench finished without errors');
+
+done_testing();
\ No newline at end of file
diff --git a/src/test/xid-64/t/002_test_gucs.pl b/src/test/xid-64/t/002_test_gucs.pl
new file mode 100644
index 0000000000..ff9f2f3052
--- /dev/null
+++ b/src/test/xid-64/t/002_test_gucs.pl
@@ -0,0 +1,79 @@
+# Tests for guc boundary values
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+use bigint;
+
+sub command_output
+{
+ my ($cmd) = @_;
+ my ($stdout, $stderr);
+ print("# Running: " . join(" ", @{$cmd}) . "\n");
+ my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
+ ok($result, "@$cmd exit code 0");
+ is($stderr, '', "@$cmd no stderr");
+ return $stdout;
+}
+
+sub set_guc
+{
+ my ($node, $guc, $val) = @_;
+ print("SET $guc = $val\n");
+ $node->safe_psql('postgres', "ALTER SYSTEM SET $guc = $val");
+ $node->restart();
+}
+
+sub test_pgbench
+{
+ my ($node) = @_;
+ $node->command_ok(
+ [ qw(pgbench --progress=5 --transactions=1000 --jobs=5 --client=5) ],
+ 'pgbench finished without errors');
+}
+
+my @guc_vals = (
+ [ "autovacuum_freeze_max_age", 100000, 2**63 - 1 ],
+ [ "autovacuum_multixact_freeze_max_age", 10000, 2**63 - 1 ],
+ [ "vacuum_freeze_min_age", 0, 2**63 - 1 ],
+ [ "vacuum_freeze_table_age", 0, 2**63 - 1 ],
+ [ "vacuum_multixact_freeze_min_age", 0, 2**63 - 1 ],
+ [ "vacuum_multixact_freeze_table_age", 0, 2**63 -1 ]
+);
+
+my $START_VAL = 2**32;
+my $MAX_VAL = 2**62;
+
+my $ixid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imxid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imoff = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+
+# Initialize master node
+my $node = PostgreSQL::Test::Cluster->new('master');
+$node->init(extra => [ "--xid=$ixid", "--multixact-id=$imxid", "--multixact-offset=$imoff" ]);
+# Disable logging of all statements to avoid log bloat during pgbench
+$node->append_conf('postgresql.conf', "log_statement = none");
+$node->start;
+
+# Fill the test database with the pgbench data
+$node->command_ok(
+ [ qw(pgbench --initialize --scale=10) ],
+ 'pgbench finished without errors');
+
+# Test all GUCs with minimum, maximum and random value inbetween
+# (run pgbench for every configuration setting)
+foreach my $gi (0 .. $#guc_vals) {
+ print($guc_vals[$gi][0]); print("\n");
+ my $guc = $guc_vals[$gi][0];
+ my $minval = $guc_vals[$gi][1];
+ my $maxval = $guc_vals[$gi][2];
+ set_guc($node, $guc, $minval);
+ test_pgbench($node);
+ set_guc($node, $guc, $maxval);
+ test_pgbench($node);
+ set_guc($node, $guc, $minval + int(rand($maxval - $minval)));
+ test_pgbench($node);
+}
+
+done_testing();
\ No newline at end of file
diff --git a/src/test/xid-64/t/003_test_integrity.pl b/src/test/xid-64/t/003_test_integrity.pl
new file mode 100644
index 0000000000..ca079f11cb
--- /dev/null
+++ b/src/test/xid-64/t/003_test_integrity.pl
@@ -0,0 +1,58 @@
+# Check integrity after dump/restore with different xids
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+use File::Compare;
+
+my $tempdir = PostgreSQL::Test::Utils::tempdir;
+use bigint;
+
+my $START_VAL = 2**32;
+my $MAX_VAL = 2**62;
+
+my $ixid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imxid = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+my $imoff = $START_VAL + int(rand($MAX_VAL - $START_VAL));
+
+# Initialize master node
+my $node = PostgreSQL::Test::Cluster->new('master');
+$node->init();
+$node->start;
+
+# Create a database and fill it with the pgbench data
+$node->safe_psql('postgres', "CREATE DATABASE pgbench_db");
+$node->command_ok(
+ [ qw(pgbench --initialize --scale=2 pgbench_db) ],
+ 'pgbench finished without errors');
+# Dump the database (cluster the main table to put data in a determined order)
+$node->safe_psql('pgbench_db', qq(
+ CREATE INDEX pa_aid_idx ON pgbench_accounts (aid);
+ CLUSTER pgbench_accounts USING pa_aid_idx));
+$node->command_ok(
+ [ "pg_dump", "-w", "--inserts", "--file=$tempdir/pgbench.sql", "pgbench_db" ],
+ 'pgdump finished without errors');
+$node->stop('fast');
+
+# Initialize second node
+my $node2 = PostgreSQL::Test::Cluster->new('master2');
+$node2->init(extra => [ "--xid=$ixid", "--multixact-id=$imxid", "--multixact-offset=$imoff" ]);
+# Disable logging of all statements to avoid log bloat during restore
+$node2->append_conf('postgresql.conf', "log_statement = none");
+$node2->start;
+
+# Create a database and restore the previous dump
+$node2->safe_psql('postgres', "CREATE DATABASE pgbench_db");
+my $txid0 = $node2->safe_psql('pgbench_db', 'SELECT txid_current()');
+print("# Initial txid_current: $txid0\n");
+$node2->command_ok(["psql", "-q", "-f", "$tempdir/pgbench.sql", "pgbench_db"]);
+
+# Dump the database and compare the dumped content with the previous one
+$node2->safe_psql('pgbench_db', 'CLUSTER pgbench_accounts');
+$node2->command_ok(
+ [ "pg_dump", "-w", "--inserts", "--file=$tempdir/pgbench2.sql", "pgbench_db" ],
+ 'pgdump finished without errors');
+ok(File::Compare::compare_text("$tempdir/pgbench.sql", "$tempdir/pgbench2.sql") == 0, "no differences detected");
+
+done_testing();
\ No newline at end of file
diff --git a/src/test/xid-64/t/004_test_relminmxid.pl b/src/test/xid-64/t/004_test_relminmxid.pl
new file mode 100644
index 0000000000..e1f6e556e5
--- /dev/null
+++ b/src/test/xid-64/t/004_test_relminmxid.pl
@@ -0,0 +1,90 @@
+# Check integrity after dump/restore with different xids
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+use bigint;
+
+my ($node, $rmm, $vacout);
+$node = PostgreSQL::Test::Cluster->new('master');
+$node->init(extra => [ "--xid=3", "--multixact-id=1", "--multixact-offset=0" ]);
+$node->append_conf('postgresql.conf', 'max_prepared_transactions = 2');
+$node->start;
+
+sub relminmxid
+{
+ my $rmm = $node->safe_psql("postgres", qq(
+ SELECT relminmxid
+ FROM pg_class
+ WHERE relname = 'foo';));
+ return $rmm + 0;
+}
+
+sub vacuum
+{
+ my ($rc, $stdout, $stderr) = $node->psql("postgres", "VACUUM foo;");
+ return $stdout.$stderr;
+}
+
+sub gen_multixact
+{
+ $node->safe_psql("postgres", qq(
+ BEGIN;
+ SELECT * FROM foo FOR KEY SHARE;
+ PREPARE TRANSACTION 'fooshare';
+ ));
+
+ my $xmax = $node->safe_psql("postgres", qq(
+ SELECT xmax FROM foo;
+ ));
+ isnt($xmax + 0, 0, "xmax not empty");
+
+ $node->safe_psql("postgres", qq(
+ BEGIN;
+ SELECT * FROM foo FOR KEY SHARE;
+ COMMIT;
+ COMMIT PREPARED 'fooshare';
+ ));
+
+ my $mxact = $node->safe_psql("postgres", qq(
+ SELECT xmax FROM foo;
+ ));
+ isnt($mxact + 0, 0, "mxact not empty");
+ cmp_ok($xmax, '>', $mxact, "xmax is greater than mxact");
+}
+
+# Initialize master node with the random xid-related parameters
+$node->safe_psql("postgres", "CREATE TABLE foo (a int); INSERT INTO foo VALUES (1);");
+
+is(relminmxid(), 1, "relminmxid is default");
+
+vacuum();
+is(relminmxid(), 1, "relminmxid is still default");
+
+gen_multixact();
+is(relminmxid(), 1, "relminmxid is still still default");
+
+unlike(vacuum(), qr/multixact.*before relminmxid/, "no relminmxid error");
+
+# No intentionally break relminmxid
+$node->safe_psql("postgres", qq(
+ UPDATE pg_class SET relminmxid = ((1::int8<<62) + 1)::text::xid
+ WHERE relname = 'foo'
+));
+cmp_ok(relminmxid(), '>', 2**62, "relminmxid broken (intentionally)");
+
+gen_multixact();
+like(vacuum(), qr/multixact.*before relminmxid/, "got relminmxid error");
+cmp_ok(relminmxid(), '>', 2**62, "relminmxid broken (still)");
+
+# Fix relminmxid by setting to default
+$node->safe_psql("postgres", qq(
+ UPDATE pg_class SET relminmxid = '1'
+ WHERE relname = 'foo'
+));
+is(relminmxid(), 1, "relminmxid is default again");
+
+unlike(vacuum(), qr/multixact.*before relminmxid/, "no relminmxid error again");
+
+done_testing();
diff --git a/src/test/xid-64/t/005_stream_subxact.pl b/src/test/xid-64/t/005_stream_subxact.pl
new file mode 100644
index 0000000000..1379af6816
--- /dev/null
+++ b/src/test/xid-64/t/005_stream_subxact.pl
@@ -0,0 +1,100 @@
+
+# Copyright (c) 2021, PostgreSQL Global Development Group
+
+# Test xids streaming of large transaction containing large subtransactions
+# near 32-bit boundary.
+#
+# Mostly it is a copy of 016_stream_subxact.pl, but with publisher xid inited
+# just before 32-bit boundary, so if xids are replicated as 32-bit values,
+# subscriber will get 0 xid value.
+use strict;
+use warnings;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+# Create publisher node
+my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
+$node_publisher->init(allows_streaming => 'logical', extra => ['-x', '4294966545']);
+$node_publisher->append_conf('postgresql.conf',
+ 'logical_decoding_work_mem = 64kB');
+$node_publisher->start;
+
+# Create subscriber node
+my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber');
+$node_subscriber->init(allows_streaming => 'logical');
+$node_subscriber->start;
+
+# Create some preexisting content on publisher
+$node_publisher->safe_psql('postgres',
+ "CREATE TABLE test_tab (a int primary key, b varchar)");
+$node_publisher->safe_psql('postgres',
+ "INSERT INTO test_tab VALUES (1, 'foo'), (2, 'bar')");
+
+# Setup structure on subscriber
+$node_subscriber->safe_psql('postgres',
+ "CREATE TABLE test_tab (a int primary key, b text, c timestamptz DEFAULT now(), d bigint DEFAULT 999)"
+);
+
+# Setup logical replication
+my $publisher_connstr = $node_publisher->connstr . ' dbname=postgres';
+$node_publisher->safe_psql('postgres',
+ "CREATE PUBLICATION tap_pub FOR TABLE test_tab");
+
+my $appname = 'tap_sub';
+$node_subscriber->safe_psql('postgres',
+ "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub WITH (streaming = on)"
+);
+
+$node_publisher->wait_for_catchup($appname);
+
+# Also wait for initial table sync to finish
+my $synced_query =
+ "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+$node_subscriber->poll_query_until('postgres', $synced_query)
+ or die "Timed out while waiting for subscriber to synchronize data";
+
+my $result =
+ $node_subscriber->safe_psql('postgres',
+ "SELECT count(*), count(c), count(d = 999) FROM test_tab");
+is($result, qq(2|2|2), 'check initial data was copied to subscriber');
+
+# Insert, update and delete enough rows to exceed 64kB limit.
+$node_publisher->safe_psql(
+ 'postgres', q{
+BEGIN;
+INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series( 3, 500) s(i);
+UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
+DELETE FROM test_tab WHERE mod(a,3) = 0;
+SAVEPOINT s1;
+INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(501, 1000) s(i);
+UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
+DELETE FROM test_tab WHERE mod(a,3) = 0;
+SAVEPOINT s2;
+INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(1001, 1500) s(i);
+UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
+DELETE FROM test_tab WHERE mod(a,3) = 0;
+SAVEPOINT s3;
+INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(1501, 2000) s(i);
+UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
+DELETE FROM test_tab WHERE mod(a,3) = 0;
+SAVEPOINT s4;
+INSERT INTO test_tab SELECT i, md5(i::text) FROM generate_series(2001, 2500) s(i);
+UPDATE test_tab SET b = md5(b) WHERE mod(a,2) = 0;
+DELETE FROM test_tab WHERE mod(a,3) = 0;
+COMMIT;
+});
+
+$node_publisher->wait_for_catchup($appname);
+
+$result =
+ $node_subscriber->safe_psql('postgres',
+ "SELECT count(*), count(c), count(d = 999) FROM test_tab");
+is($result, qq(1667|1667|1667),
+ 'check data was copied to subscriber in streaming mode and extra columns contain local defaults'
+);
+
+$node_subscriber->stop;
+$node_publisher->stop;
+
+done_testing();
diff --git a/src/test/xid-64/t/006_zeropage.pl b/src/test/xid-64/t/006_zeropage.pl
new file mode 100644
index 0000000000..fd3ac3973f
--- /dev/null
+++ b/src/test/xid-64/t/006_zeropage.pl
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+# Check WAL for ZEROPAGE record.
+
+sub command_output
+{
+ my ($cmd) = @_;
+ my ($stdout, $stderr);
+ print("# Running: " . join(" ", @{$cmd}) . "\n");
+ my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
+ return $stdout;
+}
+
+my $node = PostgreSQL::Test::Cluster->new('main');
+$node->init(extra => [ "--xid=3", "--multixact-id=3", "--multixact-offset=0" ]);;
+$node->start;
+my $pgdata = $node->data_dir;
+my $xlogfilename0 = $node->safe_psql('postgres',
+ "SELECT pg_walfile_name(pg_current_wal_lsn())");
+#$node->command_like(
+# [ 'pg_waldump', '-S', "$pgdata/pg_wal/$xlogfilename0" ],
+# qr/ZEROPAGE/,
+# 'pg_waldump prints start timestamp');
+my $wd_output = command_output(
+ [ 'pg_waldump', "$pgdata/pg_wal/$xlogfilename0" ]);
+ok($wd_output =~ qr/ZEROPAGE page 0/, "ZEROPAGE found");
+
+done_testing();
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index c2acb58df0..74f2216ad1 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -399,6 +399,7 @@ sub GenerateFiles
PACKAGE_TARNAME => lc qq{"$package_name"},
PACKAGE_URL => qq{"$package_url"},
PACKAGE_VERSION => qq{"$package_version"},
+ XID_IS_64BIT => 1,
PG_INT128_TYPE => undef,
PG_INT64_TYPE => 'long long int',
PG_KRB_SRVNAM => qq{"postgres"},
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 97c9bc1861..4912da144f 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -3360,8 +3360,8 @@ intset_internal_node
intset_leaf_node
intset_node
intvKEY
-itemIdCompact
-itemIdCompactData
+ItemIdCompact
+ItemIdCompactData
iterator
jmp_buf
join_search_hook_type
--
2.37.0 (Apple Git-136)
Maxim,
Here is a rebased version of the patch set.
This is the wrong thread / CF entry. Please see
http://cfbot.cputube.org/ and https://commitfest.postgresql.org/ and
the first email in the thread.
--
Best regards,
Aleksander Alekseev
This is the wrong thread / CF entry. Please see
Yep, my fault. Sorry about that.
--
Best regards,
Maxim Orlov.
Hi hackers,
Sorry about that.
No problem.
Thanks, Simon. Not 100% sure who exactly is invited to vote, but just
in case here is +1 from me. These patches were "Ready for Committer"
for several months now and are unlikely to get any better. So I
suggest we merge them.
Here is the rebased patchset number 44.
--
Best regards,
Aleksander Alekseev
Attachments:
v44-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v44-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From abbe74f26fe0aa7ecfd28967f192b9dbdf25a9d6 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v44 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index f0ab5fabec..c9e71e4e50 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 018cd310f7..a5b4a77570 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -265,13 +266,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -286,11 +296,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.0
v44-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v44-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From aa52183395898b73f2e4ae1a06ea1044350af9ee Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v44 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index a7dfcfb4da..3d06f7c82a 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -932,7 +932,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index a7383f553b..67e07e118a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -355,8 +355,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2856,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2864,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3115,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3135,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6c57fae312..b36294fe05 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.38.0
v44-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v44-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From b42c99e72b3f8d67cc6b436c8be2530fb93bf371 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v44 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 567 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index d33f33f170..f0ab5fabec 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index 1d4d4965ac..ef89b84ec3 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 bd4d85041d..685200d154 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5170,7 +5170,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6153,8 +6154,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6167,8 +6169,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6186,8 +6189,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6198,7 +6202,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6289,8 +6294,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6339,8 +6345,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6504,8 +6511,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6513,8 +6521,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6641,8 +6650,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6656,8 +6666,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6678,8 +6688,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 a3414a76e8..335abea67c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index dfbe37472f..864876adf7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 2dba39e349..a9d1fa9d39 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -48,8 +48,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 67e07e118a..ef4bd47eed 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -451,8 +451,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -476,8 +477,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -490,8 +491,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -526,12 +527,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -554,7 +557,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -594,8 +597,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -603,7 +606,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -657,8 +661,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -710,8 +714,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dlist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dlist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1628,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
MXactCacheMembers--;
entry = dlist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1670,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2143,8 +2153,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2178,8 +2189,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2364,7 +2375,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2613,12 +2625,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2642,8 +2654,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3026,8 +3039,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3044,16 +3057,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3307,9 +3320,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3358,7 +3372,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3394,7 +3408,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 b36294fe05..202e2aa93c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 c1ffbd89b8..a5116d10b1 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1738,8 +1738,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5471,22 +5471,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 64c65f060b..27e5cdee6f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 6dff9915a5..9b20e158eb 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2461,8 +2461,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2900,7 +2900,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3592,8 +3593,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3869,8 +3870,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4512,9 +4513,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5143,8 +5144,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 54499c06fe..d518746ddd 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1103,7 +1103,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1248,8 +1249,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1338,8 +1342,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1421,8 +1426,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1445,8 +1451,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 207a5805ba..e62de43e09 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1089,7 +1089,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1480,7 +1481,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3320,14 +3322,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3489,7 +3493,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4006,33 +4010,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 6cbb67c92a..927fd2dbe5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e9ba500a15..66cbec488c 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 207c4b27fd..67c159a492 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7db86f7885..e6d90d52da 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1028,15 +1028,15 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1346,20 +1346,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index eb724a9d7f..f4a445e5e3 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2931,12 +2931,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2944,9 +2946,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f1f2ddac17..f76bab65cb 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index bd9b066e4e..dcb3b11d57 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.0
2022年10月10日(月) 18:16 Aleksander Alekseev <aleksander@timescale.com>:
Hi hackers,
Sorry about that.
No problem.
Thanks, Simon. Not 100% sure who exactly is invited to vote, but just
in case here is +1 from me. These patches were "Ready for Committer"
for several months now and are unlikely to get any better. So I
suggest we merge them.Here is the rebased patchset number 44.
Hi
This entry was marked "Ready for committer" in the CommitFest app but cfbot
reports the patch no longer applies.
We've marked it as "Waiting on Author". As CommitFest 2022-11 is
currently underway, this would be an excellent time update the patch.
Once you think the patchset is ready for review again, you (or any
interested party) can move the patch entry forward by visiting
https://commitfest.postgresql.org/40/3489/
and changing the status to "Ready for committer".
Thanks
Ian Barwick
Hi!
This entry was marked "Ready for committer" in the CommitFest app but cfbot
reports the patch no longer applies.
Thanks for the reminder. I think, this should work.
--
Best regards,
Maxim Orlov.
Attachments:
v49-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v49-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From c3e8a82c1e5bdf816f24ba1a442296a71e62fe18 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v49 2/8] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 18 +--
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 45 ++++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 26 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 573 insertions(+), 464 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 12be87efed..2cf364279a 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5170,7 +5170,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6153,8 +6154,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6167,8 +6169,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6186,8 +6189,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6198,7 +6202,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6289,8 +6294,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6339,8 +6345,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6504,8 +6511,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6513,8 +6521,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6641,8 +6650,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6656,8 +6666,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6678,8 +6688,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 41f1ca65d0..487abe0909 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index dfbe37472f..864876adf7 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 923d3bc43d..503808cf0a 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "cutoff xid %u ntuples %u",
- xlrec->cutoff_xid, xlrec->ntuples);
+ appendStringInfo(buf, "cutoff xid %llu ntuples %u",
+ (unsigned long long) 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",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..35addab90c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -39,7 +39,8 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
for (i = 0; i < xlrec->subxcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
+ appendStringInfo(buf, " %llu",
+ (unsigned long long) xlrec->xids[xlrec->xcnt + i]);
}
}
@@ -55,8 +56,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 6bf4f8cbad..4ed7b68aa6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1187,7 +1191,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1237,7 +1242,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1547,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1628,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1670,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2141,8 +2151,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2176,8 +2187,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2362,7 +2373,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2611,12 +2623,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2640,8 +2652,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3024,8 +3037,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3042,16 +3055,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3305,9 +3318,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3356,7 +3370,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3392,7 +3406,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 b36294fe05..202e2aa93c 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -949,13 +949,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -963,12 +965,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -976,26 +980,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 883d6c0f70..c1cfe19b62 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5471,22 +5471,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 64c65f060b..27e5cdee6f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 22a15a482a..51754f3068 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2468,8 +2468,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2907,7 +2907,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3595,8 +3596,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3872,8 +3873,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4517,9 +4518,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5148,8 +5149,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 5006a5c464..a9560067e6 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1099,14 +1099,15 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
else if (sub_needs_timetravel)
{
/* track toplevel txn as well, subxact alone isn't meaningful */
- elog(DEBUG2, "forced transaction %u to do timetravel due to one of its subtransactions",
- xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel due to one of its subtransactions",
+ (unsigned long long) xid);
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1251,8 +1252,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1341,8 +1345,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1424,8 +1429,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1448,8 +1454,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index e48a3f589a..70e8d12d7b 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1113,7 +1113,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1504,7 +1505,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3358,14 +3360,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3527,7 +3531,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4045,33 +4049,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 6cbb67c92a..927fd2dbe5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1216,8 +1216,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a81ef6a201..c446fc2943 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 207c4b27fd..67c159a492 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7db86f7885..53e69e4eb4 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1028,15 +1028,17 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1346,20 +1348,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 2585e24845..598f24f20e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2930,12 +2930,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2943,9 +2945,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index f1f2ddac17..f76bab65cb 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da427f4d4a..8865c77223 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.37.0 (Apple Git-136)
v49-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v49-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From d4f81235fc038229b36f8576ff8f480169c6fa41 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v49 3/8] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 018cd310f7..a5b4a77570 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -265,13 +266,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -286,11 +296,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.37.0 (Apple Git-136)
v49-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v49-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 8112a91b6a96d51d2ba129c4fc1485da9baf52bb Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v49 1/8] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e32579de4c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 204aa95045..6bf4f8cbad 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6c57fae312..b36294fe05 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -225,8 +232,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -277,7 +284,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -392,7 +399,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -492,7 +499,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -539,7 +546,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -623,9 +630,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -681,10 +688,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -753,10 +760,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -928,9 +935,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -962,7 +969,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1013,7 +1021,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1024,10 +1032,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1068,7 +1076,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1158,7 +1166,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1223,7 +1231,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1301,7 +1309,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1324,7 +1332,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1388,9 +1396,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1404,7 +1412,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1497,9 +1505,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1512,9 +1521,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1527,7 +1537,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1555,8 +1565,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.37.0 (Apple Git-136)
On Thu, Nov 3, 2022 at 1:46 PM Maxim Orlov <orlovmg@gmail.com> wrote:
Hi!
This entry was marked "Ready for committer" in the CommitFest app but cfbot
reports the patch no longer applies.Thanks for the reminder. I think, this should work.
Have we measured the WAL overhead because of this patch set? maybe
these particular patches will not impact but IIUC this is ground work
for making xid 64 bit. So each XLOG record size will increase at
least by 4 bytes because the XLogRecord contains the xid.
--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com
2022年11月3日(木) 17:15 Maxim Orlov <orlovmg@gmail.com>:
Hi!
This entry was marked "Ready for committer" in the CommitFest app but cfbot
reports the patch no longer applies.Thanks for the reminder. I think, this should work.
Thanks for the quick update, cfbot reports no issues.
I've set the CF entry back to "Ready for Committer",
Regards
Ian Barwick
Hi Ian,
I've set the CF entry back to "Ready for Committer",
Thanks. Here is the rebased patchset.
Dilip asked a good question above about the rest of the 64-bit XIDs
patches. I'm going to do some testing and post the results to the main
64-bit XIDs thread [1]/messages/by-id/CAJ7c6TOkpJi78A9chR-j0OOMvP6G=uR+scpEKsM4jtw0dK9-3Q@mail.gmail.com.
[1]: /messages/by-id/CAJ7c6TOkpJi78A9chR-j0OOMvP6G=uR+scpEKsM4jtw0dK9-3Q@mail.gmail.com
--
Best regards,
Aleksander Alekseev
Attachments:
v45-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v45-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From cca2d25dea1a8f094947fad5eb031dd93706a718 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v45 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
v45-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v45-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From d380bbee9358dbcea31fbc9b2e2a65b8e3e734a1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v45 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
9 files changed, 93 insertions(+), 83 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e32579de4c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 204aa95045..6bf4f8cbad 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
--
2.38.1
v45-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v45-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 627aa4e39882fcde00cd13d94f5bfc90893c9082 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v45 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 102 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 566 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 807a09d36d..d6d223c414 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6643,8 +6652,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6658,8 +6668,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6680,8 +6690,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 41f1ca65d0..487abe0909 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 834ab83a0e..e6821debd9 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 3f8c5e63f3..fcf34f51e7 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nplans %u",
- xlrec->latestRemovedXid, xlrec->nplans);
+ appendStringInfo(buf, "latestRemovedXid %llu nplans %u",
+ (unsigned long long)xlrec->latestRemovedXid, xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..466cda8b4c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -55,8 +55,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 6bf4f8cbad..32dd8671ae 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1187,7 +1191,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1237,7 +1242,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,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 %llu", (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1546,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1627,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1669,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2141,8 +2150,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2176,8 +2186,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2362,7 +2372,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2611,12 +2622,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2640,8 +2651,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3024,8 +3036,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3042,16 +3054,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3305,9 +3317,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3356,7 +3369,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3392,7 +3405,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index f05e72f0dc..7be189b419 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 31f7381f2d..249b9a8a8e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2468,8 +2468,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2907,7 +2907,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3597,8 +3598,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3874,8 +3875,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4519,9 +4520,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5150,8 +5151,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 5006a5c464..398f3c367e 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1106,7 +1106,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1251,8 +1252,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1341,8 +1345,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1424,8 +1429,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1448,8 +1454,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index e48a3f589a..70e8d12d7b 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1113,7 +1113,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1504,7 +1505,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3358,14 +3360,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3527,7 +3531,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4045,33 +4049,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 8bd2ba37dd..6adf902edf 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1234,8 +1234,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a81ef6a201..c446fc2943 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 9e8b6756fe..9fa37e61ce 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7db86f7885..e6d90d52da 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1028,15 +1028,15 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1346,20 +1346,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 2585e24845..598f24f20e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2930,12 +2930,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2943,9 +2945,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da427f4d4a..8865c77223 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
Hi hackers,
I've set the CF entry back to "Ready for Committer",
Thanks. Here is the rebased patchset.
After merging 006b69fd [1]https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=006b69fd the 0001 patch needed a rebase. PFA v46.
[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=006b69fd
--
Best regards,
Aleksander Alekseev
Attachments:
v46-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v46-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 80e6f8b3cf254c055707396940347fe985561fa9 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v46 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru.c | 11 +--
10 files changed, 99 insertions(+), 88 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e32579de4c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 204aa95045..6bf4f8cbad 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..016786a4e6 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %llu on path %s",
+ (unsigned long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -170,7 +170,8 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %llu",
+ (unsigned long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
v46-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v46-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From defa1638cb079a9c8645004acade20446ce06bb5 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v46 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index bda471f5d4..ad855894be 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 9ad2287a71..bf25c941e4 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; latestRemovedXid %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
v46-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v46-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From b3c3ce1d6c6d6ec72fc4833142a6c9a1177d46f0 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v46 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 38 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 13 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 102 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 566 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 2e5bb7e9c2..0d7dcd16b8 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6643,8 +6652,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6658,8 +6668,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6680,8 +6690,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 ab1bcf3522..64144ab030 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 834ab83a0e..e6821debd9 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 7dd3c1d500..bda471f5d4 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: latestRemovedXid %u, nitems: %u",
- xlrec->latestRemovedXid, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: latestRemovedXid %llu, nitems: %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index ef443bdb16..9030e74b88 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ 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 %llu",
xlrec->ntuples,
- xlrec->latestRemovedXid);
+ (unsigned long long) xlrec->latestRemovedXid);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 3f8c5e63f3..fcf34f51e7 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
- xlrec->latestRemovedXid,
+ appendStringInfo(buf, "latestRemovedXid %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->latestRemovedXid,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,15 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "latestRemovedXid %u nplans %u",
- xlrec->latestRemovedXid, xlrec->nplans);
+ appendStringInfo(buf, "latestRemovedXid %llu nplans %u",
+ (unsigned long long)xlrec->latestRemovedXid, xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
- xlrec->cutoff_xid, xlrec->flags);
+ appendStringInfo(buf, "cutoff xid %llu flags 0x%02X",
+ (unsigned long long) xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +162,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 4843cd530d..9ad2287a71 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,9 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "latestRemovedXid %u; ndeleted %u; nupdated %u",
- xlrec->latestRemovedXid, xlrec->ndeleted, xlrec->nupdated);
+ appendStringInfo(buf, "latestRemovedXid %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->latestRemovedXid,
+ xlrec->ndeleted, xlrec->nupdated);
break;
}
case XLOG_BTREE_MARK_PAGE_HALFDEAD:
@@ -80,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -100,11 +101,11 @@ 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:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->latestRemovedFullXid),
- XidFromFullTransactionId(xlrec->latestRemovedFullXid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->latestRemovedFullXid));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index d5d921a42a..937662e5d4 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ 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: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->newestRedirectXid);
+ (unsigned long long) xlrec->newestRedirectXid);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..466cda8b4c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -55,8 +55,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 6bf4f8cbad..32dd8671ae 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1187,7 +1191,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1237,7 +1242,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,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 %llu", (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1546,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1627,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1669,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2141,8 +2150,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2176,8 +2186,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2362,7 +2372,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2611,12 +2622,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2640,8 +2651,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3024,8 +3036,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3042,16 +3054,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3305,9 +3317,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3356,7 +3369,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3392,7 +3405,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 803d169f57..4b81dfee16 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index f05e72f0dc..7be189b419 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 31f7381f2d..249b9a8a8e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2468,8 +2468,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2907,7 +2907,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3597,8 +3598,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3874,8 +3875,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4519,9 +4520,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5150,8 +5151,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 556b7fcba3..c8c059e5f9 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -882,8 +882,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -962,9 +962,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1064,8 +1064,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1090,8 +1090,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1106,7 +1106,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1251,8 +1252,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1341,8 +1345,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1424,8 +1429,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1448,8 +1454,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index e48a3f589a..70e8d12d7b 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1113,7 +1113,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1504,7 +1505,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3358,14 +3360,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3527,7 +3531,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4045,33 +4049,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ad383dbcaa..8bc611fdda 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1238,8 +1238,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index a81ef6a201..c446fc2943 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2266,10 +2266,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 9e8b6756fe..9fa37e61ce 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3983,7 +3983,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -3999,7 +4000,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4376,8 +4378,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4887,7 +4889,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4947,7 +4950,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5135,7 +5139,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 7db86f7885..e6d90d52da 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1028,15 +1028,15 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1346,20 +1346,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 2585e24845..598f24f20e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2930,12 +2930,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2943,9 +2945,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da427f4d4a..8865c77223 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
Hi hackers,
I've set the CF entry back to "Ready for Committer",
Thanks. Here is the rebased patchset.
After merging 006b69fd the 0001 patch needed a rebase. PFA v46.
After merging 1489b1ce [1]https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1489b1ce the patchset needed a rebase. PFA v47.
[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1489b1ce
--
Best regards,
Aleksander Alekseev
Attachments:
v47-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v47-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 72a4133f8c7e25da4294af5fcbfe7e1a9d98666b Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v47 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a393c72011..177fddb78d 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 97866bde93..c41a61b3f0 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
v47-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v47-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 24a2fb728b84843c82663bfc0f11f0310ad7406d Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v47 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 39 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 10 +-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 15 ++-
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 102 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 41 +++---
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 24 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
48 files changed, 566 insertions(+), 461 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 d18c5ca6f5..7e1e4dc014 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6643,8 +6652,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6658,8 +6668,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6680,8 +6690,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 ab1bcf3522..64144ab030 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 834ab83a0e..e6821debd9 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -709,21 +709,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 97f3520abb..a393c72011 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
- xlrec->snapshotConflictHorizon, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: snapshotConflictHorizon %llu, nitems: %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index a5b861bdad..d8d57e39e6 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;
- appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
+ appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %llu",
xlrec->ntuples,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 325aee93ff..89ed3da472 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nredirected %u ndead %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,16 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nplans %u",
- xlrec->snapshotConflictHorizon, xlrec->nplans);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nplans %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u flags 0x%02X",
- xlrec->snapshotConflictHorizon, xlrec->flags);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu flags 0x%02X",
+ (unsigned long long) xlrec->snapshotConflictHorizon, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +163,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..4cf8a9a4b1 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,7 +65,8 @@ 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, "%llu offset %u nmembers %d: ",
+ (unsigned long long) xlrec->mid,
xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
@@ -74,8 +75,9 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%u, %u)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
xlrec->startTruncMemb, xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index f4a70d54e6..97866bde93 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u; ndeleted %u; nupdated %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->ndeleted, xlrec->nupdated);
break;
}
@@ -81,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +101,11 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 308bd3e27f..e03ab720b7 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ spg_desc(StringInfo buf, XLogReaderState *record)
{
spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;
- appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
+ appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..466cda8b4c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -55,8 +55,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 6bf4f8cbad..32dd8671ae 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1187,7 +1191,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1237,7 +1242,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1517,7 +1523,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 %llu", (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1540,7 +1546,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1620,8 +1627,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1662,11 +1669,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2141,8 +2150,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2176,8 +2186,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2362,7 +2372,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2611,12 +2622,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2640,8 +2651,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3024,8 +3036,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3042,16 +3054,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3305,9 +3317,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3356,7 +3369,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3392,7 +3405,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 5017f4451e..2f99979cb6 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..e83c7dded9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -529,8 +529,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -819,18 +819,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2574,15 +2577,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2719,16 +2722,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2763,9 +2766,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index f05e72f0dc..7be189b419 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 31f7381f2d..249b9a8a8e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2468,8 +2468,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2907,7 +2907,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3597,8 +3598,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3874,8 +3875,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4519,9 +4520,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5150,8 +5151,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 a1fd1d92d6..34af6d42df 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -889,8 +889,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -969,9 +969,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1071,8 +1071,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1097,8 +1097,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1113,7 +1113,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1258,8 +1259,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1348,8 +1352,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1431,8 +1436,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1455,8 +1461,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index e48a3f589a..70e8d12d7b 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1113,7 +1113,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1504,7 +1505,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3358,14 +3360,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3527,7 +3531,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4045,33 +4049,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ad383dbcaa..8bc611fdda 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1238,8 +1238,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index c11bb3716f..a251953ef3 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 283517d956..078ee2383f 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1107,9 +1107,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1193,8 +1193,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1278,9 +1278,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -3988,7 +3988,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4004,7 +4005,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4381,8 +4383,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4892,7 +4894,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -4952,7 +4955,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5140,7 +5144,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index f43229dfda..c7cfefdc87 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1037,15 +1037,15 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long)entry->key.xid, entry->key.dbOid, entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1355,20 +1355,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 8822ca6230..b71a60952d 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4162,7 +4162,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4170,7 +4171,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4800,7 +4802,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 2585e24845..598f24f20e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2930,12 +2930,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2943,9 +2945,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da427f4d4a..8865c77223 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3116,9 +3116,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15627,9 +15628,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15641,10 +15643,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
v47-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v47-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 3f85daa11623cd4f44f5b16429878e5640079f09 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v47 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 ++--
src/backend/access/transam/slru.c | 98 ++++++++++++++------------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++---
src/backend/storage/lmgr/predicate.c | 10 +--
src/include/access/slru.h | 24 +++----
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru.c | 11 +--
10 files changed, 99 insertions(+), 88 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e32579de4c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 204aa95045..6bf4f8cbad 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index e8120174d6..8822ca6230 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -789,7 +789,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -809,7 +809,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -907,9 +907,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..016786a4e6 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %llu on path %s",
+ (unsigned long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -170,7 +170,8 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %llu",
+ (unsigned long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
On Mon, Nov 21, 2022 at 12:21:09PM +0300, Aleksander Alekseev wrote:
After merging 1489b1ce [1] the patchset needed a rebase. PFA v47.
[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1489b1ce
The CF bot is showing some failures here. You may want to
double-check.
--
Michael
Hi Michael,
The CF bot is showing some failures here. You may want to
double-check.
Thanks! PFA v48.
--
Best regards,
Aleksander Alekseev
Attachments:
v48-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v48-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 3bbfadc8250ca09278726d8aa8abf1d8fc069d2a Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v48 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 4 +-
src/backend/access/transam/commit_ts.c | 4 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/slru.h | 24 ++---
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
11 files changed, 113 insertions(+), 102 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e32579de4c 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..e8461ab814 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e1191a7564..d97b63d8e6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2855,7 +2855,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2863,7 +2863,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3114,7 +3114,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3134,7 +3134,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index df1c0d72e9..760a54e021 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..ae269f36db 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
v48-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v48-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From d8060b808f49d3594f36c1362d750e3aa6471178 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v48 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 40 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 15 ++-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 18 +--
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/commands/vacuum.c | 10 +-
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 54 ++++----
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/pgoutput/pgoutput.c | 3 +-
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 26 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
50 files changed, 590 insertions(+), 475 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 747db50376..1f050e4a25 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6645,8 +6654,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6660,8 +6670,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6683,8 +6693,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 ab1bcf3522..64144ab030 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index d59711b7ec..ce090a2b46 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -704,21 +704,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 97f3520abb..a393c72011 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
- xlrec->snapshotConflictHorizon, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: snapshotConflictHorizon %llu, nitems: %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index a5b861bdad..d8d57e39e6 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;
- appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
+ appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %llu",
xlrec->ntuples,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 325aee93ff..d6c27a4f76 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nredirected %u ndead %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,17 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nplans %u",
- xlrec->snapshotConflictHorizon, xlrec->nplans);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nplans %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u flags 0x%02X",
- xlrec->snapshotConflictHorizon, xlrec->flags);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu flags 0x%02X",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +164,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..5f40852e6d 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,8 +65,9 @@ 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,
- xlrec->moff, xlrec->nmembers);
+ appendStringInfo(buf, "%llu offset %llu nmembers %d: ",
+ (unsigned long long) xlrec->mid,
+ (unsigned long long) xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
}
@@ -74,9 +75,11 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
- xlrec->startTruncMemb, xlrec->endTruncMemb);
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%llu, %llu)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
+ (unsigned long long) xlrec->startTruncMemb,
+ (unsigned long long) xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index f4a70d54e6..97866bde93 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u; ndeleted %u; nupdated %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->ndeleted, xlrec->nupdated);
break;
}
@@ -81,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +101,11 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 308bd3e27f..e03ab720b7 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ spg_desc(StringInfo buf, XLogReaderState *record)
{
spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;
- appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
+ appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..35addab90c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -39,7 +39,8 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
for (i = 0; i < xlrec->subxcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
+ appendStringInfo(buf, " %llu",
+ (unsigned long long) xlrec->xids[xlrec->xcnt + i]);
}
}
@@ -55,8 +56,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e8461ab814..d978226bfb 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 d97b63d8e6..71f8caa75f 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1518,7 +1524,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1541,7 +1548,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2142,8 +2152,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2177,8 +2188,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2363,7 +2374,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2612,12 +2624,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2641,8 +2653,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3025,8 +3038,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3043,16 +3056,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3306,9 +3319,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3357,7 +3371,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3393,7 +3407,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 5017f4451e..2f99979cb6 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 97b882564f..76f3b13e00 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -528,8 +528,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -818,18 +818,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2573,15 +2576,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2718,16 +2721,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2762,9 +2765,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index a6d5ed1f6b..81cf0e96a7 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1415,14 +1415,16 @@ vac_update_relstats(Relation relation,
if (futurexid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relfrozenxid value %u with new value %u for table \"%s\"",
- oldfrozenxid, frozenxid,
+ errmsg_internal("overwrote invalid relfrozenxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldfrozenxid,
+ (unsigned long long) frozenxid,
RelationGetRelationName(relation))));
if (futuremxid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relminmxid value %u with new value %u for table \"%s\"",
- oldminmulti, minmulti,
+ errmsg_internal("overwrote invalid relminmxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldminmulti,
+ (unsigned long long) minmulti,
RelationGetRelationName(relation))));
}
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 59b0fdeb62..50172d6247 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 31f7381f2d..249b9a8a8e 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2468,8 +2468,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2907,7 +2907,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3597,8 +3598,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3874,8 +3875,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4519,9 +4520,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5150,8 +5151,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 beddcbcdea..085b055a03 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -605,8 +605,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
LWLockRelease(ProcArrayLock);
if (TransactionIdFollows(safeXid, snap->xmin))
- elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %u follows snapshot's xmin %u",
- safeXid, snap->xmin);
+ elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %llu follows snapshot's xmin %llu",
+ (unsigned long long) safeXid, (unsigned long long) snap->xmin);
MyProc->xmin = snap->xmin;
@@ -889,8 +889,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -969,9 +969,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1006,9 +1006,10 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
builder->catchange.xip = NULL;
}
- elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %u, xmax: %u",
+ elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %llu, xmax: %llu",
(uint32) builder->catchange.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax);
builder->catchange.xcnt = surviving_xids;
}
}
@@ -1071,8 +1072,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1097,8 +1098,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1106,14 +1107,15 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
else if (sub_needs_timetravel)
{
/* track toplevel txn as well, subxact alone isn't meaningful */
- elog(DEBUG2, "forced transaction %u to do timetravel due to one of its subtransactions",
- xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel due to one of its subtransactions",
+ (unsigned long long) xid);
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1258,8 +1260,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1348,8 +1353,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1431,8 +1437,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1455,8 +1462,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 96772e4d73..61ebfa08fa 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1116,7 +1116,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1507,7 +1508,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3363,14 +3365,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3532,7 +3536,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4050,33 +4054,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index ca46fba3af..571801530b 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -584,7 +584,8 @@ pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
if (!sent_begin_txn)
{
- elog(DEBUG1, "skipped replication of an empty transaction with XID: %u", txn->xid);
+ elog(DEBUG1, "skipped replication of an empty transaction with XID: %llu",
+ (unsigned long long) txn->xid);
return;
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ad383dbcaa..8bc611fdda 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1238,8 +1238,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index c11bb3716f..a251953ef3 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 0176f30270..17a80a84c3 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1118,9 +1118,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1204,8 +1204,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1289,9 +1289,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -4002,7 +4002,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4018,7 +4019,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4395,8 +4397,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4968,7 +4970,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -5028,7 +5031,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5216,7 +5220,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index f43229dfda..30bbb02afd 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1037,15 +1037,17 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1355,20 +1357,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 760a54e021..9989fd75ec 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4161,7 +4161,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4169,7 +4170,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4799,7 +4801,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 2585e24845..598f24f20e 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2930,12 +2930,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2943,9 +2945,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ad6693c358..9a34bbf8d6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3151,9 +3151,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15662,9 +15663,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15676,10 +15678,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
v48-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v48-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From a339d9eac921693a8bed2bc1265331ccf1cd7669 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v48 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a393c72011..177fddb78d 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 97866bde93..c41a61b3f0 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
Hi,
On 2022-12-07 11:40:08 +0300, Aleksander Alekseev wrote:
Hi Michael,
The CF bot is showing some failures here. You may want to
double-check.Thanks! PFA v48.
This causes a lot of failures with ubsan:
https://cirrus-ci.com/task/6035600772431872
performing post-bootstrap initialization ... ../src/backend/access/transam/slru.c:1520:9: runtime error: load of misaligned address 0x7fff6362db8c for type 'int64', which requires 8 byte alignment
0x7fff6362db8c: note: pointer points here
01 00 00 00 00 00 00 00 d0 02 00 00 00 00 00 00 d0 02 00 00 00 00 00 00 01 00 00 00 00 00 00 00
^
==18947==Using libbacktrace symbolizer.
#0 0x564d7c45cc6b in SlruScanDirCbReportPresence ../src/backend/access/transam/slru.c:1520
#1 0x564d7c45cd88 in SlruScanDirectory ../src/backend/access/transam/slru.c:1595
#2 0x564d7c44872c in TruncateCLOG ../src/backend/access/transam/clog.c:889
#3 0x564d7c62ecd7 in vac_truncate_clog ../src/backend/commands/vacuum.c:1779
#4 0x564d7c6320a8 in vac_update_datfrozenxid ../src/backend/commands/vacuum.c:1642
#5 0x564d7c632a78 in vacuum ../src/backend/commands/vacuum.c:537
#6 0x564d7c63347d in ExecVacuum ../src/backend/commands/vacuum.c:273
#7 0x564d7ca4afea in standard_ProcessUtility ../src/backend/tcop/utility.c:866
#8 0x564d7ca4b723 in ProcessUtility ../src/backend/tcop/utility.c:530
#9 0x564d7ca46e81 in PortalRunUtility ../src/backend/tcop/pquery.c:1158
#10 0x564d7ca4755d in PortalRunMulti ../src/backend/tcop/pquery.c:1315
#11 0x564d7ca47c02 in PortalRun ../src/backend/tcop/pquery.c:791
#12 0x564d7ca40ecb in exec_simple_query ../src/backend/tcop/postgres.c:1238
#13 0x564d7ca43c01 in PostgresMain ../src/backend/tcop/postgres.c:4551
#14 0x564d7ca441a4 in PostgresSingleUserMain ../src/backend/tcop/postgres.c:4028
#15 0x564d7c74d883 in main ../src/backend/main/main.c:197
#16 0x7fde7793dd09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d09)
#17 0x564d7c2d30c9 in _start (/tmp/cirrus-ci-build/build/tmp_install/usr/local/pgsql/bin/postgres+0x8530c9)
Greetings,
Andres Freund
On Wed, Dec 7, 2022 at 9:50 AM Andres Freund <andres@anarazel.de> wrote:
performing post-bootstrap initialization ... ../src/backend/access/transam/slru.c:1520:9: runtime error: load of misaligned address 0x7fff6362db8c for type 'int64', which requires 8 byte alignment
0x7fff6362db8c: note: pointer points here
01 00 00 00 00 00 00 00 d0 02 00 00 00 00 00 00 d0 02 00 00 00 00 00 00 01 00 00 00 00 00 00 00
I bet that this alignment issue can be fixed by using PGAlignedBlock
instead of a raw char buffer for a page. (I'm guessing, I haven't
directly checked.)
--
Peter Geoghegan
Hi Andres,
This causes a lot of failures with ubsan
Thanks for reporting this!
I managed to reproduce the issue locally and to fix it. UBSAN is happy
now. PFA v49.
I bet that this alignment issue can be fixed by using PGAlignedBlock
instead of a raw char buffer for a page. (I'm guessing, I haven't
directly checked.)
No, actually the problem was much simpler.
0001 changes SLRU page numbering from 32-bit to 64-bit one. This also
changed the SlruScanDirCbReportPresence() callback:
```
bool
SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
void *data)
{
int64 cutoffPage = *(int64 *) data;
```
However TruncateCLOG() and TruncateCommitTs() were not changed
accordingly in v47, they were passing a pointer to int32 as *data.
--
Best regards,
Aleksander Alekseev
Attachments:
v49-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v49-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From 435525992057e5f8cb53e71464737bd19a62ff73 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v49 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a393c72011..177fddb78d 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 97866bde93..c41a61b3f0 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
v49-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v49-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 01ce57ea3998959a1250bb85cd521d5ae1bbb4f8 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v49 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 10 +-
src/backend/access/transam/commit_ts.c | 10 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/slru.h | 24 ++---
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
11 files changed, 119 insertions(+), 108 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..e26187e4e0 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -877,7 +877,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -904,10 +904,10 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* ahead of clog truncation in case we crash, and so a standby finds out
* the new valid xid before the next checkpoint.
*/
- WriteTruncateXlogRec(cutoffPage, oldestXact, oldestxid_datoid);
+ WriteTruncateXlogRec((int)cutoffPage, oldestXact, oldestxid_datoid);
/* Now we can remove the old CLOG segment(s) */
- SimpleLruTruncate(XactCtl, cutoffPage);
+ SimpleLruTruncate(XactCtl, (int)cutoffPage);
}
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..0265d86d64 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -851,7 +851,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -865,10 +865,10 @@ TruncateCommitTs(TransactionId oldestXact)
return; /* nothing to remove */
/* Write XLOG record */
- WriteTruncateXlogRec(cutoffPage, oldestXact);
+ WriteTruncateXlogRec((int)cutoffPage, oldestXact);
/* Now we can remove the old CommitTs segment(s) */
- SimpleLruTruncate(CommitTsCtl, cutoffPage);
+ SimpleLruTruncate(CommitTsCtl, (int)cutoffPage);
}
/*
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e1191a7564..d97b63d8e6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2855,7 +2855,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2863,7 +2863,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3114,7 +3114,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3134,7 +3134,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index df1c0d72e9..760a54e021 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..ae269f36db 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
v49-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v49-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From a29e4549a925094f4105d2475b68d981f644c762 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v49 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 40 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 15 ++-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 18 +--
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/commands/vacuum.c | 10 +-
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 54 ++++----
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/pgoutput/pgoutput.c | 3 +-
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 26 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
50 files changed, 590 insertions(+), 475 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 747db50376..1f050e4a25 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6645,8 +6654,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6660,8 +6670,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6683,8 +6693,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 ab1bcf3522..64144ab030 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index d59711b7ec..ce090a2b46 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -704,21 +704,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 97f3520abb..a393c72011 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
- xlrec->snapshotConflictHorizon, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: snapshotConflictHorizon %llu, nitems: %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index a5b861bdad..d8d57e39e6 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;
- appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
+ appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %llu",
xlrec->ntuples,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 325aee93ff..d6c27a4f76 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nredirected %u ndead %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,17 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nplans %u",
- xlrec->snapshotConflictHorizon, xlrec->nplans);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nplans %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u flags 0x%02X",
- xlrec->snapshotConflictHorizon, xlrec->flags);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu flags 0x%02X",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +164,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..5f40852e6d 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,8 +65,9 @@ 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,
- xlrec->moff, xlrec->nmembers);
+ appendStringInfo(buf, "%llu offset %llu nmembers %d: ",
+ (unsigned long long) xlrec->mid,
+ (unsigned long long) xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
}
@@ -74,9 +75,11 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
- xlrec->startTruncMemb, xlrec->endTruncMemb);
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%llu, %llu)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
+ (unsigned long long) xlrec->startTruncMemb,
+ (unsigned long long) xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index f4a70d54e6..97866bde93 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u; ndeleted %u; nupdated %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->ndeleted, xlrec->nupdated);
break;
}
@@ -81,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +101,11 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 308bd3e27f..e03ab720b7 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ spg_desc(StringInfo buf, XLogReaderState *record)
{
spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;
- appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
+ appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..35addab90c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -39,7 +39,8 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
for (i = 0; i < xlrec->subxcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
+ appendStringInfo(buf, " %llu",
+ (unsigned long long) xlrec->xids[xlrec->xcnt + i]);
}
}
@@ -55,8 +56,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 0265d86d64..758c3360fd 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 d97b63d8e6..71f8caa75f 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1518,7 +1524,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1541,7 +1548,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2142,8 +2152,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2177,8 +2188,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2363,7 +2374,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2612,12 +2624,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2641,8 +2653,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3025,8 +3038,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3043,16 +3056,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3306,9 +3319,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3357,7 +3371,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3393,7 +3407,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 5017f4451e..2f99979cb6 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 97b882564f..76f3b13e00 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -528,8 +528,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -818,18 +818,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2573,15 +2576,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2718,16 +2721,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2762,9 +2765,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index a6d5ed1f6b..81cf0e96a7 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1415,14 +1415,16 @@ vac_update_relstats(Relation relation,
if (futurexid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relfrozenxid value %u with new value %u for table \"%s\"",
- oldfrozenxid, frozenxid,
+ errmsg_internal("overwrote invalid relfrozenxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldfrozenxid,
+ (unsigned long long) frozenxid,
RelationGetRelationName(relation))));
if (futuremxid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relminmxid value %u with new value %u for table \"%s\"",
- oldminmulti, minmulti,
+ errmsg_internal("overwrote invalid relminmxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldminmulti,
+ (unsigned long long) minmulti,
RelationGetRelationName(relation))));
}
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 59b0fdeb62..50172d6247 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index b567b8b59e..2b2bc1af07 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2492,8 +2492,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2931,7 +2931,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3622,8 +3623,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3899,8 +3900,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4544,9 +4545,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5175,8 +5176,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 beddcbcdea..085b055a03 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -605,8 +605,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
LWLockRelease(ProcArrayLock);
if (TransactionIdFollows(safeXid, snap->xmin))
- elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %u follows snapshot's xmin %u",
- safeXid, snap->xmin);
+ elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %llu follows snapshot's xmin %llu",
+ (unsigned long long) safeXid, (unsigned long long) snap->xmin);
MyProc->xmin = snap->xmin;
@@ -889,8 +889,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -969,9 +969,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1006,9 +1006,10 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
builder->catchange.xip = NULL;
}
- elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %u, xmax: %u",
+ elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %llu, xmax: %llu",
(uint32) builder->catchange.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax);
builder->catchange.xcnt = surviving_xids;
}
}
@@ -1071,8 +1072,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1097,8 +1098,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1106,14 +1107,15 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
else if (sub_needs_timetravel)
{
/* track toplevel txn as well, subxact alone isn't meaningful */
- elog(DEBUG2, "forced transaction %u to do timetravel due to one of its subtransactions",
- xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel due to one of its subtransactions",
+ (unsigned long long) xid);
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1258,8 +1260,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1348,8 +1353,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1431,8 +1437,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1455,8 +1462,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 96772e4d73..61ebfa08fa 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1116,7 +1116,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1507,7 +1508,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3363,14 +3365,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3532,7 +3536,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4050,33 +4054,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index ca46fba3af..571801530b 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -584,7 +584,8 @@ pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
if (!sent_begin_txn)
{
- elog(DEBUG1, "skipped replication of an empty transaction with XID: %u", txn->xid);
+ elog(DEBUG1, "skipped replication of an empty transaction with XID: %llu",
+ (unsigned long long) txn->xid);
return;
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ad383dbcaa..8bc611fdda 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1238,8 +1238,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index c11bb3716f..a251953ef3 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 0176f30270..17a80a84c3 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1118,9 +1118,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1204,8 +1204,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1289,9 +1289,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -4002,7 +4002,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4018,7 +4019,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4395,8 +4397,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4968,7 +4970,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -5028,7 +5031,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5216,7 +5220,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index f43229dfda..30bbb02afd 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1037,15 +1037,17 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1355,20 +1357,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 760a54e021..9989fd75ec 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4161,7 +4161,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4169,7 +4170,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4799,7 +4801,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index f5cd1b7493..0eb27b2acc 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2955,12 +2955,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2968,9 +2970,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ad6693c358..9a34bbf8d6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3151,9 +3151,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15662,9 +15663,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15676,10 +15678,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
Hi hackers,
I managed to reproduce the issue locally and to fix it. UBSAN is happy
now. PFA v49.
Maxim Orlov pointed out offlist that this cast is not needed:
```
- SimpleLruTruncate(CommitTsCtl, (int)cutoffPage);
+ SimpleLruTruncate(CommitTsCtl, cutoffPage);
```
SimpleLruTruncate() accepts cutoffPage as uint64 in 0001.
PFA the corrected patchset v50.
--
Best regards,
Aleksander Alekseev
Attachments:
v50-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v50-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 460a73c73fee99919f13230aff508276a3484c29 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v50 1/3] Use 64-bit numbering of SLRU pages.
Having 64-bit numbering of SLRU pages is a requirement for using 64-bit XIDs.
This is part of transition to 64bit XIDs. It does not affect XID length and
format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/clog.c | 8 +-
src/backend/access/transam/commit_ts.c | 8 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/slru.h | 24 ++---
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
11 files changed, 117 insertions(+), 106 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 77d9894dab..cee138a1f7 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -90,7 +90,7 @@ static SlruCtlData XactCtlData;
static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
Oid oldestXactDb);
@@ -877,7 +877,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -904,7 +904,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* ahead of clog truncation in case we crash, and so a standby finds out
* the new valid xid before the next checkpoint.
*/
- WriteTruncateXlogRec(cutoffPage, oldestXact, oldestxid_datoid);
+ WriteTruncateXlogRec((int)cutoffPage, oldestXact, oldestxid_datoid);
/* Now we can remove the old CLOG segment(s) */
SimpleLruTruncate(XactCtl, cutoffPage);
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..a0001d2f4f 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -851,7 +851,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -865,7 +865,7 @@ TruncateCommitTs(TransactionId oldestXact)
return; /* nothing to remove */
/* Write XLOG record */
- WriteTruncateXlogRec(cutoffPage, oldestXact);
+ WriteTruncateXlogRec((int)cutoffPage, oldestXact);
/* Now we can remove the old CommitTs segment(s) */
SimpleLruTruncate(CommitTsCtl, cutoffPage);
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e1191a7564..d97b63d8e6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2855,7 +2855,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2863,7 +2863,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3114,7 +3114,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3134,7 +3134,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..89d3edea5e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit XIDs yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index df1c0d72e9..760a54e021 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..ae269f36db 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
v50-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchapplication/octet-stream; name=v50-0003-Use-64-bit-FullTransactionId-instead-of-Epoch-xi.patchDownload
From ebe9063cf537f7ca953ce9620f15d27744e573ba Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 12:36:24 +0300
Subject: [PATCH v50 3/3] Use 64-bit FullTransactionId instead of Epoch:xid
NextXid in controldata is now compatible with old format Epoch:xid and the new
one. This is next step to make XIDs 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 75 ++++++++++---------------
contrib/pageinspect/btreefuncs.c | 5 +-
src/backend/access/rmgrdesc/gistdesc.c | 10 ++--
src/backend/access/rmgrdesc/nbtdesc.c | 10 ++--
src/backend/access/rmgrdesc/xlogdesc.c | 5 +-
src/backend/utils/misc/pg_controldata.c | 5 +-
src/bin/pg_controldata/pg_controldata.c | 5 +-
src/bin/pg_upgrade/controldata.c | 32 +++++++++--
8 files changed, 73 insertions(+), 74 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4a20950c01..053f188fed 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
break;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmin %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmin %llu precedes relation freeze threshold %llu",
(unsigned long long) xmin,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +779,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -851,24 +845,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return false;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %llu",
(unsigned long long) xvac,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -1014,24 +1005,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ psprintf("update xid %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("update xid %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1076,24 +1064,21 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->next_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ psprintf("xmax %llu precedes relation freeze threshold %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->relfrozenfxid),
- (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ psprintf("xmax %llu precedes oldest valid transaction ID %llu",
(unsigned long long) xmax,
- EpochFromFullTransactionId(ctx->oldest_fxid),
- (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) U64FromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9f120a7bf3..b18aa0af7f 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,8 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
{
FullTransactionId safexid = BTPageGetDeleteXid(page);
- elog(DEBUG2, "deleted page from block %u has safexid %u:%llu",
- blkno, EpochFromFullTransactionId(safexid),
- (unsigned long long) XidFromFullTransactionId(safexid));
+ elog(DEBUG2, "deleted page from block %u has safexid %llu",
+ blkno, (unsigned long long) U64FromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index a393c72011..177fddb78d 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,11 +26,10 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
@@ -51,9 +50,8 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
static void
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
{
- appendStringInfo(buf, "deleteXid %u:%llu; downlink %u",
- EpochFromFullTransactionId(xlrec->deleteXid),
- (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
+ appendStringInfo(buf, "deleteXid %llu; downlink %u",
+ (unsigned long long) U64FromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 97866bde93..c41a61b3f0 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -81,10 +81,9 @@ 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:%llu; ",
+ appendStringInfo(buf, "left %u; right %u; level %u; safexid %llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
- EpochFromFullTransactionId(xlrec->safexid),
- (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) U64FromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +100,10 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
- EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) U64FromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 3d30cc18c6..647d64dc9a 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%llu; oid %u; multi %llu; offset %u; "
+ "tli %u; prev tli %u; fpw %s; xid %llu; oid %u; multi %llu; offset %u; "
"oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
"oldest/newest commit timestamp xid: %llu/%llu; "
"oldest running xid %llu; %s",
@@ -53,8 +53,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
- EpochFromFullTransactionId(checkpoint->nextXid),
- (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) U64FromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
(unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 88f6f33ef5..4ab4a0a701 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%llu",
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ values[6] = CStringGetTextDatum(psprintf("%llu",
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 2c10322355..a8a46d5bf0 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,9 +247,8 @@ 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:%llu\n"),
- EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ printf(_("Latest checkpoint's NextXID: %llu\n"),
+ (unsigned long long) U64FromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c
index 73bfd14397..b05a23e92a 100644
--- a/src/bin/pg_upgrade/controldata.c
+++ b/src/bin/pg_upgrade/controldata.c
@@ -8,6 +8,7 @@
*/
#include "postgres_fe.h"
+#include "access/transam.h"
#include <ctype.h>
@@ -268,13 +269,22 @@ get_control_data(ClusterInfo *cluster, bool live_check)
}
else if ((p = strstr(bufin, "Latest checkpoint's NextXID:")) != NULL)
{
+ FullTransactionId xid;
+
p = strchr(p, ':');
if (p == NULL || strlen(p) <= 1)
pg_fatal("%d: controldata retrieval problem", __LINE__);
p++; /* remove ':' char */
- cluster->controldata.chkpnt_nxtepoch = str2uint(p);
+
+ /*
+ * NextXID representation in controldata file changed from Epoch:Xid
+ * to 64-bit FullTransactionId representation as a part of making
+ * xids 64-bit in the future. Here we support both controldata
+ * formats.
+ */
+ xid.value = strtou64(p, NULL, 10);
/*
* Delimiter changed from '/' to ':' in 9.6. We don't test for
@@ -289,11 +299,23 @@ get_control_data(ClusterInfo *cluster, bool live_check)
else
p = NULL;
- if (p == NULL || strlen(p) <= 1)
- pg_fatal("%d: controldata retrieval problem", __LINE__);
+ if (p == NULL)
+ {
+ /* FullTransactionId representation */
+ cluster->controldata.chkpnt_nxtxid = XidFromFullTransactionId(xid);
+ cluster->controldata.chkpnt_nxtepoch = EpochFromFullTransactionId(xid);
+ }
+ else
+ {
+ if (strlen(p) <= 1)
+ pg_fatal("%d: controldata retrieval problem", __LINE__);
+
+ /* Epoch:Xid representation */
+ p++; /* remove '/' or ':' char */
+ cluster->controldata.chkpnt_nxtxid = str2uint(p);
+ cluster->controldata.chkpnt_nxtepoch = (TransactionId) XidFromFullTransactionId(xid);
+ }
- p++; /* remove '/' or ':' char */
- cluster->controldata.chkpnt_nxtxid = str2uint(p);
got_xid = true;
}
else if ((p = strstr(bufin, "Latest checkpoint's NextOID:")) != NULL)
--
2.38.1
v50-0002-Use-64-bit-format-to-output-XIDs.patchapplication/octet-stream; name=v50-0002-Use-64-bit-format-to-output-XIDs.patchDownload
From 53c72c875782384723223d10a799abe1d5dccd37 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 25 Mar 2022 15:24:25 +0300
Subject: [PATCH v50 2/3] Use 64-bit format to output XIDs
Replace the %u formatting string for XIDs with %llu and cast to
unsigned long long. This is the part of a making XIDs 64-bit.
While actually XIDs are still 32-bit, this patch completely supports both
32 and 64-bit.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
contrib/amcheck/verify_heapam.c | 122 +++++++++---------
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pgrowlocks/pgrowlocks.c | 9 +-
contrib/test_decoding/test_decoding.c | 38 ++++--
src/backend/access/heap/heapam.c | 54 ++++----
src/backend/access/heap/heapam_handler.c | 4 +-
src/backend/access/heap/vacuumlazy.c | 12 +-
src/backend/access/rmgrdesc/clogdesc.c | 4 +-
src/backend/access/rmgrdesc/committsdesc.c | 4 +-
src/backend/access/rmgrdesc/gistdesc.c | 13 +-
src/backend/access/rmgrdesc/hashdesc.c | 4 +-
src/backend/access/rmgrdesc/heapdesc.c | 40 +++---
src/backend/access/rmgrdesc/mxactdesc.c | 15 ++-
src/backend/access/rmgrdesc/nbtdesc.c | 12 +-
src/backend/access/rmgrdesc/spgdesc.c | 4 +-
src/backend/access/rmgrdesc/standbydesc.c | 18 +--
src/backend/access/rmgrdesc/xactdesc.c | 10 +-
src/backend/access/rmgrdesc/xlogdesc.c | 22 ++--
src/backend/access/transam/commit_ts.c | 3 +-
src/backend/access/transam/multixact.c | 103 ++++++++-------
src/backend/access/transam/slru.c | 24 ++--
src/backend/access/transam/subtrans.c | 5 +-
src/backend/access/transam/transam.c | 8 +-
src/backend/access/transam/twophase.c | 40 +++---
src/backend/access/transam/xact.c | 16 ++-
src/backend/access/transam/xlogrecovery.c | 45 ++++---
src/backend/commands/vacuum.c | 10 +-
src/backend/nodes/outfuncs.c | 2 +-
src/backend/replication/logical/logical.c | 4 +-
.../replication/logical/reorderbuffer.c | 23 ++--
src/backend/replication/logical/snapbuild.c | 54 ++++----
src/backend/replication/logical/worker.c | 30 +++--
src/backend/replication/pgoutput/pgoutput.c | 3 +-
src/backend/replication/walreceiver.c | 5 +-
src/backend/replication/walsender.c | 6 +-
src/backend/storage/ipc/procarray.c | 35 ++---
src/backend/storage/ipc/standby.c | 26 ++--
src/backend/storage/lmgr/predicate.c | 9 +-
src/backend/utils/adt/lockfuncs.c | 3 +-
src/backend/utils/error/csvlog.c | 5 +-
src/backend/utils/error/elog.c | 14 +-
src/backend/utils/error/jsonlog.c | 8 +-
src/backend/utils/misc/pg_controldata.c | 4 +-
src/backend/utils/time/snapmgr.c | 18 ++-
src/bin/pg_amcheck/t/004_verify_heapam.pl | 8 +-
src/bin/pg_controldata/pg_controldata.c | 32 ++---
src/bin/pg_dump/pg_dump.c | 17 ++-
src/bin/pg_resetwal/pg_resetwal.c | 66 +++++-----
src/bin/pg_upgrade/pg_upgrade.c | 46 +++----
src/bin/pg_waldump/pg_waldump.c | 4 +-
50 files changed, 590 insertions(+), 475 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index b72a5c96d1..4a20950c01 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -741,24 +741,24 @@ 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",
- xmin,
+ psprintf("xmin %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes oldest valid transaction ID %u:%u",
- xmin,
+ psprintf("xmin %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmin %u precedes relation freeze threshold %u:%u",
- xmin,
+ psprintf("xmin %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmin,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false;
}
@@ -782,24 +782,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -809,13 +809,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved off tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -851,24 +851,24 @@ 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) 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",
- xvac,
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xvac,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false;
case XID_BOUNDS_OK:
break;
@@ -878,13 +878,13 @@ 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple matches our current transaction ID",
+ (unsigned long long) 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",
- xvac));
+ psprintf("old-style VACUUM FULL transaction ID %llu for moved in tuple appears to be in progress",
+ (unsigned long long) xvac));
return false;
case XID_COMMITTED:
@@ -954,19 +954,21 @@ 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",
- xmax, ctx->relminmxid));
+ psprintf("multitransaction ID %llu precedes relation minimum multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->relminmxid));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("multitransaction ID %u precedes oldest valid multitransaction ID threshold %u",
- xmax, ctx->oldest_mxact));
+ psprintf("multitransaction ID %llu precedes oldest valid multitransaction ID threshold %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->oldest_mxact));
return true;
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("multitransaction ID %u equals or exceeds next valid multitransaction ID %u",
- xmax,
- ctx->next_mxact));
+ psprintf("multitransaction ID %llu equals or exceeds next valid multitransaction ID %llu",
+ (unsigned long long) xmax,
+ (unsigned long long) ctx->next_mxact));
return true;
case XID_BOUNDS_OK:
break;
@@ -1012,24 +1014,24 @@ 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",
- xmax,
+ psprintf("update xid %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return true;
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("update xid %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return true;
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("update xid %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("update xid %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return true;
case XID_BOUNDS_OK:
break;
@@ -1074,24 +1076,24 @@ check_tuple_visibility(HeapCheckContext *ctx)
{
case XID_IN_FUTURE:
report_corruption(ctx,
- psprintf("xmax %u equals or exceeds next valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu equals or exceeds next valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->next_fxid),
- XidFromFullTransactionId(ctx->next_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->next_fxid)));
return false; /* corrupt */
case XID_PRECEDES_RELMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes relation freeze threshold %u:%u",
- xmax,
+ psprintf("xmax %llu precedes relation freeze threshold %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->relfrozenfxid),
- XidFromFullTransactionId(ctx->relfrozenfxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->relfrozenfxid)));
return false; /* corrupt */
case XID_PRECEDES_CLUSTERMIN:
report_corruption(ctx,
- psprintf("xmax %u precedes oldest valid transaction ID %u:%u",
- xmax,
+ psprintf("xmax %llu precedes oldest valid transaction ID %u:%llu",
+ (unsigned long long) xmax,
EpochFromFullTransactionId(ctx->oldest_fxid),
- XidFromFullTransactionId(ctx->oldest_fxid)));
+ (unsigned long long) XidFromFullTransactionId(ctx->oldest_fxid)));
return false; /* corrupt */
case XID_BOUNDS_OK:
case XID_INVALID:
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 9375d55e14..9f120a7bf3 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -125,9 +125,9 @@ 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:%llu",
blkno, EpochFromFullTransactionId(safexid),
- XidFromFullTransactionId(safexid));
+ (unsigned long long) XidFromFullTransactionId(safexid));
}
else
elog(DEBUG2, "deleted page from block %u has safexid %u",
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index c543277b7c..a14d90f001 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -142,7 +142,8 @@ 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, "%llu",
+ (unsigned long long) xmax);
if (infomask & HEAP_XMAX_IS_MULTI)
{
MultiXactMember *members;
@@ -183,7 +184,8 @@ pgrowlocks(PG_FUNCTION_ARGS)
strcat(values[Atnum_modes], ",");
strcat(values[Atnum_pids], ",");
}
- snprintf(buf, NCHARS, "%u", members[j].xid);
+ snprintf(buf, NCHARS, "%llu",
+ (unsigned long long) members[j].xid);
strcat(values[Atnum_xids], buf);
switch (members[j].status)
{
@@ -224,7 +226,8 @@ 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, "{%llu}",
+ (unsigned long long) 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 e0fd6f1765..eae0c0ee3c 100644
--- a/contrib/test_decoding/test_decoding.c
+++ b/contrib/test_decoding/test_decoding.c
@@ -310,7 +310,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "BEGIN");
OutputPluginWrite(ctx, last_write);
@@ -333,7 +333,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 %llu", (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "COMMIT");
@@ -386,7 +386,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -408,7 +408,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -432,7 +432,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 %llu", (unsigned long long) txn->xid);
if (data->include_timestamp)
appendStringInfo(ctx->out, " (at %s)",
@@ -781,7 +781,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "opening a streamed block for transaction");
OutputPluginWrite(ctx, last_write);
@@ -799,7 +801,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "closing a streamed block for transaction");
OutputPluginWrite(ctx, true);
@@ -833,7 +837,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "aborting streamed (sub)transaction");
OutputPluginWrite(ctx, true);
@@ -853,8 +859,10 @@ pg_decode_stream_prepare(LogicalDecodingContext *ctx,
OutputPluginPrepareWrite(ctx, true);
if (data->include_xids)
- appendStringInfo(ctx->out, "preparing streamed transaction TXN %s, txid %u",
- quote_literal_cstr(txn->gid), txn->xid);
+ appendStringInfo(ctx->out,
+ "preparing streamed transaction TXN %s, txid %llu",
+ quote_literal_cstr(txn->gid),
+ (unsigned long long) txn->xid);
else
appendStringInfo(ctx->out, "preparing streamed transaction %s",
quote_literal_cstr(txn->gid));
@@ -884,7 +892,9 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "committing streamed transaction");
@@ -918,7 +928,8 @@ 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 %llu",
+ (unsigned long long) txn->xid);
else
appendStringInfoString(ctx->out, "streaming change for transaction");
OutputPluginWrite(ctx, true);
@@ -971,7 +982,8 @@ 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 %llu",
+ (unsigned long long) 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 747db50376..1f050e4a25 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5173,7 +5173,8 @@ 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 %llu",
+ (unsigned long long) xmax);
old_infomask |= HEAP_XMAX_INVALID;
old_infomask &= ~HEAP_XMAX_LOCK_ONLY;
goto l5;
@@ -6156,8 +6157,9 @@ 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",
- multi, relminmxid)));
+ errmsg_internal("found multixact %llu from before relminmxid %llu",
+ (unsigned long long) multi,
+ (unsigned long long) relminmxid)));
else if (MultiXactIdPrecedes(multi, cutoff_multi))
{
/*
@@ -6170,8 +6172,9 @@ 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",
- multi, cutoff_multi)));
+ errmsg_internal("multixact %llu from before cutoff %llu found to be still running",
+ (unsigned long long) multi,
+ (unsigned long long) cutoff_multi)));
if (HEAP_XMAX_IS_LOCKED_ONLY(t_infomask))
{
@@ -6189,8 +6192,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
/*
* If the xid is older than the cutoff, it has to have aborted,
@@ -6201,7 +6205,8 @@ 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 %llu",
+ (unsigned long long) xid)));
*flags |= FRM_INVALIDATE_XMAX;
xid = InvalidTransactionId;
}
@@ -6292,8 +6297,9 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask,
if (TransactionIdPrecedes(txid, relfrozenxid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("found update xid %u from before relfrozenxid %u",
- txid, relfrozenxid)));
+ errmsg_internal("found update xid %llu from before relfrozenxid %llu",
+ (unsigned long long) txid,
+ (unsigned long long) relfrozenxid)));
/*
* It's an update; should we keep it? If the transaction is known
@@ -6342,8 +6348,9 @@ 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",
- update_xid, cutoff_xid)));
+ errmsg_internal("found update xid %llu from before xid cutoff %llu",
+ (unsigned long long) update_xid,
+ (unsigned long long) cutoff_xid)));
/*
* We determined that this is an Xid corresponding to an update
@@ -6506,8 +6513,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmin %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
if (xmin_frozen)
@@ -6515,8 +6523,9 @@ 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",
- xid, cutoff_xid)));
+ errmsg_internal("uncommitted xmin %llu from before xid cutoff %llu needs to be frozen",
+ (unsigned long long) xid,
+ (unsigned long long) cutoff_xid)));
frz->t_infomask |= HEAP_XMIN_FROZEN;
changed = true;
@@ -6645,8 +6654,9 @@ 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",
- xid, relfrozenxid)));
+ errmsg_internal("found xmax %llu from before relfrozenxid %llu",
+ (unsigned long long) xid,
+ (unsigned long long) relfrozenxid)));
if (TransactionIdPrecedes(xid, cutoff_xid))
{
@@ -6660,8 +6670,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple,
TransactionIdDidCommit(xid))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("cannot freeze committed xmax %u",
- xid)));
+ errmsg_internal("cannot freeze committed xmax %llu",
+ (unsigned long long) xid)));
freeze_xmax = true;
/* No need for relfrozenxid_out handling, since we'll freeze xmax */
}
@@ -6683,8 +6693,8 @@ 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",
- xid, tuple->t_infomask)));
+ errmsg_internal("found xmax %llu (infomask 0x%04x) not frozen, not multi, not normal",
+ (unsigned long long) 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 ab1bcf3522..64144ab030 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -424,8 +424,8 @@ 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\"",
- SnapshotDirty.xmin,
+ errmsg_internal("t_xmin %llu is uncommitted in tuple (%u,%u) to be updated in table \"%s\"",
+ (unsigned long long) SnapshotDirty.xmin,
ItemPointerGetBlockNumber(&tuple->t_self),
ItemPointerGetOffsetNumber(&tuple->t_self),
RelationGetRelationName(relation))));
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index d59711b7ec..ce090a2b46 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -704,21 +704,21 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
vacrel->missed_dead_pages);
diff = (int32) (ReadNextTransactionId() - OldestXmin);
appendStringInfo(&buf,
- _("removable cutoff: %u, which was %d XIDs old when operation ended\n"),
- OldestXmin, diff);
+ _("removable cutoff: %llu, which was %d XIDs old when operation ended\n"),
+ (unsigned long long) OldestXmin, diff);
if (frozenxid_updated)
{
diff = (int32) (vacrel->NewRelfrozenXid - vacrel->relfrozenxid);
appendStringInfo(&buf,
- _("new relfrozenxid: %u, which is %d XIDs ahead of previous value\n"),
- vacrel->NewRelfrozenXid, diff);
+ _("new relfrozenxid: %llu, which is %d XIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelfrozenXid, diff);
}
if (minmulti_updated)
{
diff = (int32) (vacrel->NewRelminMxid - vacrel->relminmxid);
appendStringInfo(&buf,
- _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"),
- vacrel->NewRelminMxid, diff);
+ _("new relminmxid: %llu, which is %d MXIDs ahead of previous value\n"),
+ (unsigned long long) vacrel->NewRelminMxid, diff);
}
appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"),
vacrel->frozen_pages,
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..bbb5910633 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -35,8 +35,8 @@ clog_desc(StringInfo buf, XLogReaderState *record)
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %d; oldestXact %llu",
+ xlrec.pageno, (unsigned long long) xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..4b2e9bc2ff 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -35,8 +35,8 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %d, oldestXid %llu",
+ trunc->pageno, (unsigned long long) trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/gistdesc.c b/src/backend/access/rmgrdesc/gistdesc.c
index 97f3520abb..a393c72011 100644
--- a/src/backend/access/rmgrdesc/gistdesc.c
+++ b/src/backend/access/rmgrdesc/gistdesc.c
@@ -26,18 +26,19 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec)
{
- appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber, xlrec->block,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
}
static void
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec)
{
- appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u",
- xlrec->snapshotConflictHorizon, xlrec->ntodelete);
+ appendStringInfo(buf, "delete: snapshotConflictHorizon %llu, nitems: %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->ntodelete);
}
static void
@@ -50,9 +51,9 @@ 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:%llu; downlink %u",
EpochFromFullTransactionId(xlrec->deleteXid),
- XidFromFullTransactionId(xlrec->deleteXid),
+ (unsigned long long) XidFromFullTransactionId(xlrec->deleteXid),
xlrec->downlinkOffset);
}
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index a5b861bdad..d8d57e39e6 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -113,9 +113,9 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;
- appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
+ appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %llu",
xlrec->ntuples,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
break;
}
}
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 325aee93ff..d6c27a4f76 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -58,27 +58,27 @@ 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 %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_HOT_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
+ appendStringInfo(buf, "off %u xmax %llu flags 0x%02X ",
xlrec->old_offnum,
- xlrec->old_xmax,
+ (unsigned long long) 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 %llu",
xlrec->new_offnum,
- xlrec->new_xmax);
+ (unsigned long long) xlrec->new_xmax);
}
else if (info == XLOG_HEAP_TRUNCATE)
{
@@ -103,8 +103,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
- xlrec->offnum, xlrec->locking_xid, xlrec->flags);
+ appendStringInfo(buf, "off %u: xid %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->locking_xid,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_INPLACE)
@@ -125,8 +126,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_prune *xlrec = (xl_heap_prune *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nredirected %u ndead %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nredirected %u ndead %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->nredirected,
xlrec->ndead);
}
@@ -140,15 +141,17 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u nplans %u",
- xlrec->snapshotConflictHorizon, xlrec->nplans);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu nplans %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->nplans);
}
else if (info == XLOG_HEAP2_VISIBLE)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u flags 0x%02X",
- xlrec->snapshotConflictHorizon, xlrec->flags);
+ appendStringInfo(buf, "snapshotConflictHorizon %llu flags 0x%02X",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
+ xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
@@ -161,8 +164,9 @@ 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 ",
- xlrec->offnum, xlrec->xmax, xlrec->flags);
+ appendStringInfo(buf, "off %u: xmax %llu: flags 0x%02X ",
+ xlrec->offnum, (unsigned long long) xlrec->xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP2_NEW_CID)
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..5f40852e6d 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, "%llu ", (unsigned long long) member->xid);
switch (member->status)
{
case MultiXactStatusForKeyShare:
@@ -65,8 +65,9 @@ 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,
- xlrec->moff, xlrec->nmembers);
+ appendStringInfo(buf, "%llu offset %llu nmembers %d: ",
+ (unsigned long long) xlrec->mid,
+ (unsigned long long) xlrec->moff, xlrec->nmembers);
for (i = 0; i < xlrec->nmembers; i++)
out_member(buf, &xlrec->members[i]);
}
@@ -74,9 +75,11 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
{
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
- appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
- xlrec->startTruncOff, xlrec->endTruncOff,
- xlrec->startTruncMemb, xlrec->endTruncMemb);
+ appendStringInfo(buf, "offsets [%llu, %llu), members [%llu, %llu)",
+ (unsigned long long) xlrec->startTruncOff,
+ (unsigned long long) xlrec->endTruncOff,
+ (unsigned long long) xlrec->startTruncMemb,
+ (unsigned long long) xlrec->endTruncMemb);
}
}
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index f4a70d54e6..97866bde93 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -63,8 +63,8 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- appendStringInfo(buf, "snapshotConflictHorizon %u; ndeleted %u; nupdated %u",
- xlrec->snapshotConflictHorizon,
+ appendStringInfo(buf, "snapshotConflictHorizon %llu; ndeleted %u; nupdated %u",
+ (unsigned long long) xlrec->snapshotConflictHorizon,
xlrec->ndeleted, xlrec->nupdated);
break;
}
@@ -81,10 +81,10 @@ 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:%llu; ",
xlrec->leftsib, xlrec->rightsib, xlrec->level,
EpochFromFullTransactionId(xlrec->safexid),
- XidFromFullTransactionId(xlrec->safexid));
+ (unsigned long long) XidFromFullTransactionId(xlrec->safexid));
appendStringInfo(buf, "leafleft %u; leafright %u; leaftopparent %u",
xlrec->leafleftsib, xlrec->leafrightsib,
xlrec->leaftopparent);
@@ -101,11 +101,11 @@ btree_desc(StringInfo buf, XLogReaderState *record)
{
xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
- appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%u",
+ appendStringInfo(buf, "rel %u/%u/%u; snapshotConflictHorizon %u:%llu",
xlrec->locator.spcOid, xlrec->locator.dbOid,
xlrec->locator.relNumber,
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon),
- XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
+ (unsigned long long) XidFromFullTransactionId(xlrec->snapshotConflictHorizon));
break;
}
case XLOG_BTREE_META_CLEANUP:
diff --git a/src/backend/access/rmgrdesc/spgdesc.c b/src/backend/access/rmgrdesc/spgdesc.c
index 308bd3e27f..e03ab720b7 100644
--- a/src/backend/access/rmgrdesc/spgdesc.c
+++ b/src/backend/access/rmgrdesc/spgdesc.c
@@ -118,10 +118,10 @@ spg_desc(StringInfo buf, XLogReaderState *record)
{
spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec;
- appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u",
+ appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %llu",
xlrec->nToPlaceholder,
xlrec->firstPlaceholder,
- xlrec->snapshotConflictHorizon);
+ (unsigned long long) xlrec->snapshotConflictHorizon);
}
break;
}
diff --git a/src/backend/access/rmgrdesc/standbydesc.c b/src/backend/access/rmgrdesc/standbydesc.c
index 4789df886a..35addab90c 100644
--- a/src/backend/access/rmgrdesc/standbydesc.c
+++ b/src/backend/access/rmgrdesc/standbydesc.c
@@ -21,15 +21,15 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
int i;
- appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
- xlrec->nextXid,
- xlrec->latestCompletedXid,
- xlrec->oldestRunningXid);
+ appendStringInfo(buf, "nextXid %llu latestCompletedXid %llu oldestRunningXid %llu",
+ (unsigned long long) xlrec->nextXid,
+ (unsigned long long) xlrec->latestCompletedXid,
+ (unsigned long long) xlrec->oldestRunningXid);
if (xlrec->xcnt > 0)
{
appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
for (i = 0; i < xlrec->xcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %llu", (unsigned long long) xlrec->xids[i]);
}
if (xlrec->subxid_overflow)
@@ -39,7 +39,8 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
{
appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
for (i = 0; i < xlrec->subxcnt; i++)
- appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
+ appendStringInfo(buf, " %llu",
+ (unsigned long long) xlrec->xids[xlrec->xcnt + i]);
}
}
@@ -55,8 +56,9 @@ standby_desc(StringInfo buf, XLogReaderState *record)
int i;
for (i = 0; i < xlrec->nlocks; i++)
- appendStringInfo(buf, "xid %u db %u rel %u ",
- xlrec->locks[i].xid, xlrec->locks[i].dbOid,
+ appendStringInfo(buf, "xid %llu db %u rel %u ",
+ (unsigned long long) xlrec->locks[i].xid,
+ xlrec->locks[i].dbOid,
xlrec->locks[i].relOid);
}
else if (info == XLOG_RUNNING_XACTS)
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 39752cf349..b930943bb0 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -304,7 +304,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, " %llu", (unsigned long long) subxacts[i]);
}
}
@@ -336,7 +336,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -372,7 +372,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, "%llu: ", (unsigned long long) parsed.twophase_xid);
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
@@ -429,7 +429,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, " %llu", (unsigned long long) xlrec->xsub[i]);
}
void
@@ -468,7 +468,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 %llu: ", (unsigned long long) 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 3fd7185f21..3d30cc18c6 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,26 +45,26 @@ 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:%llu; oid %u; multi %llu; offset %u; "
+ "oldest xid %llu in DB %u; oldest multi %llu in DB %u; "
+ "oldest/newest commit timestamp xid: %llu/%llu; "
+ "oldest running xid %llu; %s",
LSN_FORMAT_ARGS(checkpoint->redo),
checkpoint->ThisTimeLineID,
checkpoint->PrevTimeLineID,
checkpoint->fullPageWrites ? "true" : "false",
EpochFromFullTransactionId(checkpoint->nextXid),
- XidFromFullTransactionId(checkpoint->nextXid),
+ (unsigned long long) XidFromFullTransactionId(checkpoint->nextXid),
checkpoint->nextOid,
- checkpoint->nextMulti,
+ (unsigned long long) checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- checkpoint->oldestXid,
+ (unsigned long long) checkpoint->oldestXid,
checkpoint->oldestXidDB,
- checkpoint->oldestMulti,
+ (unsigned long long) checkpoint->oldestMulti,
checkpoint->oldestMultiDB,
- checkpoint->oldestCommitTsXid,
- checkpoint->newestCommitTsXid,
- checkpoint->oldestActiveXid,
+ (unsigned long long) checkpoint->oldestCommitTsXid,
+ (unsigned long long) checkpoint->newestCommitTsXid,
+ (unsigned long long) checkpoint->oldestActiveXid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index a0001d2f4f..a0617b8503 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -276,7 +276,8 @@ 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 %llu",
+ (unsigned long long) 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 d97b63d8e6..71f8caa75f 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -450,8 +450,9 @@ 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",
- multi, xid, mxstatus_to_string(status));
+ debug_elog5(DEBUG2, "Expand: received multi %llu, xid %llu status %s",
+ (unsigned long long) multi, (unsigned long long) xid,
+ mxstatus_to_string(status));
/*
* Note: we don't allow for old multis here. The reason is that the only
@@ -475,8 +476,8 @@ 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",
- multi, newMulti);
+ debug_elog4(DEBUG2, "Expand: %llu has no members, create singleton %llu",
+ (unsigned long long) multi, (unsigned long long) newMulti);
return newMulti;
}
@@ -489,8 +490,8 @@ 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",
- xid, multi);
+ debug_elog4(DEBUG2, "Expand: %llu is already a member of %llu",
+ (unsigned long long) xid, (unsigned long long) multi);
pfree(members);
return multi;
}
@@ -525,12 +526,14 @@ 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 %llu",
+ (unsigned long long) newMulti);
return newMulti;
}
@@ -553,7 +556,7 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
int nmembers;
int i;
- debug_elog3(DEBUG2, "IsRunning %u?", multi);
+ debug_elog3(DEBUG2, "IsRunning %llu?", (unsigned long long) multi);
/*
* "false" here means we assume our callers have checked that the given
@@ -593,8 +596,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
{
if (TransactionIdIsInProgress(members[i].xid))
{
- debug_elog4(DEBUG2, "IsRunning: member %d (%u) is running",
- i, members[i].xid);
+ debug_elog4(DEBUG2, "IsRunning: member %d (%llu) is running", i,
+ (unsigned long long) members[i].xid);
pfree(members);
return true;
}
@@ -602,7 +605,8 @@ MultiXactIdIsRunning(MultiXactId multi, bool isLockOnly)
pfree(members);
- debug_elog3(DEBUG2, "IsRunning: %u is not running", multi);
+ debug_elog3(DEBUG2, "IsRunning: %llu is not running",
+ (unsigned long long) multi);
return false;
}
@@ -656,8 +660,8 @@ MultiXactIdSetOldestMember(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %u",
- MyBackendId, nextMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestMember[%d] = %llu",
+ MyBackendId, (unsigned long long) nextMXact);
}
}
@@ -709,8 +713,8 @@ MultiXactIdSetOldestVisible(void)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %u",
- MyBackendId, oldestMXact);
+ debug_elog4(DEBUG2, "MultiXact: setting OldestVisible[%d] = %llu",
+ MyBackendId, (unsigned long long) oldestMXact);
}
}
@@ -1188,7 +1192,8 @@ GetNewMultiXactId(int nmembers, MultiXactOffset *offset)
LWLockRelease(MultiXactGenLock);
- debug_elog4(DEBUG2, "GetNew: returning %u offset %u", result, *offset);
+ debug_elog4(DEBUG2, "GetNew: returning %llu offset %u",
+ (unsigned long long) result, *offset);
return result;
}
@@ -1238,7 +1243,8 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
MultiXactOffset nextOffset;
MultiXactMember *ptr;
- debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
+ debug_elog3(DEBUG2, "GetMembers: asked for %llu",
+ (unsigned long long) multi);
if (!MultiXactIdIsValid(multi) || from_pgupgrade)
{
@@ -1518,7 +1524,8 @@ 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 %llu",
+ (unsigned long long) entry->multi);
dclist_move_head(&MXactCache, iter.cur);
return entry->multi;
}
@@ -1541,7 +1548,8 @@ mXactCacheGetById(MultiXactId multi, MultiXactMember **members)
{
dlist_iter iter;
- debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
+ debug_elog3(DEBUG2, "CacheGet: looking for %llu",
+ (unsigned long long) multi);
dclist_foreach(iter, &MXactCache)
{
@@ -1621,8 +1629,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
dclist_delete_from(&MXactCache, node);
entry = dclist_container(mXactCacheEnt, node, node);
- debug_elog3(DEBUG2, "CachePut: pruning cached multi %u",
- entry->multi);
+ debug_elog3(DEBUG2, "CachePut: pruning cached multi %llu",
+ (unsigned long long) entry->multi);
pfree(entry);
}
@@ -1663,11 +1671,13 @@ mxid_to_string(MultiXactId multi, int nmembers, MultiXactMember *members)
initStringInfo(&buf);
- appendStringInfo(&buf, "%u %d[%u (%s)", multi, nmembers, members[0].xid,
+ appendStringInfo(&buf, "%llu %d[%llu (%s)", (unsigned long long) multi,
+ nmembers, (unsigned long long) members[0].xid,
mxstatus_to_string(members[0].status));
for (i = 1; i < nmembers; i++)
- appendStringInfo(&buf, ", %u (%s)", members[i].xid,
+ appendStringInfo(&buf, ", %llu (%s)",
+ (unsigned long long) members[i].xid,
mxstatus_to_string(members[i].status));
appendStringInfoChar(&buf, ']');
@@ -2142,8 +2152,9 @@ MultiXactGetCheckptMulti(bool is_shutdown,
LWLockRelease(MultiXactGenLock);
debug_elog6(DEBUG2,
- "MultiXact: checkpoint is nextMulti %u, nextOffset %u, oldestMulti %u in DB %u",
- *nextMulti, *nextMultiOffset, *oldestMulti, *oldestMultiDB);
+ "MultiXact: checkpoint is nextMulti %llu, nextOffset %u, oldestMulti %llu in DB %u",
+ (unsigned long long) *nextMulti, *nextMultiOffset,
+ (unsigned long long) *oldestMulti, *oldestMultiDB);
}
/*
@@ -2177,8 +2188,8 @@ void
MultiXactSetNextMXact(MultiXactId nextMulti,
MultiXactOffset nextMultiOffset)
{
- debug_elog4(DEBUG2, "MultiXact: setting next multi to %u offset %u",
- nextMulti, nextMultiOffset);
+ debug_elog4(DEBUG2, "MultiXact: setting next multi to %llu offset %u",
+ (unsigned long long) nextMulti, nextMultiOffset);
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
MultiXactState->nextMXact = nextMulti;
MultiXactState->nextOffset = nextMultiOffset;
@@ -2363,7 +2374,8 @@ 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 %llu",
+ (unsigned long long) minMulti);
MultiXactState->nextMXact = minMulti;
}
if (MultiXactOffsetPrecedes(MultiXactState->nextOffset, minMultiOffset))
@@ -2612,12 +2624,12 @@ SetOffsetVacuumLimit(bool is_startup)
if (oldestOffsetKnown)
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId member is at offset %u",
- oldestOffset)));
+ (errmsg_internal("oldest MultiXactId member is at offset %llu",
+ (unsigned long long) oldestOffset)));
else
ereport(LOG,
- (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %u does not exist on disk",
- oldestMultiXactId)));
+ (errmsg("MultiXact member wraparound protections are disabled because oldest checkpointed MultiXact %llu does not exist on disk",
+ (unsigned long long) oldestMultiXactId)));
}
LWLockRelease(MultiXactTruncationLock);
@@ -2641,8 +2653,9 @@ SetOffsetVacuumLimit(bool is_startup)
(errmsg("MultiXact member wraparound protections are now enabled")));
ereport(DEBUG1,
- (errmsg_internal("MultiXact member stop limit is now %u based on MultiXact %u",
- offsetStopLimit, oldestMultiXactId)));
+ (errmsg_internal("MultiXact member stop limit is now %llu based on MultiXact %llu",
+ (unsigned long long) offsetStopLimit,
+ (unsigned long long) oldestMultiXactId)));
}
else if (prevOldestOffsetKnown)
{
@@ -3025,8 +3038,8 @@ 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",
- oldestMulti, earliest)));
+ (errmsg("oldest MultiXact %llu not found, earliest MultiXact %llu, skipping truncation",
+ (unsigned long long) oldestMulti, (unsigned long long) earliest)));
LWLockRelease(MultiXactTruncationLock);
return;
}
@@ -3043,16 +3056,16 @@ 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",
- newOldestMulti)));
+ (errmsg("cannot truncate up to MultiXact %llu because it does not exist on disk, skipping truncation",
+ (unsigned long long) newOldestMulti)));
LWLockRelease(MultiXactTruncationLock);
return;
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- oldestMulti, newOldestMulti,
+ (unsigned long long) oldestMulti, (unsigned long long) newOldestMulti,
MultiXactIdToOffsetSegment(oldestMulti),
MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
@@ -3306,9 +3319,10 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
+ "offsets [%llu, %llu), offsets segments [%x, %x), "
"members [%u, %u), members segments [%x, %x)",
- xlrec.startTruncOff, xlrec.endTruncOff,
+ (unsigned long long) xlrec.startTruncOff,
+ (unsigned long long) xlrec.endTruncOff,
MultiXactIdToOffsetSegment(xlrec.startTruncOff),
MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
@@ -3357,7 +3371,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: %llu", (unsigned long long) mxid)));
if (SRF_IS_FIRSTCALL())
{
@@ -3393,7 +3407,8 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple tuple;
char *values[2];
- values[0] = psprintf("%u", multi->members[multi->iter].xid);
+ values[0] = psprintf("%llu",
+ (unsigned long long) 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 89d3edea5e..1fc29fb45f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -950,13 +950,15 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not seek in file \"%s\" to offset %d: %m.",
path, offset)));
break;
@@ -964,12 +966,14 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
path, offset)));
break;
@@ -977,26 +981,30 @@ SlruReportIOError(SlruCtl ctl, int64 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 %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: %m.",
path, offset)));
else
ereport(ERROR,
- (errmsg("could not access status of transaction %u", xid),
+ (errmsg("could not access status of transaction %llu",
+ (unsigned long long) xid),
errdetail("Could not write to file \"%s\" at offset %d: 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 %llu",
+ (unsigned long long) 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 %llu",
+ (unsigned long long) 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 56c19021a9..9b057a6b04 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -168,8 +168,9 @@ 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",
- previousXid, parentXid);
+ elog(ERROR, "pg_subtrans contains invalid entry: xid %llu points to parent xid %llu",
+ (unsigned long long) previousXid,
+ (unsigned long long) parentXid);
}
Assert(TransactionIdIsValid(previousXid));
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5865810135..27410c4697 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -157,8 +157,8 @@ TransactionIdDidCommit(TransactionId transactionId)
parentXid = SubTransGetParent(transactionId);
if (!TransactionIdIsValid(parentXid))
{
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return false;
}
return TransactionIdDidCommit(parentXid);
@@ -206,8 +206,8 @@ TransactionIdDidAbort(TransactionId transactionId)
if (!TransactionIdIsValid(parentXid))
{
/* see notes in TransactionIdDidCommit */
- elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
- transactionId);
+ elog(WARNING, "no pg_subtrans entry for subcommitted XID %llu",
+ (unsigned long long) transactionId);
return true;
}
return TransactionIdDidAbort(parentXid);
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 5017f4451e..2f99979cb6 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -850,7 +850,8 @@ 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 %llu",
+ (unsigned long long) xid);
cached_xid = xid;
cached_gxact = result;
@@ -2089,7 +2090,8 @@ RecoverPreparedTransactions(void)
continue;
ereport(LOG,
- (errmsg("recovering prepared transaction %u from shared memory", xid)));
+ (errmsg("recovering prepared transaction %llu from shared memory",
+ (unsigned long long) xid)));
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
@@ -2182,15 +2184,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing stale two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing stale two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing stale two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2202,15 +2204,15 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing future two-phase state file for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for transaction %u",
- xid)));
+ (errmsg("removing future two-phase state from memory for transaction %llu",
+ (unsigned long long) xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
@@ -2234,13 +2236,13 @@ ProcessTwoPhaseBuffer(TransactionId xid,
if (fromdisk)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state file for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state file for transaction %llu",
+ (unsigned long long) xid)));
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted two-phase state in memory for transaction %u",
- xid)));
+ errmsg("corrupted two-phase state in memory for transaction %llu",
+ (unsigned long long) xid)));
}
/*
@@ -2401,8 +2403,8 @@ RecordTransactionAbortPrepared(TransactionId xid,
* RecordTransactionCommitPrepared ...
*/
if (TransactionIdDidCommit(xid))
- elog(PANIC, "cannot abort transaction %u, it was already committed",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
START_CRIT_SECTION();
@@ -2509,7 +2511,8 @@ 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 %llu",
+ (unsigned long long) gxact->xid);
}
/*
@@ -2552,7 +2555,8 @@ 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 %llu",
+ (unsigned long long) 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 8086b857b9..ef90415bdf 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1739,8 +1739,8 @@ 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",
- xid);
+ elog(PANIC, "cannot abort transaction %llu, it was already committed",
+ (unsigned long long) xid);
/* Fetch the data we need for the abort record */
nrels = smgrGetPendingDeletes(false, &rels);
@@ -5479,22 +5479,24 @@ ShowTransactionStateRec(const char *str, TransactionState s)
{
int i;
- appendStringInfo(&buf, ", children: %u", s->childXids[0]);
+ appendStringInfo(&buf, ", children: %llu",
+ (unsigned long long) s->childXids[0]);
for (i = 1; i < s->nChildXids; i++)
- appendStringInfo(&buf, " %u", s->childXids[i]);
+ appendStringInfo(&buf, " %llu",
+ (unsigned long long) 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: %llu/%llu/%u%s%s",
str, s->nestingLevel,
PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
- (unsigned int) XidFromFullTransactionId(s->fullTransactionId),
- (unsigned int) s->subTransactionId,
+ (unsigned long long) XidFromFullTransactionId(s->fullTransactionId),
+ (unsigned long long) s->subTransactionId,
(unsigned int) currentCommandId,
currentCommandIdUsed ? " (used)" : "",
buf.data)));
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 97b882564f..76f3b13e00 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -528,8 +528,8 @@ 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",
- recoveryTargetXid)));
+ (errmsg("starting point-in-time recovery to XID %llu",
+ (unsigned long long) recoveryTargetXid)));
else if (recoveryTarget == RECOVERY_TARGET_TIME)
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -818,18 +818,21 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
U64FromFullTransactionId(checkPoint.nextXid),
checkPoint.nextOid)));
ereport(DEBUG1,
- (errmsg_internal("next MultiXactId: %u; next MultiXactOffset: %u",
- checkPoint.nextMulti, checkPoint.nextMultiOffset)));
+ (errmsg_internal("next MultiXactId: %llu; next MultiXactOffset: %llu",
+ (unsigned long long) checkPoint.nextMulti,
+ (unsigned long long) checkPoint.nextMultiOffset)));
ereport(DEBUG1,
- (errmsg_internal("oldest unfrozen transaction ID: %u, in database %u",
- checkPoint.oldestXid, checkPoint.oldestXidDB)));
+ (errmsg_internal("oldest unfrozen transaction ID: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestXid,
+ checkPoint.oldestXidDB)));
ereport(DEBUG1,
- (errmsg_internal("oldest MultiXactId: %u, in database %u",
- checkPoint.oldestMulti, checkPoint.oldestMultiDB)));
+ (errmsg_internal("oldest MultiXactId: %llu, in database %u",
+ (unsigned long long) checkPoint.oldestMulti,
+ checkPoint.oldestMultiDB)));
ereport(DEBUG1,
- (errmsg_internal("commit timestamp Xid oldest/newest: %u/%u",
- checkPoint.oldestCommitTsXid,
- checkPoint.newestCommitTsXid)));
+ (errmsg_internal("commit timestamp Xid oldest/newest: %llu/%llu",
+ (unsigned long long) checkPoint.oldestCommitTsXid,
+ (unsigned long long) checkPoint.newestCommitTsXid)));
if (!TransactionIdIsNormal(XidFromFullTransactionId(checkPoint.nextXid)))
ereport(PANIC,
(errmsg("invalid next transaction ID")));
@@ -2573,15 +2576,15 @@ recoveryStopsBefore(XLogReaderState *record)
if (isCommit)
{
ereport(LOG,
- (errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else
{
ereport(LOG,
- (errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping before abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
}
@@ -2718,16 +2721,16 @@ recoveryStopsAfter(XLogReaderState *record)
xact_info == XLOG_XACT_COMMIT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after commit of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
else if (xact_info == XLOG_XACT_ABORT ||
xact_info == XLOG_XACT_ABORT_PREPARED)
{
ereport(LOG,
- (errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid,
+ (errmsg("recovery stopping after abort of transaction %llu, time %s",
+ (unsigned long long) recoveryStopXid,
timestamptz_to_str(recoveryStopTime))));
}
return true;
@@ -2762,9 +2765,9 @@ getRecoveryStopReason(void)
if (recoveryTarget == RECOVERY_TARGET_XID)
snprintf(reason, sizeof(reason),
- "%s transaction %u",
+ "%s transaction %llu",
recoveryStopAfter ? "after" : "before",
- recoveryStopXid);
+ (unsigned long long) recoveryStopXid);
else if (recoveryTarget == RECOVERY_TARGET_TIME)
snprintf(reason, sizeof(reason),
"%s %s\n",
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index a6d5ed1f6b..81cf0e96a7 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -1415,14 +1415,16 @@ vac_update_relstats(Relation relation,
if (futurexid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relfrozenxid value %u with new value %u for table \"%s\"",
- oldfrozenxid, frozenxid,
+ errmsg_internal("overwrote invalid relfrozenxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldfrozenxid,
+ (unsigned long long) frozenxid,
RelationGetRelationName(relation))));
if (futuremxid)
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg_internal("overwrote invalid relminmxid value %u with new value %u for table \"%s\"",
- oldminmulti, minmulti,
+ errmsg_internal("overwrote invalid relminmxid value %llu with new value %llu for table \"%s\"",
+ (unsigned long long) oldminmulti,
+ (unsigned long long) minmulti,
RelationGetRelationName(relation))));
}
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 59b0fdeb62..50172d6247 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -300,7 +300,7 @@ _outList(StringInfo str, const List *node)
else if (IsA(node, OidList))
appendStringInfo(str, " %u", lfirst_oid(lc));
else if (IsA(node, XidList))
- appendStringInfo(str, " %u", lfirst_xid(lc));
+ appendStringInfo(str, " %llu", (unsigned long long) lfirst_xid(lc));
else
elog(ERROR, "unrecognized list node type: %d",
(int) node->type);
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 625a7f4273..48a0606b9c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1643,8 +1643,8 @@ LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
SpinLockRelease(&slot->mutex);
if (got_new_xmin)
- elog(DEBUG1, "got new catalog xmin %u at %X/%X", xmin,
- LSN_FORMAT_ARGS(current_lsn));
+ elog(DEBUG1, "got new catalog xmin %llu at %X/%X",
+ (unsigned long long) xmin, LSN_FORMAT_ARGS(current_lsn));
/* candidate already valid with the current flush position, apply */
if (updated_xmin)
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index b567b8b59e..2b2bc1af07 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -2492,8 +2492,8 @@ 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",
- GetCurrentTransactionId());
+ elog(ERROR, "output plugin used XID %llu",
+ (unsigned long long) GetCurrentTransactionId());
/*
* Remember the command ID and snapshot for the next set of changes in
@@ -2931,7 +2931,8 @@ ReorderBufferAbortOld(ReorderBuffer *rb, TransactionId oldestRunningXid)
if (TransactionIdPrecedes(txn->xid, oldestRunningXid))
{
- elog(DEBUG2, "aborting old transaction %u", txn->xid);
+ elog(DEBUG2, "aborting old transaction %llu",
+ (unsigned long long) txn->xid);
/* remove potential on-disk data, and deallocate this tx */
ReorderBufferCleanupTXN(rb, txn);
@@ -3622,8 +3623,8 @@ ReorderBufferSerializeTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
Size spilled = 0;
Size size = txn->size;
- elog(DEBUG2, "spill %u changes in XID %u to disk",
- (uint32) txn->nentries_mem, txn->xid);
+ elog(DEBUG2, "spill %u changes in XID %llu to disk",
+ (uint32) txn->nentries_mem, (unsigned long long) txn->xid);
/* do the same to all child TXs */
dlist_foreach(subtxn_i, &txn->subtxns)
@@ -3899,8 +3900,8 @@ 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",
- txn->xid)));
+ errmsg("could not write to data file for XID %llu: %m",
+ (unsigned long long) txn->xid)));
}
pgstat_report_wait_end();
@@ -4544,9 +4545,9 @@ 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-%llu-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid, LSN_FORMAT_ARGS(recptr));
+ (unsigned long long) xid, LSN_FORMAT_ARGS(recptr));
}
/*
@@ -5175,8 +5176,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
{
RewriteMappingFile *f = (RewriteMappingFile *) lfirst(file);
- elog(DEBUG1, "applying mapping: \"%s\" in %u", f->fname,
- snapshot->subxip[0]);
+ elog(DEBUG1, "applying mapping: \"%s\" in %llu", f->fname,
+ (unsigned long long) 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 beddcbcdea..085b055a03 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -605,8 +605,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder)
LWLockRelease(ProcArrayLock);
if (TransactionIdFollows(safeXid, snap->xmin))
- elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %u follows snapshot's xmin %u",
- safeXid, snap->xmin);
+ elog(ERROR, "cannot build an initial slot snapshot as oldest safe xid %llu follows snapshot's xmin %llu",
+ (unsigned long long) safeXid, (unsigned long long) snap->xmin);
MyProc->xmin = snap->xmin;
@@ -889,8 +889,8 @@ 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",
- txn->xid, LSN_FORMAT_ARGS(lsn));
+ elog(DEBUG2, "adding a new snapshot to %llu at %X/%X",
+ (unsigned long long) txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -969,9 +969,9 @@ SnapBuildPurgeOlderTxn(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: %llu, xmax: %llu",
(uint32) builder->committed.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin, (unsigned long long) builder->xmax);
builder->committed.xcnt = surviving_xids;
pfree(workspace);
@@ -1006,9 +1006,10 @@ SnapBuildPurgeOlderTxn(SnapBuild *builder)
builder->catchange.xip = NULL;
}
- elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %u, xmax: %u",
+ elog(DEBUG3, "purged catalog modifying transactions from %u to %u, xmin: %llu, xmax: %llu",
(uint32) builder->catchange.xcnt, (uint32) surviving_xids,
- builder->xmin, builder->xmax);
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax);
builder->catchange.xcnt = surviving_xids;
}
}
@@ -1071,8 +1072,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
sub_needs_timetravel = true;
needs_snapshot = true;
- elog(DEBUG1, "found subtransaction %u:%u with catalog changes",
- xid, subxid);
+ elog(DEBUG1, "found subtransaction %llu:%llu with catalog changes",
+ (unsigned long long) xid, (unsigned long long) subxid);
SnapBuildAddCommittedTxn(builder, subxid);
@@ -1097,8 +1098,8 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if top-level modified catalog, it'll need a snapshot */
if (SnapBuildXidHasCatalogChanges(builder, xid, xinfo))
{
- elog(DEBUG2, "found top level transaction %u, with catalog changes",
- xid);
+ elog(DEBUG2, "found top level transaction %llu, with catalog changes",
+ (unsigned long long) xid);
needs_snapshot = true;
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
@@ -1106,14 +1107,15 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
else if (sub_needs_timetravel)
{
/* track toplevel txn as well, subxact alone isn't meaningful */
- elog(DEBUG2, "forced transaction %u to do timetravel due to one of its subtransactions",
- xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel due to one of its subtransactions",
+ (unsigned long long) xid);
needs_timetravel = true;
SnapBuildAddCommittedTxn(builder, xid);
}
else if (needs_timetravel)
{
- elog(DEBUG2, "forced transaction %u to do timetravel", xid);
+ elog(DEBUG2, "forced transaction %llu to do timetravel",
+ (unsigned long long) xid);
SnapBuildAddCommittedTxn(builder, xid);
}
@@ -1258,8 +1260,11 @@ 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",
- builder->xmin, builder->xmax, running->oldestRunningXid, xmin);
+ elog(DEBUG3, "xmin: %llu, xmax: %llu, oldest running: %llu, oldest xmin: %llu",
+ (unsigned long long) builder->xmin,
+ (unsigned long long) builder->xmax,
+ (unsigned long long) running->oldestRunningXid,
+ (unsigned long long) xmin);
LogicalIncreaseXminForSlot(lsn, xmin);
/*
@@ -1348,8 +1353,9 @@ 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",
- builder->initial_xmin_horizon, running->oldestRunningXid)));
+ errdetail_internal("initial xmin horizon of %llu vs the snapshot's %llu",
+ (unsigned long long) builder->initial_xmin_horizon,
+ (unsigned long long) running->oldestRunningXid)));
SnapBuildWaitSnapshot(running, builder->initial_xmin_horizon);
@@ -1431,8 +1437,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
@@ -1455,8 +1462,9 @@ 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.",
- running->xcnt, running->nextXid)));
+ errdetail("Waiting for transactions (approximately %d) older than %llu to end.",
+ running->xcnt,
+ (unsigned long long) running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 96772e4d73..61ebfa08fa 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1116,7 +1116,8 @@ 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 %llu",
+ (unsigned long long) prepare_data.xid);
/* Replay all the spooled operations. */
apply_spooled_messages(prepare_data.xid, prepare_data.prepare_lsn);
@@ -1507,7 +1508,8 @@ 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 %llu",
+ (unsigned long long) xid);
apply_spooled_messages(xid, commit_data.commit_lsn);
@@ -3363,14 +3365,16 @@ 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-%llu.subxacts", subid,
+ (unsigned long long) 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-%llu.changes", subid,
+ (unsigned long long) xid);
}
/*
@@ -3532,7 +3536,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_%llu", subid, (unsigned long long) xid);
}
/*
@@ -4050,33 +4054,33 @@ 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 message type \"%s\" in transaction %u",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid);
+ (unsigned long long) errarg->remote_xid);
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
else if (errarg->remote_attnum < 0)
- errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %u, finished at %X/%X",
+ errcontext("processing remote data for replication origin \"%s\" during message type \"%s\" for replication target relation \"%s.%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
else
- errcontext("processing remote data for replication origin \"%s\" during message type \"%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 message type \"%s\" for replication target relation \"%s.%s\" column \"%s\" in transaction %llu, finished at %X/%X",
errarg->origin_name,
logicalrep_message_type(errarg->command),
errarg->rel->remoterel.nspname,
errarg->rel->remoterel.relname,
errarg->rel->remoterel.attnames[errarg->remote_attnum],
- errarg->remote_xid,
+ (unsigned long long) errarg->remote_xid,
LSN_FORMAT_ARGS(errarg->finish_lsn));
}
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index ca46fba3af..571801530b 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -584,7 +584,8 @@ pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
if (!sent_begin_txn)
{
- elog(DEBUG1, "skipped replication of an empty transaction with XID: %u", txn->xid);
+ elog(DEBUG1, "skipped replication of an empty transaction with XID: %llu",
+ (unsigned long long) txn->xid);
return;
}
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ad383dbcaa..8bc611fdda 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1238,8 +1238,9 @@ 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",
- xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
+ elog(DEBUG2, "sending hot standby feedback xmin %llu epoch %u catalog_xmin %llu catalog_xmin_epoch %u",
+ (unsigned long long) xmin, xmin_epoch,
+ (unsigned long long) catalog_xmin, catalog_xmin_epoch);
/* Construct the message and send it. */
resetStringInfo(&reply_message);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index c11bb3716f..a251953ef3 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2271,10 +2271,10 @@ 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",
- feedbackXmin,
+ elog(DEBUG2, "hot standby feedback xmin %llu epoch %u, catalog_xmin %llu epoch %u reply_time %s",
+ (unsigned long long) feedbackXmin,
feedbackEpoch,
- feedbackCatalogXmin,
+ (unsigned long long) feedbackCatalogXmin,
feedbackCatalogEpoch,
replyTimeStr);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 0176f30270..17a80a84c3 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1118,9 +1118,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
return;
}
}
@@ -1204,8 +1204,8 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
if (i > 0 && TransactionIdEquals(xids[i - 1], xids[i]))
{
elog(DEBUG1,
- "found duplicated transaction %u for KnownAssignedXids insertion",
- xids[i]);
+ "found duplicated transaction %llu for KnownAssignedXids insertion",
+ (unsigned long long) xids[i]);
continue;
}
KnownAssignedXidsAdd(xids[i], xids[i], true);
@@ -1289,9 +1289,9 @@ 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)",
- standbySnapshotPendingXmin,
- running->oldestRunningXid);
+ "until oldest active xid on standby is at least %llu (now %llu)",
+ (unsigned long long) standbySnapshotPendingXmin,
+ (unsigned long long) running->oldestRunningXid);
}
/*
@@ -4002,7 +4002,8 @@ 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 %llu in MyProc",
+ (unsigned long long) anxid);
}
for (j = MyProc->subxidStatus.count - 1; j >= 0; j--)
@@ -4018,7 +4019,8 @@ 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 %llu in MyProc",
+ (unsigned long long) xid);
/* Also advance global latestCompletedXid while holding the lock */
MaintainLatestCompletedXid(latestXid);
@@ -4395,8 +4397,8 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
Assert(TransactionIdIsValid(xid));
Assert(TransactionIdIsValid(latestObservedXid));
- elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
- xid, latestObservedXid);
+ elog(trace_recovery(DEBUG4), "record known xact %llu latestObservedXid %llu",
+ (unsigned long long) xid, (unsigned long long) latestObservedXid);
/*
* When a newly observed xid arrives, it is frequently the case that it is
@@ -4968,7 +4970,8 @@ KnownAssignedXidsRemove(TransactionId xid)
{
Assert(TransactionIdIsValid(xid));
- elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %u", xid);
+ elog(trace_recovery(DEBUG4), "remove KnownAssignedXid %llu",
+ (unsigned long long) xid);
/*
* Note: we cannot consider it an error to remove an XID that's not
@@ -5028,7 +5031,8 @@ KnownAssignedXidsRemovePreceding(TransactionId removeXid)
return;
}
- elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %u", removeXid);
+ elog(trace_recovery(DEBUG4), "prune KnownAssignedXids to %llu",
+ (unsigned long long) removeXid);
/*
* Mark entries invalid starting at the tail. Since array is sorted, we
@@ -5216,7 +5220,8 @@ KnownAssignedXidsDisplay(int trace_level)
if (KnownAssignedXidsValid[i])
{
nxids++;
- appendStringInfo(&buf, "[%d]=%u ", i, KnownAssignedXids[i]);
+ appendStringInfo(&buf, "[%d]=%llu ", i,
+ (unsigned long long) KnownAssignedXids[i]);
}
}
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index f43229dfda..30bbb02afd 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1037,15 +1037,17 @@ StandbyReleaseXidEntryLocks(RecoveryLockXidEntry *xidentry)
LOCKTAG locktag;
elog(trace_recovery(DEBUG4),
- "releasing recovery lock: xid %u db %u rel %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "releasing recovery lock: xid %llu db %u rel %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
/* Release the lock ... */
SET_LOCKTAG_RELATION(locktag, entry->key.dbOid, entry->key.relOid);
if (!LockRelease(&locktag, AccessExclusiveLock, true))
{
elog(LOG,
- "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %u database %u relation %u",
- entry->key.xid, entry->key.dbOid, entry->key.relOid);
+ "RecoveryLockHash contains entry for lock no longer recorded by lock manager: xid %llu database %u relation %u",
+ (unsigned long long) entry->key.xid, entry->key.dbOid,
+ entry->key.relOid);
Assert(false);
}
/* ... and remove the per-lock hash entry */
@@ -1355,20 +1357,20 @@ 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) 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 %llu latest complete %llu next xid %llu)",
CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt,
LSN_FORMAT_ARGS(recptr),
- CurrRunningXacts->oldestRunningXid,
- CurrRunningXacts->latestCompletedXid,
- CurrRunningXacts->nextXid);
+ (unsigned long long) CurrRunningXacts->oldestRunningXid,
+ (unsigned long long) CurrRunningXacts->latestCompletedXid,
+ (unsigned long long) CurrRunningXacts->nextXid);
/*
* Ensure running_xacts information is synced to disk not too far in the
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 760a54e021..9989fd75ec 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -4161,7 +4161,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
if (SxactHasSummaryConflictIn(MySerializableXact)
@@ -4169,7 +4170,8 @@ 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 %llu.",
+ (unsigned long long) xid),
errhint("The transaction might succeed if retried.")));
MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
@@ -4799,7 +4801,8 @@ 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 %llu, during read.",
+ (unsigned long long) 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 f9b324efec..14151bc81c 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -79,7 +79,8 @@ VXIDGetDatum(BackendId bid, LocalTransactionId lxid)
*/
char vxidstr[32];
- snprintf(vxidstr, sizeof(vxidstr), "%d/%u", bid, lxid);
+ snprintf(vxidstr, sizeof(vxidstr), "%d/%llu", bid,
+ (unsigned long long) lxid);
return CStringGetTextDatum(vxidstr);
}
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index 5c49bc4209..5e7d842da3 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -153,11 +153,12 @@ 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/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfoChar(&buf, ',');
/* Transaction id */
- appendStringInfo(&buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(&buf, "%llu", (unsigned long long) GetTopTransactionIdIfAny());
appendStringInfoChar(&buf, ',');
/* Error severity */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index f5cd1b7493..0eb27b2acc 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2955,12 +2955,14 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
- snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%u",
- MyProc->backendId, MyProc->lxid);
+ snprintf(strfbuf, sizeof(strfbuf) - 1, "%d/%llu",
+ MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
- appendStringInfo(buf, "%d/%u", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(buf, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
}
else if (padding != 0)
appendStringInfoSpaces(buf,
@@ -2968,9 +2970,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
break;
case 'x':
if (padding != 0)
- appendStringInfo(buf, "%*u", padding, GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%*llu", padding,
+ (unsigned long long) GetTopTransactionIdIfAny());
else
- appendStringInfo(buf, "%u", GetTopTransactionIdIfAny());
+ appendStringInfo(buf, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
break;
case 'e':
if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c
index 27ad7686d8..df1ed14c02 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -198,12 +198,12 @@ 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,
- MyProc->lxid);
+ appendJSONKeyValueFmt(&buf, "vxid", true, "%d/%llu", MyProc->backendId,
+ (unsigned long long) MyProc->lxid);
/* Transaction id */
- appendJSONKeyValueFmt(&buf, "txid", false, "%u",
- GetTopTransactionIdIfAny());
+ appendJSONKeyValueFmt(&buf, "txid", false, "%llu",
+ (unsigned long long) GetTopTransactionIdIfAny());
/* Error severity */
if (edata->elevel)
diff --git a/src/backend/utils/misc/pg_controldata.c b/src/backend/utils/misc/pg_controldata.c
index 781f8b8758..88f6f33ef5 100644
--- a/src/backend/utils/misc/pg_controldata.c
+++ b/src/backend/utils/misc/pg_controldata.c
@@ -164,9 +164,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
values[5] = BoolGetDatum(ControlFile->checkPointCopy.fullPageWrites);
nulls[5] = false;
- values[6] = CStringGetTextDatum(psprintf("%u:%u",
+ values[6] = CStringGetTextDatum(psprintf("%u:%llu",
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid)));
nulls[6] = false;
values[7] = ObjectIdGetDatum(ControlFile->checkPointCopy.nextOid);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 2524b1c585..ceba9a4be6 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -1204,14 +1204,15 @@ ExportSnapshot(Snapshot snapshot)
*/
initStringInfo(&buf);
- appendStringInfo(&buf, "vxid:%d/%u\n", MyProc->backendId, MyProc->lxid);
+ appendStringInfo(&buf, "vxid:%d/%llu\n", MyProc->backendId,
+ (unsigned long long) 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:%llu\n", (unsigned long long) snapshot->xmin);
+ appendStringInfo(&buf, "xmax:%llu\n", (unsigned long long) snapshot->xmax);
/*
* We must include our own top transaction ID in the top-xid data, since
@@ -1228,9 +1229,10 @@ 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:%llu\n",
+ (unsigned long long) snapshot->xip[i]);
if (addTopXid)
- appendStringInfo(&buf, "xip:%u\n", topXid);
+ appendStringInfo(&buf, "xip:%llu\n", (unsigned long long) topXid);
/*
* Similarly, we add our subcommitted child XIDs to the subxid data. Here,
@@ -1244,9 +1246,11 @@ 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:%llu\n",
+ (unsigned long long) snapshot->subxip[i]);
for (i = 0; i < nchildren; i++)
- appendStringInfo(&buf, "sxp:%u\n", children[i]);
+ appendStringInfo(&buf, "sxp:%llu\n",
+ (unsigned long long) children[i]);
}
appendStringInfo(&buf, "rec:%u\n", snapshot->takenDuringRecovery);
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index bbada168f0..8050811105 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -362,7 +362,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
# Expected corruption report
push @expected,
- qr/${header}xmin $xmin precedes relation freeze threshold 0:\d+/;
+ qr/${header}xmin $xmin precedes relation freeze threshold \d+/;
}
if ($offnum == 2)
{
@@ -373,7 +373,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin $xmin precedes oldest valid transaction ID 0:\d+/;
+ qr/${$header}xmin $xmin precedes oldest valid transaction ID \d+/;
}
elsif ($offnum == 3)
{
@@ -385,7 +385,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMIN_INVALID;
push @expected,
- qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmin 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 4)
{
@@ -394,7 +394,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
$tup->{t_infomask} &= ~HEAP_XMAX_INVALID;
push @expected,
- qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID 0:\d+/;
+ qr/${$header}xmax 4026531839 equals or exceeds next valid transaction ID \d+/;
}
elsif ($offnum == 5)
{
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index c390ec51ce..2c10322355 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -247,29 +247,29 @@ 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:%llu\n"),
EpochFromFullTransactionId(ControlFile->checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile->checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile->checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile->checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile->checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile->checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile->checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile->checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile->checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile->checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile->checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile->checkPointCopy.newestCommitTsXid);
printf(_("Time of latest checkpoint: %s\n"),
ckpttime_str);
printf(_("Fake LSN counter for unlogged rels: %X/%X\n"),
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 44d957c038..6d133f60c9 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3151,9 +3151,10 @@ 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 = '%llu', datminmxid = '%llu'\n"
"WHERE datname = ",
- frozenxid, minmxid);
+ (unsigned long long) frozenxid,
+ (unsigned long long) minmxid);
appendStringLiteralAH(creaQry, datname, fout);
appendPQExpBufferStr(creaQry, ";\n");
}
@@ -15679,9 +15680,10 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = ",
- tbinfo->frozenxid, tbinfo->minmxid);
+ (unsigned long long) tbinfo->frozenxid,
+ (unsigned long long) tbinfo->minmxid);
appendStringLiteralAH(q, qualrelname, fout);
appendPQExpBufferStr(q, "::pg_catalog.regclass;\n");
@@ -15693,10 +15695,11 @@ 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 = '%llu', relminmxid = '%llu'\n"
"WHERE oid = '%u';\n",
- tbinfo->toast_frozenxid,
- tbinfo->toast_minmxid, tbinfo->toast_oid);
+ (unsigned long long) tbinfo->toast_frozenxid,
+ (unsigned long long) 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 089063f471..977491b875 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -178,7 +178,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_oldest_xid))
- pg_fatal("oldest transaction ID (-u) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("oldest transaction ID (-u) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'x':
@@ -191,7 +192,8 @@ main(int argc, char *argv[])
exit(1);
}
if (!TransactionIdIsNormal(set_xid))
- pg_fatal("transaction ID (-x) must be greater than or equal to %u", FirstNormalTransactionId);
+ pg_fatal("transaction ID (-x) must be greater than or equal to %llu",
+ (unsigned long long) FirstNormalTransactionId);
break;
case 'c':
@@ -723,29 +725,29 @@ PrintControlValues(bool guessed)
ControlFile.checkPointCopy.ThisTimeLineID);
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:%llu\n"),
EpochFromFullTransactionId(ControlFile.checkPointCopy.nextXid),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
printf(_("Latest checkpoint's NextOID: %u\n"),
ControlFile.checkPointCopy.nextOid);
- printf(_("Latest checkpoint's NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("Latest checkpoint's NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
- printf(_("Latest checkpoint's oldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("Latest checkpoint's NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("Latest checkpoint's NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("Latest checkpoint's oldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("Latest checkpoint's oldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
- printf(_("Latest checkpoint's oldestActiveXID: %u\n"),
- ControlFile.checkPointCopy.oldestActiveXid);
- printf(_("Latest checkpoint's oldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("Latest checkpoint's oldestActiveXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestActiveXid);
+ printf(_("Latest checkpoint's oldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("Latest checkpoint's oldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
- printf(_("Latest checkpoint's oldestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
- printf(_("Latest checkpoint's newestCommitTsXid:%u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("Latest checkpoint's oldestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("Latest checkpoint's newestCommitTsXid:%llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
printf(_("Maximum data alignment: %u\n"),
ControlFile.maxAlign);
/* we don't print floatFormat since can't say much useful about it */
@@ -792,18 +794,18 @@ PrintNewControlValues(void)
if (set_mxid != 0)
{
- printf(_("NextMultiXactId: %u\n"),
- ControlFile.checkPointCopy.nextMulti);
- printf(_("OldestMultiXid: %u\n"),
- ControlFile.checkPointCopy.oldestMulti);
+ printf(_("NextMultiXactId: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMulti);
+ printf(_("OldestMultiXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestMulti);
printf(_("OldestMulti's DB: %u\n"),
ControlFile.checkPointCopy.oldestMultiDB);
}
if (set_mxoff != -1)
{
- printf(_("NextMultiOffset: %u\n"),
- ControlFile.checkPointCopy.nextMultiOffset);
+ printf(_("NextMultiOffset: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.nextMultiOffset);
}
if (set_oid != 0)
@@ -814,10 +816,10 @@ PrintNewControlValues(void)
if (set_xid != 0)
{
- printf(_("NextXID: %u\n"),
- XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
- printf(_("OldestXID: %u\n"),
- ControlFile.checkPointCopy.oldestXid);
+ printf(_("NextXID: %llu\n"),
+ (unsigned long long) XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ printf(_("OldestXID: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
ControlFile.checkPointCopy.oldestXidDB);
}
@@ -830,13 +832,13 @@ PrintNewControlValues(void)
if (set_oldest_commit_ts_xid != 0)
{
- printf(_("oldestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.oldestCommitTsXid);
+ printf(_("oldestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.oldestCommitTsXid);
}
if (set_newest_commit_ts_xid != 0)
{
- printf(_("newestCommitTsXid: %u\n"),
- ControlFile.checkPointCopy.newestCommitTsXid);
+ printf(_("newestCommitTsXid: %llu\n"),
+ (unsigned long long) ControlFile.checkPointCopy.newestCommitTsXid);
}
if (set_wal_segsize != 0)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..a8b1e0ed84 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -580,16 +580,18 @@ 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_oldstxid,
+ "\"%s/pg_resetwal\" -f -u %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstxid,
new_cluster.pgdata);
check_ok();
/* 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\"",
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid,
+ "\"%s/pg_resetwal\" -f -x %llu \"%s\"",
+ new_cluster.bindir,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
"\"%s/pg_resetwal\" -f -e %u \"%s\"",
@@ -597,10 +599,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtxid,
- old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid,
new_cluster.pgdata);
check_ok();
@@ -623,11 +625,11 @@ 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 %llu -m %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmxoff,
- old_cluster.controldata.chkpnt_nxtmulti,
- old_cluster.controldata.chkpnt_oldstMulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmxoff,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_oldstMulti,
new_cluster.pgdata);
check_ok();
}
@@ -651,10 +653,10 @@ 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 %llu,%llu \"%s\"",
new_cluster.bindir,
- old_cluster.controldata.chkpnt_nxtmulti + 1,
- old_cluster.controldata.chkpnt_nxtmulti,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti + 1,
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti,
new_cluster.pgdata);
check_ok();
}
@@ -713,14 +715,14 @@ set_frozenxids(bool minmxid_only)
/* set pg_database.datfrozenxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u'",
- old_cluster.controldata.chkpnt_nxtxid));
+ "SET datfrozenxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_database.datminmxid */
PQclear(executeQueryOrDie(conn_template1,
"UPDATE pg_catalog.pg_database "
- "SET datminmxid = '%u'",
- old_cluster.controldata.chkpnt_nxtmulti));
+ "SET datminmxid = '%llu'",
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
/* get database names */
dbres = executeQueryOrDie(conn_template1,
@@ -754,24 +756,24 @@ set_frozenxids(bool minmxid_only)
/* set pg_class.relfrozenxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relfrozenxid = '%u' "
+ "SET relfrozenxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtxid));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtxid));
/* set pg_class.relminmxid */
PQclear(executeQueryOrDie(conn,
"UPDATE pg_catalog.pg_class "
- "SET relminmxid = '%u' "
+ "SET relminmxid = '%llu' "
/* only heap, materialized view, and TOAST are vacuumed */
"WHERE relkind IN ("
CppAsString2(RELKIND_RELATION) ", "
CppAsString2(RELKIND_MATVIEW) ", "
CppAsString2(RELKIND_TOASTVALUE) ")",
- old_cluster.controldata.chkpnt_nxtmulti));
+ (unsigned long long) old_cluster.controldata.chkpnt_nxtmulti));
PQfinish(conn);
/* Reset datallowconn flag */
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 9993378ca5..5a82cfdab2 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -455,10 +455,10 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record)
XLogRecGetLen(record, &rec_len, &fpi_len);
- printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ",
+ printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %20llu, lsn: %X/%08X, prev %X/%08X, ",
desc->rm_name,
rec_len, XLogRecGetTotalLen(record),
- XLogRecGetXid(record),
+ (unsigned long long) XLogRecGetXid(record),
LSN_FORMAT_ARGS(record->ReadRecPtr),
LSN_FORMAT_ARGS(xl_prev));
--
2.38.1
Hi!
As a result of discussion in the thread [0]/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com, Robert Haas proposed to focus
on making SLRU 64 bit, as a first step towards 64 bit XIDs.
Here is the patch set.
In overall, code of this patch set is based on the existing code from [0]/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
and may be simplified, due to the fact, that SLRU_PAGES_PER_SEGMENT is not
meant to be changed now.
But I decided to leave it that way. At least for now.
As always, reviews and opinions are very welcome.
Should we change status for this thread to "need review"?
[0]: /messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
--
Best regards,
Maxim Orlov.
Attachments:
v51-0003-Make-pg_upgrade-from-32-bit-to-64-bit-SLRU.patchapplication/octet-stream; name=v51-0003-Make-pg_upgrade-from-32-bit-to-64-bit-SLRU.patchDownload
From 6b682ec934728a97b6458709b4b161772d5cfa65 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Wed, 14 Dec 2022 15:24:21 +0300
Subject: [PATCH v51 3/3] =?UTF-8?q?Make=20pg=5Fupgrade=20from=2032-bit=20t?=
=?UTF-8?q?o=2064=E2=80=93bit=20SLRU?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/bin/pg_upgrade/pg_upgrade.c | 292 +++++++++++++++++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.h | 5 +
2 files changed, 293 insertions(+), 4 deletions(-)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 115faa222e..0cedc05416 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -44,6 +44,7 @@
#include <langinfo.h>
#endif
+#include "access/transam.h"
#include "catalog/pg_class_d.h"
#include "common/file_perm.h"
#include "common/logging.h"
@@ -566,6 +567,277 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
check_ok();
}
+/******************************************************************************/
+#define SLRU_PAGES_PER_SEGMENT 32 /* Should be equal to value from slru.h */
+
+#define CLOG_BITS_PER_XACT 2
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+/*
+ * Rename the files from the old cluster into it
+ */
+typedef struct SLRUSegmentState
+{
+ const char *dir;
+ FILE *file;
+ int64 segno;
+ int64 pageno;
+ bool is_empty_segment;
+} SLRUSegmentState;
+
+static char *
+slru_filename_old(const char *path, int64 segno)
+{
+ Assert(segno <= PG_INT32_MAX);
+ return psprintf("%s/%04X", path, (int) segno);
+}
+
+static char *
+slru_filename_new(const char *path, int64 segno)
+{
+ return psprintf("%s/%012llX", path, (long long) segno);
+}
+
+static inline FILE *
+open_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno),
+ char *mode, char *fatal_msg)
+{
+ char *filename = filename_fn(state->dir, state->segno);
+ FILE *fd = fopen(filename, mode);
+
+ if (!fd)
+ pg_fatal(fatal_msg, filename);
+
+ pfree(filename);
+
+ return fd;
+}
+
+static void
+close_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno))
+{
+ if (state->file != NULL)
+ {
+ if (fclose(state->file) != 0)
+ pg_fatal("could not close file \"%s\": %m",
+ filename_fn(state->dir, state->segno));
+ state->file = NULL;
+ }
+}
+
+static inline int
+read_file(SLRUSegmentState *state, void *buf)
+{
+ size_t n = fread(buf, sizeof(char), BLCKSZ, state->file);
+
+ if (n != 0)
+ return n;
+
+ if (ferror(state->file))
+ pg_fatal("could not read file \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ if (!feof(state->file))
+ pg_fatal("unknown file read state \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ close_file(state, slru_filename_old);
+
+ return 0;
+}
+
+static int
+read_old_segment_page(SLRUSegmentState *state, void *buf, bool *is_empty)
+{
+ int n;
+
+ /* Open next segment file, if needed */
+ if (!state->file)
+ {
+ state->file = open_file(state, slru_filename_old, "rb",
+ "could not open source file \"%s\": %m");
+
+ /* Set position to the needed page */
+ if (fseek(state->file, state->pageno * BLCKSZ, SEEK_SET))
+ close_file(state, slru_filename_old);
+
+ /*
+ * Skip segment conversion if segment file doesn't exist.
+ * First segment file should exist in any case.
+ */
+ if (state->segno != 0)
+ state->is_empty_segment = true;
+ }
+
+ if (state->file)
+ {
+ /* Segment file does exist, read page from it */
+ state->is_empty_segment = false;
+
+ /* Try to read BLCKSZ bytes */
+ n = read_file(state, buf);
+ *is_empty = (n == 0);
+
+ /* Zeroing buf tail if needed */
+ if (n)
+ memset((char *) buf + n, 0, BLCKSZ - n);
+ }
+ else
+ {
+ n = state->is_empty_segment ?
+ BLCKSZ : /* Skip empty block at the end of segment */
+ 0; /* We reached the last segment */
+ *is_empty = true;
+
+ if (n)
+ memset((char *) buf, 0, BLCKSZ);
+ }
+
+ state->pageno++;
+
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ /* Start new segment */
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_old);
+ }
+
+ return n;
+}
+
+static void
+write_new_segment_page(SLRUSegmentState *state, void *buf, bool is_empty)
+{
+ /*
+ * Create a new segment file if we still didn't. Creation is postponed
+ * until the first non-empty page is found. This helps not to create
+ * completely empty segments.
+ */
+ if (!state->file && !is_empty)
+ {
+ state->file = open_file(state, slru_filename_new, "wb",
+ "could not open target file \"%s\": %m");
+
+ /* Write zeroes to the previously skipped prefix */
+ if (state->pageno > 0)
+ {
+ char zerobuf[BLCKSZ] = {0};
+
+ for (int64 i = 0; i < state->pageno; i++)
+ {
+ if (fwrite(zerobuf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+ }
+
+ }
+
+ /* Write page to the new segment (if it was created) */
+ if (state->file)
+ {
+ if (fwrite(buf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+
+ state->pageno++;
+
+ /*
+ * Did we reach the maximum page number? Then close segment file and
+ * create a new one on the next iteration
+ */
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_new);
+ }
+}
+
+static void
+convert_pg_xact_segments(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg = {0};
+ SLRUSegmentState newseg = {0};
+ char buf[BLCKSZ] = {0};
+ FullTransactionId oldestxid;
+ FullTransactionId nxtxid;
+ uint32 epoch;
+ int64 pageno;
+ uint64 xid;
+
+ oldseg.dir = old_subdir;
+ newseg.dir = new_subdir;
+
+ /* wraparound without epoch is not possible */
+ if (old_cluster.controldata.chkpnt_nxtepoch == 0 &&
+ old_cluster.controldata.chkpnt_oldstxid > old_cluster.controldata.chkpnt_nxtxid)
+ {
+ pg_fatal("inconsistent pg_xact of directory \"%s\"",
+ old_cluster.pgdata);
+ }
+
+ /* get full transactions bounds from old cluster */
+ epoch = old_cluster.controldata.chkpnt_nxtepoch;
+ nxtxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_nxtxid);
+ if (old_cluster.controldata.chkpnt_oldstxid > XidFromFullTransactionId(nxtxid))
+ --epoch;
+
+ oldestxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_oldstxid);
+
+ /* get init segments and pages */
+ pageno = oldestxid.value / CLOG_XACTS_PER_PAGE;
+
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ /* Copy xid flags reading only needed segment pages */
+ for (xid = oldestxid.value & ~(CLOG_XACTS_PER_PAGE - 1);
+ xid <= ((nxtxid.value - 1) & ~(CLOG_XACTS_PER_PAGE - 1));
+ xid += CLOG_XACTS_PER_PAGE)
+ {
+ bool is_empty;
+ int len;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxTransactionId / CLOG_XACTS_PER_PAGE / SLRU_PAGES_PER_SEGMENT)
+ {
+ Assert(!oldseg.pageno);
+ Assert(!oldseg.file);
+ Assert(!newseg.pageno);
+ Assert(!newseg.file);
+
+ oldseg.segno = 0;
+ }
+
+ len = read_old_segment_page(&oldseg, buf, &is_empty);
+
+ /*
+ * Ignore read errors, copy all existing segment pages in the
+ * interesting xid range.
+ */
+ is_empty |= len <= 0;
+
+ Assert(len >= 0);
+ Assert(is_empty == false);
+
+ write_new_segment_page(&newseg, buf, is_empty);
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+}
+
static void
copy_xact_xlog_xid(void)
{
@@ -573,10 +845,22 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ if (old_cluster.controldata.cat_ver < SLRU_FORMAT_CHANGE_CAT_VER)
+ {
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+ char *old_path = psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster));
+ char *new_path = psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster));
+
+ convert_pg_xact_segments(old_path, new_path);
+ pfree(old_path);
+ pfree(new_path);
+ }
+ else
+ copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
+ "pg_clog" : "pg_xact",
+ GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
+ "pg_clog" : "pg_xact");
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 31589b0fdc..0cfafc8810 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -126,6 +126,11 @@ extern char *output_files[];
*/
#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
+/*
+ * change in SLRU numbering to 64–bit
+ */
+#define SLRU_FORMAT_CHANGE_CAT_VER 202212092
+
/*
* Each relation is represented by a relinfo structure.
--
2.38.1
v51-0001-Use-internal-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v51-0001-Use-internal-64-bit-numbering-of-SLRU-pages.patchDownload
From ad2279f9bfad051676d199edc80dc741978ca3de Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v51 1/3] Use internal 64-bit numbering of SLRU pages.
This is part of transition to 64bit XIDs and 64bit SLRU page numbering.
It does not affect XID length and format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/transam/clog.c | 50 +++++-----
src/backend/access/transam/commit_ts.c | 6 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/clog.h | 2 +-
src/include/access/slru.h | 24 ++---
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
14 files changed, 144 insertions(+), 133 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index 87513732be..f44fec2ae1 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 8832efc7c1..e73c8c8d91 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -89,24 +89,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +162,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +236,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +245,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +271,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +337,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +411,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +637,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -734,7 +734,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +754,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +773,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +838,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +877,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +949,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +963,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +991,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 9aa4675cb7..cdc1d15b48 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -851,7 +851,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -936,7 +936,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e1191a7564..d97b63d8e6 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2855,7 +2855,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2863,7 +2863,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3114,7 +3114,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3134,7 +3134,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 6feda87f57..3703975a87 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 66d3548155..56c19021a9 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 3e1b92df03..056dca8e47 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index df1c0d72e9..760a54e021 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index 543f2e2643..73bc172309 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 130c41c863..4f5a324da2 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index aa13e1d66e..16be4bec13 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 049af878de..b0e297d78e 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 41e648fecd..ae269f36db 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
v51-0002-Use-64-bit-pages-representation-in-SLRU-callers.patchapplication/octet-stream; name=v51-0002-Use-64-bit-pages-representation-in-SLRU-callers.patchDownload
From f3ffcbb190649dbc9cf2f5bfdc7d0a13d846cba9 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Wed, 23 Mar 2022 13:16:26 +0300
Subject: [PATCH v51 2/3] Use 64-bit pages representation in SLRU callers.
Previously SLRU page counters were changed to unsigned 64-bit. As a next
separate step to making XID's 64-bit, we switch internal page counters to 64-bit
in SLRU callers: clog, mxact, commit_ts etc. This patch still doesn't change
xid's representation but is a requirement to do so.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/committsdesc.c | 10 +--
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 60 +++++++++++---
src/backend/access/transam/commit_ts.c | 82 ++++++++++++++-----
src/backend/access/transam/multixact.c | 44 +++++-----
src/backend/access/transam/slru.c | 8 +-
src/backend/access/transam/subtrans.c | 72 +++++++++++-----
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/commit_ts.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/recovery/t/003_recovery_targets.pl | 2 +-
11 files changed, 196 insertions(+), 94 deletions(-)
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index 3a65538bb0..623b93d0b5 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index 7076be2b3f..5db1960394 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index e73c8c8d91..6eb75d6577 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -47,13 +47,6 @@
/*
* Defines for CLOG page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * CLOG page numbering also wraps around at 0xFFFFFFFF/CLOG_XACTS_PER_PAGE,
- * and CLOG segment numbering at
- * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateCLOG (see CLOGPagePrecedes).
*/
/* We need two bits per xact, so four xacts fit in a byte */
@@ -62,7 +55,49 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -753,8 +788,7 @@ ZeroCLOGPage(int64 pageno, bool writeXlog)
void
StartupCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int64 pageno = TransactionIdToPage(xid);
+ int64 pageno = FullTransactionIdToPage(ShmemVariableCache->nextXid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -772,7 +806,8 @@ StartupCLOG(void)
void
TrimCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
+ FullTransactionId fxid = ShmemVariableCache->nextXid;
+ TransactionId xid = XidFromFullTransactionId(fxid);
int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -848,7 +883,7 @@ ExtendCLOG(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -944,7 +979,6 @@ CLOGPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + CLOG_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index cdc1d15b48..9ec4d8c848 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,49 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToCTsPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToCTsPageNoLock(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToCTsPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +144,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +211,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +255,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +307,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -587,7 +628,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -679,8 +720,7 @@ CommitTsParameterChange(bool newvalue, bool oldvalue)
static void
ActivateCommitTs(void)
{
- TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -691,8 +731,7 @@ ActivateCommitTs(void)
}
LWLockRelease(CommitTsLock);
- xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- pageno = TransactionIdToCTsPage(xid);
+ pageno = FullTransactionIdToCTsPage(ShmemVariableCache->nextXid);
/*
* Re-Initialize our idea of the latest page number.
@@ -813,7 +852,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -832,7 +871,7 @@ ExtendCommitTs(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToCTsPage(newestXact);
+ pageno = TransactionIdToCTsPageNoLock(newestXact);
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
@@ -950,15 +989,14 @@ CommitTsPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + COMMIT_TS_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -966,7 +1004,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -991,10 +1029,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index d97b63d8e6..a2573b3951 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -352,8 +352,8 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
@@ -364,7 +364,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -862,8 +862,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1223,8 +1223,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1926,7 +1926,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1942,7 +1942,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1972,7 +1972,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2007,7 +2007,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2032,7 +2032,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2401,7 +2401,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2450,7 +2450,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2732,7 +2732,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -3192,10 +3192,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3240,10 +3240,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3255,10 +3255,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3300,7 +3300,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 3703975a87..f9d182644d 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -63,11 +63,7 @@
static int inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
- /*
- * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
- */
- Assert(segno <= PG_INT32_MAX);
- return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
}
/*
@@ -1576,7 +1572,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
segno = (int) strtol(clde->d_name, NULL, 16);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 56c19021a9..ae48ba6914 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -38,20 +38,54 @@
/*
* Defines for SubTrans page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * SubTrans page numbering also wraps around at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes) and zeroing
- * them in StartupSUBTRANS.
*/
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ /* make local copy */
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,7 +97,7 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
+static int ZeroSUBTRANSPage(int64 pageno);
static bool SubTransPagePrecedes(int64 page1, int64 page2);
@@ -73,7 +107,7 @@ static bool SubTransPagePrecedes(int64 page1, int64 page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +142,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -233,7 +267,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +283,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -262,7 +296,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
startPage = TransactionIdToPage(oldestActiveXID);
nextXid = ShmemVariableCache->nextXid;
- endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
+ endPage = FullTransactionIdToPage(nextXid);
while (startPage != endPage)
{
@@ -307,7 +341,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -317,7 +351,7 @@ ExtendSUBTRANS(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
@@ -337,7 +371,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 3dba7d8a69..f1ceb4a4bd 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 7662f8e1a9..d2cfb02e14 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..8019ff916d 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index e8e1a420bc..5da765d3e6 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -57,7 +57,7 @@ $node_primary->init(has_archiving => 1, allows_streaming => 1);
# Bump the transaction ID epoch. This is useful to stress the portability
# of recovery_target_xid parsing.
-system_or_bail('pg_resetwal', '--epoch', '1', $node_primary->data_dir);
+system_or_bail('pg_resetwal', '-x', '0x10000000', $node_primary->data_dir);
# Start it
$node_primary->start;
--
2.38.1
On Mon, Dec 19, 2022 at 6:41 AM Maxim Orlov <orlovmg@gmail.com> wrote:
As always, reviews and opinions are very welcome.
Hi! I think that 64-bit xids are a very important feature and I want
to help advance it. That's why I want to try to understand a patch
better.
Do I get it right that the proposed v51 patchset only changes the SLRU
filenames and type of pageno representation? Is SLRU wraparound still
exactly there after 0xFFFFFFFF byte?
The thing is we had some nasty bugs because SLRU wraparound is tricky.
And I think it would be beneficial if we could get to continuous SLRU
space. But the patch seems to avoid addressing this problem.
Also, I do not understand what is the reason for splitting 1st and 2nd
steps. Certainly, there must be some logic behind it, but I just can't
grasp it...
And the purpose of the 3rd step with pg_upgrade changes is a complete
mystery for me. Please excuse my incompetence in the topic, but maybe
some commit message or comments would help. What kind of xact segments
conversion we do? Why is it only necessary for xacts, but not other
SLRUs?
Thank you for working on this important project!
Best regards, Andrey Borodin.
On Mon, 19 Dec 2022 at 22:40, Maxim Orlov <orlovmg@gmail.com> wrote:
Hi!
As a result of discussion in the thread [0], Robert Haas proposed to focus
on making SLRU 64 bit, as a first step towards 64 bit XIDs.
Here is the patch set.In overall, code of this patch set is based on the existing code from [0]
and may be simplified, due to the fact, that SLRU_PAGES_PER_SEGMENT is not
meant to be changed now.
But I decided to leave it that way. At least for now.As always, reviews and opinions are very welcome.
For v51-0003. We can use GetClogDirName instead of GET_MAJOR_VERSION in
copy_subdir_files().
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 1c49c63444..3934978b97 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -857,10 +857,7 @@ copy_xact_xlog_xid(void)
pfree(new_path);
}
else
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ copy_subdir_files(GetClogDirName(old_cluster), GetClogDirName(new_cluster));
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
Do I get it right that the proposed v51 patchset only changes the SLRU
filenames and type of pageno representation? Is SLRU wraparound still
exactly there after 0xFFFFFFFF byte?
After applying the whole patch set, SLRU will become 64–bit without a
wraparound. Thus, no wraparound
should be there.
0001 - should make SLRU internally 64–bit, no effects from "outside"
0002 - should make SLRU callers 64–bit, SLRU segment files naming are
changed
0003 - make upgrade from previous versions feasible
Also, I do not understand what is the reason for splitting 1st and 2nd
steps. Certainly, there must be some logic behind it, but I just can't
grasp it...
As we did discuss somewhere in the beginning of the discussion, we try to
make every commit as independent as possible.
Thus, it is much easier to review and commit. I see no problem to meld
these commits into one, if consensus will be reached.
And the purpose of the 3rd step with pg_upgrade changes is a complete
mystery for me. Please excuse my incompetence in the topic, but maybe
some commit message or comments would help. What kind of xact segments
conversion we do? Why is it only necessary for xacts, but not other
SLRUs?
The purpose of the third patch is to make upgrade feasible. Since we've
change pg_xact files naming,
Postgres could not read status of "old" transactions from "old" pg_xact
files. So, we have to convert those files.
The major problem here is that we must handle possible segment wraparound
(in "old" cluster). The whole idea
for an upgrade is to read SLRU pages for pg_xact one by one and write it in
a "new" filename.
Maybe, It's just a little bit complicated, since the algorithm is intended
to deal with different SLRU pages per segment
in "new" and "old" clusters. But, on the other hand, it is already created
in original patch set of 64–bit XIDs and will be useful
in the future. AFAICS, arguably, any variant of 64–bit XIDs should lead to
increase of an amount of SLRU pages per segment.
And as for other SLRUs, they cannot survive pg_upgrade mostly by the fact,
that cluster must be stopped upon upgrade.
Thus, no conversion needed.
--
Best regards,
Maxim Orlov.
Hi Andrey,
Hi! I think that 64-bit xids are a very important feature and I want
to help advance it. That's why I want to try to understand a patch
better.
Thanks for your interest to the patchset!
Do I get it right that the proposed v51 patchset only changes the SLRU
filenames and type of pageno representation? Is SLRU wraparound still
exactly there after 0xFFFFFFFF byte?
OK, let me give some background then. I suspect you already know this,
but this can be useful for other reviewers. Additionally we have two
rather large threads on our hands and it's easy to lose track of
things.
SLRU is basically a general-purpose LRU implementation with ReadPage()
/ WritePage() interface with the only exception that instead of
something like Page* object it operates slot numbers (array indexes).
SLRU is used as an underlying container for several internal
PostgreSQL structures, most importantly CLOG. Despite the name CLOG is
not a log (journal) but rather a large bit array. For every
transaction it stores two bits that reflect the status of the
transaction (more detail in clog.c / clog.h).
Currently SLRU operates 32-bit page numbers. What we currently agreed
on [1]/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com and what we are trying to achieve in this thread is to make
SLRU pages 64-bit. The rest of the 64-bit XIDs is discussed in another
thread [2]/messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com -- Best regards, Aleksander Alekseev.
As Robert Haas put it:
Specifically, there are a couple of patches in here that
have to do with making SLRUs indexed by 64-bit integers rather than by
32-bit integers. We've had repeated bugs in the area of handling SLRU
wraparound in the past, some of which have caused data loss. Just by
chance, I ran across a situation just yesterday where an SLRU wrapped
around on disk for reasons that I don't really understand yet and
chaos ensued. Switching to an indexing system for SLRUs that does not
ever wrap around would probably enable us to get rid of a whole bunch
of crufty code, and would also likely improve the general reliability
of the system in situations where wraparound is threatened. It seems
like a really, really good idea.
So our goal here is to eliminate wrap-around for SLRU. It means that
if I save something to the page 0x0000000012345678 it will stay there
forever. Other parts of the system however have to form proper 64-bit
page numbers in order to make it work. If they don't the wrap-around
is possible for these particular subsystems (but not SLRU per se).
Also, I do not understand what is the reason for splitting 1st and 2nd
steps. Certainly, there must be some logic behind it, but I just can't
grasp it...
0001 patch changes the SLRU internals without affecting the callers.
It also preserves the short SLRU filenames which means nothing changes
for an outside observer. All it changes is PostgreSQL binary. It can
be merged any time and even backported to the previous versions if we
want to.
The 0002 patch makes changes to the callers and also enlarges SLRU
filenames. For sure we could do everything at once, but it would
complicate testing and more importantly code review. Personally I
believe Maxim did a great job here. Both patches were easy to read and
understand (relatively, of course).
And the purpose of the 3rd step with pg_upgrade changes is a complete
mystery for me.
0001 and 0002 will work fine for new PostgreSQL instances. But if you
have an instance that already has on-disk state we have to move the
SLRU segments accordingly. This is what 0003 does.
That's the theory at least. Personally I still have to meditate a bit
more on the code in order to get a good understanding of it,
especially the parts that deal with transaction epochs because this is
something I have limited experience with. Also I wouldn't exclude the
possibility of bugs. Particularly this part of 0003:
```
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
```
looks suspicious to me.
I agree that adding a couple of additional comments could be
appropriate, especially when it comes to epochs.
[1]: /messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
[2]: /messages/by-id/CACG=ezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe=pyyjVWA@mail.gmail.com -- Best regards, Aleksander Alekseev
--
Best regards,
Aleksander Alekseev
On Fri, 6 Jan 2023 at 09:51, Japin Li <japinli@hotmail.com> wrote:
For v51-0003. We can use GetClogDirName instead of GET_MAJOR_VERSION in
copy_subdir_files().
Of course! Tanks! I'll address this in the next iteration, v52.
--
Best regards,
Maxim Orlov.
Hi!
Here is a new patch set.
I've added comments and make use GetClogDirName call in copy_subdir_files.
--
Best regards,
Maxim Orlov.
Attachments:
v52-0003-Make-pg_upgrade-from-32-bit-to-64-bit-SLRU.patchapplication/octet-stream; name=v52-0003-Make-pg_upgrade-from-32-bit-to-64-bit-SLRU.patchDownload
From 6e0ed718339267793cd0a5aa3adaa8cb019fb815 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Wed, 14 Dec 2022 15:24:21 +0300
Subject: [PATCH v52 3/3] =?UTF-8?q?Make=20pg=5Fupgrade=20from=2032-bit=20t?=
=?UTF-8?q?o=2064=E2=80=93bit=20SLRU?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We read SLRU pages of pg_xact segments from old cluster
one by one and write them in a new segments files.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/bin/pg_upgrade/pg_upgrade.c | 312 +++++++++++++++++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.h | 5 +
2 files changed, 313 insertions(+), 4 deletions(-)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5597d3105..06b6d394e8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -44,6 +44,7 @@
#include <langinfo.h>
#endif
+#include "access/transam.h"
#include "catalog/pg_class_d.h"
#include "common/file_perm.h"
#include "common/logging.h"
@@ -566,6 +567,298 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
check_ok();
}
+/******************************************************************************/
+#define SLRU_PAGES_PER_SEGMENT 32 /* Should be equal to value from slru.h */
+
+#define CLOG_BITS_PER_XACT 2
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+/*
+ * Rename the files from the old cluster into it
+ */
+typedef struct SLRUSegmentState
+{
+ const char *dir;
+ FILE *file;
+ int64 segno;
+ int64 pageno;
+ bool is_empty_segment;
+} SLRUSegmentState;
+
+/*
+ * Old cluster SlruFileName (i.e. 32-bit)
+ */
+static char *
+slru_filename_old(const char *path, int64 segno)
+{
+ Assert(segno <= PG_INT32_MAX);
+ return psprintf("%s/%04X", path, (int) segno);
+}
+
+/*
+ * New cluster SlruFileName (i.e. 64-bit)
+ */
+static char *
+slru_filename_new(const char *path, int64 segno)
+{
+ return psprintf("%s/%012llX", path, (long long) segno);
+}
+
+/*
+ * Generalized fopen for SLRU segment file
+ */
+static inline FILE *
+open_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno),
+ char *mode, char *fatal_msg)
+{
+ char *filename = filename_fn(state->dir, state->segno);
+ FILE *fd = fopen(filename, mode);
+
+ if (!fd)
+ pg_fatal(fatal_msg, filename);
+
+ pfree(filename);
+
+ return fd;
+}
+
+/*
+ * Generalized fclose for SLRU segment file
+ */
+static void
+close_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno))
+{
+ if (state->file != NULL)
+ {
+ if (fclose(state->file) != 0)
+ pg_fatal("could not close file \"%s\": %m",
+ filename_fn(state->dir, state->segno));
+ state->file = NULL;
+ }
+}
+
+/*
+ * Generalized fread of BLCKSZ fro, SLRU segment file
+ */
+static inline int
+read_file(SLRUSegmentState *state, void *buf)
+{
+ size_t n = fread(buf, sizeof(char), BLCKSZ, state->file);
+
+ if (n != 0)
+ return n;
+
+ if (ferror(state->file))
+ pg_fatal("could not read file \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ if (!feof(state->file))
+ pg_fatal("unknown file read state \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ close_file(state, slru_filename_old);
+
+ return 0;
+}
+
+static int
+read_old_segment_page(SLRUSegmentState *state, void *buf, bool *is_empty)
+{
+ int n;
+
+ /* Open next segment file, if needed */
+ if (!state->file)
+ {
+ state->file = open_file(state, slru_filename_old, "rb",
+ "could not open source file \"%s\": %m");
+
+ /* Set position to the needed page */
+ if (fseek(state->file, state->pageno * BLCKSZ, SEEK_SET))
+ close_file(state, slru_filename_old);
+
+ /*
+ * Skip segment conversion if segment file doesn't exist.
+ * First segment file should exist in any case.
+ */
+ if (state->segno != 0)
+ state->is_empty_segment = true;
+ }
+
+ if (state->file)
+ {
+ /* Segment file does exist, read page from it */
+ state->is_empty_segment = false;
+
+ /* Try to read BLCKSZ bytes */
+ n = read_file(state, buf);
+ *is_empty = (n == 0);
+
+ /* Zeroing buf tail if needed */
+ if (n)
+ memset((char *) buf + n, 0, BLCKSZ - n);
+ }
+ else
+ {
+ n = state->is_empty_segment ?
+ BLCKSZ : /* Skip empty block at the end of segment */
+ 0; /* We reached the last segment */
+ *is_empty = true;
+
+ if (n)
+ memset((char *) buf, 0, BLCKSZ);
+ }
+
+ state->pageno++;
+
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ /* Start new segment */
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_old);
+ }
+
+ return n;
+}
+
+static void
+write_new_segment_page(SLRUSegmentState *state, void *buf, bool is_empty)
+{
+ /*
+ * Create a new segment file if we still didn't. Creation is postponed
+ * until the first non-empty page is found. This helps not to create
+ * completely empty segments.
+ */
+ if (!state->file && !is_empty)
+ {
+ state->file = open_file(state, slru_filename_new, "wb",
+ "could not open target file \"%s\": %m");
+
+ /* Write zeroes to the previously skipped prefix */
+ if (state->pageno > 0)
+ {
+ char zerobuf[BLCKSZ] = {0};
+
+ for (int64 i = 0; i < state->pageno; i++)
+ {
+ if (fwrite(zerobuf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+ }
+
+ }
+
+ /* Write page to the new segment (if it was created) */
+ if (state->file)
+ {
+ if (fwrite(buf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+
+ state->pageno++;
+
+ /*
+ * Did we reach the maximum page number? Then close segment file and
+ * create a new one on the next iteration
+ */
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_new);
+ }
+}
+
+/*
+ * Convert pg_xact from 32bit to 64bit format.
+ *
+ * We read SLRU pages of pg_xact segments from old cluster one by one and write
+ * them in a new segments files.
+ */
+static void
+convert_pg_xact_segments(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg = {0};
+ SLRUSegmentState newseg = {0};
+ char buf[BLCKSZ] = {0};
+ FullTransactionId oldestxid;
+ FullTransactionId nxtxid;
+ uint32 epoch;
+ int64 pageno;
+ uint64 xid;
+
+ oldseg.dir = old_subdir;
+ newseg.dir = new_subdir;
+
+ /* wraparound without epoch is not possible */
+ if (old_cluster.controldata.chkpnt_nxtepoch == 0 &&
+ old_cluster.controldata.chkpnt_oldstxid > old_cluster.controldata.chkpnt_nxtxid)
+ {
+ pg_fatal("inconsistent pg_xact of directory \"%s\"",
+ old_cluster.pgdata);
+ }
+
+ /* get full transactions bounds from old cluster */
+ epoch = old_cluster.controldata.chkpnt_nxtepoch;
+ nxtxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_nxtxid);
+ if (old_cluster.controldata.chkpnt_oldstxid > XidFromFullTransactionId(nxtxid))
+ --epoch;
+
+ oldestxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_oldstxid);
+
+ /* get init segments and pages */
+ pageno = oldestxid.value / CLOG_XACTS_PER_PAGE;
+
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ /* Copy xid flags reading only needed segment pages */
+ for (xid = oldestxid.value & ~(CLOG_XACTS_PER_PAGE - 1);
+ xid <= ((nxtxid.value - 1) & ~(CLOG_XACTS_PER_PAGE - 1));
+ xid += CLOG_XACTS_PER_PAGE)
+ {
+ bool is_empty;
+ int len;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxTransactionId / CLOG_XACTS_PER_PAGE / SLRU_PAGES_PER_SEGMENT)
+ {
+ Assert(!oldseg.pageno);
+ Assert(!oldseg.file);
+ Assert(!newseg.pageno);
+ Assert(!newseg.file);
+
+ oldseg.segno = 0;
+ }
+
+ len = read_old_segment_page(&oldseg, buf, &is_empty);
+
+ /*
+ * Ignore read errors, copy all existing segment pages in the
+ * interesting xid range.
+ */
+ is_empty |= len <= 0;
+
+ Assert(len >= 0);
+ Assert(is_empty == false);
+
+ write_new_segment_page(&newseg, buf, is_empty);
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+}
+
static void
copy_xact_xlog_xid(void)
{
@@ -573,10 +866,21 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+
+ if (old_cluster.controldata.cat_ver < SLRU_FORMAT_CHANGE_CAT_VER)
+ {
+ char *old_path = psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster));
+ char *new_path = psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster));
+
+ convert_pg_xact_segments(old_path, new_path);
+ pfree(old_path);
+ pfree(new_path);
+ }
+ else
+ copy_subdir_files(GetClogDirName(old_cluster),
+ GetClogDirName(new_cluster));
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 5f2a116f23..9a26d0f859 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -126,6 +126,11 @@ extern char *output_files[];
*/
#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
+/*
+ * change in SLRU numbering to 64–bit
+ */
+#define SLRU_FORMAT_CHANGE_CAT_VER 202212092
+
/*
* Each relation is represented by a relinfo structure.
--
2.38.1
v52-0002-Use-64-bit-pages-representation-in-SLRU-callers.patchapplication/octet-stream; name=v52-0002-Use-64-bit-pages-representation-in-SLRU-callers.patchDownload
From ce1a279c81db49cf2bebc13afd556858e3f5ae8b Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Wed, 23 Mar 2022 13:16:26 +0300
Subject: [PATCH v52 2/3] Use 64-bit pages representation in SLRU callers.
Previously SLRU page counters were changed to unsigned 64-bit. As a next
separate step to making XID's 64-bit, we switch internal page counters to 64-bit
in SLRU callers: clog, mxact, commit_ts etc. This patch still doesn't change
xid's representation but is a requirement to do so.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/committsdesc.c | 10 +--
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 60 +++++++++++---
src/backend/access/transam/commit_ts.c | 82 ++++++++++++++-----
src/backend/access/transam/multixact.c | 44 +++++-----
src/backend/access/transam/slru.c | 8 +-
src/backend/access/transam/subtrans.c | 72 +++++++++++-----
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/commit_ts.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/recovery/t/003_recovery_targets.pl | 2 +-
11 files changed, 196 insertions(+), 94 deletions(-)
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 0005d4cd78..08b8b226ba 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -47,13 +47,6 @@
/*
* Defines for CLOG page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * CLOG page numbering also wraps around at 0xFFFFFFFF/CLOG_XACTS_PER_PAGE,
- * and CLOG segment numbering at
- * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateCLOG (see CLOGPagePrecedes).
*/
/* We need two bits per xact, so four xacts fit in a byte */
@@ -62,7 +55,49 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -753,8 +788,7 @@ ZeroCLOGPage(int64 pageno, bool writeXlog)
void
StartupCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int64 pageno = TransactionIdToPage(xid);
+ int64 pageno = FullTransactionIdToPage(ShmemVariableCache->nextXid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -772,7 +806,8 @@ StartupCLOG(void)
void
TrimCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
+ FullTransactionId fxid = ShmemVariableCache->nextXid;
+ TransactionId xid = XidFromFullTransactionId(fxid);
int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -848,7 +883,7 @@ ExtendCLOG(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -944,7 +979,6 @@ CLOGPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + CLOG_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 7be10e21e2..b5d0c8a08c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,49 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToCTsPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToCTsPageNoLock(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToCTsPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +144,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +211,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +255,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +307,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -569,7 +610,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -661,8 +702,7 @@ CommitTsParameterChange(bool newvalue, bool oldvalue)
static void
ActivateCommitTs(void)
{
- TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -673,8 +713,7 @@ ActivateCommitTs(void)
}
LWLockRelease(CommitTsLock);
- xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- pageno = TransactionIdToCTsPage(xid);
+ pageno = FullTransactionIdToCTsPage(ShmemVariableCache->nextXid);
/*
* Re-Initialize our idea of the latest page number.
@@ -795,7 +834,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -814,7 +853,7 @@ ExtendCommitTs(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToCTsPage(newestXact);
+ pageno = TransactionIdToCTsPageNoLock(newestXact);
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
@@ -932,15 +971,14 @@ CommitTsPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + COMMIT_TS_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +986,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +1011,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index accdb6c98a..c5137becfb 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1928,7 +1928,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1944,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1974,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2009,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2034,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2403,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2452,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2735,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -3191,10 +3191,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3239,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3254,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3299,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 1a16326426..22c9bf3284 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -63,11 +63,7 @@
static int inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
- /*
- * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
- */
- Assert(segno <= PG_INT32_MAX);
- return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
}
/*
@@ -1576,7 +1572,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
segno = (int) strtol(clde->d_name, NULL, 16);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 18e6c13e3e..c343055bbf 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -38,20 +38,54 @@
/*
* Defines for SubTrans page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * SubTrans page numbering also wraps around at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes) and zeroing
- * them in StartupSUBTRANS.
*/
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ /* make local copy */
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,7 +97,7 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
+static int ZeroSUBTRANSPage(int64 pageno);
static bool SubTransPagePrecedes(int64 page1, int64 page2);
@@ -73,7 +107,7 @@ static bool SubTransPagePrecedes(int64 page1, int64 page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +142,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -233,7 +267,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +283,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -262,7 +296,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
startPage = TransactionIdToPage(oldestActiveXID);
nextXid = ShmemVariableCache->nextXid;
- endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
+ endPage = FullTransactionIdToPage(nextXid);
while (startPage != endPage)
{
@@ -307,7 +341,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -317,7 +351,7 @@ ExtendSUBTRANS(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
@@ -337,7 +371,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 0c304105c5..69119d30b7 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..8019ff916d 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 84d06096f6..a99a4fa9ce 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -57,7 +57,7 @@ $node_primary->init(has_archiving => 1, allows_streaming => 1);
# Bump the transaction ID epoch. This is useful to stress the portability
# of recovery_target_xid parsing.
-system_or_bail('pg_resetwal', '--epoch', '1', $node_primary->data_dir);
+system_or_bail('pg_resetwal', '-x', '0x10000000', $node_primary->data_dir);
# Start it
$node_primary->start;
--
2.38.1
v52-0001-Use-internal-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v52-0001-Use-internal-64-bit-numbering-of-SLRU-pages.patchDownload
From b10fc2af11c99953ea2edad8e5485dfc1ce0f5ff Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v52 1/3] Use internal 64-bit numbering of SLRU pages.
This is part of transition to 64bit XIDs and 64bit SLRU page numbering.
It does not affect XID length and format.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/transam/clog.c | 50 +++++-----
src/backend/access/transam/commit_ts.c | 6 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/clog.h | 2 +-
src/include/access/slru.h | 24 ++---
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
14 files changed, 144 insertions(+), 133 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..0005d4cd78 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -89,24 +89,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +162,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +236,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +245,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +271,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +337,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +411,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +637,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -734,7 +734,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +754,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +773,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +838,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +877,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +949,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +963,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +991,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..7be10e21e2 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -833,7 +833,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +918,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e75e1fdf74..accdb6c98a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -356,8 +356,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..1a16326426 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..18e6c13e3e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..3c8b3f7b16 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 327adef5d3..6aa510e4a3 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..859ec6e589 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index b5c6f46d03..fd81ed31d4 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index bad6647f40..577428668a 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.38.1
Hi Maxim,
Here is a new patch set.
I've added comments and make use GetClogDirName call in copy_subdir_files.
Jacob Champion pointed out (offlist, cc:'ed) that we may be wrong on this one:
0001 patch changes the SLRU internals without affecting the callers.
0001 - should make SLRU internally 64–bit, no effects from "outside"
... and apparently Jacob is right.
Besides other things 0001 modifies CLOG_ZEROPAGE and CLOG_TRUNCATE WAL
records - it makes changes to WriteZeroPageXlogRec() and
WriteTruncateXlogRec() and corresponding changes to clog_desc() and
clog_redo().
Firstly, it means that the patch doesn't change what it claims to
change. I think these changes should be part of 0002.
Secondly, shouldn't we introduce a new WAL record type in order to
make the code backward compatible with previous PG versions? I'm not
100% sure how the upgrade procedure works in all the details. If it
requires the DBMS to be gracefully shut down before the upgrade then
we are probably fine here.
--
Best regards,
Aleksander Alekseev
Hi Maxim,
Secondly, shouldn't we introduce a new WAL record type in order to
make the code backward compatible with previous PG versions? I'm not
100% sure how the upgrade procedure works in all the details. If it
requires the DBMS to be gracefully shut down before the upgrade then
we are probably fine here.
After reading [1]https://www.postgresql.org/docs/current/pgupgrade.html carefully it looks like we shouldn't worry about
this. The upgrade procedure explicitly requires to run `pg_ctl stop`
during step 8 of the upgrade procedure, i.e. not in the immediate mode
[2]: https://www.postgresql.org/docs/current/app-pg-ctl.html
what I can tell there is no way they will see WAL records they
wouldn't understand.
[1]: https://www.postgresql.org/docs/current/pgupgrade.html
[2]: https://www.postgresql.org/docs/current/app-pg-ctl.html
--
Best regards,
Aleksander Alekseev
On Wed, Jan 11, 2023 at 1:48 AM Aleksander Alekseev
<aleksander@timescale.com> wrote:
After reading [1] carefully it looks like we shouldn't worry about
this. The upgrade procedure explicitly requires to run `pg_ctl stop`
during step 8 of the upgrade procedure, i.e. not in the immediate mode
[2].
Yeah, pg_upgrade will briefly start and stop the old server to make
sure all the WAL is replayed, and won't transfer any of the files
over. AFAIK, major-version WAL changes are fine; it was the previous
claim that we could do it in a minor version that I was unsure about.
Thanks!
--Jacob
Hi hackers,
Yeah, pg_upgrade will briefly start and stop the old server to make
sure all the WAL is replayed, and won't transfer any of the files
over. AFAIK, major-version WAL changes are fine; it was the previous
claim that we could do it in a minor version that I was unsure about.
OK, here is the patchset v53 where I mostly modified the commit
messages. It is explicitly said that 0001 modifies the WAL records and
why we decided to do it in this patch. Additionally any mention of
64-bit XIDs is removed since it is not guaranteed that the rest of the
patches are going to be accepted. 64-bit SLRU page numbering is a
valuable change per se.
Changing the status of the CF entry to RfC apparently was a bit
premature. It looks like the patchset can use a few more rounds of
review.
In 0002:
```
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToCTsPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
```
I'm pretty confident that shared memory can't be accessed like this,
without taking a lock. Although it may work on x64 generally we can
get garbage, unless nextXid is accessed atomically and has a
corresponding atomic type. On top of that I'm pretty sure
TransactionIds can't be compared with the regular comparison
operators. All in all, so far I don't understand why this piece of
code should be so complicated.
The same applies to:
```
-#define TransactionIdToPage(xid) ((xid) / (TransactionId)
SUBTRANS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
```
... in subtrans.c
Maxim, perhaps you could share with us what your reasoning was here?
--
Best regards,
Aleksander Alekseev
Attachments:
v53-0002-Utilize-64-bit-SLRU-page-numbers-in-SLRU-callers.patchapplication/octet-stream; name=v53-0002-Utilize-64-bit-SLRU-page-numbers-in-SLRU-callers.patchDownload
From 02fe863400d7eb75c56a71c40f85abe0653023f1 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Wed, 23 Mar 2022 13:16:26 +0300
Subject: [PATCH v53 2/3] Utilize 64-bit SLRU page numbers in SLRU callers
Previously SLRU page numbers were changed to unsigned 64-bit without affecting
the callers. This patch modifies the callers: clog, mxact, commit_ts, etc.
The upgrade procedure is implemented in the following patch.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/committsdesc.c | 10 +--
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 60 +++++++++++---
src/backend/access/transam/commit_ts.c | 82 ++++++++++++++-----
src/backend/access/transam/multixact.c | 44 +++++-----
src/backend/access/transam/slru.c | 8 +-
src/backend/access/transam/subtrans.c | 72 +++++++++++-----
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/commit_ts.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/recovery/t/003_recovery_targets.pl | 2 +-
11 files changed, 196 insertions(+), 94 deletions(-)
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 0005d4cd78..08b8b226ba 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -47,13 +47,6 @@
/*
* Defines for CLOG page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * CLOG page numbering also wraps around at 0xFFFFFFFF/CLOG_XACTS_PER_PAGE,
- * and CLOG segment numbering at
- * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateCLOG (see CLOGPagePrecedes).
*/
/* We need two bits per xact, so four xacts fit in a byte */
@@ -62,7 +55,49 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -753,8 +788,7 @@ ZeroCLOGPage(int64 pageno, bool writeXlog)
void
StartupCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int64 pageno = TransactionIdToPage(xid);
+ int64 pageno = FullTransactionIdToPage(ShmemVariableCache->nextXid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -772,7 +806,8 @@ StartupCLOG(void)
void
TrimCLOG(void)
{
- TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
+ FullTransactionId fxid = ShmemVariableCache->nextXid;
+ TransactionId xid = XidFromFullTransactionId(fxid);
int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -848,7 +883,7 @@ ExtendCLOG(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -944,7 +979,6 @@ CLOGPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + CLOG_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index 7be10e21e2..b5d0c8a08c 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,49 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToCTsPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ /* make a local copy */
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToCTsPageNoLock(TransactionId xid)
+{
+ return TransactionIdToCTsPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToCTsPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +144,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +211,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +255,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +307,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -569,7 +610,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -661,8 +702,7 @@ CommitTsParameterChange(bool newvalue, bool oldvalue)
static void
ActivateCommitTs(void)
{
- TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -673,8 +713,7 @@ ActivateCommitTs(void)
}
LWLockRelease(CommitTsLock);
- xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- pageno = TransactionIdToCTsPage(xid);
+ pageno = FullTransactionIdToCTsPage(ShmemVariableCache->nextXid);
/*
* Re-Initialize our idea of the latest page number.
@@ -795,7 +834,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -814,7 +853,7 @@ ExtendCommitTs(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToCTsPage(newestXact);
+ pageno = TransactionIdToCTsPageNoLock(newestXact);
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
@@ -932,15 +971,14 @@ CommitTsPagePrecedes(int64 page1, int64 page2)
TransactionIdPrecedes(xid1, xid2 + COMMIT_TS_XACTS_PER_PAGE - 1));
}
-
/*
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +986,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +1011,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index accdb6c98a..c5137becfb 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,8 +354,8 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1928,7 +1928,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1944,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1974,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2009,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2034,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2403,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2452,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2735,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -3191,10 +3191,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3239,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3254,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3299,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 1a16326426..22c9bf3284 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -63,11 +63,7 @@
static int inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
- /*
- * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
- */
- Assert(segno <= PG_INT32_MAX);
- return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
}
/*
@@ -1576,7 +1572,7 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
segno = (int) strtol(clde->d_name, NULL, 16);
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 18e6c13e3e..c343055bbf 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -38,20 +38,54 @@
/*
* Defines for SubTrans page sizes. A page is the same BLCKSZ as is used
* everywhere else in Postgres.
- *
- * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
- * SubTrans page numbering also wraps around at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at
- * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
- * explicit notice of that fact in this module, except when comparing segment
- * and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes) and zeroing
- * them in StartupSUBTRANS.
*/
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+static inline int64
+TransactionIdToPageInternal(TransactionId xid, bool lock)
+{
+ FullTransactionId fxid,
+ nextXid;
+ uint32 epoch;
+
+ /* make local copy */
+ if (lock)
+ LWLockAcquire(XidGenLock, LW_SHARED);
+
+ nextXid = ShmemVariableCache->nextXid;
+
+ if (lock)
+ LWLockRelease(XidGenLock);
+
+ epoch = EpochFromFullTransactionId(nextXid);
+ if (xid > XidFromFullTransactionId(nextXid))
+ --epoch;
+
+ fxid = FullTransactionIdFromEpochAndXid(epoch, xid);
+
+ return fxid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, true);
+}
+
+static inline int64
+TransactionIdToPageNoLock(TransactionId xid)
+{
+ return TransactionIdToPageInternal(xid, false);
+}
+
+static inline int64
+FullTransactionIdToPage(FullTransactionId xid)
+{
+ return xid.value / (uint64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,7 +97,7 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
+static int ZeroSUBTRANSPage(int64 pageno);
static bool SubTransPagePrecedes(int64 page1, int64 page2);
@@ -73,7 +107,7 @@ static bool SubTransPagePrecedes(int64 page1, int64 page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +142,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -233,7 +267,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +283,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -262,7 +296,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
startPage = TransactionIdToPage(oldestActiveXID);
nextXid = ShmemVariableCache->nextXid;
- endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
+ endPage = FullTransactionIdToPage(nextXid);
while (startPage != endPage)
{
@@ -307,7 +341,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -317,7 +351,7 @@ ExtendSUBTRANS(TransactionId newestXact)
!TransactionIdEquals(newestXact, FirstNormalTransactionId))
return;
- pageno = TransactionIdToPage(newestXact);
+ pageno = TransactionIdToPageNoLock(newestXact);
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
@@ -337,7 +371,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 0c304105c5..69119d30b7 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..8019ff916d 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 84d06096f6..a99a4fa9ce 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -57,7 +57,7 @@ $node_primary->init(has_archiving => 1, allows_streaming => 1);
# Bump the transaction ID epoch. This is useful to stress the portability
# of recovery_target_xid parsing.
-system_or_bail('pg_resetwal', '--epoch', '1', $node_primary->data_dir);
+system_or_bail('pg_resetwal', '-x', '0x10000000', $node_primary->data_dir);
# Start it
$node_primary->start;
--
2.39.0
v53-0001-Use-64-bit-numbering-of-SLRU-pages.patchapplication/octet-stream; name=v53-0001-Use-64-bit-numbering-of-SLRU-pages.patchDownload
From 33cee2e2b778d93edd559ad725f5645b45c6abf7 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v53 1/3] Use 64-bit numbering of SLRU pages
The changes to SLRU are made without affecting the callers. The callers are
modified in the following patches.
Additionally the patch modifies CLOG_ZEROPAGE and CLOG_TRUNCATE WAL
records because it was convenient to do not separately but in this patch.
Due to the way the upgrade procedure works the system will not see
any records it may not understand. The patch is not intended to be
back-ported.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Jacob Champion <jchampion@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/transam/clog.c | 50 +++++-----
src/backend/access/transam/commit_ts.c | 6 +-
src/backend/access/transam/multixact.c | 12 +--
src/backend/access/transam/slru.c | 98 ++++++++++---------
src/backend/access/transam/subtrans.c | 4 +-
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/include/access/clog.h | 2 +-
src/include/access/slru.h | 24 ++---
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
14 files changed, 144 insertions(+), 133 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..0005d4cd78 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -89,24 +89,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +162,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +236,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +245,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +271,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +337,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +411,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +637,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -734,7 +734,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +754,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +773,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +838,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +877,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +930,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +949,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +963,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +991,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..7be10e21e2 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -108,7 +108,7 @@ static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
static void WriteZeroPageXlogRec(int pageno);
@@ -833,7 +833,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +918,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index e75e1fdf74..accdb6c98a 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -356,8 +356,8 @@ static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..1a16326426 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,15 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ /*
+ * Since we do not have 64 bit SLRU yet, make sure have no overflow here.
+ */
+ Assert(segno <= PG_INT32_MAX);
+ return snprintf(path, MAXPGPATH, "%s/%04X", ctl->Dir, (int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +82,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,20 +145,20 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
*/
-
Size
SimpleLruShmemSize(int nslots, int nlsns)
{
@@ -162,7 +169,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +233,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +285,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +400,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +500,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +547,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +631,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +689,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +761,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +936,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -963,7 +970,8 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
else
ereport(ERROR,
(errmsg("could not access status of transaction %u", xid),
- errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.", path, offset)));
+ errdetail("Could not read from file \"%s\" at offset %d: read too few bytes.",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
if (errno)
@@ -1014,7 +1022,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1033,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1077,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1167,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1232,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1310,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1333,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1397,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1413,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1506,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1522,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1538,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1566,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..18e6c13e3e 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -64,7 +64,7 @@ static SlruCtlData SubTransCtlData;
static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -359,7 +359,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..3c8b3f7b16 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 327adef5d3..6aa510e4a3 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -439,7 +439,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -788,7 +788,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -808,7 +808,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -906,9 +906,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..859ec6e589 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index b5c6f46d03..fd81ed31d4 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index bad6647f40..577428668a 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %d on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %d", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.39.0
v53-0003-pg_upgrade-from-32-bit-to-64-bit-SLRU-page-numbe.patchapplication/octet-stream; name=v53-0003-pg_upgrade-from-32-bit-to-64-bit-SLRU-page-numbe.patchDownload
From 4b5c8fca238fe3c4011a3bd6b694cbdd866d826f Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Wed, 14 Dec 2022 15:24:21 +0300
Subject: [PATCH v53 3/3] =?UTF-8?q?pg=5Fupgrade=20from=2032-bit=20to=2064?=
=?UTF-8?q?=E2=80=93bit=20SLRU=20page=20numbers?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The upgrade procedure is straightforward: read SLRU pages of pg_xact segments
one by one from the old cluster and write them in new segment files.
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Maxim Orlov <orlovmg@gmail.com>
Author: Pavel Borisov <pashkin.elfe@gmail.com>
Author: Yura Sokolov <y.sokolov@postgrespro.ru> <funny.falcon@gmail.com>
Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/bin/pg_upgrade/pg_upgrade.c | 312 +++++++++++++++++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.h | 5 +
2 files changed, 313 insertions(+), 4 deletions(-)
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5597d3105..06b6d394e8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -44,6 +44,7 @@
#include <langinfo.h>
#endif
+#include "access/transam.h"
#include "catalog/pg_class_d.h"
#include "common/file_perm.h"
#include "common/logging.h"
@@ -566,6 +567,298 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
check_ok();
}
+/******************************************************************************/
+#define SLRU_PAGES_PER_SEGMENT 32 /* Should be equal to value from slru.h */
+
+#define CLOG_BITS_PER_XACT 2
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+/*
+ * Rename the files from the old cluster into it
+ */
+typedef struct SLRUSegmentState
+{
+ const char *dir;
+ FILE *file;
+ int64 segno;
+ int64 pageno;
+ bool is_empty_segment;
+} SLRUSegmentState;
+
+/*
+ * Old cluster SlruFileName (i.e. 32-bit)
+ */
+static char *
+slru_filename_old(const char *path, int64 segno)
+{
+ Assert(segno <= PG_INT32_MAX);
+ return psprintf("%s/%04X", path, (int) segno);
+}
+
+/*
+ * New cluster SlruFileName (i.e. 64-bit)
+ */
+static char *
+slru_filename_new(const char *path, int64 segno)
+{
+ return psprintf("%s/%012llX", path, (long long) segno);
+}
+
+/*
+ * Generalized fopen for SLRU segment file
+ */
+static inline FILE *
+open_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno),
+ char *mode, char *fatal_msg)
+{
+ char *filename = filename_fn(state->dir, state->segno);
+ FILE *fd = fopen(filename, mode);
+
+ if (!fd)
+ pg_fatal(fatal_msg, filename);
+
+ pfree(filename);
+
+ return fd;
+}
+
+/*
+ * Generalized fclose for SLRU segment file
+ */
+static void
+close_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno))
+{
+ if (state->file != NULL)
+ {
+ if (fclose(state->file) != 0)
+ pg_fatal("could not close file \"%s\": %m",
+ filename_fn(state->dir, state->segno));
+ state->file = NULL;
+ }
+}
+
+/*
+ * Generalized fread of BLCKSZ fro, SLRU segment file
+ */
+static inline int
+read_file(SLRUSegmentState *state, void *buf)
+{
+ size_t n = fread(buf, sizeof(char), BLCKSZ, state->file);
+
+ if (n != 0)
+ return n;
+
+ if (ferror(state->file))
+ pg_fatal("could not read file \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ if (!feof(state->file))
+ pg_fatal("unknown file read state \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ close_file(state, slru_filename_old);
+
+ return 0;
+}
+
+static int
+read_old_segment_page(SLRUSegmentState *state, void *buf, bool *is_empty)
+{
+ int n;
+
+ /* Open next segment file, if needed */
+ if (!state->file)
+ {
+ state->file = open_file(state, slru_filename_old, "rb",
+ "could not open source file \"%s\": %m");
+
+ /* Set position to the needed page */
+ if (fseek(state->file, state->pageno * BLCKSZ, SEEK_SET))
+ close_file(state, slru_filename_old);
+
+ /*
+ * Skip segment conversion if segment file doesn't exist.
+ * First segment file should exist in any case.
+ */
+ if (state->segno != 0)
+ state->is_empty_segment = true;
+ }
+
+ if (state->file)
+ {
+ /* Segment file does exist, read page from it */
+ state->is_empty_segment = false;
+
+ /* Try to read BLCKSZ bytes */
+ n = read_file(state, buf);
+ *is_empty = (n == 0);
+
+ /* Zeroing buf tail if needed */
+ if (n)
+ memset((char *) buf + n, 0, BLCKSZ - n);
+ }
+ else
+ {
+ n = state->is_empty_segment ?
+ BLCKSZ : /* Skip empty block at the end of segment */
+ 0; /* We reached the last segment */
+ *is_empty = true;
+
+ if (n)
+ memset((char *) buf, 0, BLCKSZ);
+ }
+
+ state->pageno++;
+
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ /* Start new segment */
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_old);
+ }
+
+ return n;
+}
+
+static void
+write_new_segment_page(SLRUSegmentState *state, void *buf, bool is_empty)
+{
+ /*
+ * Create a new segment file if we still didn't. Creation is postponed
+ * until the first non-empty page is found. This helps not to create
+ * completely empty segments.
+ */
+ if (!state->file && !is_empty)
+ {
+ state->file = open_file(state, slru_filename_new, "wb",
+ "could not open target file \"%s\": %m");
+
+ /* Write zeroes to the previously skipped prefix */
+ if (state->pageno > 0)
+ {
+ char zerobuf[BLCKSZ] = {0};
+
+ for (int64 i = 0; i < state->pageno; i++)
+ {
+ if (fwrite(zerobuf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+ }
+
+ }
+
+ /* Write page to the new segment (if it was created) */
+ if (state->file)
+ {
+ if (fwrite(buf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+
+ state->pageno++;
+
+ /*
+ * Did we reach the maximum page number? Then close segment file and
+ * create a new one on the next iteration
+ */
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_new);
+ }
+}
+
+/*
+ * Convert pg_xact from 32bit to 64bit format.
+ *
+ * We read SLRU pages of pg_xact segments from old cluster one by one and write
+ * them in a new segments files.
+ */
+static void
+convert_pg_xact_segments(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg = {0};
+ SLRUSegmentState newseg = {0};
+ char buf[BLCKSZ] = {0};
+ FullTransactionId oldestxid;
+ FullTransactionId nxtxid;
+ uint32 epoch;
+ int64 pageno;
+ uint64 xid;
+
+ oldseg.dir = old_subdir;
+ newseg.dir = new_subdir;
+
+ /* wraparound without epoch is not possible */
+ if (old_cluster.controldata.chkpnt_nxtepoch == 0 &&
+ old_cluster.controldata.chkpnt_oldstxid > old_cluster.controldata.chkpnt_nxtxid)
+ {
+ pg_fatal("inconsistent pg_xact of directory \"%s\"",
+ old_cluster.pgdata);
+ }
+
+ /* get full transactions bounds from old cluster */
+ epoch = old_cluster.controldata.chkpnt_nxtepoch;
+ nxtxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_nxtxid);
+ if (old_cluster.controldata.chkpnt_oldstxid > XidFromFullTransactionId(nxtxid))
+ --epoch;
+
+ oldestxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_oldstxid);
+
+ /* get init segments and pages */
+ pageno = oldestxid.value / CLOG_XACTS_PER_PAGE;
+
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ /* Copy xid flags reading only needed segment pages */
+ for (xid = oldestxid.value & ~(CLOG_XACTS_PER_PAGE - 1);
+ xid <= ((nxtxid.value - 1) & ~(CLOG_XACTS_PER_PAGE - 1));
+ xid += CLOG_XACTS_PER_PAGE)
+ {
+ bool is_empty;
+ int len;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxTransactionId / CLOG_XACTS_PER_PAGE / SLRU_PAGES_PER_SEGMENT)
+ {
+ Assert(!oldseg.pageno);
+ Assert(!oldseg.file);
+ Assert(!newseg.pageno);
+ Assert(!newseg.file);
+
+ oldseg.segno = 0;
+ }
+
+ len = read_old_segment_page(&oldseg, buf, &is_empty);
+
+ /*
+ * Ignore read errors, copy all existing segment pages in the
+ * interesting xid range.
+ */
+ is_empty |= len <= 0;
+
+ Assert(len >= 0);
+ Assert(is_empty == false);
+
+ write_new_segment_page(&newseg, buf, is_empty);
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+}
+
static void
copy_xact_xlog_xid(void)
{
@@ -573,10 +866,21 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+
+ if (old_cluster.controldata.cat_ver < SLRU_FORMAT_CHANGE_CAT_VER)
+ {
+ char *old_path = psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster));
+ char *new_path = psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster));
+
+ convert_pg_xact_segments(old_path, new_path);
+ pfree(old_path);
+ pfree(new_path);
+ }
+ else
+ copy_subdir_files(GetClogDirName(old_cluster),
+ GetClogDirName(new_cluster));
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 5f2a116f23..9a26d0f859 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -126,6 +126,11 @@ extern char *output_files[];
*/
#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
+/*
+ * change in SLRU numbering to 64–bit
+ */
+#define SLRU_FORMAT_CHANGE_CAT_VER 202212092
+
/*
* Each relation is represented by a relinfo structure.
--
2.39.0
Hi,
OK, here is the patchset v53 where I mostly modified the commit
messages. It is explicitly said that 0001 modifies the WAL records and
why we decided to do it in this patch. Additionally any mention of
64-bit XIDs is removed since it is not guaranteed that the rest of the
patches are going to be accepted. 64-bit SLRU page numbering is a
valuable change per se.Changing the status of the CF entry to RfC apparently was a bit
premature. It looks like the patchset can use a few more rounds of
review.In 0002:
[...]
Maxim, perhaps you could share with us what your reasoning was here?
I played with the patch a bit and managed to figure out what you tried
to accomplish. Unfortunately generally you can't derive a
FullTransactionId from a TransactionId, and you can't access
ShmemVariableCache fields without taking a lock unless during the
startup when there are no concurrent processes.
I don't think this patch should do anything but change the SLRU
indexing from 32-bit to 64-bit one. Trying to address the wraparounds
would be nice but I'm afraid we are not quite there yet.
Also I found strage little changes that seemed to be unrelated to the
patch. I believe they ended up here by accident (used to be a part of
64-bit XIDs patchset) and removed them.
PFA the cleaned up version of the patch. I noticed that splitting it
into parts doesn't help much with the review or testing, nor seems it
likely that the patches are going to be merged separately one by one.
For these reasons I merged everything into a single patch.
The convert_pg_xact_segments() function is still obviously
overengineered. As I understand, all it has to do is simply renaming
pg_xact/XXXX to pg_xact/00000000XXXX. Unfortunately I used up all the
mana for today and have to take a long rest in order to continue.
--
Best regards,
Aleksander Alekseev
Attachments:
v54-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v54-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 0f3443d6544b2b871486429f961e9e6e740a8f20 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v54] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system. This being said
this particular patch only changes the indexing and doesn't address the
wraparound per se.
The patch also changes the SLRU segment naming. E.g instead of pg_xact/1234
now we have pg_xact/000000001234. The upgrade procedure is straightforward.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 61 ++--
src/backend/access/transam/commit_ts.c | 48 +--
src/backend/access/transam/multixact.c | 56 +--
src/backend/access/transam/slru.c | 94 ++---
src/backend/access/transam/subtrans.c | 30 +-
src/backend/commands/async.c | 18 +-
src/backend/storage/lmgr/predicate.c | 10 +-
src/bin/pg_upgrade/pg_upgrade.c | 320 +++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.h | 5 +
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 24 +-
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 25 +-
21 files changed, 546 insertions(+), 197 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..4a4f71453e 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..d7a7e88348 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -569,7 +577,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +670,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +803,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +841,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +926,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +945,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +956,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +981,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fe6698d5ff..a0e28cf443 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1928,7 +1928,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1944,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1974,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2009,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2034,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2403,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2452,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2735,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3191,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3239,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3254,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3299,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..ba63602cdc 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,11 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +78,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +141,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +166,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +230,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +282,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +397,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +497,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +544,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +628,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +686,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +758,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +933,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1018,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1029,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1073,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1163,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1228,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1306,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1329,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1393,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1409,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1502,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1518,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1534,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1562,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1572,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..8937a31d46 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -233,7 +241,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +257,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +315,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +345,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +367,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..3c8b3f7b16 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index bfc352aed8..cf01c81159 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -842,9 +842,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5597d3105..1a4bd74ae5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -44,6 +44,7 @@
#include <langinfo.h>
#endif
+#include "access/transam.h"
#include "catalog/pg_class_d.h"
#include "common/file_perm.h"
#include "common/logging.h"
@@ -566,6 +567,306 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
check_ok();
}
+// AALEKSEEV TODO FIXME: refactor vvv
+/******************************************************************************/
+#define SLRU_PAGES_PER_SEGMENT 32 /* Should be equal to value from slru.h */
+
+#define CLOG_BITS_PER_XACT 2
+#define CLOG_XACTS_PER_BYTE 4
+#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
+/*
+ * Rename the files from the old cluster into it
+ */
+typedef struct SLRUSegmentState
+{
+ const char *dir;
+ FILE *file;
+ int64 segno;
+ int64 pageno;
+ bool is_empty_segment;
+} SLRUSegmentState;
+
+/*
+ * Old cluster SlruFileName (i.e. 32-bit)
+ */
+static char *
+slru_filename_old(const char *path, int64 segno)
+{
+ Assert(segno <= PG_INT32_MAX);
+ return psprintf("%s/%04X", path, (int) segno);
+}
+
+/*
+ * New cluster SlruFileName (i.e. 64-bit)
+ */
+static char *
+slru_filename_new(const char *path, int64 segno)
+{
+ return psprintf("%s/%012llX", path, (long long) segno);
+}
+
+/*
+ * Generalized fopen for SLRU segment file
+ */
+static inline FILE *
+open_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno),
+ char *mode, char *fatal_msg)
+{
+ char *filename = filename_fn(state->dir, state->segno);
+ FILE *fd = fopen(filename, mode);
+
+ if (!fd)
+ pg_fatal(fatal_msg, filename);
+
+ pfree(filename);
+
+ return fd;
+}
+
+/*
+ * Generalized fclose for SLRU segment file
+ */
+static void
+close_file(SLRUSegmentState *state,
+ char * (filename_fn)(const char *path, int64 segno))
+{
+ if (state->file != NULL)
+ {
+ if (fclose(state->file) != 0)
+ pg_fatal("could not close file \"%s\": %m",
+ filename_fn(state->dir, state->segno));
+ state->file = NULL;
+ }
+}
+
+/*
+ * Generalized fread of BLCKSZ fro, SLRU segment file
+ */
+static inline int
+read_file(SLRUSegmentState *state, void *buf)
+{
+ size_t n = fread(buf, sizeof(char), BLCKSZ, state->file);
+
+ if (n != 0)
+ return n;
+
+ if (ferror(state->file))
+ pg_fatal("could not read file \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ if (!feof(state->file))
+ pg_fatal("unknown file read state \"%s\": %m",
+ slru_filename_old(state->dir, state->segno));
+
+ close_file(state, slru_filename_old);
+
+ return 0;
+}
+
+static int
+read_old_segment_page(SLRUSegmentState *state, void *buf, bool *is_empty)
+{
+ int n;
+
+ /* Open next segment file, if needed */
+ if (!state->file)
+ {
+ state->file = open_file(state, slru_filename_old, "rb",
+ "could not open source file \"%s\": %m");
+
+ /* Set position to the needed page */
+ if (fseek(state->file, state->pageno * BLCKSZ, SEEK_SET))
+ close_file(state, slru_filename_old);
+
+ /*
+ * Skip segment conversion if segment file doesn't exist.
+ * First segment file should exist in any case.
+ */
+ if (state->segno != 0)
+ state->is_empty_segment = true;
+ }
+
+ if (state->file)
+ {
+ /* Segment file does exist, read page from it */
+ state->is_empty_segment = false;
+
+ /* Try to read BLCKSZ bytes */
+ n = read_file(state, buf);
+ *is_empty = (n == 0);
+
+ /* Zeroing buf tail if needed */
+ if (n)
+ memset((char *) buf + n, 0, BLCKSZ - n);
+ }
+ else
+ {
+ n = state->is_empty_segment ?
+ BLCKSZ : /* Skip empty block at the end of segment */
+ 0; /* We reached the last segment */
+ *is_empty = true;
+
+ if (n)
+ memset((char *) buf, 0, BLCKSZ);
+ }
+
+ state->pageno++;
+
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ /* Start new segment */
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_old);
+ }
+
+ return n;
+}
+
+static void
+write_new_segment_page(SLRUSegmentState *state, void *buf, bool is_empty)
+{
+ /*
+ * Create a new segment file if we still didn't. Creation is postponed
+ * until the first non-empty page is found. This helps not to create
+ * completely empty segments.
+ */
+ if (!state->file && !is_empty)
+ {
+ state->file = open_file(state, slru_filename_new, "wb",
+ "could not open target file \"%s\": %m");
+
+ /* Write zeroes to the previously skipped prefix */
+ if (state->pageno > 0)
+ {
+ char zerobuf[BLCKSZ] = {0};
+
+ for (int64 i = 0; i < state->pageno; i++)
+ {
+ if (fwrite(zerobuf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+ }
+
+ }
+
+ /* Write page to the new segment (if it was created) */
+ if (state->file)
+ {
+ if (fwrite(buf, sizeof(char), BLCKSZ, state->file) != BLCKSZ)
+ pg_fatal("could not write file \"%s\": %m",
+ slru_filename_new(state->dir, state->segno));
+ }
+
+ state->pageno++;
+
+ /*
+ * Did we reach the maximum page number? Then close segment file and
+ * create a new one on the next iteration
+ */
+ if (state->pageno >= SLRU_PAGES_PER_SEGMENT)
+ {
+ state->segno++;
+ state->pageno = 0;
+ close_file(state, slru_filename_new);
+ }
+}
+
+/*
+ * Convert pg_xact from 32bit to 64bit format.
+ *
+ * We read SLRU pages of pg_xact segments from old cluster one by one and write
+ * them in a new segments files.
+ *
+ * AALEKSEEV TODO FIXME rewrite this
+ */
+static void
+convert_pg_xact_segments(const char *old_subdir, const char *new_subdir)
+{
+ SLRUSegmentState oldseg = {0};
+ SLRUSegmentState newseg = {0};
+ char buf[BLCKSZ] = {0};
+ FullTransactionId oldestxid;
+ FullTransactionId nxtxid;
+ uint32 epoch;
+ int64 pageno;
+ uint64 xid;
+
+ oldseg.dir = old_subdir;
+ newseg.dir = new_subdir;
+
+ prep_status("AALEKSEEV DEBUG convert_pg_xact_segments(), old_subdir = %s, new_subdir = %s",
+ old_subdir, new_subdir);
+
+ /* wraparound without epoch is not possible */
+ if (old_cluster.controldata.chkpnt_nxtepoch == 0 &&
+ old_cluster.controldata.chkpnt_oldstxid > old_cluster.controldata.chkpnt_nxtxid)
+ {
+ pg_fatal("inconsistent pg_xact of directory \"%s\"",
+ old_cluster.pgdata);
+ }
+
+ /* get full transactions bounds from old cluster */
+ epoch = old_cluster.controldata.chkpnt_nxtepoch;
+ nxtxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_nxtxid);
+ if (old_cluster.controldata.chkpnt_oldstxid > XidFromFullTransactionId(nxtxid))
+ --epoch;
+
+ oldestxid = FullTransactionIdFromEpochAndXid(epoch,
+ old_cluster.controldata.chkpnt_oldstxid);
+
+ /* get init segments and pages */
+ pageno = oldestxid.value / CLOG_XACTS_PER_PAGE;
+
+ oldseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ oldseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ newseg.segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ newseg.pageno = pageno % SLRU_PAGES_PER_SEGMENT;
+
+ /* Copy xid flags reading only needed segment pages */
+ for (xid = oldestxid.value & ~(CLOG_XACTS_PER_PAGE - 1);
+ xid <= ((nxtxid.value - 1) & ~(CLOG_XACTS_PER_PAGE - 1));
+ xid += CLOG_XACTS_PER_PAGE)
+ {
+ bool is_empty;
+ int len;
+
+ /* Handle possible segment wraparound */
+ if (oldseg.segno > MaxTransactionId / CLOG_XACTS_PER_PAGE / SLRU_PAGES_PER_SEGMENT)
+ {
+ Assert(!oldseg.pageno);
+ Assert(!oldseg.file);
+ Assert(!newseg.pageno);
+ Assert(!newseg.file);
+
+ oldseg.segno = 0;
+ }
+
+ len = read_old_segment_page(&oldseg, buf, &is_empty);
+
+ /*
+ * Ignore read errors, copy all existing segment pages in the
+ * interesting xid range.
+ */
+ is_empty |= len <= 0;
+
+ Assert(len >= 0);
+ Assert(is_empty == false);
+
+ write_new_segment_page(&newseg, buf, is_empty);
+ }
+
+ /* Release resources */
+ close_file(&oldseg, slru_filename_old);
+ close_file(&newseg, slru_filename_new);
+}
+
+// ^^^ AALEKSEEV TODO FIXME - until here
+
static void
copy_xact_xlog_xid(void)
{
@@ -573,10 +874,21 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+
+ if (old_cluster.controldata.cat_ver < SLRU_FORMAT_CHANGE_CAT_VER)
+ {
+ char *old_path = psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster));
+ char *new_path = psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster));
+
+ convert_pg_xact_segments(old_path, new_path);
+ pfree(old_path);
+ pfree(new_path);
+ }
+ else
+ copy_subdir_files(GetClogDirName(old_cluster),
+ GetClogDirName(new_cluster));
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 5f2a116f23..ca9c7978f8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -126,6 +126,11 @@ extern char *output_files[];
*/
#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
+/*
+ * change in SLRU indexing to 64–bit integers
+ */
+#define SLRU_FORMAT_CHANGE_CAT_VER 202212092
+
/*
* Each relation is represented by a relinfo structure.
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 0c304105c5..69119d30b7 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..859ec6e589 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4258cd92c9..a2cc0dc96f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..8019ff916d 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 622f43da04..577428668a 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.39.1
Hi,
The convert_pg_xact_segments() function is still obviously
overengineered. As I understand, all it has to do is simply renaming
pg_xact/XXXX to pg_xact/00000000XXXX. Unfortunately I used up all the
mana for today and have to take a long rest in order to continue.
PFA the corrected patch v55.
One thing that still bothers me is that during the upgrade we only
migrate the CLOG segments (i.e. pg_xact / pg_clog) and completely
ignore all the rest of SLRUs:
* pg_commit_ts
* pg_multixact/offsets
* pg_multixact/members
* pg_subtrans
* pg_notify
* pg_serial
My knowledge in this area is somewhat limited and I can't tell whether
this is OK. I will investigate but also I could use some feedback from
the reviewers.
--
Best regards,
Aleksander Alekseev
Attachments:
v55-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v55-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 86be6924f21a72212276f78213bfe83f8e5e6ab6 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v55] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system. This being said
this particular patch only changes the indexing and doesn't address the
wraparound per se.
The patch also changes the SLRU segment naming. E.g instead of pg_xact/1234
now we have pg_xact/000000001234. The upgrade procedure is straightforward.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 61 +++++++-----
src/backend/access/transam/commit_ts.c | 48 ++++++----
src/backend/access/transam/multixact.c | 56 +++++------
src/backend/access/transam/slru.c | 94 +++++++++---------
src/backend/access/transam/subtrans.c | 30 +++---
src/backend/commands/async.c | 18 ++--
src/backend/storage/lmgr/predicate.c | 10 +-
src/bin/pg_upgrade/pg_upgrade.c | 95 ++++++++++++++++++-
src/bin/pg_upgrade/pg_upgrade.h | 5 +
src/bin/pg_verifybackup/t/003_corruption.pl | 2 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 24 ++---
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +--
src/test/modules/test_slru/test_slru.c | 25 ++---
21 files changed, 321 insertions(+), 197 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..4a4f71453e 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..d7a7e88348 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -569,7 +577,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +670,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +803,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +841,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +926,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +945,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +956,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +981,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fe6698d5ff..a0e28cf443 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1928,7 +1928,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1944,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1974,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2009,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2034,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2403,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2452,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2735,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2854,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2862,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3113,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3133,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3191,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3239,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3254,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3299,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..ba63602cdc 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,11 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, (long long) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +78,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +141,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +166,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -226,8 +230,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -278,7 +282,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +397,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +497,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +544,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +628,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +686,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +758,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +933,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1018,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1029,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1073,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1163,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1228,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1306,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1329,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1393,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1409,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1502,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1518,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,7 +1534,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1556,8 +1562,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1572,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if ((len == 12 || len == 13 || len == 14) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..8937a31d46 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -233,7 +241,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +257,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +315,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +345,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +367,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..3c8b3f7b16 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index bfc352aed8..cf01c81159 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -842,9 +842,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index e5597d3105..22d10bed01 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -38,6 +38,7 @@
#include "postgres_fe.h"
+#include <dirent.h>
#include <time.h>
#ifdef HAVE_LANGINFO_H
@@ -566,6 +567,84 @@ copy_subdir_files(const char *old_subdir, const char *new_subdir)
check_ok();
}
+static inline bool
+IsSLRUSegmentWith32BitAddressing(const char *fname)
+{
+ return (strlen(fname) == 4 && \
+ strspn(fname, "0123456789ABCDEF") == 4);
+}
+
+/*
+ * Scan the given old SLRU directory (e.g. pg_xact) and copy/link every
+ * old_dir/XXXX segment to new_dir/00000000XXXX.
+ *
+ * The naming was changed when we moved from 32-bit integer indexing of SLRU
+ * segments to 64-bit integer indexing.
+ */
+static void
+convert_slru_segments(const char *old_dir, const char *new_dir)
+{
+ DIR *dir;
+ struct dirent *de;
+ char old_file[MAXPGPATH];
+ char new_file[MAXPGPATH];
+
+ /*
+ * These namespace and relation names are needed for the error messages.
+ * Since here we are not dealing with any particular namespace or
+ * relation, in an unlikely event of an error display "(none)".
+ */
+ const char *nspname = "(none)";
+ const char *relname = "(none)";
+
+ dir = opendir(old_dir);
+ if (dir == NULL)
+ pg_fatal("could not open directory \"%s\": %m", old_dir);
+
+ while (errno = 0, (de = readdir(dir)) != NULL)
+ {
+ /* Most importantly this check skips . and .. */
+ if (!IsSLRUSegmentWith32BitAddressing(de->d_name))
+ continue;
+
+ snprintf(old_file, sizeof(old_file), "%s/%s", old_dir, de->d_name);
+ snprintf(new_file, sizeof(new_file), "%s/00000000%s", new_dir, de->d_name);
+
+ /*
+ * Copy/link will fail if new_file already exists unless we explicitly
+ * unlink it. It there is no new_file unlink does nothing.
+ */
+ unlink(new_file);
+
+ switch (user_opts.transfer_mode)
+ {
+ case TRANSFER_MODE_CLONE:
+ pg_log(PG_VERBOSE, "cloning \"%s\" to \"%s\"",
+ old_file, new_file);
+ cloneFile(old_file, new_file, nspname, relname);
+ break;
+ case TRANSFER_MODE_COPY:
+ pg_log(PG_VERBOSE, "copying \"%s\" to \"%s\"",
+ old_file, new_file);
+ copyFile(old_file, new_file, nspname, relname);
+ break;
+ case TRANSFER_MODE_LINK:
+ pg_log(PG_VERBOSE, "linking \"%s\" to \"%s\"",
+ old_file, new_file);
+ linkFile(old_file, new_file, nspname, relname);
+ }
+ }
+
+ if (errno)
+ pg_fatal("could not read directory \"%s\": %m", old_dir);
+
+ if (closedir(dir))
+ pg_fatal("could not close directory \"%s\": %m", old_dir);
+}
+
+#define GetClogDirName(cluster) \
+ GET_MAJOR_VERSION(cluster.major_version) <= 906 ? "pg_clog" : "pg_xact"
+
static void
copy_xact_xlog_xid(void)
{
@@ -573,10 +652,18 @@ copy_xact_xlog_xid(void)
* Copy old commit logs to new data dir. pg_clog has been renamed to
* pg_xact in post-10 clusters.
*/
- copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact",
- GET_MAJOR_VERSION(new_cluster.major_version) <= 906 ?
- "pg_clog" : "pg_xact");
+ if (old_cluster.controldata.cat_ver < SLRU_FORMAT_CHANGE_CAT_VER)
+ {
+ char *old_path = psprintf("%s/%s", old_cluster.pgdata, GetClogDirName(old_cluster));
+ char *new_path = psprintf("%s/%s", new_cluster.pgdata, GetClogDirName(new_cluster));
+
+ convert_slru_segments(old_path, new_path);
+ pfree(old_path);
+ pfree(new_path);
+ }
+ else
+ copy_subdir_files(GetClogDirName(old_cluster),
+ GetClogDirName(new_cluster));
prep_status("Setting oldest XID for new cluster");
exec_prog(UTILITY_LOG_FILE, NULL, true, true,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 5f2a116f23..ca9c7978f8 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -126,6 +126,11 @@ extern char *output_files[];
*/
#define JSONB_FORMAT_CHANGE_CAT_VER 201409291
+/*
+ * change in SLRU indexing to 64–bit integers
+ */
+#define SLRU_FORMAT_CHANGE_CAT_VER 202212092
+
/*
* Each relation is represented by a relinfo structure.
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 0c304105c5..69119d30b7 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -174,7 +174,7 @@ sub mutilate_extra_tablespace_file
sub mutilate_missing_file
{
my ($backup_path) = @_;
- my $pathname = "$backup_path/pg_xact/0000";
+ my $pathname = "$backup_path/pg_xact/000000000000";
unlink($pathname) || die "$pathname: $!";
return;
}
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..859ec6e589 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,7 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -143,10 +143,10 @@ extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +155,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4258cd92c9..a2cc0dc96f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..8019ff916d 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 622f43da04..577428668a 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
--
2.39.1
On Tue, 21 Feb 2023 at 16:59, Aleksander Alekseev <aleksander@timescale.com>
wrote:
Hi,
One thing that still bothers me is that during the upgrade we only
migrate the CLOG segments (i.e. pg_xact / pg_clog) and completely
ignore all the rest of SLRUs:* pg_commit_ts
* pg_multixact/offsets
* pg_multixact/members
* pg_subtrans
* pg_notify
* pg_serial
Hi! We do ignore these values, since in order to pg_upgrade the server it
must be properly stopped and no transactions can outlast this moment.
--
Best regards,
Maxim Orlov.
(CC list trimmed, gmail wouldn't let me send otherwise)
On 22/02/2023 16:29, Maxim Orlov wrote:
On Tue, 21 Feb 2023 at 16:59, Aleksander Alekseev
<aleksander@timescale.com <mailto:aleksander@timescale.com>> wrote:
One thing that still bothers me is that during the upgrade we only
migrate the CLOG segments (i.e. pg_xact / pg_clog) and completely
ignore all the rest of SLRUs:* pg_commit_ts
* pg_multixact/offsets
* pg_multixact/members
* pg_subtrans
* pg_notify
* pg_serialHi! We do ignore these values, since in order to pg_upgrade the server
it must be properly stopped and no transactions can outlast this moment.
That sounds right for pg_serial, pg_notify, and pg_subtrans. But not for
pg_commit_ts and the pg_multixacts.
This needs tests for pg_upgrading those SLRUs, after 0, 1 and N wraparounds.
I'm surprised that these patches extend the page numbering to 64 bits,
but never actually uses the high bits. The XID "epoch" is not used, and
pg_xact still wraps around and the segment names are still reused. I
thought we could stop doing that. Certainly if we start supporting
64-bit XIDs properly, that will need to change and we will pg_upgrade
will need to rename the segments again.
The previous versions of these patches did that, but I think you changed
tact in response to Robert's suggestion at [1]/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com:
Lest we miss the forest for the trees, there is an aspect of this
patch that I find to be an extremely good idea and think we should try
to get committed even if the rest of the patch set ends up in the
rubbish bin. Specifically, there are a couple of patches in here that
have to do with making SLRUs indexed by 64-bit integers rather than by
32-bit integers. We've had repeated bugs in the area of handling SLRU
wraparound in the past, some of which have caused data loss. Just by
chance, I ran across a situation just yesterday where an SLRU wrapped
around on disk for reasons that I don't really understand yet and
chaos ensued. Switching to an indexing system for SLRUs that does not
ever wrap around would probably enable us to get rid of a whole bunch
of crufty code, and would also likely improve the general reliability
of the system in situations where wraparound is threatened. It seems
like a really, really good idea.
These new versions of this patch don't achieve the goal of avoiding
wraparound. I think the previous versions that did that was the right
approach.
[1]: /messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
/messages/by-id/CA+TgmoZFmTGjgkmjgkcm2-vQq3_TzcoMKmVimvQLx9oJLbye0Q@mail.gmail.com
- Heikki
On Mon, 27 Feb 2023 at 12:10, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
(CC list trimmed, gmail wouldn't let me send otherwise)
That sounds right for pg_serial, pg_notify, and pg_subtrans. But not for
pg_commit_ts and the pg_multixacts.This needs tests for pg_upgrading those SLRUs, after 0, 1 and N
wraparounds.Yep, that's my fault. I've forgotten about pg_multixacts. But for the
pg_commit_ts it's a bit complicated story.
The thing is, if we do upgrade, old files from pg_commit_ts not copied into
a new server.
For example, I've checked one more time on the current master branch:
1). initdb
2). add "track_commit_timestamp = on" into postgresql.conf
3). pgbench
4). $ ls pg_commit_ts/
0000 0005 000A 000F 0014 0019 001E 0023...
...009A 009F 00A4 00A9 00AE 00B3 00B8 00BD 00C2
5). do pg_upgrade
6). $ ls pg_commit_ts/
0000 00C2
Either I do not understand something, or the files from pg_commit_ts
directory are not copied.
--
Best regards,
Maxim Orlov.
On 28/02/2023 16:17, Maxim Orlov wrote:
Either I do not understand something, or the files from pg_commit_ts
directory are not copied.
Huh, yeah you're right, pg_upgrade doesn't copy pg_commit_ts.
- Heikki
Hi,
I'm surprised that these patches extend the page numbering to 64 bits,
but never actually uses the high bits. The XID "epoch" is not used, and
pg_xact still wraps around and the segment names are still reused. I
thought we could stop doing that.
To clarify, the idea is to let CLOG grow indefinitely and simply store
FullTransactionId -> TransactionStatus (two bits). Correct?
I didn't investigate this in much detail but it may affect quite some
amount of code since TransactionIdDidCommit() and
TransactionIdDidCommit() currently both deal with TransactionId, not
FullTransactionId. IMO, this would be a nice change however, assuming
we are ready for it.
In the previous version of the patch there was an attempt to derive
FullTransactionId from TransactionId but it was wrong for the reasons
named above in the thread. Thus is was removed and the patch
simplified.
--
Best regards,
Aleksander Alekseev
On 01/03/2023 12:21, Aleksander Alekseev wrote:
Hi,
I'm surprised that these patches extend the page numbering to 64 bits,
but never actually uses the high bits. The XID "epoch" is not used, and
pg_xact still wraps around and the segment names are still reused. I
thought we could stop doing that.To clarify, the idea is to let CLOG grow indefinitely and simply store
FullTransactionId -> TransactionStatus (two bits). Correct?
Correct.
I didn't investigate this in much detail but it may affect quite some
amount of code since TransactionIdDidCommit() and
TransactionIdDidCommit() currently both deal with TransactionId, not
FullTransactionId. IMO, this would be a nice change however, assuming
we are ready for it.
Yep, it's a lot of code churn..
In the previous version of the patch there was an attempt to derive
FullTransactionId from TransactionId but it was wrong for the reasons
named above in the thread. Thus is was removed and the patch
simplified.
Yeah, it's tricky to get it right. Clearly we need to do it at some
point though.
All in all, this is a big effort. I spent some more time reviewing this
in the last few days, and thought a lot about what the path forward here
could be. And I haven't looked at the actual 64-bit XIDs patch set yet,
just this patch to use 64-bit addressing in SLRUs.
This patch is the first step, but we have a bit of a chicken and egg
problem, because this patch on its own isn't very interesting, but on
the other hand, we need it to work on the follow up items. Here's how I
see the development path for this (and again, this is just for the
64-bit SLRUs work, not the bigger 64-bit-XIDs-in-heapam effort):
1. Use 64 bit page numbers in SLRUs (this patch)
I would like to make one change here: I'd prefer to keep the old 4-digit
segment names, until we actually start to use the wider address space.
Let's allow each SLRU to specify how many digits to use in the
filenames, so that we convert one SLRU at a time.
If we do that, and don't change any of the existing SLRUs to actually
use the wider space of page and segment numbers yet, this patch becomes
just refactoring with no on-disk format changes. No pg_upgrade needed.
The next patches will start to make use of the wider address space, one
SLRU at a time.
2. Use the larger segment file names in async.c, to lift the current 8
GB limit on the max number of pending notifications.
No one actually minds the limit, it's quite generous as it is. But there
is some code and complexity in async.c to avoid the wraparound that
could be made simpler if we used longer SLRU segment names and avoided
the wraparound altogether.
I wonder if we should actually add an artificial limit, as a GUC. If
there are gigabytes of notifications queued up, something's probably
wrong with the system, and you're not going to be happy if we just
remove the limit so it can grow to terabytes until you run out of disk
space.
3. Extend pg_multixact so that pg_multixact/members is addressed by
64-bit offsets.
Currently, multi-XIDs can wrap around, requiring anti-wraparound
freezing, but independently of that, the pg_multixact/members SLRU can
also wrap around. We track both, and trigger anti-wraparound if either
SLRU is about to wrap around. If we redefine MultiXactOffset as a 64-bit
integer, we can avoid the pg_multixact/members wraparound altogether. A
downside is that pg_multixact/offsets will take twice as much space, but
I think that's a good tradeoff. Or perhaps we can play tricks like store
a single 64-bit offset on each pg_multixact/offsets page, and a 32-bit
offset from that for each XID, to avoid making it so much larger.
This would reduce the need to do anti-wraparound VACUUMs on systems that
use multixacts heavily. Needs pg_upgrade support.
4. Extend pg_subtrans to 64-bits.
This isn't all that interesting because the active region of pg_subtrans
cannot be wider than 32 bits anyway, because you'll still reach the
general 32-bit XID wraparound. But it might be less confusing in some
places.
I actually started to write a patch to do this, to see how complicated
it is. It quickly proliferates into expanding other XIDs to 64-bits,
like TransactionXmin, frozenXid calculation in vacuum.c, known-assigned
XID tracking in procarray.c. etc. It's going to be necessary to convert
32-bit XIDs to FullTransactionIds at some boundaries, and I'm not sure
where exactly that should happen. It's easier to do the conversions
close to subtrans.c, but then I'm not sure how much it gets us in terms
of reducing confusion. It's easy to get confused with the epochs during
conversions, as you noted. On the other hand, if we change much more of
the backend to use FullTransactionIds, the patch becomes much more invasive.
Nice thing with pg_subtrans, though, is that it doesn't require
pg_upgrade support.
5. Extend pg_xact to 64-bits.
Similar to pg_subtrans, really, but needs pg_upgrade support.
6. (a bonus thing that I noticed while thinking of pg_xact.) Extend
pg_twophase.c, to use FullTransactionIds.
Currently, the twophase state files in pg_twophase are named according
to the 32 bit Xid of the transaction. Let's switch to FullTransactionId
there.
As we start to refactor these things, I also think it would be good to
have more explicit tracking of the valid range of SLRU pages in each
SLRU. Take pg_subtrans for example: it's not very clear what pages have
been initialized, especially during different stages of startup. It
would be good to have clear start and end page numbers, and throw an
error if you try to look up anything outside those bounds. Same for all
other SLRUs.
I propose that we try to finish 1 and 2 for v16. And maybe 6. I think
that's doable. It doesn't have any great user-visible benefits yet, but
we need to start somewhere.
- Heikki
On Tue, 17 Jan 2023 at 16:33, Aleksander Alekseev <aleksander@timescale.com>
wrote:
Hi hackers,
Maxim, perhaps you could share with us what your reasoning was here?
I'm really sorry for late response, but better late than never. Yes, we
can not access shared memory without lock.
In this particular case, we use XidGenLock. That is why we use lock
argument to take it is it was not taken previously.
Actually, we may place assertion in this insist.
As for xid compare: we do not compare xids here, we are checking for
wraparound, so, AFAICS, this code is correct.
On Mon, 6 Mar 2023 at 22:48, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
1. Use 64 bit page numbers in SLRUs (this patch)
2. Use the larger segment file names in async.c, to lift the current 8
GB limit on the max number of pending notifications.3. Extend pg_multixact so that pg_multixact/members is addressed by
64-bit offsets.4. Extend pg_subtrans to 64-bits.
5. Extend pg_xact to 64-bits.
6. (a bonus thing that I noticed while thinking of pg_xact.) Extend
pg_twophase.c, to use FullTransactionIds.Currently, the twophase state files in pg_twophase are named according
to the 32 bit Xid of the transaction. Let's switch to FullTransactionId
there....
I propose that we try to finish 1 and 2 for v16. And maybe 6. I think
that's doable. It doesn't have any great user-visible benefits yet, but
we need to start somewhere.- Heikki
Yes, this is a great idea! My only concern here is that we're going in
circles here. You see, patch 1 is what was proposed
in the beginning of this thread. Anyway, I will be happy if we are being
able to push this topic forward.
As for making pg_multixact 64 bit, I spend the last couple of days to make
proper pg_upgrade for pg_multixact's and for pg_xact's
with wraparound and I've understood, that it is not a simple task compare
to pg_xact's. The problem is, we do not have epoch for
multixacts, so we do not have ability to "overcome" wraparound. The
solution may be adding some kind of epoch for multixacts or
make them 64 bit in "main" 64-xid patch, but in perspective of this thread,
in my view, this should be last in line here.
In pg_xact we do not have such a problem, we do have epoch for transacions,
so conversion should be pretty obvious:
0000 -> 000000000000
0001 -> 000000000001
...
0FFE -> 000000000FFE
0FFF -> 000000000FFF
0000 -> 000000010000
0001 -> 000000010001
So, in my view, the plan should be:
1. Use internal 64 bit page numbers in SLRUs without changing segments
naming.
2. Use the larger segment file names in async.c, to lift the current 8 GB
limit on the max number of pending notifications.
3. Extend pg_xact to 64-bits.
4. Extend pg_subtrans to 64-bits.
5. Extend pg_multixact so that pg_multixact/members is addressed by 64-bit
offsets.
6. Extend pg_twophase.c, to use FullTransactionIds. (a bonus thing)
Thoughts?
--
Best regards,
Maxim Orlov.
On Mon, 6 Mar 2023 at 22:48, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
On 01/03/2023 12:21, Aleksander Alekseev wrote:
Hi,
I'm surprised that these patches extend the page numbering to 64 bits,
but never actually uses the high bits. The XID "epoch" is not used, and
pg_xact still wraps around and the segment names are still reused. I
thought we could stop doing that.To clarify, the idea is to let CLOG grow indefinitely and simply store
FullTransactionId -> TransactionStatus (two bits). Correct?Correct.
I didn't investigate this in much detail but it may affect quite some
amount of code since TransactionIdDidCommit() and
TransactionIdDidCommit() currently both deal with TransactionId, not
FullTransactionId. IMO, this would be a nice change however, assuming
we are ready for it.Yep, it's a lot of code churn..
In the previous version of the patch there was an attempt to derive
FullTransactionId from TransactionId but it was wrong for the reasons
named above in the thread. Thus is was removed and the patch
simplified.Yeah, it's tricky to get it right. Clearly we need to do it at some
point though.All in all, this is a big effort. I spent some more time reviewing this
in the last few days, and thought a lot about what the path forward here
could be. And I haven't looked at the actual 64-bit XIDs patch set yet,
just this patch to use 64-bit addressing in SLRUs.This patch is the first step, but we have a bit of a chicken and egg
problem, because this patch on its own isn't very interesting, but on
the other hand, we need it to work on the follow up items. Here's how I
see the development path for this (and again, this is just for the
64-bit SLRUs work, not the bigger 64-bit-XIDs-in-heapam effort):1. Use 64 bit page numbers in SLRUs (this patch)
I would like to make one change here: I'd prefer to keep the old 4-digit
segment names, until we actually start to use the wider address space.
Let's allow each SLRU to specify how many digits to use in the
filenames, so that we convert one SLRU at a time.If we do that, and don't change any of the existing SLRUs to actually
use the wider space of page and segment numbers yet, this patch becomes
just refactoring with no on-disk format changes. No pg_upgrade needed.The next patches will start to make use of the wider address space, one
SLRU at a time.2. Use the larger segment file names in async.c, to lift the current 8
GB limit on the max number of pending notifications.No one actually minds the limit, it's quite generous as it is. But there
is some code and complexity in async.c to avoid the wraparound that
could be made simpler if we used longer SLRU segment names and avoided
the wraparound altogether.I wonder if we should actually add an artificial limit, as a GUC. If
there are gigabytes of notifications queued up, something's probably
wrong with the system, and you're not going to be happy if we just
remove the limit so it can grow to terabytes until you run out of disk
space.3. Extend pg_multixact so that pg_multixact/members is addressed by
64-bit offsets.Currently, multi-XIDs can wrap around, requiring anti-wraparound
freezing, but independently of that, the pg_multixact/members SLRU can
also wrap around. We track both, and trigger anti-wraparound if either
SLRU is about to wrap around. If we redefine MultiXactOffset as a 64-bit
integer, we can avoid the pg_multixact/members wraparound altogether. A
downside is that pg_multixact/offsets will take twice as much space, but
I think that's a good tradeoff. Or perhaps we can play tricks like store
a single 64-bit offset on each pg_multixact/offsets page, and a 32-bit
offset from that for each XID, to avoid making it so much larger.This would reduce the need to do anti-wraparound VACUUMs on systems that
use multixacts heavily. Needs pg_upgrade support.4. Extend pg_subtrans to 64-bits.
This isn't all that interesting because the active region of pg_subtrans
cannot be wider than 32 bits anyway, because you'll still reach the
general 32-bit XID wraparound. But it might be less confusing in some
places.I actually started to write a patch to do this, to see how complicated
it is. It quickly proliferates into expanding other XIDs to 64-bits,
like TransactionXmin, frozenXid calculation in vacuum.c, known-assigned
XID tracking in procarray.c. etc. It's going to be necessary to convert
32-bit XIDs to FullTransactionIds at some boundaries, and I'm not sure
where exactly that should happen. It's easier to do the conversions
close to subtrans.c, but then I'm not sure how much it gets us in terms
of reducing confusion. It's easy to get confused with the epochs during
conversions, as you noted. On the other hand, if we change much more of
the backend to use FullTransactionIds, the patch becomes much more
invasive.Nice thing with pg_subtrans, though, is that it doesn't require
pg_upgrade support.5. Extend pg_xact to 64-bits.
Similar to pg_subtrans, really, but needs pg_upgrade support.
6. (a bonus thing that I noticed while thinking of pg_xact.) Extend
pg_twophase.c, to use FullTransactionIds.Currently, the twophase state files in pg_twophase are named according
to the 32 bit Xid of the transaction. Let's switch to FullTransactionId
there.As we start to refactor these things, I also think it would be good to
have more explicit tracking of the valid range of SLRU pages in each
SLRU. Take pg_subtrans for example: it's not very clear what pages have
been initialized, especially during different stages of startup. It
would be good to have clear start and end page numbers, and throw an
error if you try to look up anything outside those bounds. Same for all
other SLRUs.I propose that we try to finish 1 and 2 for v16. And maybe 6. I think
that's doable. It doesn't have any great user-visible benefits yet, but
we need to start somewhere.- Heikki
--
Best regards,
Maxim Orlov.
On 07/03/2023 13:38, Maxim Orlov wrote:
As for making pg_multixact 64 bit, I spend the last couple of days to
make proper pg_upgrade for pg_multixact's and for pg_xact's
with wraparound and I've understood, that it is not a simple task
compare to pg_xact's. The problem is, we do not have epoch for
multixacts, so we do not have ability to "overcome" wraparound. The
solution may be adding some kind of epoch for multixacts or
make them 64 bit in "main" 64-xid patch, but in perspective of this
thread, in my view, this should be last in line here.
That is true for pg_multixact/offsets. We will indeed need to add an
epoch and introduce the concept of FullMultiXactIds for that. However,
we can change pg_multixact/members independently of that. We can extend
MultiXactOffset from 32 to 64 bits, and eliminate pg_multixact/members
wraparound, while keeping multi-xids 32 bits wide.
- Heikki
Hi,
Here's how I see the development path for this [...]
So, in my view, the plan should be [...]
Thoughts?
The plan looks great! I would also explicitly include this:
As we start to refactor these things, I also think it would be good to
have more explicit tracking of the valid range of SLRU pages in each
SLRU. Take pg_subtrans for example: it's not very clear what pages have
been initialized, especially during different stages of startup. It
would be good to have clear start and end page numbers, and throw an
error if you try to look up anything outside those bounds. Same for all
other SLRUs.
So the plan becomes:
1. Use internal 64 bit page numbers in SLRUs without changing segments naming.
2. Use the larger segment file names in async.c, to lift the current 8
GB limit on the max number of pending notifications.
3. Extend pg_xact to 64-bits.
4. Extend pg_subtrans to 64-bits.
5. Extend pg_multixact so that pg_multixact/members is addressed by
64-bit offsets.
6. Extend pg_twophase.c, to use FullTransactionIds. (a bonus thing)
7. More explicit tracking of the valid range of SLRU pages in each SLRU
Where our main focus for PG16 is going to be 1 and 2, and we may try
to deliver 6 and 7 too if time will permit.
Maxim and I agreed (offlist) that I'm going to submit 1 and 2. The
patch 1 is ready, please see the attachment. I'm currently working on
2 and going to submit it in a bit. It seems to be relatively
straightforward but I don't want to rush things and want to make sure
I didn't miss something.
I wonder if we should actually add an artificial limit, as a GUC.
Yes, I think we need some sort of limit. Using a GUC would be the most
straightforward approach. Alternatively we could derive the limit from
the existing GUCs, similarly to how we derive the default value of
wal_buffers from shared_buffers [1]https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-WAL-BUFFERS. However, off the top of my head
we only have max_wal_size and it doesn't strike me as a good candidate
for deriving something for NOTIFY / LISTEN.
So I'm going to add max_notify_segments GUC with the default value of
65536 as it is now. If the new GUC will receive a push back from the
community we can always use a hard-coded value instead, or no limit at
all.
[1]: https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-WAL-BUFFERS
--
Best regards,
Aleksander Alekseev
Attachments:
v56-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v56-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 10a064d35b96bd035d569d46d5f5b15f6154ad4d Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v56] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 +++++----
src/backend/access/transam/commit_ts.c | 51 +++++---
src/backend/access/transam/multixact.c | 62 ++++-----
src/backend/access/transam/slru.c | 123 +++++++++++-------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 27 ++--
17 files changed, 273 insertions(+), 201 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3a40b196f0 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..89a34008a9 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fe6698d5ff..dd77440134 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..df59c4d775 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,16 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir,
+ (long long) segno);
+ else
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +83,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +146,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +171,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +196,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +235,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +275,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +288,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +403,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +503,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +550,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +634,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +692,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +764,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +939,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1024,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1035,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1079,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1169,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1234,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1312,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1335,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1399,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1415,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1508,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1524,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1540,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 12);
+ else
+
+ /*
+ * XXX Should we still consider 5 and 6 to be a correct length? It
+ * looks like it was previously allowed but now SlruFileName() can't
+ * return such a name.
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1589,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1599,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..2b1d13cc8c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..0ffb8f1b29 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 6b5a416873..cf1ced846e 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..37d56e836d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4258cd92c9..a2cc0dc96f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 622f43da04..c410aada5d 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -236,7 +237,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, false);
}
void
--
2.39.2
On Tue, 7 Mar 2023 at 15:38, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
That is true for pg_multixact/offsets. We will indeed need to add an
epoch and introduce the concept of FullMultiXactIds for that. However,
we can change pg_multixact/members independently of that. We can extend
MultiXactOffset from 32 to 64 bits, and eliminate pg_multixact/members
wraparound, while keeping multi-xids 32 bits wide.Yes, you're totally correct. If it will be committable that way, I'm all
for that.
--
Best regards,
Maxim Orlov.
Hi,
1. Use internal 64 bit page numbers in SLRUs without changing segments naming.
2. Use the larger segment file names in async.c, to lift the current 8
GB limit on the max number of pending notifications.
[...]Where our main focus for PG16 is going to be 1 and 2, and we may try
to deliver 6 and 7 too if time will permit.Maxim and I agreed (offlist) that I'm going to submit 1 and 2. The
patch 1 is ready, please see the attachment. I'm currently working on
2 and going to submit it in a bit. It seems to be relatively
straightforward but I don't want to rush things and want to make sure
I didn't miss something.
PFA the patch v57 which now includes both 1 and 2.
--
Best regards,
Aleksander Alekseev
Attachments:
v57-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v57-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From bdb40dd329c0d61d0b954b4120a3a5cea0bdce46 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v57 1/2] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 +++++----
src/backend/access/transam/commit_ts.c | 51 +++++---
src/backend/access/transam/multixact.c | 62 ++++-----
src/backend/access/transam/slru.c | 123 +++++++++++-------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 27 ++--
17 files changed, 273 insertions(+), 201 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3a40b196f0 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..89a34008a9 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fe6698d5ff..dd77440134 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..df59c4d775 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,16 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir,
+ (long long) segno);
+ else
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +83,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +146,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +171,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +196,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +235,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +275,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +288,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +403,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +503,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +550,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +634,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +692,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +764,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +939,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1024,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1035,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1079,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1169,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1234,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1312,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1335,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1399,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1415,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1508,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1524,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1540,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 12);
+ else
+
+ /*
+ * XXX Should we still consider 5 and 6 to be a correct length? It
+ * looks like it was previously allowed but now SlruFileName() can't
+ * return such a name.
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1589,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1599,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..2b1d13cc8c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..0ffb8f1b29 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 23461b46f6..8291aa495f 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..37d56e836d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4258cd92c9..a2cc0dc96f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 622f43da04..c410aada5d 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -236,7 +237,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, false);
}
void
--
2.39.2
v57-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v57-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From bc23ed3d92303bbb98ee064772c00ea702cd89cf Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v57 2/2] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index e5c41cc6c6..127f3e4c53 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2147,6 +2147,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 0ffb8f1b29..bccb661d38 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied == max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 1c0583fe26..1852391687 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2637,6 +2637,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index d06074b86f..049d5213d6 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -162,6 +162,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.39.2
Hi!
As suggested before by Heikki Linnakangas, I've added a patch for making
2PC transaction state 64-bit.
At first, my intention was to rebuild all twophase interface to use
FullTransactionId. But doing this in a proper
manner would lead to switching from TransactionId to FullTransactionId in
PGPROC and patch become too
big to handle here.
So I decided to keep it simple for now and use wrap logic trick and calc
FullTransactionId on current epoch,
since the span of active xids cannot exceed one epoch at any given time.
Patches 1 and 2 are the same as above.
--
Best regards,
Maxim Orlov.
Attachments:
v57-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v57-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From a8719a8eb6299c93eed6877073312fd1776cfae9 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v57 2/3] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 481f93cea1..7ee30492f7 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2147,6 +2147,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 0ffb8f1b29..bccb661d38 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied == max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 1c0583fe26..1852391687 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2637,6 +2637,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index d06074b86f..049d5213d6 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -162,6 +162,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.39.1
v57-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v57-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From 90f099079eaa77d0ed79aa20ef49968db79a4146 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v57 3/3] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 068e59bec0..e103ffb6d3 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -941,8 +941,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1881,13 +1919,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.39.1
v57-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v57-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 76a622f9bc4c678a7eb7576ad965613b6fc4b658 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v57 1/3] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 +++++----
src/backend/access/transam/commit_ts.c | 51 +++++---
src/backend/access/transam/multixact.c | 62 ++++-----
src/backend/access/transam/slru.c | 123 +++++++++++-------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 27 ++--
17 files changed, 273 insertions(+), 201 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3a40b196f0 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..89a34008a9 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index fe6698d5ff..dd77440134 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 5ab86238a9..df59c4d775 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,16 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir,
+ (long long) segno);
+ else
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +83,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +146,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +171,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +196,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +235,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +275,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +288,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +403,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +503,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +550,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +634,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +692,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +764,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +939,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1024,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1035,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1079,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1169,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1234,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1312,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1335,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1399,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1415,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1508,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1524,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1540,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 12);
+ else
+
+ /*
+ * XXX Should we still consider 5 and 6 to be a correct length? It
+ * looks like it was previously allowed but now SlruFileName() can't
+ * return such a name.
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1589,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1599,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..2b1d13cc8c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..0ffb8f1b29 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 23461b46f6..8291aa495f 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..37d56e836d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 4258cd92c9..a2cc0dc96f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 622f43da04..c410aada5d 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -54,7 +54,7 @@ static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
const char test_tranche_name[] = "test_slru_tranche";
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -63,7 +63,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -98,7 +98,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -116,7 +116,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -134,7 +134,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -147,7 +147,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -155,8 +155,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -164,13 +164,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -178,7 +179,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -208,7 +209,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -236,7 +237,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, false);
}
void
--
2.39.1
Hi,
As suggested before by Heikki Linnakangas, I've added a patch for making 2PC transaction state 64-bit.
At first, my intention was to rebuild all twophase interface to use FullTransactionId. But doing this in a proper
manner would lead to switching from TransactionId to FullTransactionId in PGPROC and patch become too
big to handle here.So I decided to keep it simple for now and use wrap logic trick and calc FullTransactionId on current epoch,
since the span of active xids cannot exceed one epoch at any given time.Patches 1 and 2 are the same as above.
Thanks! 0003 LGTM. I'll mark the CF entry as RfC.
I propose that we try to finish 1 and 2 for v16. And maybe 6. I think
that's doable. It doesn't have any great user-visible benefits yet, but
we need to start somewhere.
+1.
However there are only a few days left if we are going to do this
within March CF...
--
Best regards,
Aleksander Alekseev
On 09/03/2023 17:21, Aleksander Alekseev wrote:
v57-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patch
Reviewing this now. I think it's almost ready to be committed.
There's another big effort going on to move SLRUs to the regular buffer
cache (https://commitfest.postgresql.org/43/3514/). I wonder how moving
to 64 bit page numbers will affect that. BlockNumber is still 32 bits,
after all.
+/* + * An internal function used by SlruScanDirectory(). + * + * Returns true if a file with a name of a given length may be a correct + * SLRU segment. + */ +static inline bool +SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len) +{ + if (ctl->long_segment_names) + return (len == 12); + else + + /* + * XXX Should we still consider 5 and 6 to be a correct length? It + * looks like it was previously allowed but now SlruFileName() can't + * return such a name. + */ + return (len == 4 || len == 5 || len == 6); +}
Huh, I didn't realize that 5 and 6 character SLRU segment names are
possible. But indeed they are. Commit 638cf09e76d allowed 5-character
lengths:
commit 638cf09e76d70dd83d8123e7079be6c0532102d2
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Thu Jan 2 18:17:29 2014 -0300Handle 5-char filenames in SlruScanDirectory
Original users of slru.c were all producing 4-digit filenames, so that
was all that that code was prepared to handle. Changes to multixact.c
in the course of commit 0ac5ad5134f made pg_multixact/members create
5-digit filenames once a certain threshold was reached, which
SlruScanDirectory wasn't prepared to deal with; in particular,
5-digit-name files were not removed during truncation. Change that
routine to make it aware of those files, and have it process them just
like any others.Right now, some pg_multixact/members directories will contain a mixture
of 4-char and 5-char filenames. A future commit is expected fix things
so that each slru.c user declares the correct maximum width for the
files it produces, to avoid such unsightly mixtures.Noticed while investigating bug #8673 reported by Serge Negodyuck.
And later commit 73c986adde5, which introduced commit_ts, allowed 6
characters. With 8192 block size, pg_commit_ts segments are indeed 5
chars wide, and with 512 block size, 6 chars are needed.
This patch makes the filenames always 12 characters wide (for SLRUs that
opt-in to the new naming). That's actually not enough for the full range
that a 64 bit page number can represent. Should we make it 16 characters
now, to avoid repeating the same mistake we made earlier? Or make it
more configurable, on a per-SLRU basis. One reason I don't want to just
make it 16 characters is that WAL segment filenames are also 16 hex
characters, which could cause confusion.
--
Heikki Linnakangas
Neon (https://neon.tech)
Hi,
Reviewing this now. I think it's almost ready to be committed.
There's another big effort going on to move SLRUs to the regular buffer
cache (https://commitfest.postgresql.org/43/3514/). I wonder how moving
to 64 bit page numbers will affect that. BlockNumber is still 32 bits,
after all.
Somehow I didn't pay too much attention to this effort, thanks. I will
familiarize myself with the patch. Intuitively I don't think that the
patchse should block each other.
This patch makes the filenames always 12 characters wide (for SLRUs that
opt-in to the new naming). That's actually not enough for the full range
that a 64 bit page number can represent. Should we make it 16 characters
now, to avoid repeating the same mistake we made earlier? Or make it
more configurable, on a per-SLRU basis. One reason I don't want to just
make it 16 characters is that WAL segment filenames are also 16 hex
characters, which could cause confusion.
Good catch. I propose the following solution:
```
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
if (ctl->long_segment_names)
- return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir,
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
(long long) segno);
else
return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
```
PFE the corrected patchset v58.
--
Best regards,
Aleksander Alekseev
Attachments:
v58-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v58-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From 01cb7d0bf5a761d47cf89cc60358458e2e77fc7f Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v58 3/3] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 068e59bec0..e103ffb6d3 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -941,8 +941,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1881,13 +1919,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.41.0
v58-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v58-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 83e4f98972c6c0a70783038225f6aa3c2174c332 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v58 1/3] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 +++++----
src/backend/access/transam/commit_ts.c | 51 ++++---
src/backend/access/transam/multixact.c | 62 +++++----
src/backend/access/transam/slru.c | 130 ++++++++++++------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 27 ++--
17 files changed, 280 insertions(+), 201 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3a40b196f0 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..89a34008a9 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index abb022e067..da2a9e37df 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 71ac70fb40..82f6b6bf89 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,23 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ else
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +90,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +153,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +178,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +203,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +242,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +282,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +295,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +410,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +510,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +557,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +641,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +699,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +771,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +946,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1031,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1042,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1086,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1176,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1241,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1319,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1342,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1406,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1422,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1515,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1531,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1547,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * XXX should we still consider such names to be valid?
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1596,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1606,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..2b1d13cc8c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceeed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ef909cf4e0..0ffb8f1b29 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index 1af41213b4..dd40d1a720 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index a8a424d92d..37d56e836d 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f32693..4b25961249 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index cfbcfa6797..ef2469ef91 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c47..337b88fc17 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -233,7 +234,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, false);
}
void
--
2.41.0
v58-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v58-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From 5021d763f699bc22d447b398cc027bf810ebc499 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v58 2/3] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 6262cb7bb2..53be4b7cb2 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2196,6 +2196,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 0ffb8f1b29..bccb661d38 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied == max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index f8ef87d26d..4ab722f3e2 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2663,6 +2663,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e4c0269fa3..cf78fed165 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -167,6 +167,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.41.0
Hi,
Reviewing this now. I think it's almost ready to be committed.
There's another big effort going on to move SLRUs to the regular buffer
cache (https://commitfest.postgresql.org/43/3514/). I wonder how moving
to 64 bit page numbers will affect that. BlockNumber is still 32 bits,
after all.Somehow I didn't pay too much attention to this effort, thanks. I will
familiarize myself with the patch. Intuitively I don't think that the
patchse should block each other.This patch makes the filenames always 12 characters wide (for SLRUs that
opt-in to the new naming). That's actually not enough for the full range
that a 64 bit page number can represent. Should we make it 16 characters
now, to avoid repeating the same mistake we made earlier? Or make it
more configurable, on a per-SLRU basis. One reason I don't want to just
make it 16 characters is that WAL segment filenames are also 16 hex
characters, which could cause confusion.Good catch. I propose the following solution:
``` SlruFileName(SlruCtl ctl, char *path, int64 segno) { if (ctl->long_segment_names) - return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, + /* + * We could use 16 characters here but the disadvantage would be that + * the SLRU segments will be hard to distinguish from WAL segments. + * + * For this reason we use 15 characters. It is enough but also means + * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily. + */ + return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir, (long long) segno); else return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, ```PFE the corrected patchset v58.
While triaging the patches for the September CF [1]/messages/by-id/0737f444-59bb-ac1d-2753-873c40da0840@eisentraut.org -- Best regards, Aleksander Alekseev a consensus was
reached that the patchset needs another round of review. Also I
removed myself from the list of reviewers in order to make it clear
that a review from somebody else would be appreciated.
[1]: /messages/by-id/0737f444-59bb-ac1d-2753-873c40da0840@eisentraut.org -- Best regards, Aleksander Alekseev
--
Best regards,
Aleksander Alekseev
This patch makes the filenames always 12 characters wide (for SLRUs that
opt-in to the new naming). That's actually not enough for the full range
that a 64 bit page number can represent. Should we make it 16 characters
now, to avoid repeating the same mistake we made earlier? Or make it
more configurable, on a per-SLRU basis. One reason I don't want to just
make it 16 characters is that WAL segment filenames are also 16 hex
characters, which could cause confusion.Good catch. I propose the following solution:
``` SlruFileName(SlruCtl ctl, char *path, int64 segno) { if (ctl->long_segment_names) - return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, + /* + * We could use 16 characters here but the disadvantage would be that + * the SLRU segments will be hard to distinguish from WAL segments. + * + * For this reason we use 15 characters. It is enough but also means + * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily. + */ + return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir, (long long) segno); else return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, ```PFE the corrected patchset v58.
Good idea
________________________________
发件人: Aleksander Alekseev <aleksander@timescale.com>
发送时间: 2023年9月4日 22:41
收件人: Postgres hackers <pgsql-hackers@lists.postgresql.org>
抄送: Heikki Linnakangas <hlinnaka@iki.fi>; Maxim Orlov <orlovmg@gmail.com>; Jacob Champion <jchampion@timescale.com>; Japin Li <japinli@hotmail.com>; Andres Freund <andres@anarazel.de>; Michael Paquier <michael@paquier.xyz>; Pavel Borisov <pashkin.elfe@gmail.com>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>; Alexander Korotkov <aekorotkov@gmail.com>
主题: Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
Hi,
Reviewing this now. I think it's almost ready to be committed.
There's another big effort going on to move SLRUs to the regular buffer
cache (https://commitfest.postgresql.org/43/3514/). I wonder how moving
to 64 bit page numbers will affect that. BlockNumber is still 32 bits,
after all.Somehow I didn't pay too much attention to this effort, thanks. I will
familiarize myself with the patch. Intuitively I don't think that the
patchse should block each other.This patch makes the filenames always 12 characters wide (for SLRUs that
opt-in to the new naming). That's actually not enough for the full range
that a 64 bit page number can represent. Should we make it 16 characters
now, to avoid repeating the same mistake we made earlier? Or make it
more configurable, on a per-SLRU basis. One reason I don't want to just
make it 16 characters is that WAL segment filenames are also 16 hex
characters, which could cause confusion.Good catch. I propose the following solution:
``` SlruFileName(SlruCtl ctl, char *path, int64 segno) { if (ctl->long_segment_names) - return snprintf(path, MAXPGPATH, "%s/%012llX", ctl->Dir, + /* + * We could use 16 characters here but the disadvantage would be that + * the SLRU segments will be hard to distinguish from WAL segments. + * + * For this reason we use 15 characters. It is enough but also means + * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily. + */ + return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir, (long long) segno); else return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, ```PFE the corrected patchset v58.
While triaging the patches for the September CF [1]/messages/by-id/0737f444-59bb-ac1d-2753-873c40da0840@eisentraut.org -- Best regards, Aleksander Alekseev a consensus was
reached that the patchset needs another round of review. Also I
removed myself from the list of reviewers in order to make it clear
that a review from somebody else would be appreciated.
[1]: /messages/by-id/0737f444-59bb-ac1d-2753-873c40da0840@eisentraut.org -- Best regards, Aleksander Alekseev
--
Best regards,
Aleksander Alekseev
Hi!
On Wed, Jul 5, 2023 at 4:46 PM Aleksander Alekseev <aleksander@timescale.com>
wrote:
PFE the corrected patchset v58.
I'd like to revive this thread.
This patchset is extracted from a larger patchset implementing 64-bit
xids. It converts page numbers in SLRUs into 64 bits. The most SLRUs save
the same file naming scheme, thus their on-disk representation remains the
same. However, the patch 0002 converts pg_notify to actually use a new
naming scheme. Therefore pg_notify can benefit from simplification and
getting rid of wraparound.
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceeed
2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
Is there any reason we transform macro into a function? If not, I propose
to leave this as a macro. BTW, there is a typo in a word "exceeed".
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ /*
+ * We could use 16 characters here but the disadvantage would be
that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT
easily.
+ */
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ else
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+}
I think it worth adding asserts here to verify there is no overflow making
us mapping different segments into the same files.
+ return occupied == max_notify_queue_pages;
I'm not sure if the current code could actually allow to occupy more than
max_notify_queue_pages. Probably not even in extreme cases. But I still
think it will more safe and easier to read to write "occupied >=
max_notify_queue"_pages here.
diff --git a/src/test/modules/test_slru/test_slru.c
b/src/test/modules/test_slru/test_slru.c
The actual 64-bitness of SLRU pages isn't much exercised in our automated
tests. It would be too exhausting to make pg_notify actually use higher
than 2**32 page numbers. Thus, I think test/modules/test_slru is a good
place to give high page numbers a good test.
------
Regards,
Alexander Korotkov
On Mon, 6 Nov 2023 at 17:07, Alexander Korotkov <aekorotkov@gmail.com> wrote:
Hi!
On Wed, Jul 5, 2023 at 4:46 PM Aleksander Alekseev <aleksander@timescale.com> wrote:
PFE the corrected patchset v58.
I'd like to revive this thread.
This patchset is extracted from a larger patchset implementing 64-bit xids. It converts page numbers in SLRUs into 64 bits. The most SLRUs save the same file naming scheme, thus their on-disk representation remains the same. However, the patch 0002 converts pg_notify to actually use a new naming scheme. Therefore pg_notify can benefit from simplification and getting rid of wraparound.
-#define TransactionIdToCTsPage(xid) \ - ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE) + +/* + * Although we return an int64 the actual value can't currently exceeed 2**32. + */ +static inline int64 +TransactionIdToCTsPage(TransactionId xid) +{ + return xid / (int64) COMMIT_TS_XACTS_PER_PAGE; +}Is there any reason we transform macro into a function? If not, I propose to leave this as a macro. BTW, there is a typo in a word "exceeed".
If I remember right, the compiler will make equivalent code from
inline functions and macros, and functions has an additional benefit:
the compiler will report type mismatch if any. That was the only
reason.
Also, I looked at v58-0001 and don't quite agree with mentioning the
authors of the original 64-xid patch, from which the current patch is
derived, as just "privious input" persons.
Regards, Pavel Borisov
On Mon, Nov 6, 2023 at 3:42 PM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
On Mon, 6 Nov 2023 at 17:07, Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Wed, Jul 5, 2023 at 4:46 PM Aleksander Alekseev <aleksander@timescale.com> wrote:
PFE the corrected patchset v58.
I'd like to revive this thread.
This patchset is extracted from a larger patchset implementing 64-bit xids. It converts page numbers in SLRUs into 64 bits. The most SLRUs save the same file naming scheme, thus their on-disk representation remains the same. However, the patch 0002 converts pg_notify to actually use a new naming scheme. Therefore pg_notify can benefit from simplification and getting rid of wraparound.
-#define TransactionIdToCTsPage(xid) \ - ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE) + +/* + * Although we return an int64 the actual value can't currently exceeed 2**32. + */ +static inline int64 +TransactionIdToCTsPage(TransactionId xid) +{ + return xid / (int64) COMMIT_TS_XACTS_PER_PAGE; +}Is there any reason we transform macro into a function? If not, I propose to leave this as a macro. BTW, there is a typo in a word "exceeed".
If I remember right, the compiler will make equivalent code from
inline functions and macros, and functions has an additional benefit:
the compiler will report type mismatch if any. That was the only
reason.
Then it's OK to leave it as an inline function.
Also, I looked at v58-0001 and don't quite agree with mentioning the
authors of the original 64-xid patch, from which the current patch is
derived, as just "privious input" persons.
+1, for converting all "previous input" persons as additional authors.
That would be a pretty long list of authors though.
BTW, I'm a bit puzzled on who should be the first author now?
------
Regards,
Alexander Korotkov
On Mon, 6 Nov 2023 at 18:01, Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Mon, Nov 6, 2023 at 3:42 PM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
On Mon, 6 Nov 2023 at 17:07, Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Wed, Jul 5, 2023 at 4:46 PM Aleksander Alekseev <aleksander@timescale.com> wrote:
PFE the corrected patchset v58.
I'd like to revive this thread.
This patchset is extracted from a larger patchset implementing 64-bit xids. It converts page numbers in SLRUs into 64 bits. The most SLRUs save the same file naming scheme, thus their on-disk representation remains the same. However, the patch 0002 converts pg_notify to actually use a new naming scheme. Therefore pg_notify can benefit from simplification and getting rid of wraparound.
-#define TransactionIdToCTsPage(xid) \ - ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE) + +/* + * Although we return an int64 the actual value can't currently exceeed 2**32. + */ +static inline int64 +TransactionIdToCTsPage(TransactionId xid) +{ + return xid / (int64) COMMIT_TS_XACTS_PER_PAGE; +}Is there any reason we transform macro into a function? If not, I propose to leave this as a macro. BTW, there is a typo in a word "exceeed".
If I remember right, the compiler will make equivalent code from
inline functions and macros, and functions has an additional benefit:
the compiler will report type mismatch if any. That was the only
reason.Then it's OK to leave it as an inline function.
Also, I looked at v58-0001 and don't quite agree with mentioning the
authors of the original 64-xid patch, from which the current patch is
derived, as just "privious input" persons.+1, for converting all "previous input" persons as additional authors.
That would be a pretty long list of authors though.
BTW, I'm a bit puzzled on who should be the first author now?
Thanks! It's long, I agree, but the activity around this was huge and
involved many people, the patch itself already has more than
half-hundred iterations to date. I think at least people mentioned in
the commit message of v58 are fair to have author status.
As for the first, I'm not sure, it's hard for me to evaluate what is
more important, the initial prototype, or the final improvement
iterations. I don't think the existing order in a commit message has
some meaning. Maybe it's worth throwing a dice.
Regards, Pavel
Hi,
If I remember right, the compiler will make equivalent code from
inline functions and macros, and functions has an additional benefit:
the compiler will report type mismatch if any. That was the only
reason.Then it's OK to leave it as an inline function.
+1
BTW, I'm a bit puzzled on who should be the first author now?
Thanks! It's long, I agree, but the activity around this was huge and
involved many people, the patch itself already has more than
half-hundred iterations to date. I think at least people mentioned in
the commit message of v58 are fair to have author status.As for the first, I'm not sure, it's hard for me to evaluate what is
more important, the initial prototype, or the final improvement
iterations. I don't think the existing order in a commit message has
some meaning. Maybe it's worth throwing a dice.
Personally I was not aware that the order of the authors in a commit
message carries any information. To my knowledge it doesn't not. I
believe this patchset is a team effort, so I suggest keeping the
commit message as is or shuffling the authors randomly. I believe we
should do our best to reflect the input of people who previously
contributed to the effort, if anyone are aware of them, and add them
to the commit message if they are not there yet. Pretty sure Git will
forgive us if the list ends up being long. Hopefully so will people
who we mistakenly forget.
--
Best regards,
Aleksander Alekseev
Alexander,
PFE the corrected patchset v58.
I'd like to revive this thread.
Many thanks for your comments and suggestions.
I think it worth adding asserts here to verify there is no overflow making us mapping different segments into the same files.
Sorry, I didn't understand this one. Maybe you could provide the exact code?
--
Best regards,
Aleksander Alekseev
On Mon, Nov 6, 2023 at 4:38 PM Aleksander Alekseev <aleksander@timescale.com>
wrote:
PFE the corrected patchset v58.
I'd like to revive this thread.
Many thanks for your comments and suggestions.
I think it worth adding asserts here to verify there is no overflow
making us mapping different segments into the same files.
Sorry, I didn't understand this one. Maybe you could provide the exact
code?
I actually meant this.
static int inline
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
if (ctl->long_segment_names)
{
/*
* We could use 16 characters here but the disadvantage would be
that
* the SLRU segments will be hard to distinguish from WAL segments.
*
* For this reason we use 15 characters. It is enough but also means
* that in the future we can't decrease SLRU_PAGES_PER_SEGMENT
easily.
*/
Assert(segno >= 0 && segno <= 0x1000000000000000);
return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
(long long) segno);
}
else
{
Assert(segno >= 0 && segno <= 0x10000);
return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
(unsigned int) segno);
}
}
As I now get, snprintf() wouldn't just truncate the high signs, instead it
will use more characters. But I think assertions are useful anyway.
------
Regards,
Alexander Korotkov
Hi Alexander,
-#define TransactionIdToCTsPage(xid) \ - ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE) + +/* + * Although we return an int64 the actual value can't currently exceeed 2**32. + */ +static inline int64 +TransactionIdToCTsPage(TransactionId xid) +{ + return xid / (int64) COMMIT_TS_XACTS_PER_PAGE; +}Is there any reason we transform macro into a function? If not, I propose to leave this as a macro. BTW, there is a typo in a word "exceeed".
I kept the inline function, as we agreed above.
Typo fixed.
+static int inline +SlruFileName(SlruCtl ctl, char *path, int64 segno) +{ + if (ctl->long_segment_names) + /* + * We could use 16 characters here but the disadvantage would be that + * the SLRU segments will be hard to distinguish from WAL segments. + * + * For this reason we use 15 characters. It is enough but also means + * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily. + */ + return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir, + (long long) segno); + else + return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, + (unsigned int) segno); +}I think it worth adding asserts here to verify there is no overflow making us mapping different segments into the same files.
Added. I noticed a off-by-one error in the code snippet proposed
above, so my code differs a bit.
+ return occupied == max_notify_queue_pages;
I'm not sure if the current code could actually allow to occupy more than max_notify_queue_pages. Probably not even in extreme cases. But I still think it will more safe and easier to read to write "occupied >= max_notify_queue"_pages here.
Fixed.
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.cThe actual 64-bitness of SLRU pages isn't much exercised in our automated tests. It would be too exhausting to make pg_notify actually use higher than 2**32 page numbers. Thus, I think test/modules/test_slru is a good place to give high page numbers a good test.
Fixed. I choose not to change any numbers in the test in order to
check any corner cases, etc. The code patches for long_segment_names =
true and long_segment_names = false are almost the same thus it will
not improve code coverage. Using the current numbers will allow to
easily switch back to long_segment_names = false in the test if
necessary.
PFA the corrected patchset v59.
--
Best regards,
Aleksander Alekseev
Attachments:
v59-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v59-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From c1ae96cb5d28a6c012477a37a3d5409956ee7535 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v59 3/3] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Reviewed-by: Alexander Korotkov, Aleksander Alekseev, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index c6af8cfd7e..0a850f4dc4 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -942,8 +942,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1882,13 +1920,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.42.0
v59-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v59-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From e13f74f2123d64c462e846b6e0db6f33958cb96c Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v59 2/3] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: Alexander Korotkov, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index bd70ff2e4b..4564c62f67 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2151,6 +2151,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 346bc28a36..2651d8904b 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied >= max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 7605eff9b9..1f593c6e3d 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2687,6 +2687,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e48c066a5b..cf9f283cfe 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -166,6 +166,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.42.0
v59-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v59-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 3e7611f2f49daf3ee375947c766732e174b5425d Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v59 1/3] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 ++++----
src/backend/access/transam/commit_ts.c | 51 ++++---
src/backend/access/transam/multixact.c | 62 ++++----
src/backend/access/transam/slru.c | 136 ++++++++++++------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 32 +++--
18 files changed, 292 insertions(+), 202 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3ac61fd6b4 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..ce69f220f4 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57ed34c0a8..db3423f12e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9ed24e1185..3b2a2d2d90 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,29 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ {
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ Assert(segno >= 0 && segno <= 0xFFFFFFFFFFFFFFF);
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ }
+ else
+ {
+ Assert(segno >= 0 && segno <= 0xFFFF);
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +96,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +159,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +184,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +209,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +248,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +288,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +301,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +416,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +516,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +563,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +647,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +705,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +777,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +952,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1037,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1048,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1092,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1182,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1247,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1325,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1348,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1412,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1428,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1521,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1537,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1553,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * XXX should we still consider such names to be valid?
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1602,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1612,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..9ce810285b 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 38ddae08b8..346bc28a36 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index a794546db3..eb684fa544 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 552cc19e68..7a1ec405af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f32693..4b25961249 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 963cc82125..d0af1d902a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..4e5e562b43 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c47..5ae8a332ff 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -213,6 +214,11 @@ test_slru_page_precedes_logically(int page1, int page2)
static void
test_slru_shmem_startup(void)
{
+ /*
+ * Short segments names are well tested elsewhere so in this test we
+ * are focusing on long names.
+ */
+ const bool long_segment_names = true;
const char slru_dir_name[] = "pg_test_slru";
int test_tranche_id;
@@ -233,7 +239,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, long_segment_names);
}
void
--
2.42.0
Hi again,
PFA the corrected patchset v59.
On second thought, I believe this Assert is incorrect:
```
+ else
+ {
+ Assert(segno >= 0 && segno <= 0xFFFF);
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
```
See SlruCorrectSegmentFilenameLength():
```
if (ctl->long_segment_names)
return (len == 15); /* see SlruFileName() */
else
/*
* Commit 638cf09e76d allowed 5-character lengths. Later commit
* 73c986adde5 allowed 6-character length.
*
* XXX should we still consider such names to be valid?
*/
return (len == 4 || len == 5 || len == 6);
```
Should we just drop it or check that segno is <= 0xFFFFFF?
--
Best regards,
Aleksander Alekseev
On Mon, 6 Nov 2023 at 16:07, Alexander Korotkov <aekorotkov@gmail.com>
wrote:
Hi!
On Wed, Jul 5, 2023 at 4:46 PM Aleksander Alekseev <
aleksander@timescale.com> wrote:PFE the corrected patchset v58.
I'd like to revive this thread.
Hi! Great news!
BTW, there is a typo in a word "exceeed".
Fixed.
+static int inline +SlruFileName(SlruCtl ctl, char *path, int64 segno) +{ ... +}I think it worth adding asserts here to verify there is no overflow making
us mapping different segments into the same files.
Agree, assertion added.
+ return occupied == max_notify_queue_pages;
I'm not sure if the current code could actually allow to occupy more than
max_notify_queue_pages. Probably not even in extreme cases. But I still
think it will more safe and easier to read to write "occupied >=
max_notify_queue"_pages here.
Fixed.
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.cThe actual 64-bitness of SLRU pages isn't much exercised in our automated
tests. It would be too exhausting to make pg_notify actually use higher
than 2**32 page numbers. Thus, I think test/modules/test_slru is a good
place to give high page numbers a good test.
PFA, I've add test for a 64-bit SLRU pages.
By the way, there is another one useful thing we may do here. For now
pg_commit_ts functionality is rather strange: if it was enabled, then
disabled and then enabled again all the data from before will be
discarded. Meanwhile, users expected to have their commit timestamps for
all transactions, which were "logged" when this feature was enabled. It's
weird.
AFICS, the only reason for this behaviour is becouse of transaction
wraparound. It may occur while the feature is disabled end it is safe to
simply remove all the data from previous period. If we switch to
FullTransactionId in commit_ts we can overcome this limitation. But I'm
not sure if it worth to try to fix this in current patchset, since it is
already non trivial.
--
Best regards,
Maxim Orlov.
Attachments:
v59-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v59-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From 7dbe4ea952c9ed11b6ddc713bd056b86c5d90624 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v59 3/4] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index c6af8cfd7e..0a850f4dc4 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -942,8 +942,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1882,13 +1920,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.42.0
v59-0004-Add-SLRU-tests-for-64-bit-page-case.patchapplication/octet-stream; name=v59-0004-Add-SLRU-tests-for-64-bit-page-case.patchDownload
From ea4c44bbeef122e5ccfe02ed33b5c40c2d9cda96 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Tue, 7 Nov 2023 18:44:19 +0300
Subject: [PATCH v59 4/4] Add SLRU tests for 64-bit page case
Previously, we add 64-bit naming for SLRU segments. But no tests were provided,
so add test for "long" SLRU segments name, i.e. for 64-bit variant of it.
Author: Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
.../modules/test_slru/expected/test_slru.out | 151 ++++++++++++++++++
src/test/modules/test_slru/sql/test_slru.sql | 46 +++++-
src/test/modules/test_slru/test_slru--1.0.sql | 2 +
src/test/modules/test_slru/test_slru.c | 12 ++
4 files changed, 210 insertions(+), 1 deletion(-)
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..7e09722766 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -1,4 +1,7 @@
CREATE EXTENSION test_slru;
+--
+-- Test cases for a "normal", i.e. 32 bit pages.
+--
SELECT test_slru_page_exists(12345);
test_slru_page_exists
-----------------------
@@ -132,4 +135,152 @@ SELECT test_slru_page_exists(12393);
f
(1 row)
+--
+-- Now same as above, but for "long", i.e. 64 bit pages.
+--
+SELECT test_slru_allow_long_names();
+ test_slru_allow_long_names
+----------------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU with 64 bit pages');
+ test_slru_page_write
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_read(0x1234500000000);
+ test_slru_page_read
+-----------------------------
+ Test SLRU with 64 bit pages
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU with 64 bit pages'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+ count
+-------
+ 48
+(1 row)
+
+ -- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000025, true);
+ test_slru_page_read
+-----------------------------
+ Test SLRU with 64 bit pages
+(1 row)
+
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000025);
+ test_slru_page_readonly
+-----------------------------
+ Test SLRU with 64 bit pages
+(1 row)
+
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+ test_slru_page_readonly
+-----------------------------
+ Test SLRU with 64 bit pages
+(1 row)
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+ test_slru_page_writeall
+-------------------------
+
+(1 row)
+
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000025);
+NOTICE: Called SlruSyncFileTag() for segment 10007944888321 on path pg_test_slru/000091A28000001
+ test_slru_page_sync
+---------------------
+
+(1 row)
+
+SELECT test_slru_page_sync(0x1234500000030);
+NOTICE: Called SlruSyncFileTag() for segment 10007944888321 on path pg_test_slru/000091A28000001
+ test_slru_page_sync
+---------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+NOTICE: Called SlruDeleteSegment() for segment 10007944888321
+ test_slru_page_delete
+-----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000025);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_truncate(0x1234500000025);
+ test_slru_page_truncate
+-------------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000025);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Full deletion
+SELECT test_slru_delete_all();
+ test_slru_delete_all
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000025);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
DROP EXTENSION test_slru;
diff --git a/src/test/modules/test_slru/sql/test_slru.sql b/src/test/modules/test_slru/sql/test_slru.sql
index fe0d1342a9..14e45c4d1f 100644
--- a/src/test/modules/test_slru/sql/test_slru.sql
+++ b/src/test/modules/test_slru/sql/test_slru.sql
@@ -1,5 +1,8 @@
CREATE EXTENSION test_slru;
+--
+-- Test cases for a "normal", i.e. 32 bit pages.
+--
SELECT test_slru_page_exists(12345);
SELECT test_slru_page_write(12345, 'Test SLRU');
SELECT test_slru_page_read(12345);
@@ -35,4 +38,45 @@ SELECT test_slru_page_exists(12345);
SELECT test_slru_page_exists(12377);
SELECT test_slru_page_exists(12393);
-DROP EXTENSION test_slru;
+--
+-- Now same as above, but for "long", i.e. 64 bit pages.
+--
+SELECT test_slru_allow_long_names();
+
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU with 64 bit pages');
+SELECT test_slru_page_read(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000000);
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU with 64 bit pages'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+
+ -- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000025, true);
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000025);
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000025);
+SELECT test_slru_page_sync(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000025);
+SELECT test_slru_page_truncate(0x1234500000025);
+SELECT test_slru_page_exists(0x1234500000025);
+
+-- Full deletion
+SELECT test_slru_delete_all();
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000025);
+SELECT test_slru_page_exists(0x1234500000030);
+
+DROP EXTENSION test_slru;
\ No newline at end of file
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 202e8da3fd..3f4d0e9ef1 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -19,3 +19,5 @@ CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
+CREATE OR REPLACE FUNCTION test_slru_allow_long_names() RETURNS VOID
+ AS 'MODULE_PATHNAME', 'test_slru_allow_long_names' LANGUAGE C;
\ No newline at end of file
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index 337b88fc17..540387637d 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -36,6 +36,7 @@ PG_FUNCTION_INFO_V1(test_slru_page_sync);
PG_FUNCTION_INFO_V1(test_slru_page_delete);
PG_FUNCTION_INFO_V1(test_slru_page_truncate);
PG_FUNCTION_INFO_V1(test_slru_delete_all);
+PG_FUNCTION_INFO_V1(test_slru_allow_long_names);
/* Number of SLRU page slots */
#define NUM_TEST_BUFFERS 16
@@ -179,6 +180,7 @@ test_slru_page_truncate(PG_FUNCTION_ARGS)
int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
+
PG_RETURN_VOID();
}
@@ -191,6 +193,14 @@ test_slru_delete_all(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+Datum
+test_slru_allow_long_names(PG_FUNCTION_ARGS)
+{
+ TestSlruCtl->long_segment_names = true;
+
+ PG_RETURN_VOID();
+}
+
/*
* Module load callbacks and initialization.
*/
@@ -232,6 +242,8 @@ test_slru_shmem_startup(void)
LWLockInitialize(TestSLRULock, test_tranche_id);
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
+ TestSlruCtl->long_segment_names = false;
+
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
test_tranche_id, SYNC_HANDLER_NONE, false);
--
2.42.0
v59-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v59-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 68138c145ca739a94fcfa094bba7ccf0fd2a35a9 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v59 1/4] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Aleksander Alekseev, Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 ++++----
src/backend/access/transam/commit_ts.c | 51 ++++---
src/backend/access/transam/multixact.c | 62 ++++----
src/backend/access/transam/slru.c | 138 ++++++++++++------
src/backend/access/transam/subtrans.c | 34 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 27 ++--
17 files changed, 289 insertions(+), 201 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..33896c6515 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+/*
+ * Although we return an int64, the actual value can't currently exceed
+ * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..88eca914d7 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64, the actual value can't currently exceed
+ * 0xFFFFFFFF/COMMIT_TS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57ed34c0a8..db3423f12e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9ed24e1185..ff9b7954c1 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,31 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static inline int
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ else
+ {
+ /*
+ * Make sure we do not deal with overflow here to avoid accessing wrong
+ * slru segment.
+ */
+ Assert(segno <= 0xFFFF);
+
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +98,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +161,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +186,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +211,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +250,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +290,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +303,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +418,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +518,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +565,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +649,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +707,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +779,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +954,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1039,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1050,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1094,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1184,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1249,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1327,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1350,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1414,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1430,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1523,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1539,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1555,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * XXX should we still consider such names to be valid?
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1604,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1614,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..64673eaef6 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,16 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +72,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +82,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +117,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +202,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +243,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +259,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +317,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +347,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +369,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 38ddae08b8..346bc28a36 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index a794546db3..eb684fa544 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 552cc19e68..7a1ec405af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f32693..4b25961249 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 963cc82125..d0af1d902a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c47..337b88fc17 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -233,7 +234,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, false);
}
void
--
2.42.0
v59-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v59-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From 10df8320b7c1758f51703cf8bad5de96c96ccad2 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v59 2/4] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index bd70ff2e4b..4564c62f67 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2151,6 +2151,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 346bc28a36..2651d8904b 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied >= max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 7605eff9b9..1f593c6e3d 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2687,6 +2687,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e48c066a5b..cf9f283cfe 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -166,6 +166,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.42.0
Maxim,
I see both of us accounted for Alexanders feedback and submitted v59.
Your newer version seems to have issues on cfbot, so resubmitting the
previous patchset that passes the tests. Please feel free to add
changes.
See SlruCorrectSegmentFilenameLength():
```
if (ctl->long_segment_names)
return (len == 15); /* see SlruFileName() */
else
/*
* Commit 638cf09e76d allowed 5-character lengths. Later commit
* 73c986adde5 allowed 6-character length.
*
* XXX should we still consider such names to be valid?
*/
return (len == 4 || len == 5 || len == 6);
```Should we just drop it or check that segno is <= 0xFFFFFF?
I also choose to change this Assert and to add a corresponding comment:
else
{
- Assert(segno >= 0 && segno <= 0xFFFF);
+ /*
+ * Despite the fact that %04X format string is used up to 24 bit
+ * integers are allowed. See SlruCorrectSegmentFilenameLength()
+ */
+ Assert(segno >= 0 && segno <= 0xFFFFFF);
return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
(unsigned int) segno);
}
--
Best regards,
Aleksander Alekseev
Attachments:
v60-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v60-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From f4031ff4357d45f7f2e7e960bf94c07177dd2b0e Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v60 1/3] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 63 ++++----
src/backend/access/transam/commit_ts.c | 51 ++++---
src/backend/access/transam/multixact.c | 62 ++++----
src/backend/access/transam/slru.c | 140 ++++++++++++------
src/backend/access/transam/subtrans.c | 33 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 32 ++--
18 files changed, 296 insertions(+), 202 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..3ac61fd6b4 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,16 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +98,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +171,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +245,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +254,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +280,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +346,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +420,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +646,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +706,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +743,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +763,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +782,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +847,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +886,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +939,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +958,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +972,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1000,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..ce69f220f4 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,16 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +111,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +178,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +222,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +274,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +531,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +578,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +671,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +804,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +842,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +927,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +946,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +957,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +982,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57ed34c0a8..db3423f12e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9ed24e1185..4ada9ae6a7 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,33 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ {
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ Assert(segno >= 0 && segno <= 0xFFFFFFFFFFFFFFF);
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ }
+ else
+ {
+ /*
+ * Despite the fact that %04X format string is used up to 24 bit
+ * integers are allowed. See SlruCorrectSegmentFilenameLength()
+ */
+ Assert(segno >= 0 && segno <= 0xFFFFFF);
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +100,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +163,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +188,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +213,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +252,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +292,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +305,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +420,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +520,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +567,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +651,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +709,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +781,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +956,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1041,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1052,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1096,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1186,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1251,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1329,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1352,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1416,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1432,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1525,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1541,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1557,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * XXX should we still consider such names to be valid?
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1606,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1616,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = (int64) strtol(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..9ce810285b 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,15 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceed 2**32.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +71,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +81,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +116,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +201,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +242,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +258,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +316,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +346,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +368,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 38ddae08b8..346bc28a36 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index a794546db3..eb684fa544 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 552cc19e68..7a1ec405af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f32693..4b25961249 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 963cc82125..d0af1d902a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..4e5e562b43 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c47..5ae8a332ff 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -213,6 +214,11 @@ test_slru_page_precedes_logically(int page1, int page2)
static void
test_slru_shmem_startup(void)
{
+ /*
+ * Short segments names are well tested elsewhere so in this test we
+ * are focusing on long names.
+ */
+ const bool long_segment_names = true;
const char slru_dir_name[] = "pg_test_slru";
int test_tranche_id;
@@ -233,7 +239,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, long_segment_names);
}
void
--
2.42.0
v60-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v60-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From f12738c7538fefc98619eee9f5ae2594923af757 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v60 3/3] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Reviewed-by: Alexander Korotkov, Aleksander Alekseev, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index c6af8cfd7e..0a850f4dc4 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -942,8 +942,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1882,13 +1920,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.42.0
v60-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v60-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From 3d7e6bbd8cb7a5bf9edcc8248037db687772bc7a Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v60 2/3] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: Alexander Korotkov, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index bd70ff2e4b..4564c62f67 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2151,6 +2151,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 346bc28a36..2651d8904b 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied >= max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 7605eff9b9..1f593c6e3d 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2687,6 +2687,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e48c066a5b..cf9f283cfe 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -166,6 +166,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.42.0
Aleksander Alekseev,
Maxim,
I see both of us accounted for Alexanders feedback and submitted v59.
Your newer version seems to have issues on cfbot, so resubmitting the
previous patchset that passes the tests. Please feel free to add
changes.
For unknown reasons, I do not receive any of your emails from after
2023-11-07 11:57:12 (Message-ID: CAJ7c6TN1hKqNPGrNcq96SUyD=
Z61raKGXF8iqq36qr90oudxRg@mail.gmail.com).
Even after resend.
Anyway, PFA patch set of version 61. I've made some minor changes in the
0001 and add 004 in order to test actual 64-bit SLRU pages.
As for CF bot had failed on my v59 patch set, this is because of the bug.
It's manifested because of added 64-bit pages tests.
The problem was in segno calculation, since we convert it from file name
using strtol call. But strtol return long,
which is 4 byte long in x86.
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
--
Best regards,
Maxim Orlov.
Attachments:
v61-0003-Make-use-FullTransactionId-in-2PC-filenames.patchapplication/octet-stream; name=v61-0003-Make-use-FullTransactionId-in-2PC-filenames.patchDownload
From f19bf594e019a5d11d9cec96180dacc9936ce665 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH v61 3/4] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov
Reviewed-by: Alexander Korotkov, Aleksander Alekseev, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index c6af8cfd7e..0a850f4dc4 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -942,8 +942,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1882,13 +1920,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.34.1
v61-0004-Add-SLRU-tests-for-64-bit-page-case.patchapplication/octet-stream; name=v61-0004-Add-SLRU-tests-for-64-bit-page-case.patchDownload
From 21a497fb2ff4d960930e928a5d4f2501168c25e3 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Thu, 9 Nov 2023 18:02:25 +0300
Subject: [PATCH v61 4/4] Add SLRU tests for 64-bit page case
Previously, we add 64-bit naming for SLRU segments. But no tests for the actual
64-bit pages were provided.
Author: Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
.../modules/test_slru/expected/test_slru.out | 135 ++++++++++++++++++
src/test/modules/test_slru/sql/test_slru.sql | 38 +++++
2 files changed, 173 insertions(+)
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 4e5e562b43..185c56e5d6 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -132,4 +132,139 @@ SELECT test_slru_page_exists(12393);
f
(1 row)
+--
+-- Test 64-bit pages
+--
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU 64-bit');
+ test_slru_page_write
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_read(0x1234500000000);
+ test_slru_page_read
+---------------------
+ Test SLRU 64-bit
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU 64-bit'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+ count
+-------
+ 48
+(1 row)
+
+-- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000020, true);
+ test_slru_page_read
+---------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000020);
+ test_slru_page_readonly
+-------------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+ test_slru_page_readonly
+-------------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+ test_slru_page_writeall
+-------------------------
+
+(1 row)
+
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000030);
+NOTICE: Called SlruSyncFileTag() for segment 10007944888321 on path pg_test_slru/000091A28000001
+ test_slru_page_sync
+---------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+NOTICE: Called SlruDeleteSegment() for segment 10007944888321
+ test_slru_page_delete
+-----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_truncate(0x1234500000020);
+ test_slru_page_truncate
+-------------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Full deletion
+SELECT test_slru_delete_all();
+ test_slru_delete_all
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
DROP EXTENSION test_slru;
diff --git a/src/test/modules/test_slru/sql/test_slru.sql b/src/test/modules/test_slru/sql/test_slru.sql
index fe0d1342a9..b1b376581a 100644
--- a/src/test/modules/test_slru/sql/test_slru.sql
+++ b/src/test/modules/test_slru/sql/test_slru.sql
@@ -35,4 +35,42 @@ SELECT test_slru_page_exists(12345);
SELECT test_slru_page_exists(12377);
SELECT test_slru_page_exists(12393);
+--
+-- Test 64-bit pages
+--
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU 64-bit');
+SELECT test_slru_page_read(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000000);
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU 64-bit'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+
+-- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000020, true);
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000020);
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000020);
+SELECT test_slru_page_truncate(0x1234500000020);
+SELECT test_slru_page_exists(0x1234500000020);
+
+-- Full deletion
+SELECT test_slru_delete_all();
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000020);
+SELECT test_slru_page_exists(0x1234500000030);
+
DROP EXTENSION test_slru;
--
2.34.1
v61-0002-Use-larger-segment-file-names-for-pg_notify.patchapplication/octet-stream; name=v61-0002-Use-larger-segment-file-names-for-pg_notify.patchDownload
From 8f863d4a7d9458bbb04c5209cd420f8df222803d Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH v61 2/4] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Aleksander Alekseev
Reviewed-by: Alexander Korotkov, TODO FIXME
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index fc35a46e5e..81beea4005 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2151,6 +2151,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a1..6c1f09bd45 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d..fd6ed54e8f 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 346bc28a36..2651d8904b 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied >= max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index beed72abbd..4ce67b95fd 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2687,6 +2687,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e48c066a5b..cf9f283cfe 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -166,6 +166,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e1..a44472b352 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.34.1
v61-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchapplication/octet-stream; name=v61-0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32.patchDownload
From 6a9eb58e98194ba2a977b473fc09a60393e2fda6 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH v61 1/4] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Maxim Orlov, Aleksander Alekseev. With privious input from Alexander Korotkov,
Teodor Sigaev, Nikita Glukhov, Pavel Borisov, Yura Sokolov.
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 64 ++++----
src/backend/access/transam/commit_ts.c | 52 ++++---
src/backend/access/transam/multixact.c | 62 ++++----
src/backend/access/transam/slru.c | 140 ++++++++++++------
src/backend/access/transam/subtrans.c | 34 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 32 ++--
18 files changed, 299 insertions(+), 202 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da..6b367622ca 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd507..6a1a6413f1 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca18..e423a3da5e 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d5876..cc60eab1e2 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,17 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +99,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +172,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +246,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +255,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +281,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +347,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +421,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +647,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +707,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +744,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +764,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +783,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +848,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +887,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +940,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +959,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +973,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1001,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc70..502a3d6068 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,17 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/COMMIT_TS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +112,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +179,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +223,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +275,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +532,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +579,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +672,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +805,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +843,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +928,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +947,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +958,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +983,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57ed34c0a8..db3423f12e 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9ed24e1185..ab62edf335 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,33 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ {
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ Assert(segno >= 0 && segno <= INT64CONST(0xFFFFFFFFFFFFFFF));
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ }
+ else
+ {
+ /*
+ * Despite the fact that %04X format string is used up to 24 bit
+ * integers are allowed. See SlruCorrectSegmentFilenameLength()
+ */
+ Assert(segno >= 0 && segno <= INT64CONST(0xFFFFFF));
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +100,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +163,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +188,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +213,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +252,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +292,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +305,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +420,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +520,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +567,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +651,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +709,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +781,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +956,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1041,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1052,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1096,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1186,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1251,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1329,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1352,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1416,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1432,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1525,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1541,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1557,34 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * XXX should we still consider such names to be valid?
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1606,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1616,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167..64673eaef6 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,16 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +72,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +82,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +117,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +202,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +243,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +259,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +317,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +347,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +369,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 38ddae08b8..346bc28a36 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index a794546db3..eb684fa544 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073..8fd99ba670 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51..11fa3a922d 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 552cc19e68..7a1ec405af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f32693..4b25961249 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 963cc82125..d0af1d902a 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205..4e5e562b43 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df01..202e8da3fd 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c47..5ae8a332ff 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -213,6 +214,11 @@ test_slru_page_precedes_logically(int page1, int page2)
static void
test_slru_shmem_startup(void)
{
+ /*
+ * Short segments names are well tested elsewhere so in this test we
+ * are focusing on long names.
+ */
+ const bool long_segment_names = true;
const char slru_dir_name[] = "pg_test_slru";
int test_tranche_id;
@@ -233,7 +239,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, long_segment_names);
}
void
--
2.34.1
Alexander, Maxim,
Thank you for revisions.
On Thu, Nov 9, 2023 at 6:22 PM Maxim Orlov <orlovmg@gmail.com> wrote:
Aleksander Alekseev,
Maxim,
I see both of us accounted for Alexanders feedback and submitted v59.
Your newer version seems to have issues on cfbot, so resubmitting the
previous patchset that passes the tests. Please feel free to add
changes.For unknown reasons, I do not receive any of your emails from after 2023-11-07 11:57:12 (Message-ID: CAJ7c6TN1hKqNPGrNcq96SUyD=Z61raKGXF8iqq36qr90oudxRg@mail.gmail.com).
Even after resend.Anyway, PFA patch set of version 61. I've made some minor changes in the 0001 and add 004 in order to test actual 64-bit SLRU pages.
As for CF bot had failed on my v59 patch set, this is because of the bug. It's manifested because of added 64-bit pages tests.
The problem was in segno calculation, since we convert it from file name using strtol call. But strtol return long,
which is 4 byte long in x86.- segno = (int) strtol(clde->d_name, NULL, 16); + segno = strtoi64(clde->d_name, NULL, 16);
v61 looks good to me. I'm going to push it as long as there are no objections.
------
Regards,
Alexander Korotkov
Hello Alexander,
27.11.2023 02:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no objections.
I've looked at the patch set and found a typo:
occured
And a warning:
$ CC=gcc-12 CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-clobbered
-Wno-missing-field-initializers" ./configure -q && make -s
slru.c:63:1: warning: ‘inline’ is not at beginning of declaration [-Wold-style-declaration]
63 | static int inline
| ^~~~~~
Maybe it's worth fixing before committing...
Best regards,
Alexander
Андрей, привет!
Текущее положение у меня такое.
.
*pg_stats and range statisticsTracking statements entry timestamp in
pg_stat_statements*
Уже закоммичены.
*XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL
15)*
Если всё будет и замечаний не возникнет ок, завтра утром закоммичу.
*Add semi-join pushdown to postgres_fdw*
Переработал патч, сделал обработку условий более аккурантно. Хочу попросить
ещё 2 часа на финальное ревью и коммит.
*May be BUG. Periodic burst growth of the checkpoint_req counter on
replica.*
Сегодня вечером планирую доделать и выложить review.
------
Regards,
Alexander Korotkov
------
Regards,
Alexander Korotkov
On Mon, Nov 27, 2023 at 9:00 AM Alexander Lakhin <exclusion@gmail.com>
wrote:
Show quoted text
Hello Alexander,
27.11.2023 02:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no
objections.
I've looked at the patch set and found a typo:
occuredAnd a warning:
$ CC=gcc-12 CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare
-Wno-clobbered
-Wno-missing-field-initializers" ./configure -q && make -s
slru.c:63:1: warning: ‘inline’ is not at beginning of declaration
[-Wold-style-declaration]
63 | static int inline
| ^~~~~~Maybe it's worth fixing before committing...
Best regards,
Alexander
On 27/11/2023 01:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no objections.
This was discussed earlier, but is still present in v61:
+/* + * An internal function used by SlruScanDirectory(). + * + * Returns true if a file with a name of a given length may be a correct + * SLRU segment. + */ +static inline bool +SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len) +{ + if (ctl->long_segment_names) + return (len == 15); /* see SlruFileName() */ + else + /* + * Commit 638cf09e76d allowed 5-character lengths. Later commit + * 73c986adde5 allowed 6-character length. + * + * XXX should we still consider such names to be valid? + */ + return (len == 4 || len == 5 || len == 6); +} +
I think it's pretty sloppy that the "short" filenames can be 4, 5 or 6
chars long. For pg_multixact/members, which introduced the 5-char case,
I think we should always pad the filenames 5 characters, and for
commit_ts which introduced the 6 char case, always pad to 6 characters.
Instead of a "long_segment_names" boolean, how about an integer field,
to specify the length.
That means that we'll need pg_upgrade to copy pg_multixact/members files
under the new names. That should be pretty straightforward.
--
Heikki Linnakangas
Neon (https://neon.tech)
Hi, Heikki!
On Tue, 28 Nov 2023 at 13:13, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
On 27/11/2023 01:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no objections.
This was discussed earlier, but is still present in v61:
+/* + * An internal function used by SlruScanDirectory(). + * + * Returns true if a file with a name of a given length may be a correct + * SLRU segment. + */ +static inline bool +SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len) +{ + if (ctl->long_segment_names) + return (len == 15); /* see SlruFileName() */ + else + /* + * Commit 638cf09e76d allowed 5-character lengths. Later commit + * 73c986adde5 allowed 6-character length. + * + * XXX should we still consider such names to be valid? + */ + return (len == 4 || len == 5 || len == 6); +} +I think it's pretty sloppy that the "short" filenames can be 4, 5 or 6
chars long. For pg_multixact/members, which introduced the 5-char case,
I think we should always pad the filenames 5 characters, and for
commit_ts which introduced the 6 char case, always pad to 6 characters.Instead of a "long_segment_names" boolean, how about an integer field,
to specify the length.That means that we'll need pg_upgrade to copy pg_multixact/members files
under the new names. That should be pretty straightforward.
I think what's done in patch 0001 is just an extension of existing
logic and moving it into separate function.
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
I'd prefer to leave it as it is as a part of 64-bit extension patch.
Regards,
Pavel.
On 28/11/2023 12:14, Pavel Borisov wrote:
On Tue, 28 Nov 2023 at 13:13, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
On 27/11/2023 01:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no objections.
This was discussed earlier, but is still present in v61:
+/* + * An internal function used by SlruScanDirectory(). + * + * Returns true if a file with a name of a given length may be a correct + * SLRU segment. + */ +static inline bool +SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len) +{ + if (ctl->long_segment_names) + return (len == 15); /* see SlruFileName() */ + else + /* + * Commit 638cf09e76d allowed 5-character lengths. Later commit + * 73c986adde5 allowed 6-character length. + * + * XXX should we still consider such names to be valid? + */ + return (len == 4 || len == 5 || len == 6); +} +I think it's pretty sloppy that the "short" filenames can be 4, 5 or 6
chars long. For pg_multixact/members, which introduced the 5-char case,
I think we should always pad the filenames 5 characters, and for
commit_ts which introduced the 6 char case, always pad to 6 characters.Instead of a "long_segment_names" boolean, how about an integer field,
to specify the length.That means that we'll need pg_upgrade to copy pg_multixact/members files
under the new names. That should be pretty straightforward.I think what's done in patch 0001 is just an extension of existing
logic and moving it into separate function.
That's right. I'm arguing that now is a good time to clean it up.
I won't insist if Alexander prefers to commit it as it is, though. But
let's at least explain how this works in the comment, instead of the XXX.
--
Heikki Linnakangas
Neon (https://neon.tech)
On Tue, 28 Nov 2023 at 14:37, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
On 28/11/2023 12:14, Pavel Borisov wrote:
On Tue, 28 Nov 2023 at 13:13, Heikki Linnakangas <hlinnaka@iki.fi>
wrote:
On 27/11/2023 01:43, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no
objections.
This was discussed earlier, but is still present in v61:
+/* + * An internal function used by SlruScanDirectory(). + * + * Returns true if a file with a name of a given length may be acorrect
+ * SLRU segment. + */ +static inline bool +SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len) +{ + if (ctl->long_segment_names) + return (len == 15); /* see SlruFileName() */ + else + /* + * Commit 638cf09e76d allowed 5-character lengths. Latercommit
+ * 73c986adde5 allowed 6-character length. + * + * XXX should we still consider such names to be valid? + */ + return (len == 4 || len == 5 || len == 6); +} +I think it's pretty sloppy that the "short" filenames can be 4, 5 or 6
chars long. For pg_multixact/members, which introduced the 5-char case,
I think we should always pad the filenames 5 characters, and for
commit_ts which introduced the 6 char case, always pad to 6 characters.Instead of a "long_segment_names" boolean, how about an integer field,
to specify the length.That means that we'll need pg_upgrade to copy pg_multixact/members files
under the new names. That should be pretty straightforward.I think what's done in patch 0001 is just an extension of existing
logic and moving it into separate function.That's right. I'm arguing that now is a good time to clean it up.
I won't insist if Alexander prefers to commit it as it is, though. But
let's at least explain how this works in the comment, instead of the XXX.
I agree with you that would be good to add a comment instead of XXX and
commit.
Pavel
Hi,
I think what's done in patch 0001 is just an extension of existing
logic and moving it into separate function.That's right. I'm arguing that now is a good time to clean it up.
I won't insist if Alexander prefers to commit it as it is, though. But
let's at least explain how this works in the comment, instead of the XXX.I agree with you that would be good to add a comment instead of XXX and commit.
+1
One could argue that getting rid of short filenames entirely in the
long term (i.e. always long_segment_names == true) could be a better
strategy. Maybe it's not but I believe this should be discussed
separately from the patchset under question.
--
Best regards,
Aleksander Alekseev
Hi!
On Tue, Nov 28, 2023 at 2:06 PM Aleksander Alekseev
<aleksander@timescale.com> wrote:
I think what's done in patch 0001 is just an extension of existing
logic and moving it into separate function.That's right. I'm arguing that now is a good time to clean it up.
I won't insist if Alexander prefers to commit it as it is, though. But
let's at least explain how this works in the comment, instead of the XXX.I agree with you that would be good to add a comment instead of XXX and commit.
+1
One could argue that getting rid of short filenames entirely in the
long term (i.e. always long_segment_names == true) could be a better
strategy. Maybe it's not but I believe this should be discussed
separately from the patchset under question.
Heikki, thank you for catching this.
This mess with file names formats already lasts quite long. I don't
think we should hurry unifying this as long as we're anyway going to
change that in near future.
Please, find the revised patchset with relevant comment.
------
Regards,
Alexander Korotkov
Attachments:
0003-Make-use-FullTransactionId-in-2PC-filenames-v62.patchapplication/octet-stream; name=0003-Make-use-FullTransactionId-in-2PC-filenames-v62.patchDownload
From d2c9ecbd415965690f64c056964a2084095347af Mon Sep 17 00:00:00 2001
From: Maxim Orlov <orlovmg@gmail.com>
Date: Mon, 20 Mar 2023 18:23:55 +0300
Subject: [PATCH 3/4] Make use FullTransactionId in 2PC filenames
Switch from using TransactionId to FullTransactionId in naming of 2PC files.
Transaction state file in the pg_twophase directory now have extra 8 bytes in
the name to address an epoch of a given xid.
Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/transam/twophase.c | 50 ++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index c6af8cfd7e2..0a850f4dc4e 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -942,8 +942,46 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
/* State file support */
/************************************************************************/
-#define TwoPhaseFilePath(path, xid) \
- snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X", xid)
+/*
+ * Compute the FullTransactionId for the given TransactionId.
+ *
+ * The wrap logic is safe here because the span of active xids cannot exceed one
+ * epoch at any given time.
+ */
+static inline FullTransactionId
+AdjustToFullTransactionId(TransactionId xid)
+{
+ FullTransactionId nextFullXid;
+ TransactionId nextXid;
+ uint32 epoch;
+
+ Assert(TransactionIdIsValid(xid));
+
+ LWLockAcquire(XidGenLock, LW_SHARED);
+ nextFullXid = ShmemVariableCache->nextXid;
+ LWLockRelease(XidGenLock);
+
+ nextXid = XidFromFullTransactionId(nextFullXid);
+ epoch = EpochFromFullTransactionId(nextFullXid);
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
+ epoch--;
+ }
+
+ return FullTransactionIdFromEpochAndXid(epoch, xid);
+}
+
+static inline int
+TwoPhaseFilePath(char *path, TransactionId xid)
+{
+ FullTransactionId fxid = AdjustToFullTransactionId(xid);
+
+ return snprintf(path, MAXPGPATH, TWOPHASE_DIR "/%08X%08X",
+ EpochFromFullTransactionId(fxid),
+ XidFromFullTransactionId(fxid));
+}
/*
* 2PC state file format:
@@ -1882,13 +1920,15 @@ restoreTwoPhaseData(void)
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
{
- if (strlen(clde->d_name) == 8 &&
- strspn(clde->d_name, "0123456789ABCDEF") == 8)
+ if (strlen(clde->d_name) == 16 &&
+ strspn(clde->d_name, "0123456789ABCDEF") == 16)
{
TransactionId xid;
+ FullTransactionId fxid;
char *buf;
- xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
+ fxid = FullTransactionIdFromU64(strtou64(clde->d_name, NULL, 16));
+ xid = XidFromFullTransactionId(fxid);
buf = ProcessTwoPhaseBuffer(xid, InvalidXLogRecPtr,
true, false, false);
--
2.39.3 (Apple Git-145)
0002-Use-larger-segment-file-names-for-pg_notify-v62.patchapplication/octet-stream; name=0002-Use-larger-segment-file-names-for-pg_notify-v62.patchDownload
From 1738577b90e285b8dd077d5f8adac51874e3482c Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Tue, 7 Mar 2023 15:45:03 +0300
Subject: [PATCH 2/4] Use larger segment file names for pg_notify
This avoids the wraparound in async.c and removes the corresponding code
complexity. The maximum amount of allocated SLRU pages for NOTIFY / LISTEN
queue is now determined by the max_notify_queue_pages GUC. The default
value is 1048576. It allows to consume up to 8 GB of disk space which is
exactly the limit we had previously.
Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
doc/src/sgml/config.sgml | 16 +++
doc/src/sgml/ref/listen.sgml | 1 +
doc/src/sgml/ref/notify.sgml | 1 +
src/backend/commands/async.c | 122 +++++-------------
src/backend/utils/misc/guc_tables.c | 10 ++
src/backend/utils/misc/postgresql.conf.sample | 3 +
src/include/commands/async.h | 1 +
7 files changed, 62 insertions(+), 92 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 93735e3aea5..94d1eb2b81a 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2151,6 +2151,22 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages">
+ <term><varname>max_notify_queue_pages</varname> (<type>integer</type>)
+ <indexterm>
+ <primary><varname>max_notify_queue_pages</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Specifies the maximum amount of allocated pages for
+ <xref linkend="sql-notify"/> / <xref linkend="sql-listen"/> queue.
+ The default value is 1048576. For 8 KB pages it allows to consume
+ up to 8 GB of disk space.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 2fab9d65a10..6c1f09bd455 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -148,6 +148,7 @@ Asynchronous notification "virtual" received from server process with PID 8448.
<simplelist type="inline">
<member><xref linkend="sql-notify"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index d7dcbea02d4..fd6ed54e8f9 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -228,6 +228,7 @@ Asynchronous notification "foo" with payload "payload" received from server proc
<simplelist type="inline">
<member><xref linkend="sql-listen"/></member>
<member><xref linkend="sql-unlisten"/></member>
+ <member><xref linkend="guc-max-notify-queue-pages"/></member>
</simplelist>
</refsect1>
</refentry>
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 346bc28a36f..2651d8904b6 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -103,12 +103,11 @@
* until we reach either a notification from an uncommitted transaction or
* the head pointer's position.
*
- * 6. To avoid SLRU wraparound and limit disk space consumption, the tail
- * pointer needs to be advanced so that old pages can be truncated.
- * This is relatively expensive (notably, it requires an exclusive lock),
- * so we don't want to do it often. We make sending backends do this work
- * if they advanced the queue head into a new page, but only once every
- * QUEUE_CLEANUP_DELAY pages.
+ * 6. To limit disk space consumption, the tail pointer needs to be advanced
+ * so that old pages can be truncated. This is relatively expensive
+ * (notably, it requires an exclusive lock), so we don't want to do it
+ * often. We make sending backends do this work if they advanced the queue
+ * head into a new page, but only once every QUEUE_CLEANUP_DELAY pages.
*
* An application that listens on the same channel it notifies will get
* NOTIFY messages for its own NOTIFYs. These can be ignored, if not useful,
@@ -120,7 +119,7 @@
* The amount of shared memory used for notify management (NUM_NOTIFY_BUFFERS)
* can be varied without affecting anything but performance. The maximum
* amount of notification data that can be queued at one time is determined
- * by slru.c's wraparound limit; see QUEUE_MAX_PAGE below.
+ * by max_notify_queue_pages GUC.
*-------------------------------------------------------------------------
*/
@@ -312,23 +311,8 @@ static SlruCtlData NotifyCtlData;
#define NotifyCtl (&NotifyCtlData)
#define QUEUE_PAGESIZE BLCKSZ
-#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
-/*
- * Use segments 0000 through FFFF. Each contains SLRU_PAGES_PER_SEGMENT pages
- * which gives us the pages from 0 to SLRU_PAGES_PER_SEGMENT * 0x10000 - 1.
- * We could use as many segments as SlruScanDirectory() allows, but this gives
- * us so much space already that it doesn't seem worth the trouble.
- *
- * The most data we can have in the queue at a time is QUEUE_MAX_PAGE/2
- * pages, because more than that would confuse slru.c into thinking there
- * was a wraparound condition. With the default BLCKSZ this means there
- * can be up to 8GB of queued-and-not-read data.
- *
- * Note: it's possible to redefine QUEUE_MAX_PAGE with a smaller multiple of
- * SLRU_PAGES_PER_SEGMENT, for easier testing of queue-full behaviour.
- */
-#define QUEUE_MAX_PAGE (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+#define QUEUE_FULL_WARN_INTERVAL 5000 /* warn at most once every 5s */
/*
* listenChannels identifies the channels we are actually listening to
@@ -439,12 +423,15 @@ static bool amRegisteredListener = false;
/* have we advanced to a page that's a multiple of QUEUE_CLEANUP_DELAY? */
static bool tryAdvanceTail = false;
-/* GUC parameter */
+/* GUC parameters */
bool Trace_notify = false;
+/* For 8 KB pages this gives 8 GB of disk space */
+int max_notify_queue_pages = 1048576;
+
/* local function prototypes */
-static int64 asyncQueuePageDiff(int64 p, int64 q);
-static bool asyncQueuePagePrecedes(int64 p, int64 q);
+static inline int64 asyncQueuePageDiff(int64 p, int64 q);
+static inline bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -474,39 +461,23 @@ static int notification_match(const void *key1, const void *key2, Size keysize);
static void ClearPendingActionsAndNotifies(void);
/*
- * Compute the difference between two queue page numbers (i.e., p - q),
- * accounting for wraparound.
+ * Compute the difference between two queue page numbers.
+ * Previously this function accounted for a wraparound.
*/
-static int64
+static inline int64
asyncQueuePageDiff(int64 p, int64 q)
{
- int64 diff;
-
- /*
- * We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
- * in the range 0..QUEUE_MAX_PAGE.
- */
- Assert(p >= 0 && p <= QUEUE_MAX_PAGE);
- Assert(q >= 0 && q <= QUEUE_MAX_PAGE);
-
- diff = p - q;
- if (diff >= ((QUEUE_MAX_PAGE + 1) / 2))
- diff -= QUEUE_MAX_PAGE + 1;
- else if (diff < -((QUEUE_MAX_PAGE + 1) / 2))
- diff += QUEUE_MAX_PAGE + 1;
- return diff;
+ return p - q;
}
/*
- * Is p < q, accounting for wraparound?
- *
- * Since asyncQueueIsFull() blocks creation of a page that could precede any
- * extant page, we need not assess entries within a page.
+ * Determines whether p precedes q.
+ * Previously this function accounted for a wraparound.
*/
-static bool
+static inline bool
asyncQueuePagePrecedes(int64 p, int64 q)
{
- return asyncQueuePageDiff(p, q) < 0;
+ return p < q;
}
/*
@@ -566,12 +537,13 @@ AsyncShmemInit(void)
}
/*
- * Set up SLRU management of the pg_notify data.
+ * Set up SLRU management of the pg_notify data. Note that long segment
+ * names are used in order to avoid wraparound.
*/
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE, false);
+ SYNC_HANDLER_NONE, true);
if (!found)
{
@@ -1305,27 +1277,11 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int nexthead;
- int boundary;
+ int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int occupied = headPage - tailPage;
- /*
- * The queue is full if creating a new head page would create a page that
- * logically precedes the current global tail pointer, ie, the head
- * pointer would wrap around compared to the tail. We cannot create such
- * a head page for fear of confusing slru.c. For safety we round the tail
- * pointer back to a segment boundary (truncation logic in
- * asyncQueueAdvanceTail does not do this, so doing it here is optional).
- *
- * Note that this test is *not* dependent on how much space there is on
- * the current head page. This is necessary because asyncQueueAddEntries
- * might try to create the next head page in any case.
- */
- nexthead = QUEUE_POS_PAGE(QUEUE_HEAD) + 1;
- if (nexthead > QUEUE_MAX_PAGE)
- nexthead = 0; /* wrap around */
- boundary = QUEUE_STOP_PAGE;
- boundary -= boundary % SLRU_PAGES_PER_SEGMENT;
- return asyncQueuePagePrecedes(nexthead, boundary);
+ return occupied >= max_notify_queue_pages;
}
/*
@@ -1355,8 +1311,6 @@ asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
if (offset + QUEUEALIGN(AsyncQueueEntryEmptySize) > QUEUE_PAGESIZE)
{
pageno++;
- if (pageno > QUEUE_MAX_PAGE)
- pageno = 0; /* wrap around */
offset = 0;
pageJump = true;
}
@@ -1433,9 +1387,6 @@ asyncQueueAddEntries(ListCell *nextNotify)
* If this is the first write since the postmaster started, we need to
* initialize the first page of the async SLRU. Otherwise, the current
* page should be initialized already, so just fetch it.
- *
- * (We could also take the first path when the SLRU position has just
- * wrapped around, but re-zeroing the page is harmless in that case.)
*/
pageno = QUEUE_POS_PAGE(queue_head);
if (QUEUE_POS_IS_ZERO(queue_head))
@@ -1548,20 +1499,12 @@ asyncQueueUsage(void)
{
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied;
-
- occupied = headPage - tailPage;
+ int occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
- if (occupied < 0)
- {
- /* head has wrapped around, tail not yet */
- occupied += QUEUE_MAX_PAGE + 1;
- }
-
- return (double) occupied / (double) ((QUEUE_MAX_PAGE + 1) / 2);
+ return (double) occupied / (double) max_notify_queue_pages;
}
/*
@@ -2209,11 +2152,6 @@ asyncQueueAdvanceTail(void)
*/
SimpleLruTruncate(NotifyCtl, newtailpage);
- /*
- * Update QUEUE_STOP_PAGE. This changes asyncQueueIsFull()'s verdict
- * for the segment immediately prior to the old tail, allowing fresh
- * data into that segment.
- */
LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE);
QUEUE_STOP_PAGE = newtailpage;
LWLockRelease(NotifyQueueLock);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index b764ef69980..5c6f5af8736 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2687,6 +2687,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"max_notify_queue_pages", PGC_POSTMASTER, RESOURCES_DISK,
+ gettext_noop("Sets the maximum number of allocated pages for NOTIFY / LISTEN queue."),
+ NULL,
+ },
+ &max_notify_queue_pages,
+ 1048576, 64, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"wal_decode_buffer_size", PGC_POSTMASTER, WAL_RECOVERY,
gettext_noop("Buffer size for reading ahead in the WAL during recovery."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e48c066a5b1..cf9f283cfee 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -166,6 +166,9 @@
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
+#max_notify_queue_pages = 1048576 # limits the number of SLRU pages allocated
+ # for NOTIFY / LISTEN queue
+
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index 02da6ba7e11..a44472b3526 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -21,6 +21,7 @@
#define NUM_NOTIFY_BUFFERS 8
extern PGDLLIMPORT bool Trace_notify;
+extern PGDLLIMPORT int max_notify_queue_pages;
extern PGDLLIMPORT volatile sig_atomic_t notifyInterruptPending;
extern Size AsyncShmemSize(void);
--
2.39.3 (Apple Git-145)
0004-Add-SLRU-tests-for-64-bit-page-case-v62.patchapplication/octet-stream; name=0004-Add-SLRU-tests-for-64-bit-page-case-v62.patchDownload
From 68168d5f85ff1638eccb37273465fb5a13dfa3b0 Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Thu, 9 Nov 2023 18:02:25 +0300
Subject: [PATCH 4/4] Add SLRU tests for 64-bit page case
Previously, we add 64-bit naming for SLRU segments. But no tests for the actual
64-bit pages were provided.
Author: Maxim Orlov
Reviewed-by: Aleksander Alekseev, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
.../modules/test_slru/expected/test_slru.out | 135 ++++++++++++++++++
src/test/modules/test_slru/sql/test_slru.sql | 38 +++++
2 files changed, 173 insertions(+)
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 4e5e562b434..185c56e5d62 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -132,4 +132,139 @@ SELECT test_slru_page_exists(12393);
f
(1 row)
+--
+-- Test 64-bit pages
+--
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU 64-bit');
+ test_slru_page_write
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_read(0x1234500000000);
+ test_slru_page_read
+---------------------
+ Test SLRU 64-bit
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU 64-bit'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+ count
+-------
+ 48
+(1 row)
+
+-- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000020, true);
+ test_slru_page_read
+---------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000020);
+ test_slru_page_readonly
+-------------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+ test_slru_page_readonly
+-------------------------
+ Test SLRU 64-bit
+(1 row)
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+ test_slru_page_writeall
+-------------------------
+
+(1 row)
+
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000030);
+NOTICE: Called SlruSyncFileTag() for segment 10007944888321 on path pg_test_slru/000091A28000001
+ test_slru_page_sync
+---------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ t
+(1 row)
+
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+NOTICE: Called SlruDeleteSegment() for segment 10007944888321
+ test_slru_page_delete
+-----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_truncate(0x1234500000020);
+ test_slru_page_truncate
+-------------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+-- Full deletion
+SELECT test_slru_delete_all();
+ test_slru_delete_all
+----------------------
+
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000000);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000020);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
+SELECT test_slru_page_exists(0x1234500000030);
+ test_slru_page_exists
+-----------------------
+ f
+(1 row)
+
DROP EXTENSION test_slru;
diff --git a/src/test/modules/test_slru/sql/test_slru.sql b/src/test/modules/test_slru/sql/test_slru.sql
index fe0d1342a94..b1b376581ab 100644
--- a/src/test/modules/test_slru/sql/test_slru.sql
+++ b/src/test/modules/test_slru/sql/test_slru.sql
@@ -35,4 +35,42 @@ SELECT test_slru_page_exists(12345);
SELECT test_slru_page_exists(12377);
SELECT test_slru_page_exists(12393);
+--
+-- Test 64-bit pages
+--
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_write(0x1234500000000, 'Test SLRU 64-bit');
+SELECT test_slru_page_read(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000000);
+
+-- 48 extra pages
+SELECT count(test_slru_page_write(a, 'Test SLRU 64-bit'))
+ FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
+
+-- Reading page in buffer for read and write
+SELECT test_slru_page_read(0x1234500000020, true);
+-- Reading page in buffer for read-only
+SELECT test_slru_page_readonly(0x1234500000020);
+-- Reading page not in buffer with read-only
+SELECT test_slru_page_readonly(0x1234500000001);
+
+-- Write all the pages in buffers
+SELECT test_slru_page_writeall();
+-- Flush the last page written out.
+SELECT test_slru_page_sync(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Segment deletion
+SELECT test_slru_page_delete(0x1234500000030);
+SELECT test_slru_page_exists(0x1234500000030);
+-- Page truncation
+SELECT test_slru_page_exists(0x1234500000020);
+SELECT test_slru_page_truncate(0x1234500000020);
+SELECT test_slru_page_exists(0x1234500000020);
+
+-- Full deletion
+SELECT test_slru_delete_all();
+SELECT test_slru_page_exists(0x1234500000000);
+SELECT test_slru_page_exists(0x1234500000020);
+SELECT test_slru_page_exists(0x1234500000030);
+
DROP EXTENSION test_slru;
--
2.39.3 (Apple Git-145)
0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32-v62.patchapplication/octet-stream; name=0001-Index-SLRUs-by-64-bit-integers-rather-than-by-32-v62.patchDownload
From b926af64e98943ca04d4ce0a7b92d136d12b2a3c Mon Sep 17 00:00:00 2001
From: Maxim Orlov <m.orlov@postgrespro.ru>
Date: Fri, 11 Mar 2022 11:36:34 +0300
Subject: [PATCH 1/4] Index SLRUs by 64-bit integers rather than by 32-bit
integers
We've had repeated bugs in the area of handling SLRU wraparound in the past,
some of which have caused data loss. Switching to an indexing system for SLRUs
that does not wrap around should allow us to get rid of a whole bunch
of problems and improve the overall reliability of the system.
This particular patch however only changes the indexing and doesn't address
the wraparound per se. This is going to be done in the following patches.
Author: Maxim Orlov, Aleksander Alekseev, Alexander Korotkov, Teodor Sigaev
Author: Nikita Glukhov, Pavel Borisov, Yura Sokolov
Reviewed-by: Jacob Champion, Heikki Linnakangas, Alexander Korotkov
Reviewed-by: Japin Li, Pavel Borisov, Tom Lane, Peter Eisentraut, Andres Freund
Reviewed-by: Andrey Borodin, Dilip Kumar, Aleksander Alekseev
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
---
src/backend/access/rmgrdesc/clogdesc.c | 10 +-
src/backend/access/rmgrdesc/committsdesc.c | 10 +-
src/backend/access/rmgrdesc/mxactdesc.c | 6 +-
src/backend/access/transam/clog.c | 64 ++++----
src/backend/access/transam/commit_ts.c | 52 ++++---
src/backend/access/transam/multixact.c | 62 ++++----
src/backend/access/transam/slru.c | 142 ++++++++++++------
src/backend/access/transam/subtrans.c | 34 +++--
src/backend/commands/async.c | 20 +--
src/backend/storage/lmgr/predicate.c | 13 +-
src/include/access/clog.h | 2 +-
src/include/access/commit_ts.h | 2 +-
src/include/access/slru.h | 34 +++--
src/include/storage/proc.h | 2 +-
src/include/storage/sync.h | 2 +-
.../modules/test_slru/expected/test_slru.out | 2 +-
src/test/modules/test_slru/test_slru--1.0.sql | 14 +-
src/test/modules/test_slru/test_slru.c | 32 ++--
18 files changed, 301 insertions(+), 202 deletions(-)
diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c
index e60b76f9da6..6b367622ca4 100644
--- a/src/backend/access/rmgrdesc/clogdesc.c
+++ b/src/backend/access/rmgrdesc/clogdesc.c
@@ -25,18 +25,18 @@ clog_desc(StringInfo buf, XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "page %d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "page %lld", (long long) pageno);
}
else if (info == CLOG_TRUNCATE)
{
xl_clog_truncate xlrec;
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
- appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ appendStringInfo(buf, "page %lld; oldestXact %u",
+ (long long) xlrec.pageno, xlrec.oldestXact);
}
}
diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c
index e7155cd5072..6a1a6413f1d 100644
--- a/src/backend/access/rmgrdesc/committsdesc.c
+++ b/src/backend/access/rmgrdesc/committsdesc.c
@@ -26,17 +26,17 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == COMMIT_TS_TRUNCATE)
{
xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec;
- appendStringInfo(buf, "pageno %d, oldestXid %u",
- trunc->pageno, trunc->oldestXid);
+ appendStringInfo(buf, "pageno %lld, oldestXid %u",
+ (long long) trunc->pageno, trunc->oldestXid);
}
}
diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c
index a2fa1eca181..e423a3da5e0 100644
--- a/src/backend/access/rmgrdesc/mxactdesc.c
+++ b/src/backend/access/rmgrdesc/mxactdesc.c
@@ -55,10 +55,10 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
- memcpy(&pageno, rec, sizeof(int));
- appendStringInfo(buf, "%d", pageno);
+ memcpy(&pageno, rec, sizeof(pageno));
+ appendStringInfo(buf, "%lld", (long long) pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a431d58767..cc60eab1e21 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -62,7 +62,17 @@
#define CLOG_XACTS_PER_PAGE (BLCKSZ * CLOG_XACTS_PER_BYTE)
#define CLOG_XACT_BITMASK ((1 << CLOG_BITS_PER_XACT) - 1)
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) CLOG_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/CLOG_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) CLOG_XACTS_PER_PAGE;
+}
+
#define TransactionIdToPgIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_PAGE)
#define TransactionIdToByte(xid) (TransactionIdToPgIndex(xid) / CLOG_XACTS_PER_BYTE)
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
@@ -89,24 +99,24 @@ static SlruCtlData XactCtlData;
#define XactCtl (&XactCtlData)
-static int ZeroCLOGPage(int pageno, bool writeXlog);
-static bool CLOGPagePrecedes(int page1, int page2);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
+static int ZeroCLOGPage(int64 pageno, bool writeXlog);
+static bool CLOGPagePrecedes(int64 page1, int64 page2);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact,
Oid oldestXactDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page);
static void TransactionIdSetStatusBit(TransactionId xid, XidStatus status,
XLogRecPtr lsn, int slotno);
static void set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn);
static bool TransactionGroupUpdateXidStatus(TransactionId xid,
- XidStatus status, XLogRecPtr lsn, int pageno);
+ XidStatus status, XLogRecPtr lsn, int64 pageno);
static void TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno);
+ XLogRecPtr lsn, int64 pageno);
/*
@@ -162,7 +172,7 @@ void
TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(xid); /* get page of parent */
+ int64 pageno = TransactionIdToPage(xid); /* get page of parent */
int i;
Assert(status == TRANSACTION_STATUS_COMMITTED ||
@@ -236,7 +246,7 @@ static void
set_status_by_pages(int nsubxids, TransactionId *subxids,
XidStatus status, XLogRecPtr lsn)
{
- int pageno = TransactionIdToPage(subxids[0]);
+ int64 pageno = TransactionIdToPage(subxids[0]);
int offset = 0;
int i = 0;
@@ -245,7 +255,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
while (i < nsubxids)
{
int num_on_page = 0;
- int nextpageno;
+ int64 nextpageno;
do
{
@@ -271,7 +281,7 @@ set_status_by_pages(int nsubxids, TransactionId *subxids,
static void
TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno,
+ XLogRecPtr lsn, int64 pageno,
bool all_xact_same_page)
{
/* Can't use group update when PGPROC overflows. */
@@ -337,7 +347,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
int slotno;
int i;
@@ -411,7 +421,7 @@ TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
*/
static bool
TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
- XLogRecPtr lsn, int pageno)
+ XLogRecPtr lsn, int64 pageno)
{
volatile PROC_HDR *procglobal = ProcGlobal;
PGPROC *proc = MyProc;
@@ -637,7 +647,7 @@ TransactionIdSetStatusBit(TransactionId xid, XidStatus status, XLogRecPtr lsn, i
XidStatus
TransactionIdGetStatus(TransactionId xid, XLogRecPtr *lsn)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int byteno = TransactionIdToByte(xid);
int bshift = TransactionIdToBIndex(xid) * CLOG_BITS_PER_XACT;
int slotno;
@@ -697,7 +707,7 @@ CLOGShmemInit(void)
XactCtl->PagePrecedes = CLOGPagePrecedes;
SimpleLruInit(XactCtl, "Xact", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
XactSLRULock, "pg_xact", LWTRANCHE_XACT_BUFFER,
- SYNC_HANDLER_CLOG);
+ SYNC_HANDLER_CLOG, false);
SlruPagePrecedesUnitTests(XactCtl, CLOG_XACTS_PER_PAGE);
}
@@ -734,7 +744,7 @@ BootStrapCLOG(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCLOGPage(int pageno, bool writeXlog)
+ZeroCLOGPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -754,7 +764,7 @@ void
StartupCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -773,7 +783,7 @@ void
TrimCLOG(void)
{
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
@@ -838,7 +848,7 @@ CheckPointCLOG(void)
void
ExtendCLOG(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -877,7 +887,7 @@ ExtendCLOG(TransactionId newestXact)
void
TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -930,7 +940,7 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid)
* don't optimize that edge case.
*/
static bool
-CLOGPagePrecedes(int page1, int page2)
+CLOGPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -949,10 +959,10 @@ CLOGPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE);
}
@@ -963,7 +973,7 @@ WriteZeroPageXlogRec(int pageno)
* in TruncateCLOG().
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXact, Oid oldestXactDb)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXact, Oid oldestXactDb)
{
XLogRecPtr recptr;
xl_clog_truncate xlrec;
@@ -991,10 +1001,10 @@ clog_redo(XLogReaderState *record)
if (info == CLOG_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index b897fabc702..502a3d6068f 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -65,8 +65,17 @@ typedef struct CommitTimestampEntry
#define COMMIT_TS_XACTS_PER_PAGE \
(BLCKSZ / SizeOfCommitTimestampEntry)
-#define TransactionIdToCTsPage(xid) \
- ((xid) / (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
+
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/COMMIT_TS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToCTsPage(TransactionId xid)
+{
+ return xid / (int64) COMMIT_TS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToCTsEntry(xid) \
((xid) % (TransactionId) COMMIT_TS_XACTS_PER_PAGE)
@@ -103,16 +112,16 @@ bool track_commit_timestamp;
static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno);
+ RepOriginId nodeid, int64 pageno);
static void TransactionIdSetCommitTs(TransactionId xid, TimestampTz ts,
RepOriginId nodeid, int slotno);
static void error_commit_ts_disabled(void);
-static int ZeroCommitTsPage(int pageno, bool writeXlog);
-static bool CommitTsPagePrecedes(int page1, int page2);
+static int ZeroCommitTsPage(int64 pageno, bool writeXlog);
+static bool CommitTsPagePrecedes(int64 page1, int64 page2);
static void ActivateCommitTs(void);
static void DeactivateCommitTs(void);
-static void WriteZeroPageXlogRec(int pageno);
-static void WriteTruncateXlogRec(int pageno, TransactionId oldestXid);
+static void WriteZeroPageXlogRec(int64 pageno);
+static void WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid);
/*
* TransactionTreeSetCommitTsData
@@ -170,7 +179,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
i = 0;
for (;;)
{
- int pageno = TransactionIdToCTsPage(headxid);
+ int64 pageno = TransactionIdToCTsPage(headxid);
int j;
for (j = i; j < nsubxids; j++)
@@ -214,7 +223,7 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
static void
SetXidCommitTsInPage(TransactionId xid, int nsubxids,
TransactionId *subxids, TimestampTz ts,
- RepOriginId nodeid, int pageno)
+ RepOriginId nodeid, int64 pageno)
{
int slotno;
int i;
@@ -266,7 +275,7 @@ bool
TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
RepOriginId *nodeid)
{
- int pageno = TransactionIdToCTsPage(xid);
+ int64 pageno = TransactionIdToCTsPage(xid);
int entryno = TransactionIdToCTsEntry(xid);
int slotno;
CommitTimestampEntry entry;
@@ -523,7 +532,8 @@ CommitTsShmemInit(void)
SimpleLruInit(CommitTsCtl, "CommitTs", CommitTsShmemBuffers(), 0,
CommitTsSLRULock, "pg_commit_ts",
LWTRANCHE_COMMITTS_BUFFER,
- SYNC_HANDLER_COMMIT_TS);
+ SYNC_HANDLER_COMMIT_TS,
+ false);
SlruPagePrecedesUnitTests(CommitTsCtl, COMMIT_TS_XACTS_PER_PAGE);
commitTsShared = ShmemInitStruct("CommitTs shared",
@@ -569,7 +579,7 @@ BootStrapCommitTs(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroCommitTsPage(int pageno, bool writeXlog)
+ZeroCommitTsPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -662,7 +672,7 @@ static void
ActivateCommitTs(void)
{
TransactionId xid;
- int pageno;
+ int64 pageno;
/* If we've done this already, there's nothing to do */
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
@@ -795,7 +805,7 @@ CheckPointCommitTs(void)
void
ExtendCommitTs(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* Nothing to do if module not enabled. Note we do an unlocked read of
@@ -833,7 +843,7 @@ ExtendCommitTs(TransactionId newestXact)
void
TruncateCommitTs(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -918,7 +928,7 @@ AdvanceOldestCommitTsXid(TransactionId oldestXact)
* oldestXact=N+2.1, it would be precious at oldestXact=N+2.9.
*/
static bool
-CommitTsPagePrecedes(int page1, int page2)
+CommitTsPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -937,10 +947,10 @@ CommitTsPagePrecedes(int page1, int page2)
* Write a ZEROPAGE xlog record
*/
static void
-WriteZeroPageXlogRec(int pageno)
+WriteZeroPageXlogRec(int64 pageno)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_COMMIT_TS_ID, COMMIT_TS_ZEROPAGE);
}
@@ -948,7 +958,7 @@ WriteZeroPageXlogRec(int pageno)
* Write a TRUNCATE xlog record
*/
static void
-WriteTruncateXlogRec(int pageno, TransactionId oldestXid)
+WriteTruncateXlogRec(int64 pageno, TransactionId oldestXid)
{
xl_commit_ts_truncate xlrec;
@@ -973,10 +983,10 @@ commit_ts_redo(XLogReaderState *record)
if (info == COMMIT_TS_ZEROPAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(CommitTsSLRULock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 57ed34c0a88..db3423f12e2 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -354,10 +354,10 @@ static void mXactCachePut(MultiXactId multi, int nmembers,
static char *mxstatus_to_string(MultiXactStatus status);
/* management of SLRU infrastructure */
-static int ZeroMultiXactOffsetPage(int pageno, bool writeXlog);
-static int ZeroMultiXactMemberPage(int pageno, bool writeXlog);
-static bool MultiXactOffsetPagePrecedes(int page1, int page2);
-static bool MultiXactMemberPagePrecedes(int page1, int page2);
+static int ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog);
+static int ZeroMultiXactMemberPage(int64 pageno, bool writeXlog);
+static bool MultiXactOffsetPagePrecedes(int64 page1, int64 page2);
+static bool MultiXactMemberPagePrecedes(int64 page1, int64 page2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
@@ -366,7 +366,7 @@ static bool MultiXactOffsetWouldWrap(MultiXactOffset boundary,
MultiXactOffset start, uint32 distance);
static bool SetOffsetVacuumLimit(bool is_startup);
static bool find_multixact_start(MultiXactId multi, MultiXactOffset *result);
-static void WriteMZeroPageXlogRec(int pageno, uint8 info);
+static void WriteMZeroPageXlogRec(int64 pageno, uint8 info);
static void WriteMTruncateXlogRec(Oid oldestMultiDB,
MultiXactId startTruncOff,
MultiXactId endTruncOff,
@@ -864,8 +864,8 @@ static void
RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
int nmembers, MultiXactMember *members)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1225,8 +1225,8 @@ int
GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
bool from_pgupgrade, bool isLockOnly)
{
- int pageno;
- int prev_pageno;
+ int64 pageno;
+ int64 prev_pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -1854,13 +1854,15 @@ MultiXactShmemInit(void)
"MultiXactOffset", NUM_MULTIXACTOFFSET_BUFFERS, 0,
MultiXactOffsetSLRULock, "pg_multixact/offsets",
LWTRANCHE_MULTIXACTOFFSET_BUFFER,
- SYNC_HANDLER_MULTIXACT_OFFSET);
+ SYNC_HANDLER_MULTIXACT_OFFSET,
+ false);
SlruPagePrecedesUnitTests(MultiXactOffsetCtl, MULTIXACT_OFFSETS_PER_PAGE);
SimpleLruInit(MultiXactMemberCtl,
"MultiXactMember", NUM_MULTIXACTMEMBER_BUFFERS, 0,
MultiXactMemberSLRULock, "pg_multixact/members",
LWTRANCHE_MULTIXACTMEMBER_BUFFER,
- SYNC_HANDLER_MULTIXACT_MEMBER);
+ SYNC_HANDLER_MULTIXACT_MEMBER,
+ false);
/* doesn't call SimpleLruTruncate() or meet criteria for unit tests */
/* Initialize our shared state struct */
@@ -1928,7 +1930,7 @@ BootStrapMultiXact(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
+ZeroMultiXactOffsetPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1944,7 +1946,7 @@ ZeroMultiXactOffsetPage(int pageno, bool writeXlog)
* Ditto, for MultiXactMember
*/
static int
-ZeroMultiXactMemberPage(int pageno, bool writeXlog)
+ZeroMultiXactMemberPage(int64 pageno, bool writeXlog)
{
int slotno;
@@ -1974,7 +1976,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
static void
MaybeExtendOffsetSlru(void)
{
- int pageno;
+ int64 pageno;
pageno = MultiXactIdToOffsetPage(MultiXactState->nextMXact);
@@ -2009,7 +2011,7 @@ StartupMultiXact(void)
{
MultiXactId multi = MultiXactState->nextMXact;
MultiXactOffset offset = MultiXactState->nextOffset;
- int pageno;
+ int64 pageno;
/*
* Initialize offset's idea of the latest page number.
@@ -2034,7 +2036,7 @@ TrimMultiXact(void)
MultiXactOffset offset;
MultiXactId oldestMXact;
Oid oldestMXactDB;
- int pageno;
+ int64 pageno;
int entryno;
int flagsoff;
@@ -2403,7 +2405,7 @@ MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB)
static void
ExtendMultiXactOffset(MultiXactId multi)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first MultiXactId of a page. But beware: just after
@@ -2452,7 +2454,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
flagsbit = MXOffsetToFlagsBitShift(offset);
if (flagsoff == 0 && flagsbit == 0)
{
- int pageno;
+ int64 pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -2735,7 +2737,7 @@ static bool
find_multixact_start(MultiXactId multi, MultiXactOffset *result)
{
MultiXactOffset offset;
- int pageno;
+ int64 pageno;
int entryno;
int slotno;
MultiXactOffset *offptr;
@@ -2854,7 +2856,7 @@ MultiXactMemberFreezeThreshold(void)
typedef struct mxtruncinfo
{
- int earliestExistingPage;
+ int64 earliestExistingPage;
} mxtruncinfo;
/*
@@ -2862,7 +2864,7 @@ typedef struct mxtruncinfo
* This callback determines the earliest existing page number.
*/
static bool
-SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
mxtruncinfo *trunc = (mxtruncinfo *) data;
@@ -3113,7 +3115,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
* translational symmetry.
*/
static bool
-MultiXactOffsetPagePrecedes(int page1, int page2)
+MultiXactOffsetPagePrecedes(int64 page1, int64 page2)
{
MultiXactId multi1;
MultiXactId multi2;
@@ -3133,7 +3135,7 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
* purposes. There is no "invalid offset number" so use the numbers verbatim.
*/
static bool
-MultiXactMemberPagePrecedes(int page1, int page2)
+MultiXactMemberPagePrecedes(int64 page1, int64 page2)
{
MultiXactOffset offset1;
MultiXactOffset offset2;
@@ -3191,10 +3193,10 @@ MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
* OFFSETs page (info shows which)
*/
static void
-WriteMZeroPageXlogRec(int pageno, uint8 info)
+WriteMZeroPageXlogRec(int64 pageno, uint8 info)
{
XLogBeginInsert();
- XLogRegisterData((char *) (&pageno), sizeof(int));
+ XLogRegisterData((char *) (&pageno), sizeof(pageno));
(void) XLogInsert(RM_MULTIXACT_ID, info);
}
@@ -3239,10 +3241,10 @@ multixact_redo(XLogReaderState *record)
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactOffsetSLRULock, LW_EXCLUSIVE);
@@ -3254,10 +3256,10 @@ multixact_redo(XLogReaderState *record)
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
- int pageno;
+ int64 pageno;
int slotno;
- memcpy(&pageno, XLogRecGetData(record), sizeof(int));
+ memcpy(&pageno, XLogRecGetData(record), sizeof(pageno));
LWLockAcquire(MultiXactMemberSLRULock, LW_EXCLUSIVE);
@@ -3299,7 +3301,7 @@ multixact_redo(XLogReaderState *record)
else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
{
xl_multixact_truncate xlrec;
- int pageno;
+ int64 pageno;
memcpy(&xlrec, XLogRecGetData(record),
SizeOfMultiXactTruncate);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 9ed24e1185c..e783160d77a 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,8 +60,33 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-#define SlruFileName(ctl, path, seg) \
- snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir, seg)
+static int inline
+SlruFileName(SlruCtl ctl, char *path, int64 segno)
+{
+ if (ctl->long_segment_names)
+ {
+ /*
+ * We could use 16 characters here but the disadvantage would be that
+ * the SLRU segments will be hard to distinguish from WAL segments.
+ *
+ * For this reason we use 15 characters. It is enough but also means
+ * that in the future we can't decrease SLRU_PAGES_PER_SEGMENT easily.
+ */
+ Assert(segno >= 0 && segno <= INT64CONST(0xFFFFFFFFFFFFFFF));
+ return snprintf(path, MAXPGPATH, "%s/%015llX", ctl->Dir,
+ (long long) segno);
+ }
+ else
+ {
+ /*
+ * Despite the fact that %04X format string is used up to 24 bit
+ * integers are allowed. See SlruCorrectSegmentFilenameLength()
+ */
+ Assert(segno >= 0 && segno <= INT64CONST(0xFFFFFF));
+ return snprintf(path, MAXPGPATH, "%s/%04X", (ctl)->Dir,
+ (unsigned int) segno);
+ }
+}
/*
* During SimpleLruWriteAll(), we will usually not need to write more than one
@@ -75,7 +100,7 @@ typedef struct SlruWriteAllData
{
int num_files; /* # files actually open */
int fd[MAX_WRITEALL_BUFFERS]; /* their FD's */
- int segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
+ int64 segno[MAX_WRITEALL_BUFFERS]; /* their log seg#s */
} SlruWriteAllData;
typedef struct SlruWriteAllData *SlruWriteAll;
@@ -138,15 +163,16 @@ static int slru_errno;
static void SimpleLruZeroLSNs(SlruCtl ctl, int slotno);
static void SimpleLruWaitIO(SlruCtl ctl, int slotno);
static void SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata);
-static bool SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno);
-static bool SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno,
+static bool SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno);
+static bool SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno,
SlruWriteAll fdata);
-static void SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid);
-static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
+static void SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid);
+static int SlruSelectLRUPage(SlruCtl ctl, int64 pageno);
static bool SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename,
- int segpage, void *data);
-static void SlruInternalDeleteSegment(SlruCtl ctl, int segno);
+ int64 segpage, void *data);
+static void SlruInternalDeleteSegment(SlruCtl ctl, int64 segno);
+
/*
* Initialization of shared memory
@@ -162,7 +188,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
sz += MAXALIGN(nslots * sizeof(char *)); /* page_buffer[] */
sz += MAXALIGN(nslots * sizeof(SlruPageStatus)); /* page_status[] */
sz += MAXALIGN(nslots * sizeof(bool)); /* page_dirty[] */
- sz += MAXALIGN(nslots * sizeof(int)); /* page_number[] */
+ sz += MAXALIGN(nslots * sizeof(int64)); /* page_number[] */
sz += MAXALIGN(nslots * sizeof(int)); /* page_lru_count[] */
sz += MAXALIGN(nslots * sizeof(LWLockPadded)); /* buffer_locks[] */
@@ -187,7 +213,7 @@ SimpleLruShmemSize(int nslots, int nlsns)
void
SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler)
+ SyncRequestHandler sync_handler, bool long_segment_names)
{
SlruShared shared;
bool found;
@@ -226,8 +252,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset += MAXALIGN(nslots * sizeof(SlruPageStatus));
shared->page_dirty = (bool *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(bool));
- shared->page_number = (int *) (ptr + offset);
- offset += MAXALIGN(nslots * sizeof(int));
+ shared->page_number = (int64 *) (ptr + offset);
+ offset += MAXALIGN(nslots * sizeof(int64));
shared->page_lru_count = (int *) (ptr + offset);
offset += MAXALIGN(nslots * sizeof(int));
@@ -266,6 +292,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
*/
ctl->shared = shared;
ctl->sync_handler = sync_handler;
+ ctl->long_segment_names = long_segment_names;
strlcpy(ctl->Dir, subdir, sizeof(ctl->Dir));
}
@@ -278,7 +305,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruZeroPage(SlruCtl ctl, int pageno)
+SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -393,7 +420,7 @@ SimpleLruWaitIO(SlruCtl ctl, int slotno)
* Control lock must be held at entry, and will be held at exit.
*/
int
-SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid)
{
SlruShared shared = ctl->shared;
@@ -493,7 +520,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
* It is unspecified whether the lock will be shared or exclusive.
*/
int
-SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
+SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -540,7 +567,7 @@ static void
SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int pageno = shared->page_number[slotno];
+ int64 pageno = shared->page_number[slotno];
bool ok;
/* If a write is in progress, wait for it to finish */
@@ -624,9 +651,9 @@ SimpleLruWritePage(SlruCtl ctl, int slotno)
* large enough to contain the given page.
*/
bool
-SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
+SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -682,10 +709,10 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
* read/write operations. We could cache one virtual file pointer ...
*/
static bool
-SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
+SlruPhysicalReadPage(SlruCtl ctl, int64 pageno, int slotno)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -754,10 +781,10 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* SimpleLruWriteAll.
*/
static bool
-SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
+SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
{
SlruShared shared = ctl->shared;
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
off_t offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -929,9 +956,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
* SlruPhysicalWritePage. Call this after cleaning up shared-memory state.
*/
static void
-SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
+SlruReportIOError(SlruCtl ctl, int64 pageno, TransactionId xid)
{
- int segno = pageno / SLRU_PAGES_PER_SEGMENT;
+ int64 segno = pageno / SLRU_PAGES_PER_SEGMENT;
int rpageno = pageno % SLRU_PAGES_PER_SEGMENT;
int offset = rpageno * BLCKSZ;
char path[MAXPGPATH];
@@ -1014,7 +1041,7 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-SlruSelectLRUPage(SlruCtl ctl, int pageno)
+SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
{
SlruShared shared = ctl->shared;
@@ -1025,10 +1052,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
int cur_count;
int bestvalidslot = 0; /* keep compiler quiet */
int best_valid_delta = -1;
- int best_valid_page_number = 0; /* keep compiler quiet */
+ int64 best_valid_page_number = 0; /* keep compiler quiet */
int bestinvalidslot = 0; /* keep compiler quiet */
int best_invalid_delta = -1;
- int best_invalid_page_number = 0; /* keep compiler quiet */
+ int64 best_invalid_page_number = 0; /* keep compiler quiet */
/* See if page already has a buffer assigned */
for (slotno = 0; slotno < shared->num_slots; slotno++)
@@ -1069,7 +1096,7 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
for (slotno = 0; slotno < shared->num_slots; slotno++)
{
int this_delta;
- int this_page_number;
+ int64 this_page_number;
if (shared->page_status[slotno] == SLRU_PAGE_EMPTY)
return slotno;
@@ -1159,7 +1186,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
SlruShared shared = ctl->shared;
SlruWriteAllData fdata;
int slotno;
- int pageno = 0;
+ int64 pageno = 0;
int i;
bool ok;
@@ -1224,7 +1251,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
* after it has accrued freshly-written data.
*/
void
-SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
+SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1302,7 +1329,7 @@ restart:
* they either can't yet contain anything, or have already been cleaned out.
*/
static void
-SlruInternalDeleteSegment(SlruCtl ctl, int segno)
+SlruInternalDeleteSegment(SlruCtl ctl, int64 segno)
{
char path[MAXPGPATH];
@@ -1325,7 +1352,7 @@ SlruInternalDeleteSegment(SlruCtl ctl, int segno)
* Delete an individual SLRU segment, identified by the segment number.
*/
void
-SlruDeleteSegment(SlruCtl ctl, int segno)
+SlruDeleteSegment(SlruCtl ctl, int64 segno)
{
SlruShared shared = ctl->shared;
int slotno;
@@ -1389,9 +1416,9 @@ restart:
* first>=cutoff && last>=cutoff: no; every page of this segment is too young
*/
static bool
-SlruMayDeleteSegment(SlruCtl ctl, int segpage, int cutoffPage)
+SlruMayDeleteSegment(SlruCtl ctl, int64 segpage, int64 cutoffPage)
{
- int seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
+ int64 seg_last_page = segpage + SLRU_PAGES_PER_SEGMENT - 1;
Assert(segpage % SLRU_PAGES_PER_SEGMENT == 0);
@@ -1405,7 +1432,7 @@ SlruPagePrecedesTestOffset(SlruCtl ctl, int per_page, uint32 offset)
{
TransactionId lhs,
rhs;
- int newestPage,
+ int64 newestPage,
oldestPage;
TransactionId newestXact,
oldestXact;
@@ -1498,9 +1525,10 @@ SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page)
* one containing the page passed as "data".
*/
bool
-SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
return true; /* found one; don't iterate any more */
@@ -1513,9 +1541,10 @@ SlruScanDirCbReportPresence(SlruCtl ctl, char *filename, int segpage, void *data
* This callback deletes segments prior to the one passed in as "data".
*/
static bool
-SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int64 segpage,
+ void *data)
{
- int cutoffPage = *(int *) data;
+ int64 cutoffPage = *(int64 *) data;
if (SlruMayDeleteSegment(ctl, segpage, cutoffPage))
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
@@ -1528,13 +1557,36 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
* This callback deletes all segments.
*/
bool
-SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage, void *data)
+SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
SlruInternalDeleteSegment(ctl, segpage / SLRU_PAGES_PER_SEGMENT);
return false; /* keep going */
}
+/*
+ * An internal function used by SlruScanDirectory().
+ *
+ * Returns true if a file with a name of a given length may be a correct
+ * SLRU segment.
+ */
+static inline bool
+SlruCorrectSegmentFilenameLength(SlruCtl ctl, size_t len)
+{
+ if (ctl->long_segment_names)
+ return (len == 15); /* see SlruFileName() */
+ else
+ /*
+ * Commit 638cf09e76d allowed 5-character lengths. Later commit
+ * 73c986adde5 allowed 6-character length.
+ *
+ * Note: There is an ongoing plan to migrate all SLRUs to 64-bit page
+ * numbers, and the corresponding 15-character file names, which may
+ * eventually deprecate the support for 4, 5, and 6-character names.
+ */
+ return (len == 4 || len == 5 || len == 6);
+}
+
/*
* Scan the SimpleLru directory and apply a callback to each file found in it.
*
@@ -1556,8 +1608,8 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool retval = false;
DIR *cldir;
struct dirent *clde;
- int segno;
- int segpage;
+ int64 segno;
+ int64 segpage;
cldir = AllocateDir(ctl->Dir);
while ((clde = ReadDir(cldir, ctl->Dir)) != NULL)
@@ -1566,10 +1618,10 @@ SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
len = strlen(clde->d_name);
- if ((len == 4 || len == 5 || len == 6) &&
+ if (SlruCorrectSegmentFilenameLength(ctl, len) &&
strspn(clde->d_name, "0123456789ABCDEF") == len)
{
- segno = (int) strtol(clde->d_name, NULL, 16);
+ segno = strtoi64(clde->d_name, NULL, 16);
segpage = segno * SLRU_PAGES_PER_SEGMENT;
elog(DEBUG2, "SlruScanDirectory invoking callback on %s/%s",
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 62bb610167c..64673eaef6b 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -51,7 +51,16 @@
/* We need four bytes per xact */
#define SUBTRANS_XACTS_PER_PAGE (BLCKSZ / sizeof(TransactionId))
-#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
+/*
+ * Although we return an int64 the actual value can't currently exceed
+ * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE.
+ */
+static inline int64
+TransactionIdToPage(TransactionId xid)
+{
+ return xid / (int64) SUBTRANS_XACTS_PER_PAGE;
+}
+
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
@@ -63,8 +72,8 @@ static SlruCtlData SubTransCtlData;
#define SubTransCtl (&SubTransCtlData)
-static int ZeroSUBTRANSPage(int pageno);
-static bool SubTransPagePrecedes(int page1, int page2);
+static int ZeroSUBTRANSPage(int64 pageno);
+static bool SubTransPagePrecedes(int64 page1, int64 page2);
/*
@@ -73,7 +82,7 @@ static bool SubTransPagePrecedes(int page1, int page2);
void
SubTransSetParent(TransactionId xid, TransactionId parent)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -108,7 +117,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent)
TransactionId
SubTransGetParent(TransactionId xid)
{
- int pageno = TransactionIdToPage(xid);
+ int64 pageno = TransactionIdToPage(xid);
int entryno = TransactionIdToEntry(xid);
int slotno;
TransactionId *ptr;
@@ -193,7 +202,8 @@ SUBTRANSShmemInit(void)
SubTransCtl->PagePrecedes = SubTransPagePrecedes;
SimpleLruInit(SubTransCtl, "Subtrans", NUM_SUBTRANS_BUFFERS, 0,
SubtransSLRULock, "pg_subtrans",
- LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SUBTRANS_BUFFER, SYNC_HANDLER_NONE,
+ false);
SlruPagePrecedesUnitTests(SubTransCtl, SUBTRANS_XACTS_PER_PAGE);
}
@@ -233,7 +243,7 @@ BootStrapSUBTRANS(void)
* Control lock must be held at entry, and will be held at exit.
*/
static int
-ZeroSUBTRANSPage(int pageno)
+ZeroSUBTRANSPage(int64 pageno)
{
return SimpleLruZeroPage(SubTransCtl, pageno);
}
@@ -249,8 +259,8 @@ void
StartupSUBTRANS(TransactionId oldestActiveXID)
{
FullTransactionId nextXid;
- int startPage;
- int endPage;
+ int64 startPage;
+ int64 endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
@@ -307,7 +317,7 @@ CheckPointSUBTRANS(void)
void
ExtendSUBTRANS(TransactionId newestXact)
{
- int pageno;
+ int64 pageno;
/*
* No work except at first XID of a page. But beware: just after
@@ -337,7 +347,7 @@ ExtendSUBTRANS(TransactionId newestXact)
void
TruncateSUBTRANS(TransactionId oldestXact)
{
- int cutoffPage;
+ int64 cutoffPage;
/*
* The cutoff point is the start of the segment containing oldestXact. We
@@ -359,7 +369,7 @@ TruncateSUBTRANS(TransactionId oldestXact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SubTransPagePrecedes(int page1, int page2)
+SubTransPagePrecedes(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 38ddae08b86..346bc28a36f 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -196,7 +196,7 @@ typedef struct AsyncQueueEntry
*/
typedef struct QueuePosition
{
- int page; /* SLRU page number */
+ int64 page; /* SLRU page number */
int offset; /* byte offset within page */
} QueuePosition;
@@ -443,8 +443,8 @@ static bool tryAdvanceTail = false;
bool Trace_notify = false;
/* local function prototypes */
-static int asyncQueuePageDiff(int p, int q);
-static bool asyncQueuePagePrecedes(int p, int q);
+static int64 asyncQueuePageDiff(int64 p, int64 q);
+static bool asyncQueuePagePrecedes(int64 p, int64 q);
static void queue_listen(ListenActionKind action, const char *channel);
static void Async_UnlistenOnExit(int code, Datum arg);
static void Exec_ListenPreCommit(void);
@@ -477,10 +477,10 @@ static void ClearPendingActionsAndNotifies(void);
* Compute the difference between two queue page numbers (i.e., p - q),
* accounting for wraparound.
*/
-static int
-asyncQueuePageDiff(int p, int q)
+static int64
+asyncQueuePageDiff(int64 p, int64 q)
{
- int diff;
+ int64 diff;
/*
* We have to compare modulo (QUEUE_MAX_PAGE+1)/2. Both inputs should be
@@ -504,7 +504,7 @@ asyncQueuePageDiff(int p, int q)
* extant page, we need not assess entries within a page.
*/
static bool
-asyncQueuePagePrecedes(int p, int q)
+asyncQueuePagePrecedes(int64 p, int64 q)
{
return asyncQueuePageDiff(p, q) < 0;
}
@@ -571,7 +571,7 @@ AsyncShmemInit(void)
NotifyCtl->PagePrecedes = asyncQueuePagePrecedes;
SimpleLruInit(NotifyCtl, "Notify", NUM_NOTIFY_BUFFERS, 0,
NotifySLRULock, "pg_notify", LWTRANCHE_NOTIFY_BUFFER,
- SYNC_HANDLER_NONE);
+ SYNC_HANDLER_NONE, false);
if (!found)
{
@@ -1336,7 +1336,7 @@ asyncQueueIsFull(void)
static bool
asyncQueueAdvance(volatile QueuePosition *position, int entryLength)
{
- int pageno = QUEUE_POS_PAGE(*position);
+ int64 pageno = QUEUE_POS_PAGE(*position);
int offset = QUEUE_POS_OFFSET(*position);
bool pageJump = false;
@@ -1409,7 +1409,7 @@ asyncQueueAddEntries(ListCell *nextNotify)
{
AsyncQueueEntry qe;
QueuePosition queue_head;
- int pageno;
+ int64 pageno;
int offset;
int slotno;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index a794546db3e..eb684fa5444 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -437,7 +437,7 @@ static void SetPossibleUnsafeConflict(SERIALIZABLEXACT *roXact, SERIALIZABLEXACT
static void ReleaseRWConflict(RWConflict conflict);
static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
-static bool SerialPagePrecedesLogically(int page1, int page2);
+static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
@@ -724,7 +724,7 @@ FlagSxactUnsafe(SERIALIZABLEXACT *sxact)
* Analogous to CLOGPagePrecedes().
*/
static bool
-SerialPagePrecedesLogically(int page1, int page2)
+SerialPagePrecedesLogically(int64 page1, int64 page2)
{
TransactionId xid1;
TransactionId xid2;
@@ -744,7 +744,7 @@ SerialPagePrecedesLogicallyUnitTests(void)
{
int per_page = SERIAL_ENTRIESPERPAGE,
offset = per_page / 2;
- int newestPage,
+ int64 newestPage,
oldestPage,
headPage,
targetPage;
@@ -809,7 +809,8 @@ SerialInit(void)
SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
SimpleLruInit(SerialSlruCtl, "Serial",
NUM_SERIAL_BUFFERS, 0, SerialSLRULock, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE);
+ LWTRANCHE_SERIAL_BUFFER, SYNC_HANDLER_NONE,
+ false);
#ifdef USE_ASSERT_CHECKING
SerialPagePrecedesLogicallyUnitTests();
#endif
@@ -842,9 +843,9 @@ static void
SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
{
TransactionId tailXid;
- int targetPage;
+ int64 targetPage;
int slotno;
- int firstZeroPage;
+ int64 firstZeroPage;
bool isNewPage;
Assert(TransactionIdIsValid(xid));
diff --git a/src/include/access/clog.h b/src/include/access/clog.h
index d99444f073f..8fd99ba670b 100644
--- a/src/include/access/clog.h
+++ b/src/include/access/clog.h
@@ -31,7 +31,7 @@ typedef int XidStatus;
typedef struct xl_clog_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXact;
Oid oldestXactDb;
} xl_clog_truncate;
diff --git a/src/include/access/commit_ts.h b/src/include/access/commit_ts.h
index 5087cdce51e..11fa3a922d9 100644
--- a/src/include/access/commit_ts.h
+++ b/src/include/access/commit_ts.h
@@ -60,7 +60,7 @@ typedef struct xl_commit_ts_set
typedef struct xl_commit_ts_truncate
{
- int pageno;
+ int64 pageno;
TransactionId oldestXid;
} xl_commit_ts_truncate;
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 552cc19e685..7a1ec405afb 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -64,7 +64,7 @@ typedef struct SlruSharedData
char **page_buffer;
SlruPageStatus *page_status;
bool *page_dirty;
- int *page_number;
+ int64 *page_number;
int *page_lru_count;
LWLockPadded *buffer_locks;
@@ -95,7 +95,7 @@ typedef struct SlruSharedData
* this is not critical data, since we use it only to avoid swapping out
* the latest page.
*/
- int latest_page_number;
+ int64 latest_page_number;
/* SLRU's index for statistics purposes (might not be unique) */
int slru_stats_idx;
@@ -127,7 +127,14 @@ typedef struct SlruCtlData
* the behavior of this callback has no functional implications.) Use
* SlruPagePrecedesUnitTests() in SLRUs meeting its criteria.
*/
- bool (*PagePrecedes) (int, int);
+ bool (*PagePrecedes) (int64, int64);
+
+ /*
+ * If true, use long segment filenames formed from lower 48 bits of the
+ * segment number, e.g. pg_xact/000000001234. Otherwise, use short filenames
+ * formed from lower 16 bits of the segment number e.g. pg_xact/1234.
+ */
+ bool long_segment_names;
/*
* Dir is set during SimpleLruInit and does not change thereafter. Since
@@ -142,11 +149,12 @@ typedef SlruCtlData *SlruCtl;
extern Size SimpleLruShmemSize(int nslots, int nlsns);
extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
LWLock *ctllock, const char *subdir, int tranche_id,
- SyncRequestHandler sync_handler);
-extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
-extern int SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
+ SyncRequestHandler sync_handler,
+ bool long_segment_names);
+extern int SimpleLruZeroPage(SlruCtl ctl, int64 pageno);
+extern int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok,
TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno,
TransactionId xid);
extern void SimpleLruWritePage(SlruCtl ctl, int slotno);
extern void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied);
@@ -155,20 +163,20 @@ extern void SlruPagePrecedesUnitTests(SlruCtl ctl, int per_page);
#else
#define SlruPagePrecedesUnitTests(ctl, per_page) do {} while (0)
#endif
-extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
-extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno);
+extern void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage);
+extern bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno);
-typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int segpage,
+typedef bool (*SlruScanCallback) (SlruCtl ctl, char *filename, int64 segpage,
void *data);
extern bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data);
-extern void SlruDeleteSegment(SlruCtl ctl, int segno);
+extern void SlruDeleteSegment(SlruCtl ctl, int64 segno);
extern int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path);
/* SlruScanDirectory public callbacks */
extern bool SlruScanDirCbReportPresence(SlruCtl ctl, char *filename,
- int segpage, void *data);
-extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int segpage,
+ int64 segpage, void *data);
+extern bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage,
void *data);
#endif /* SLRU_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index ef74f326932..4b259612495 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -281,7 +281,7 @@ struct PGPROC
TransactionId clogGroupMemberXid; /* transaction id of clog group member */
XidStatus clogGroupMemberXidStatus; /* transaction status of clog
* group member */
- int clogGroupMemberPage; /* clog page corresponding to
+ int64 clogGroupMemberPage; /* clog page corresponding to
* transaction id of clog group member */
XLogRecPtr clogGroupMemberLsn; /* WAL location of commit record for clog
* group member */
diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
index 963cc82125a..d0af1d902a7 100644
--- a/src/include/storage/sync.h
+++ b/src/include/storage/sync.h
@@ -52,7 +52,7 @@ typedef struct FileTag
int16 handler; /* SyncRequestHandler value, saving space */
int16 forknum; /* ForkNumber, saving space */
RelFileLocator rlocator;
- uint32 segno;
+ uint64 segno;
} FileTag;
extern void InitSync(void);
diff --git a/src/test/modules/test_slru/expected/test_slru.out b/src/test/modules/test_slru/expected/test_slru.out
index 0e66fdc205f..4e5e562b434 100644
--- a/src/test/modules/test_slru/expected/test_slru.out
+++ b/src/test/modules/test_slru/expected/test_slru.out
@@ -61,7 +61,7 @@ SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
-NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/0183
+NOTICE: Called SlruSyncFileTag() for segment 387 on path pg_test_slru/000000000000183
test_slru_page_sync
---------------------
diff --git a/src/test/modules/test_slru/test_slru--1.0.sql b/src/test/modules/test_slru/test_slru--1.0.sql
index 8635e7df015..202e8da3fde 100644
--- a/src/test/modules/test_slru/test_slru--1.0.sql
+++ b/src/test/modules/test_slru/test_slru--1.0.sql
@@ -1,21 +1,21 @@
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_slru" to load this file. \quit
-CREATE OR REPLACE FUNCTION test_slru_page_write(int, text) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_write(bigint, text) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_write' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_page_writeall() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_writeall' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_sync(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_sync(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_sync' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_read(int, bool DEFAULT true) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_read(bigint, bool DEFAULT true) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_read' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_readonly(int) RETURNS text
+CREATE OR REPLACE FUNCTION test_slru_page_readonly(bigint) RETURNS text
AS 'MODULE_PATHNAME', 'test_slru_page_readonly' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_exists(int) RETURNS bool
+CREATE OR REPLACE FUNCTION test_slru_page_exists(bigint) RETURNS bool
AS 'MODULE_PATHNAME', 'test_slru_page_exists' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_delete(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_delete(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_delete' LANGUAGE C;
-CREATE OR REPLACE FUNCTION test_slru_page_truncate(int) RETURNS VOID
+CREATE OR REPLACE FUNCTION test_slru_page_truncate(bigint) RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_page_truncate' LANGUAGE C;
CREATE OR REPLACE FUNCTION test_slru_delete_all() RETURNS VOID
AS 'MODULE_PATHNAME', 'test_slru_delete_all' LANGUAGE C;
diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c
index ae21444c476..5ae8a332ff5 100644
--- a/src/test/modules/test_slru/test_slru.c
+++ b/src/test/modules/test_slru/test_slru.c
@@ -51,7 +51,7 @@ static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool
-test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
+test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
{
elog(NOTICE, "Calling test_slru_scan_cb()");
return SlruScanDirCbDeleteAll(ctl, filename, segpage, data);
@@ -60,7 +60,7 @@ test_slru_scan_cb(SlruCtl ctl, char *filename, int segpage, void *data)
Datum
test_slru_page_write(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = text_to_cstring(PG_GETARG_TEXT_PP(1));
int slotno;
@@ -95,7 +95,7 @@ test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum
test_slru_page_read(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool write_ok = PG_GETARG_BOOL(1);
char *data = NULL;
int slotno;
@@ -113,7 +113,7 @@ test_slru_page_read(PG_FUNCTION_ARGS)
Datum
test_slru_page_readonly(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
char *data = NULL;
int slotno;
@@ -131,7 +131,7 @@ test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum
test_slru_page_exists(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
bool found;
LWLockAcquire(TestSLRULock, LW_EXCLUSIVE);
@@ -144,7 +144,7 @@ test_slru_page_exists(PG_FUNCTION_ARGS)
Datum
test_slru_page_sync(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
char path[MAXPGPATH];
@@ -152,8 +152,8 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruSyncFileTag(TestSlruCtl, &ftag, path);
- elog(NOTICE, "Called SlruSyncFileTag() for segment %u on path %s",
- ftag.segno, path);
+ elog(NOTICE, "Called SlruSyncFileTag() for segment %lld on path %s",
+ (long long) ftag.segno, path);
PG_RETURN_VOID();
}
@@ -161,13 +161,14 @@ test_slru_page_sync(PG_FUNCTION_ARGS)
Datum
test_slru_page_delete(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
FileTag ftag;
ftag.segno = pageno / SLRU_PAGES_PER_SEGMENT;
SlruDeleteSegment(TestSlruCtl, ftag.segno);
- elog(NOTICE, "Called SlruDeleteSegment() for segment %u", ftag.segno);
+ elog(NOTICE, "Called SlruDeleteSegment() for segment %lld",
+ (long long) ftag.segno);
PG_RETURN_VOID();
}
@@ -175,7 +176,7 @@ test_slru_page_delete(PG_FUNCTION_ARGS)
Datum
test_slru_page_truncate(PG_FUNCTION_ARGS)
{
- int pageno = PG_GETARG_INT32(0);
+ int64 pageno = PG_GETARG_INT64(0);
SimpleLruTruncate(TestSlruCtl, pageno);
PG_RETURN_VOID();
@@ -205,7 +206,7 @@ test_slru_shmem_request(void)
}
static bool
-test_slru_page_precedes_logically(int page1, int page2)
+test_slru_page_precedes_logically(int64 page1, int64 page2)
{
return page1 < page2;
}
@@ -213,6 +214,11 @@ test_slru_page_precedes_logically(int page1, int page2)
static void
test_slru_shmem_startup(void)
{
+ /*
+ * Short segments names are well tested elsewhere so in this test we
+ * are focusing on long names.
+ */
+ const bool long_segment_names = true;
const char slru_dir_name[] = "pg_test_slru";
int test_tranche_id;
@@ -233,7 +239,7 @@ test_slru_shmem_startup(void)
TestSlruCtl->PagePrecedes = test_slru_page_precedes_logically;
SimpleLruInit(TestSlruCtl, "TestSLRU",
NUM_TEST_BUFFERS, 0, TestSLRULock, slru_dir_name,
- test_tranche_id, SYNC_HANDLER_NONE);
+ test_tranche_id, SYNC_HANDLER_NONE, long_segment_names);
}
void
--
2.39.3 (Apple Git-145)
Alexander Lakhin <exclusion@gmail.com> writes:
And a warning:
$ CC=gcc-12 CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-clobbered
-Wno-missing-field-initializers" ./configure -q && make -s
slru.c:63:1: warning: ‘inline’ is not at beginning of declaration [-Wold-style-declaration]
63 | static int inline
| ^~~~~~
Maybe it's worth fixing before committing...
This should have been fixed before commit, because there are now a
dozen buildfarm animals complaining about it, as well as who-knows-
how-many developers' compilers.
calliphoridae | 2023-11-30 02:48:59 | /home/bf/bf-build/calliphoridae/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
canebrake | 2023-11-29 14:22:10 | /home/bf/bf-build/canebrake/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
culicidae | 2023-11-30 02:49:06 | /home/bf/bf-build/culicidae/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
desmoxytes | 2023-11-30 03:11:15 | /home/bf/bf-build/desmoxytes/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
flaviventris | 2023-11-30 02:53:19 | /home/bf/bf-build/flaviventris/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
francolin | 2023-11-30 02:26:08 | ../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
grassquit | 2023-11-30 02:58:36 | /home/bf/bf-build/grassquit/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
komodoensis | 2023-11-30 03:07:52 | /home/bf/bf-build/komodoensis/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
phycodurus | 2023-11-29 14:29:02 | /home/bf/bf-build/phycodurus/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
piculet | 2023-11-30 02:32:57 | ../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
pogona | 2023-11-29 14:22:31 | /home/bf/bf-build/pogona/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
rorqual | 2023-11-30 02:32:41 | ../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
serinus | 2023-11-30 02:47:05 | /home/bf/bf-build/serinus/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
skink | 2023-11-29 14:23:05 | /home/bf/bf-build/skink-master/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
taipan | 2023-11-30 03:03:52 | /home/bf/bf-build/taipan/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
tamandua | 2023-11-30 02:49:50 | /home/bf/bf-build/tamandua/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
regards, tom lane
On Thu, 30 Nov 2023 at 08:03, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Alexander Lakhin <exclusion@gmail.com> writes:
And a warning:
$ CC=gcc-12 CFLAGS="-Wall -Wextra -Wno-unused-parameter-Wno-sign-compare -Wno-clobbered
-Wno-missing-field-initializers" ./configure -q && make -s
slru.c:63:1: warning: ‘inline’ is not at beginning of declaration[-Wold-style-declaration]
63 | static int inline
| ^~~~~~Maybe it's worth fixing before committing...
This should have been fixed before commit, because there are now a
dozen buildfarm animals complaining about it, as well as who-knows-
how-many developers' compilers.calliphoridae | 2023-11-30 02:48:59 |
/home/bf/bf-build/calliphoridae/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
canebrake | 2023-11-29 14:22:10 |
/home/bf/bf-build/canebrake/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
culicidae | 2023-11-30 02:49:06 |
/home/bf/bf-build/culicidae/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
desmoxytes | 2023-11-30 03:11:15 |
/home/bf/bf-build/desmoxytes/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
flaviventris | 2023-11-30 02:53:19 |
/home/bf/bf-build/flaviventris/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
francolin | 2023-11-30 02:26:08 |
../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not
at beginning of declaration [-Wold-style-declaration]
grassquit | 2023-11-30 02:58:36 |
/home/bf/bf-build/grassquit/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
komodoensis | 2023-11-30 03:07:52 |
/home/bf/bf-build/komodoensis/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
phycodurus | 2023-11-29 14:29:02 |
/home/bf/bf-build/phycodurus/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
piculet | 2023-11-30 02:32:57 |
../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not
at beginning of declaration [-Wold-style-declaration]
pogona | 2023-11-29 14:22:31 |
/home/bf/bf-build/pogona/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
rorqual | 2023-11-30 02:32:41 |
../pgsql/src/backend/access/transam/slru.c:63:1: warning: 'inline' is not
at beginning of declaration [-Wold-style-declaration]
serinus | 2023-11-30 02:47:05 |
/home/bf/bf-build/serinus/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
skink | 2023-11-29 14:23:05 |
/home/bf/bf-build/skink-master/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
taipan | 2023-11-30 03:03:52 |
/home/bf/bf-build/taipan/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]
tamandua | 2023-11-30 02:49:50 |
/home/bf/bf-build/tamandua/HEAD/pgsql.build/../pgsql/src/backend/access/transam/slru.c:63:1:
warning: 'inline' is not at beginning of declaration
[-Wold-style-declaration]regards, tom lane
Agree. The fix is attached.
Regards,
Pavel
Attachments:
0001-Fix-warning-due-non-standard-inline-declaration-in-4.patchapplication/octet-stream; name=0001-Fix-warning-due-non-standard-inline-declaration-in-4.patchDownload
From ecdb7cc6b1c0c5693eaf262b91dcc8a7ebf2fcb4 Mon Sep 17 00:00:00 2001
From: Pavel Borisov <pashkin.elfe@gmail.com>
Date: Thu, 30 Nov 2023 12:28:52 +0400
Subject: [PATCH] Fix warning due non-standard inline declaration in
4ed8f0913bfdb5f355
---
src/backend/access/transam/slru.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index ac49c99c8bf..7a371d90344 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -60,7 +60,7 @@
#include "storage/fd.h"
#include "storage/shmem.h"
-static int inline
+static inline int
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
if (ctl->long_segment_names)
--
2.39.2 (Apple Git-143)
On Thu, Nov 30, 2023 at 10:29 AM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
Agree. The fix is attached.
What an oversight.
Thank you, pushed!
------
Regards,
Alexander Korotkov
On Thu, Nov 30, 2023 at 4:37 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:
On Thu, Nov 30, 2023 at 10:29 AM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
Agree. The fix is attached.
What an oversight.
Thank you, pushed!
With that, is there any more work pending, or can we close the CF entry?
On Mon, 4 Dec 2023 at 10:34, John Naylor <johncnaylorls@gmail.com> wrote:
On Thu, Nov 30, 2023 at 4:37 PM Alexander Korotkov <aekorotkov@gmail.com>
wrote:On Thu, Nov 30, 2023 at 10:29 AM Pavel Borisov <pashkin.elfe@gmail.com>
wrote:
Agree. The fix is attached.
What an oversight.
Thank you, pushed!With that, is there any more work pending, or can we close the CF entry?
I think this is complete and could be closed.
Regards,
Pavel
On Mon, Dec 4, 2023 at 3:12 PM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
I think this is complete and could be closed.
Done.
Hi orlovmg@gmail.com
That's good news, I think we can continue discuss for (https://commitfest.postgresql.org/43/3594/)
Best regards
________________________________
发件人: John Naylor <johncnaylorls@gmail.com>
发送时间: 2023年12月4日 18:22
收件人: Pavel Borisov <pashkin.elfe@gmail.com>
抄送: Alexander Korotkov <aekorotkov@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Alexander Lakhin <exclusion@gmail.com>; Maxim Orlov <orlovmg@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; Postgres hackers <pgsql-hackers@lists.postgresql.org>; Heikki Linnakangas <hlinnaka@iki.fi>; Japin Li <japinli@hotmail.com>; Andres Freund <andres@anarazel.de>; Michael Paquier <michael@paquier.xyz>; Peter Eisentraut <peter.eisentraut@enterprisedb.com>
主题: Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)
On Mon, Dec 4, 2023 at 3:12 PM Pavel Borisov <pashkin.elfe@gmail.com> wrote:
I think this is complete and could be closed.
Done.
Hi,
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=loach&dt=2023-12-16%2005%3A25%3A18
TRAP: failed Assert("epoch > 0"), File: "twophase.c", Line: 969, PID: 71030
0xa8edcd <ExceptionalCondition+0x6d> at
/usr/home/pgbf/buildroot/HEAD/pgsql.build/tmp_install/home/pgbf/buildroot/HEAD/inst/bin/postgres
0x613863 <ReadTwoPhaseFile+0x463> at
/usr/home/pgbf/buildroot/HEAD/pgsql.build/tmp_install/home/pgbf/buildroot/HEAD/inst/bin/postgres
That's the new assertion from 5a1dfde8:
+ * The wrap logic is safe here because the span of active xids cannot
exceed one
+ * epoch at any given time.
...
+ if (unlikely(xid > nextXid))
+ {
+ /* Wraparound occured, must be from a prev epoch. */
+ Assert(epoch > 0);
On Sun, Dec 17, 2023 at 1:48 AM Thomas Munro <thomas.munro@gmail.com> wrote:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=loach&dt=2023-12-16%2005%3A25%3A18
TRAP: failed Assert("epoch > 0"), File: "twophase.c", Line: 969, PID: 71030
0xa8edcd <ExceptionalCondition+0x6d> at
/usr/home/pgbf/buildroot/HEAD/pgsql.build/tmp_install/home/pgbf/buildroot/HEAD/inst/bin/postgres
0x613863 <ReadTwoPhaseFile+0x463> at
/usr/home/pgbf/buildroot/HEAD/pgsql.build/tmp_install/home/pgbf/buildroot/HEAD/inst/bin/postgresThat's the new assertion from 5a1dfde8:
+ * The wrap logic is safe here because the span of active xids cannot exceed one + * epoch at any given time. ... + if (unlikely(xid > nextXid)) + { + /* Wraparound occured, must be from a prev epoch. */ + Assert(epoch > 0);
Thank you for noticing this. I did some investigations.
AdjustToFullTransactionId() uses TransamVariables->nextXid to convert
TransactionId into FullTransactionId. However,
ProcArrayApplyRecoveryInfo() first checks two phase transactions then
updates TransamVariables->nextXid. Please, see the draft patch
fixing this. I'll do further check if it has some side-effects.
------
Regards,
Alexander Korotkov
Attachments:
fix_ProcArrayApplyRecoveryInfo_update_nextXid.patchapplication/octet-stream; name=fix_ProcArrayApplyRecoveryInfo_update_nextXid.patchDownload
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 11e1446cd11..d37cc2821ad 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -952,7 +952,7 @@ static inline FullTransactionId
AdjustToFullTransactionId(TransactionId xid)
{
FullTransactionId nextFullXid;
- TransactionId nextXid;
+ TransactionId cutoffXid;
uint32 epoch;
Assert(TransactionIdIsValid(xid));
@@ -961,9 +961,9 @@ AdjustToFullTransactionId(TransactionId xid)
nextFullXid = TransamVariables->nextXid;
LWLockRelease(XidGenLock);
- nextXid = XidFromFullTransactionId(nextFullXid);
+ cutoffXid = XidFromFullTransactionId(nextFullXid);
epoch = EpochFromFullTransactionId(nextFullXid);
- if (unlikely(xid > nextXid))
+ if (unlikely(xid > cutoffXid))
{
/* Wraparound occurred, must be from a prev epoch. */
Assert(epoch > 0);
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 976f7856fbf..15a28788d51 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1053,6 +1053,7 @@ void
ProcArrayApplyRecoveryInfo(RunningTransactions running)
{
TransactionId *xids;
+ TransactionId xid;
int nxids;
int i;
@@ -1066,6 +1067,16 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
*/
ExpireOldKnownAssignedTransactionIds(running->oldestRunningXid);
+ /*
+ * Adjust TransamVariables->nextXid before StandbyReleaseOldLocks(),
+ * because we will need it up to date for accessing two-phase transactions
+ * in StandbyReleaseOldLocks().
+ */
+ xid = running->nextXid;
+ TransactionIdRetreat(xid);
+ AdvanceNextFullTransactionIdPastXid(xid);
+ Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
+
/*
* Remove stale locks, if any.
*/
@@ -1275,11 +1286,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
LWLockRelease(ProcArrayLock);
- /* TransamVariables->nextXid must be beyond any observed xid. */
- AdvanceNextFullTransactionIdPastXid(latestObservedXid);
-
- Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
-
KnownAssignedXidsDisplay(DEBUG3);
if (standbyState == STANDBY_SNAPSHOT_READY)
elog(DEBUG1, "recovery snapshots are now enabled");
On Tue, Nov 28, 2023 at 11:14 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
I think it's pretty sloppy that the "short" filenames can be 4, 5 or 6
chars long. For pg_multixact/members, which introduced the 5-char case,
I think we should always pad the filenames 5 characters, and for
commit_ts which introduced the 6 char case, always pad to 6 characters.Instead of a "long_segment_names" boolean, how about an integer field,
to specify the length.That means that we'll need pg_upgrade to copy pg_multixact/members files
under the new names. That should be pretty straightforward.
Do you think it could be useful if the file names were not sequential
numbers ...0000, ...0001, ...0002 but instead used the 64 bit 'index'
number for the contained data? In the cases where the index is an
fxid, such as pg_xact, pg_serial etc that seems easy to grok, and for
the multixacts or notify it's a bit more arbitrary but that's not
worse (and it is perhaps even meaningful, number of multixacts etc).
For example, pg_serial holds a uint64_t for every xid, so that's 32768
= 0x8000 xids per 256kB file, and you might see the following files on
disk:
0000000000000000
0000000000008000
0000000000010000
... so that it's very clear what fxid ranges are being held. It might
also make the file unlinking logic more straightforward in the
non-modulo cases (not sure). Of course you can work it out with
simple arithmetic but I wonder if human administrators who don't have
a C-level understanding of PostgreSQL would find this scheme more
cromulent when trying to understand, quickly, whether the system is
retaining expected data.
(Assuming we actually get the indexes to be 64 bit in the first place.
I started thinking/hacking around how to do that for the specific case of
pg_serial because it's [by its own admission] a complete mess right now,
and I was investigating its disk usage, see nearby thread, but then
I found my way here and realised I'm probably duplicating work that's
already been/being done so I'm trying to catch up here... forgive me if
the above was already covered, so many messages...)
On Mon, Nov 27, 2023 at 01:43:26AM +0200, Alexander Korotkov wrote:
v61 looks good to me. I'm going to push it as long as there are no objections.
This yielded commit 4ed8f09 "Index SLRUs by 64-bit integers rather than by
32-bit integers" and left some expressions coercing SLRU page numbers to int.
Two sources:
grep -i 'int\b.*page' $(git grep -l SimpleLruInit)
make && touch $(git grep -l SimpleLruInit) && make PROFILE=-Wconversion 2>&1 | less -p '.int. from .int64. may alter its value'
(Not every match needs to change.)
--- a/src/include/access/slru.h +++ b/src/include/access/slru.h
@@ -127,7 +127,15 @@ typedef struct SlruCtlData * the behavior of this callback has no functional implications.) Use * SlruPagePrecedesUnitTests() in SLRUs meeting its criteria. */ - bool (*PagePrecedes) (int, int); + bool (*PagePrecedes) (int64, int64); + + /* + * If true, use long segment filenames formed from lower 48 bits of the + * segment number, e.g. pg_xact/000000001234. Otherwise, use short + * filenames formed from lower 16 bits of the segment number e.g. + * pg_xact/1234. + */ + bool long_segment_names;
SlruFileName() makes 15-character (60-bit) file names. Where does the 48-bit
limit arise? How does the SlruFileName() comment about a 24-bit limit for
short names relate this comment's 16-bit limit?
nm
Hi Noah,
This yielded commit 4ed8f09 "Index SLRUs by 64-bit integers rather than by
32-bit integers" and left some expressions coercing SLRU page numbers to int.
Two sources:grep -i 'int\b.*page' $(git grep -l SimpleLruInit)
make && touch $(git grep -l SimpleLruInit) && make PROFILE=-Wconversion 2>&1 | less -p '.int. from .int64. may alter its value'(Not every match needs to change.)
I examined the new warnings introduced by 4ed8f09. Most of them seem
to be harmless, for instance:
```
slru.c:657:43: warning: conversion from ‘int64’ {aka ‘long int’} to
‘int’ may change value [-Wconversion]
657 | int rpageno = pageno %
SLRU_PAGES_PER_SEGMENT;
```
```
slru.c: In function ‘SlruReportIOError’:
slru.c:962:43: warning: conversion from ‘int64’ {aka ‘long int’} to
‘int’ may change value [-Wconversion]
962 | int rpageno = pageno %
SLRU_PAGES_PER_SEGMENT;
```
Interestingly the patch decreased the overall number of warnings.
I prepared the patch for clog.c. The rest of the warnings don't strike
me as something we should immediately act on unless we have a bug
report. Or perhaps there is a particular warning that worries you?
@@ -127,7 +127,15 @@ typedef struct SlruCtlData * the behavior of this callback has no functional implications.) Use * SlruPagePrecedesUnitTests() in SLRUs meeting its criteria. */ - bool (*PagePrecedes) (int, int); + bool (*PagePrecedes) (int64, int64); + + /* + * If true, use long segment filenames formed from lower 48 bits of the + * segment number, e.g. pg_xact/000000001234. Otherwise, use short + * filenames formed from lower 16 bits of the segment number e.g. + * pg_xact/1234. + */ + bool long_segment_names;SlruFileName() makes 15-character (60-bit) file names. Where does the 48-bit
limit arise? How does the SlruFileName() comment about a 24-bit limit for
short names relate this comment's 16-bit limit?
Yes, this comment is wrong. Here is a fix.
[1]: /messages/by-id/CAJ7c6TNMuKWUuMfh5KWgJJBoJGqPHYdZeN4t+LB6WdRLbDfVTw@mail.gmail.com
--
Best regards,
Aleksander Alekseev
Attachments:
v1-0002-Use-int64-for-page-numbers-in-clog.c.patchapplication/octet-stream; name=v1-0002-Use-int64-for-page-numbers-in-clog.c.patchDownload
From 209c658da61aa75a828a15b42247c620fbe2a5fa Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 14:02:42 +0300
Subject: [PATCH v1 2/2] Use int64 for page numbers in clog.c
Oversight of 4ed8f0913bfd
Aleksander Alekseev, reported by Noah Misch
---
src/backend/access/transam/clog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 44c253246b..e6f79320e9 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
PGPROC *proc = MyProc;
uint32 nextidx;
uint32 wakeidx;
- int prevpageno;
+ int64 prevpageno;
LWLock *prevlock = NULL;
/* We should definitely have an XID whose status needs to be updated. */
@@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
while (nextidx != INVALID_PROC_NUMBER)
{
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
- int thispageno = nextproc->clogGroupMemberPage;
+ int64 thispageno = nextproc->clogGroupMemberPage;
/*
* If the page to update belongs to a different bank than the previous
--
2.45.2
v1-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchapplication/octet-stream; name=v1-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchDownload
From 261fbe5176f168c1cb8a74a873ad7a6a7ec28e10 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 12:59:15 +0300
Subject: [PATCH v1 1/2] Fix the comment for SlruCtlData.long_segment_names
Oversight of 4ed8f0913bfd
Aleksander Alekseev, reported by Noah Misch
---
src/include/access/slru.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8a8d191873..269dad37af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,10 +134,8 @@ typedef struct SlruCtlData
bits16 bank_mask;
/*
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment filenames. Use short filenames otherwise.
+ * See SlruFileName().
*/
bool long_segment_names;
--
2.45.2
On Wed, Jun 26, 2024 at 02:09:58PM +0300, Aleksander Alekseev wrote:
This yielded commit 4ed8f09 "Index SLRUs by 64-bit integers rather than by
32-bit integers" and left some expressions coercing SLRU page numbers to int.
Two sources:grep -i 'int\b.*page' $(git grep -l SimpleLruInit)
make && touch $(git grep -l SimpleLruInit) && make PROFILE=-Wconversion 2>&1 | less -p '.int. from .int64. may alter its value'(Not every match needs to change.)
I examined the new warnings introduced by 4ed8f09. Most of them seem
to be harmless, for instance:
[...]
I prepared the patch for clog.c. The rest of the warnings don't strike
me as something we should immediately act on unless we have a bug
report. Or perhaps there is a particular warning that worries you?
Is "int" acceptable or unacceptable in the following grep match?
src/backend/commands/async.c:1274: int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
Hi,
I prepared the patch for clog.c. The rest of the warnings don't strike
me as something we should immediately act on unless we have a bug
report. Or perhaps there is a particular warning that worries you?Is "int" acceptable or unacceptable in the following grep match?
src/backend/commands/async.c:1274: int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
Good catch. We better use int64s here.
Here is the corrected patchset.
--
Best regards,
Aleksander Alekseev
Attachments:
v2-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchapplication/octet-stream; name=v2-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchDownload
From e9a26231860bbc65fe70dbcdf730971271e627d3 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 12:59:15 +0300
Subject: [PATCH v2 1/2] Fix the comment for SlruCtlData.long_segment_names
Oversight of 4ed8f0913bfd
Aleksander Alekseev, reported by Noah Misch
---
src/include/access/slru.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8a8d191873..269dad37af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,10 +134,8 @@ typedef struct SlruCtlData
bits16 bank_mask;
/*
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment filenames. Use short filenames otherwise.
+ * See SlruFileName().
*/
bool long_segment_names;
--
2.45.2
v2-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchapplication/octet-stream; name=v2-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchDownload
From bf5cfda7b04005e6b221faa4382b27b46c50cbd1 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 14:02:42 +0300
Subject: [PATCH v2 2/2] Use int64 for page numbers in clog.c & async.c
Oversight of 4ed8f0913bfd
Aleksander Alekseev, Noah Misch
---
src/backend/access/transam/clog.c | 4 ++--
src/backend/commands/async.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 44c253246b..e6f79320e9 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
PGPROC *proc = MyProc;
uint32 nextidx;
uint32 wakeidx;
- int prevpageno;
+ int64 prevpageno;
LWLock *prevlock = NULL;
/* We should definitely have an XID whose status needs to be updated. */
@@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
while (nextidx != INVALID_PROC_NUMBER)
{
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
- int thispageno = nextproc->clogGroupMemberPage;
+ int64 thispageno = nextproc->clogGroupMemberPage;
/*
* If the page to update belongs to a different bank than the previous
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ab4c72762d..f38c5feabb 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -1271,9 +1271,9 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
- int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied = headPage - tailPage;
+ int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int64 occupied = headPage - tailPage;
return occupied >= max_notify_queue_pages;
}
--
2.45.2
Hi,
Here is the corrected patchset.
TWIMC this is currently listed as an open item for PG17 [1]https://wiki.postgresql.org/wiki/PostgreSQL_17_Open_Items.
Sorry if everyone interested is already aware.
[1]: https://wiki.postgresql.org/wiki/PostgreSQL_17_Open_Items
--
Best regards,
Aleksander Alekseev
On Mon, Jul 08, 2024 at 12:30:09PM +0300, Aleksander Alekseev wrote:
TWIMC this is currently listed as an open item for PG17 [1].
Sorry if everyone interested is already aware.[1]: https://wiki.postgresql.org/wiki/PostgreSQL_17_Open_Items
The proposed patch looks rather incomplete to me, based on the fact
that this stuff has a lot of inconsistencies with the types used when
manipulating 64b SLRU pages. Some of them are harder to catch as the
variables don't specifically refer to pages.
So, even after v2, there are two more of these in asyncQueueUsage()
with the two QUEUE_POS_PAGE() for the head and tail positions:
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
asyncQueueReadAllNotifications() also has one:
int curpage = QUEUE_POS_PAGE(pos);
asyncQueueAdvanceTail() declares the following:
int oldtailpage;
int newtailpage;
int boundary;
AsyncQueueControl.stopPage is an int.
And that's only for async.c. Alexander K., as the owner of the open
item, are you planning to look at that?
--
Michael
Hi,
The proposed patch looks rather incomplete to me, based on the fact
that this stuff has a lot of inconsistencies with the types used when
manipulating 64b SLRU pages. Some of them are harder to catch as the
variables don't specifically refer to pages.So, even after v2, there are two more of these in asyncQueueUsage()
with the two QUEUE_POS_PAGE() for the head and tail positions:
int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);asyncQueueReadAllNotifications() also has one:
int curpage = QUEUE_POS_PAGE(pos);asyncQueueAdvanceTail() declares the following:
int oldtailpage;
int newtailpage;
int boundary;AsyncQueueControl.stopPage is an int.
And that's only for async.c. Alexander K., as the owner of the open
item, are you planning to look at that?
Thanks, Michael. I prepared a corrected patchset.
--
Best regards,
Aleksander Alekseev
Attachments:
v3-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchapplication/octet-stream; name=v3-0001-Fix-the-comment-for-SlruCtlData.long_segment_name.patchDownload
From 63a4e848a23af0ef5289ba9ad38054f7e15fb1d7 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 12:59:15 +0300
Subject: [PATCH v3 1/2] Fix the comment for SlruCtlData.long_segment_names
Oversight of 4ed8f0913bfd
Aleksander Alekseev, reported by Noah Misch
---
src/include/access/slru.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8a8d191873..269dad37af 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,10 +134,8 @@ typedef struct SlruCtlData
bits16 bank_mask;
/*
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment filenames. Use short filenames otherwise.
+ * See SlruFileName().
*/
bool long_segment_names;
--
2.45.2
v3-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchapplication/octet-stream; name=v3-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchDownload
From 64224afc26215c718d50e4387912449fda8e7036 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 14:02:42 +0300
Subject: [PATCH v3 2/2] Use int64 for page numbers in clog.c & async.c
Oversight of 4ed8f0913bfd
Aleksander Alekseev, Noah Misch, Michael Paquier
---
src/backend/access/transam/clog.c | 4 ++--
src/backend/commands/async.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 44c253246b..e6f79320e9 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
PGPROC *proc = MyProc;
uint32 nextidx;
uint32 wakeidx;
- int prevpageno;
+ int64 prevpageno;
LWLock *prevlock = NULL;
/* We should definitely have an XID whose status needs to be updated. */
@@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
while (nextidx != INVALID_PROC_NUMBER)
{
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
- int thispageno = nextproc->clogGroupMemberPage;
+ int64 thispageno = nextproc->clogGroupMemberPage;
/*
* If the page to update belongs to a different bank than the previous
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ab4c72762d..3c43a700e7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -283,7 +283,7 @@ typedef struct AsyncQueueControl
QueuePosition head; /* head points to the next free location */
QueuePosition tail; /* tail must be <= the queue position of every
* listening backend */
- int stopPage; /* oldest unrecycled page; must be <=
+ int64 stopPage; /* oldest unrecycled page; must be <=
* tail.page */
ProcNumber firstListener; /* id of first listener, or
* INVALID_PROC_NUMBER */
@@ -1271,9 +1271,9 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
- int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied = headPage - tailPage;
+ int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int64 occupied = headPage - tailPage;
return occupied >= max_notify_queue_pages;
}
@@ -1505,9 +1505,9 @@ pg_notification_queue_usage(PG_FUNCTION_ARGS)
static double
asyncQueueUsage(void)
{
- int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
- int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied = headPage - tailPage;
+ int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int64 occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
@@ -1932,7 +1932,7 @@ asyncQueueReadAllNotifications(void)
do
{
- int curpage = QUEUE_POS_PAGE(pos);
+ int64 curpage = QUEUE_POS_PAGE(pos);
int curoffset = QUEUE_POS_OFFSET(pos);
int slotno;
int copysize;
@@ -2108,9 +2108,9 @@ static void
asyncQueueAdvanceTail(void)
{
QueuePosition min;
- int oldtailpage;
- int newtailpage;
- int boundary;
+ int64 oldtailpage;
+ int64 newtailpage;
+ int64 boundary;
/* Restrict task to one backend per cluster; see SimpleLruTruncate(). */
LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE);
--
2.45.2
On Thu, Jul 11, 2024 at 01:11:05PM +0300, Aleksander Alekseev wrote:
Thanks, Michael. I prepared a corrected patchset.
A comment about v3-0001.
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment filenames. Use short filenames otherwise.
+ * See SlruFileName().
We're losing some details here even if SlruFileName() has some
explanations, because one would need to read through the snprintf's
04X to know that short file names include 4 characters. I'm OK to
mention SlruFileName() rather than duplicate the knowledge here, but
SlruFileName() should also be updated to mention the same level of
details with some examples of file names.
--
Michael
Hi,
A comment about v3-0001.
- * If true, use long segment filenames formed from lower 48 bits of the - * segment number, e.g. pg_xact/000000001234. Otherwise, use short - * filenames formed from lower 16 bits of the segment number e.g. - * pg_xact/1234. + * If true, use long segment filenames. Use short filenames otherwise. + * See SlruFileName().We're losing some details here even if SlruFileName() has some
explanations, because one would need to read through the snprintf's
04X to know that short file names include 4 characters. I'm OK to
mention SlruFileName() rather than duplicate the knowledge here, but
SlruFileName() should also be updated to mention the same level of
details with some examples of file names.
Fair enough. Here is the updated patchset.
--
Best regards,
Aleksander Alekseev
Attachments:
v4-0001-Refactor-the-comments-about-formatting-SLRU-segme.patchapplication/x-patch; name=v4-0001-Refactor-the-comments-about-formatting-SLRU-segme.patchDownload
From 0b8d67ab6cc582b356e639175f85d30982f2fb2c Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 12:59:15 +0300
Subject: [PATCH v4 1/2] Refactor the comments about formatting SLRU segment
filenames
The comment for SlruCtlData.long_segment_names was just wrong, an oversight
of commit 4ed8f0913bfd.
While on it, additionally clarify what SlruFileName() does and how it uses
SlruCtlData.long_segment_names.
Aleksander Alekseev. Reported by Noah Misch. Reviewed by Michael Paquier.
---
src/backend/access/transam/slru.c | 22 ++++++++++++++++++++++
src/include/access/slru.h | 15 +++++++++++----
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 77b05cc0a7..168df26065 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -72,6 +72,28 @@
#include "storage/shmem.h"
#include "utils/guc_hooks.h"
+/*
+ * Converts segment number to the filename of the segment.
+ *
+ * path: should point to a buffer at least MAXPGPATH characters long.
+ *
+ * If ctl->long_segment_names is true, segno can be in 0 .. (2^60-1) range and
+ * the resulting filename will be like:
+ *
+ * slru_dir/123456789ABCDEF (15 characters)
+ *
+ * This is the recommended way of formatting for all new code.
+ *
+ * If ctl->long_segment_names is false, segno can be in 0 .. (2^24-1) range.
+ * The resulting filename will be one of:
+ *
+ * slru_dir/1234 if 0 <= segno < 2^16
+ * slru_dir/12345 if 2^16 <= segno < 2^20
+ * slru_dir/123456 if 2^20 <= segno < 2^24
+ *
+ * This is the legacy way of formatting that is kept for backward compatibility.
+ * New code shouldn't use it.
+ */
static inline int
SlruFileName(SlruCtl ctl, char *path, int64 segno)
{
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 8a8d191873..c836fa8534 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -134,10 +134,17 @@ typedef struct SlruCtlData
bits16 bank_mask;
/*
- * If true, use long segment filenames formed from lower 48 bits of the
- * segment number, e.g. pg_xact/000000001234. Otherwise, use short
- * filenames formed from lower 16 bits of the segment number e.g.
- * pg_xact/1234.
+ * If true, use long segment filenames. Use short filenames otherwise.
+ *
+ * Each segment contains SLRU_PAGES_PER_SEGMENT pages, i.e.:
+ *
+ * Segment # Contains pages
+ * 0 0 .. (SLRU_PAGES_PER_SEGMENT-1)
+ * 1 SLRU_PAGES_PER_SEGMENT .. (SLRU_PAGES_PER_SEGMENT*2-1)
+ * ... etc ..
+ *
+ * The filename of the segment is formed from its number. For more details
+ * regarding exact rules see SlruFileName().
*/
bool long_segment_names;
--
2.45.2
v4-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchapplication/x-patch; name=v4-0002-Use-int64-for-page-numbers-in-clog.c-async.c.patchDownload
From 6811fa964cce2f2f308793ca8d627d7c6dc3f1b2 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Wed, 26 Jun 2024 14:02:42 +0300
Subject: [PATCH v4 2/2] Use int64 for page numbers in clog.c & async.c
Oversight of 4ed8f0913bfd
Aleksander Alekseev, Noah Misch, Michael Paquier
---
src/backend/access/transam/clog.c | 4 ++--
src/backend/commands/async.c | 22 +++++++++++-----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 44c253246b..e6f79320e9 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -445,7 +445,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
PGPROC *proc = MyProc;
uint32 nextidx;
uint32 wakeidx;
- int prevpageno;
+ int64 prevpageno;
LWLock *prevlock = NULL;
/* We should definitely have an XID whose status needs to be updated. */
@@ -577,7 +577,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
while (nextidx != INVALID_PROC_NUMBER)
{
PGPROC *nextproc = &ProcGlobal->allProcs[nextidx];
- int thispageno = nextproc->clogGroupMemberPage;
+ int64 thispageno = nextproc->clogGroupMemberPage;
/*
* If the page to update belongs to a different bank than the previous
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index ab4c72762d..3c43a700e7 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -283,7 +283,7 @@ typedef struct AsyncQueueControl
QueuePosition head; /* head points to the next free location */
QueuePosition tail; /* tail must be <= the queue position of every
* listening backend */
- int stopPage; /* oldest unrecycled page; must be <=
+ int64 stopPage; /* oldest unrecycled page; must be <=
* tail.page */
ProcNumber firstListener; /* id of first listener, or
* INVALID_PROC_NUMBER */
@@ -1271,9 +1271,9 @@ asyncQueueUnregister(void)
static bool
asyncQueueIsFull(void)
{
- int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
- int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied = headPage - tailPage;
+ int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int64 occupied = headPage - tailPage;
return occupied >= max_notify_queue_pages;
}
@@ -1505,9 +1505,9 @@ pg_notification_queue_usage(PG_FUNCTION_ARGS)
static double
asyncQueueUsage(void)
{
- int headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
- int tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
- int occupied = headPage - tailPage;
+ int64 headPage = QUEUE_POS_PAGE(QUEUE_HEAD);
+ int64 tailPage = QUEUE_POS_PAGE(QUEUE_TAIL);
+ int64 occupied = headPage - tailPage;
if (occupied == 0)
return (double) 0; /* fast exit for common case */
@@ -1932,7 +1932,7 @@ asyncQueueReadAllNotifications(void)
do
{
- int curpage = QUEUE_POS_PAGE(pos);
+ int64 curpage = QUEUE_POS_PAGE(pos);
int curoffset = QUEUE_POS_OFFSET(pos);
int slotno;
int copysize;
@@ -2108,9 +2108,9 @@ static void
asyncQueueAdvanceTail(void)
{
QueuePosition min;
- int oldtailpage;
- int newtailpage;
- int boundary;
+ int64 oldtailpage;
+ int64 newtailpage;
+ int64 boundary;
/* Restrict task to one backend per cluster; see SimpleLruTruncate(). */
LWLockAcquire(NotifyQueueTailLock, LW_EXCLUSIVE);
--
2.45.2
On Fri, Jul 12, 2024 at 12:44:54PM +0300, Aleksander Alekseev wrote:
Fair enough. Here is the updated patchset.
Hearing nothing but cicadas as now is their season, I have taken the
initiative here to address this open item.
0001 felt a bit too complicated in slru.h, so I have simplified it and
kept all the details in slru.c with SlruFileName().
I have reviewed all the code that uses SLRUs, and spotted three more
problematic code paths in predicate.c that needed an update like the
others for some pagenos. I've added these, and applied 0002. We
should be good now.
--
Michael
Hi,
Hearing nothing but cicadas as now is their season, I have taken the
initiative here to address this open item.0001 felt a bit too complicated in slru.h, so I have simplified it and
kept all the details in slru.c with SlruFileName().I have reviewed all the code that uses SLRUs, and spotted three more
problematic code paths in predicate.c that needed an update like the
others for some pagenos. I've added these, and applied 0002. We
should be good now.
Thank you!
--
Best regards,
Aleksander Alekseev
On Tue, Jul 23, 2024 at 06:01:44PM +0900, Michael Paquier wrote:
Hearing nothing but cicadas as now is their season, I have taken the
initiative here to address this open item.0001 felt a bit too complicated in slru.h, so I have simplified it and
kept all the details in slru.c with SlruFileName().I have reviewed all the code that uses SLRUs, and spotted three more
problematic code paths in predicate.c that needed an update like the
others for some pagenos. I've added these, and applied 0002. We
should be good now.
I'm still seeing need for s/int/int64/ at:
- "pagesegno" variable
- return value of MultiXactIdToOffsetSegment()
- return value of MXOffsetToMemberSegment()
- callers of previous two
Only the first should be a live bug, since multixact isn't electing the higher
pageno ceiling.
On Wed, Jul 24, 2024 at 06:00:59AM -0700, Noah Misch wrote:
I'm still seeing need for s/int/int64/ at:
Nice catches! I've missed these.
- "pagesegno" variable
- return value of MultiXactIdToOffsetSegment()
Only used in four places for two elog(DEBUG1) entries with %x.
- return value of MXOffsetToMemberSegment()
Also used in four places for two elog(DEBUG1) entries with %x, plus
three callers in PerformMembersTruncation(), nothing fancy.
Only the first should be a live bug, since multixact isn't electing the higher
pageno ceiling.
Yes, and it makes a switch to long segment names everywhere easier.
There is a patch in the air to do that, without the pg_upgrade
additions required to do the transfer, though.
I am attaching a patch for all these you have spotted, switching the
logs to use %llx. Does that look fine for you?
--
Michael
Attachments:
0001-Fix-a-couple-of-extra-spots-missing-the-int-int64-sw.patchtext/plain; charset=us-asciiDownload
From d2bae5b020ab6a5182a52f4a8e58a39a7d3a5947 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Thu, 25 Jul 2024 10:47:51 +0900
Subject: [PATCH] Fix a couple of extra spots missing the int->int64 switch for
SLRU pages
---
src/backend/access/transam/multixact.c | 39 +++++++++++++-------------
src/backend/access/transam/slru.c | 2 +-
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 675affe4f7..b7b47ef076 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -120,7 +120,7 @@ MultiXactIdToOffsetEntry(MultiXactId multi)
return multi % MULTIXACT_OFFSETS_PER_PAGE;
}
-static inline int
+static inline int64
MultiXactIdToOffsetSegment(MultiXactId multi)
{
return MultiXactIdToOffsetPage(multi) / SLRU_PAGES_PER_SEGMENT;
@@ -174,7 +174,7 @@ MXOffsetToMemberPage(MultiXactOffset offset)
return offset / MULTIXACT_MEMBERS_PER_PAGE;
}
-static inline int
+static inline int64
MXOffsetToMemberSegment(MultiXactOffset offset)
{
return MXOffsetToMemberPage(offset) / SLRU_PAGES_PER_SEGMENT;
@@ -3039,10 +3039,10 @@ SlruScanDirCbFindEarliest(SlruCtl ctl, char *filename, int64 segpage, void *data
static void
PerformMembersTruncation(MultiXactOffset oldestOffset, MultiXactOffset newOldestOffset)
{
- const int maxsegment = MXOffsetToMemberSegment(MaxMultiXactOffset);
- int startsegment = MXOffsetToMemberSegment(oldestOffset);
- int endsegment = MXOffsetToMemberSegment(newOldestOffset);
- int segment = startsegment;
+ const int64 maxsegment = MXOffsetToMemberSegment(MaxMultiXactOffset);
+ int64 startsegment = MXOffsetToMemberSegment(oldestOffset);
+ int64 endsegment = MXOffsetToMemberSegment(newOldestOffset);
+ int64 segment = startsegment;
/*
* Delete all the segments but the last one. The last segment can still
@@ -3050,7 +3050,8 @@ PerformMembersTruncation(MultiXactOffset oldestOffset, MultiXactOffset newOldest
*/
while (segment != endsegment)
{
- elog(DEBUG2, "truncating multixact members segment %x", segment);
+ elog(DEBUG2, "truncating multixact members segment %llx",
+ (unsigned long long) segment);
SlruDeleteSegment(MultiXactMemberCtl, segment);
/* move to next segment, handling wraparound correctly */
@@ -3201,14 +3202,14 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
}
elog(DEBUG1, "performing multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
- "members [%u, %u), members segments [%x, %x)",
+ "offsets [%u, %u), offsets segments [%llx, %llx), "
+ "members [%u, %u), members segments [%llx, %llx)",
oldestMulti, newOldestMulti,
- MultiXactIdToOffsetSegment(oldestMulti),
- MultiXactIdToOffsetSegment(newOldestMulti),
+ (unsigned long long) MultiXactIdToOffsetSegment(oldestMulti),
+ (unsigned long long) MultiXactIdToOffsetSegment(newOldestMulti),
oldestOffset, newOldestOffset,
- MXOffsetToMemberSegment(oldestOffset),
- MXOffsetToMemberSegment(newOldestOffset));
+ (unsigned long long) MXOffsetToMemberSegment(oldestOffset),
+ (unsigned long long) MXOffsetToMemberSegment(newOldestOffset));
/*
* Do truncation, and the WAL logging of the truncation, in a critical
@@ -3461,14 +3462,14 @@ multixact_redo(XLogReaderState *record)
SizeOfMultiXactTruncate);
elog(DEBUG1, "replaying multixact truncation: "
- "offsets [%u, %u), offsets segments [%x, %x), "
- "members [%u, %u), members segments [%x, %x)",
+ "offsets [%u, %u), offsets segments [%llx, %llx), "
+ "members [%u, %u), members segments [%llx, %llx)",
xlrec.startTruncOff, xlrec.endTruncOff,
- MultiXactIdToOffsetSegment(xlrec.startTruncOff),
- MultiXactIdToOffsetSegment(xlrec.endTruncOff),
+ (unsigned long long) MultiXactIdToOffsetSegment(xlrec.startTruncOff),
+ (unsigned long long) MultiXactIdToOffsetSegment(xlrec.endTruncOff),
xlrec.startTruncMemb, xlrec.endTruncMemb,
- MXOffsetToMemberSegment(xlrec.startTruncMemb),
- MXOffsetToMemberSegment(xlrec.endTruncMemb));
+ (unsigned long long) MXOffsetToMemberSegment(xlrec.startTruncMemb),
+ (unsigned long long) MXOffsetToMemberSegment(xlrec.endTruncMemb));
/* should not be required, but more than cheap enough */
LWLockAcquire(MultiXactTruncationLock, LW_EXCLUSIVE);
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 248aa1a655..713d3bff3f 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -1532,7 +1532,7 @@ restart:
did_write = false;
for (int slotno = 0; slotno < shared->num_slots; slotno++)
{
- int pagesegno;
+ int64 pagesegno;
int curbank = SlotGetBankNumber(slotno);
/*
--
2.45.2
On Thu, Jul 25, 2024 at 10:52:13AM +0900, Michael Paquier wrote:
On Wed, Jul 24, 2024 at 06:00:59AM -0700, Noah Misch wrote:
I'm still seeing need for s/int/int64/ at:
I am attaching a patch for all these you have spotted, switching the
logs to use %llx. Does that look fine for you?
Yes. I think that completes the project.
On Fri, Jul 26, 2024 at 3:42 AM Noah Misch <noah@leadboat.com> wrote:
On Thu, Jul 25, 2024 at 10:52:13AM +0900, Michael Paquier wrote:
On Wed, Jul 24, 2024 at 06:00:59AM -0700, Noah Misch wrote:
I'm still seeing need for s/int/int64/ at:
I am attaching a patch for all these you have spotted, switching the
logs to use %llx. Does that look fine for you?Yes. I think that completes the project.
Thanks to everybody for working on this. It's pity I didn't notice
this is v17 open item on me. Sorry for this.
I tool a look on commits and on other slru code for similar issue.
Everything looks good for me.
------
Regards,
Alexander Korotkov
Supabase
On Fri, Jul 26, 2024 at 11:50:48PM +0300, Alexander Korotkov wrote:
Thanks to everybody for working on this. It's pity I didn't notice
this is v17 open item on me. Sorry for this.
No problem. I've just applied now the remaining pieces down to 17.
--
Michael
On Sat, Jul 27, 2024 at 07:24:33AM +0900, Michael Paquier wrote:
I've just applied now the remaining pieces down to 17.
Comparing commit c9e2457 to the patch in ZqGvzSbW5TGKqZcE@paquier.xyz, the
commit lacks the slru.c portion.
On Sat, Aug 10, 2024 at 10:50:55AM -0700, Noah Misch wrote:
On Sat, Jul 27, 2024 at 07:24:33AM +0900, Michael Paquier wrote:
I've just applied now the remaining pieces down to 17.
Comparing commit c9e2457 to the patch in ZqGvzSbW5TGKqZcE@paquier.xyz, the
commit lacks the slru.c portion.
And a portion of multixact.c as well, thanks! I am pretty sure that I
have messed up with a `git add` while doing a rebase on this dev
branch. I'll take care of it.
--
Michael