On Mon, Sep 14, 2026 at 09:01:27PM +0200, Peter Eisentraut wrote:
> I think the symbol OID8_FORMAT should be purged from the code.  Its presence
> is just going to cause confusion, with people using it in incorrect ways,
> and inviting more XXX_FORMAT symbols to be added.  We have just been working
> on getting rid of these after all.

Okay.  The string idea is discarded then, in profit of some PRIu64 in
these three spots.

Perhaps getting rid of OID8_FORMAT entirely is the best thing to do,
as you suggest.  The attached does so, better applied down to v19
that's not been released yet.  The xlogdesc.c feels slightly weird,
but perhaps that's OK.  WDYT? 
--
Michael
From 59b5de5c59075dc133f9d31d9628c862fbfffaab Mon Sep 17 00:00:00 2001
From: Michael Paquier <[email protected]>
Date: Tue, 15 Sep 2026 08:01:34 +0900
Subject: [PATCH] Remove OID8_FORMAT

---
 src/include/c.h                               |  1 -
 src/backend/access/heap/heaptoast.c           | 10 ++++----
 src/backend/access/rmgrdesc/xlogdesc.c        |  4 ++--
 src/backend/access/transam/varsup.c           |  2 +-
 src/backend/access/transam/xlogrecovery.c     |  2 +-
 .../replication/logical/reorderbuffer.c       |  4 ++--
 src/bin/pg_upgrade/pg_upgrade.c               |  2 +-
 contrib/amcheck/verify_heapam.c               | 24 +++++++++----------
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/src/include/c.h b/src/include/c.h
index 20cfbac54e71..3b75f0b86106 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -692,7 +692,6 @@ typedef uint64_t uint64;
 /* snprintf format strings to use for 64-bit integers */
 #define INT64_FORMAT "%" PRId64
 #define UINT64_FORMAT "%" PRIu64
-#define OID8_FORMAT "%" PRIu64
 
 /*
  * 128-bit signed and unsigned integers
diff --git a/src/backend/access/heap/heaptoast.c 
b/src/backend/access/heap/heaptoast.c
index 81154c17376c..20653b653c89 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -729,7 +729,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid8 valueid, 
int32 attrsize,
                else
                {
                        /* should never happen */
-                       elog(ERROR, "found toasted toast chunk for toast value 
" OID8_FORMAT " in %s",
+                       elog(ERROR, "found toasted toast chunk for toast value 
%" PRIu64 " in %s",
                                 valueid, RelationGetRelationName(toastrel));
                        chunksize = 0;          /* keep compiler quiet */
                        chunkdata = NULL;
@@ -741,13 +741,13 @@ heap_fetch_toast_slice(Relation toastrel, Oid8 valueid, 
int32 attrsize,
                if (curchunk != expectedchunk)
                        ereport(ERROR,
                                        (errcode(ERRCODE_DATA_CORRUPTED),
-                                        errmsg_internal("unexpected chunk 
number %d (expected %d) for toast value " OID8_FORMAT " in %s",
+                                        errmsg_internal("unexpected chunk 
number %d (expected %d) for toast value %" PRIu64 " in %s",
                                                                         
curchunk, expectedchunk, valueid,
                                                                         
RelationGetRelationName(toastrel))));
                if (curchunk > endchunk)
                        ereport(ERROR,
                                        (errcode(ERRCODE_DATA_CORRUPTED),
-                                        errmsg_internal("unexpected chunk 
number %d (out of range %d..%d) for toast value " OID8_FORMAT " in %s",
+                                        errmsg_internal("unexpected chunk 
number %d (out of range %d..%d) for toast value %" PRIu64 " in %s",
                                                                         
curchunk,
                                                                         
startchunk, endchunk, valueid,
                                                                         
RelationGetRelationName(toastrel))));
@@ -756,7 +756,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid8 valueid, 
int32 attrsize,
                if (chunksize != expected_size)
                        ereport(ERROR,
                                        (errcode(ERRCODE_DATA_CORRUPTED),
-                                        errmsg_internal("unexpected chunk size 
%d (expected %d) in chunk %d of %d for toast value " OID8_FORMAT " in %s",
+                                        errmsg_internal("unexpected chunk size 
%d (expected %d) in chunk %d of %d for toast value %" PRIu64 " in %s",
                                                                         
chunksize, expected_size,
                                                                         
curchunk, totalchunks, valueid,
                                                                         
RelationGetRelationName(toastrel))));
@@ -785,7 +785,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid8 valueid, 
int32 attrsize,
        if (expectedchunk != (endchunk + 1))
                ereport(ERROR,
                                (errcode(ERRCODE_DATA_CORRUPTED),
-                                errmsg_internal("missing chunk number %d for 
toast value " OID8_FORMAT " in %s",
+                                errmsg_internal("missing chunk number %d for 
toast value %" PRIu64 " in %s",
                                                                 expectedchunk, 
valueid,
                                                                 
RelationGetRelationName(toastrel))));
 
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c 
b/src/backend/access/rmgrdesc/xlogdesc.c
index 64e749c1e6b7..323acd74467d 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -101,7 +101,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
                CheckPoint *checkpoint = (CheckPoint *) rec;
 
                appendStringInfo(buf, "redo %X/%08X; "
-                                                "tli %u; prev tli %u; fpw %s; 
wal_level %s; logical decoding %s; xid %u:%u; oid " OID8_FORMAT "; multi %u; 
offset %" PRIu64 "; "
+                                                "tli %u; prev tli %u; fpw %s; 
wal_level %s; logical decoding %s; xid %u:%u; oid %" PRIu64 "; multi %u; offset 
%" PRIu64 "; "
                                                 "oldest xid %u in DB %u; 
oldest multi %u in DB %u; "
                                                 "oldest/newest commit 
timestamp xid: %u/%u; "
                                                 "oldest running xid %u; "
@@ -132,7 +132,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
                Oid8            nextOid;
 
                memcpy(&nextOid, rec, sizeof(Oid8));
-               appendStringInfo(buf, OID8_FORMAT, nextOid);
+               appendStringInfo(buf, "%" PRIu64, nextOid);
        }
        else if (info == XLOG_RESTORE_POINT)
        {
diff --git a/src/backend/access/transam/varsup.c 
b/src/backend/access/transam/varsup.c
index 889bdebe1880..912f7cb1d2c4 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -652,7 +652,7 @@ SetNextObjectId(Oid8 nextOid)
        LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
 
        if (TransamVariables->nextOid > nextOid)
-               elog(ERROR, "too late to advance OID counter to " OID8_FORMAT 
", it is now " OID8_FORMAT,
+               elog(ERROR, "too late to advance OID counter to %" PRIu64 ", it 
is now %" PRIu64,
                         nextOid, TransamVariables->nextOid);
 
        TransamVariables->nextOid = nextOid;
diff --git a/src/backend/access/transam/xlogrecovery.c 
b/src/backend/access/transam/xlogrecovery.c
index fff8d57ac61d..54aaec9529f5 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -840,7 +840,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool 
*wasShutdown_ptr,
                                                        
LSN_FORMAT_ARGS(checkPoint.redo),
                                                        wasShutdown ? "true" : 
"false"));
        ereport(DEBUG1,
-                       (errmsg_internal("next transaction ID: " UINT64_FORMAT 
"; next OID: " OID8_FORMAT,
+                       (errmsg_internal("next transaction ID: " UINT64_FORMAT 
"; next OID: %" PRIu64,
                                                         
U64FromFullTransactionId(checkPoint.nextXid),
                                                         checkPoint.nextOid)));
        ereport(DEBUG1,
diff --git a/src/backend/replication/logical/reorderbuffer.c 
b/src/backend/replication/logical/reorderbuffer.c
index 534fe338b386..ab39e8cc12c7 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5061,11 +5061,11 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, 
ReorderBufferTXN *txn,
                dlist_init(&ent->chunks);
 
                if (chunk_seq != 0)
-                       elog(ERROR, "got sequence entry %d for toast chunk " 
OID8_FORMAT " instead of seq 0",
+                       elog(ERROR, "got sequence entry %d for toast chunk %" 
PRIu64 " instead of seq 0",
                                 chunk_seq, chunk_id);
        }
        else if (found && chunk_seq != ent->last_chunk_seq + 1)
-               elog(ERROR, "got sequence entry %d for toast chunk " 
OID8_FORMAT " instead of seq %d",
+               elog(ERROR, "got sequence entry %d for toast chunk %" PRIu64 " 
instead of seq %d",
                         chunk_seq, chunk_id, ent->last_chunk_seq + 1);
 
        chunk = DatumGetPointer(fastgetattr(newtup, 3, desc, &isnull));
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 3704c620603c..c0fadb3f3177 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -196,7 +196,7 @@ main(int argc, char **argv)
         */
        prep_status("Setting next OID for new cluster");
        exec_prog(UTILITY_LOG_FILE, NULL, true, true,
-                         "\"%s/pg_resetwal\" -o " OID8_FORMAT " \"%s\"",
+                         "\"%s/pg_resetwal\" -o %" PRIu64 " \"%s\"",
                          new_cluster.bindir, 
old_cluster.controldata.chkpnt_nxtoid,
                          new_cluster.pgdata);
        check_ok();
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 33b00fa4dc5c..9af6a78e459e 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1576,7 +1576,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
        if (isnull)
        {
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " has toast chunk with null sequence number",
+                                                               psprintf("toast 
value %" PRIu64 " has toast chunk with null sequence number",
                                                                                
 toast_valueid));
                return;
        }
@@ -1584,7 +1584,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
        {
                /* Either the TOAST index is corrupt, or we don't have all 
chunks. */
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " index scan returned chunk %d when expecting chunk %d",
+                                                               psprintf("toast 
value %" PRIu64 " index scan returned chunk %d when expecting chunk %d",
                                                                                
 toast_valueid,
                                                                                
 chunk_seq, *expected_chunk_seq));
        }
@@ -1596,7 +1596,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
        if (isnull)
        {
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " chunk %d has null data",
+                                                               psprintf("toast 
value %" PRIu64 " chunk %d has null data",
                                                                                
 toast_valueid,
                                                                                
 chunk_seq));
                return;
@@ -1616,7 +1616,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
                uint32          header = ((varattrib_4b *) 
chunk)->va_4byte.va_header;
 
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " chunk %d has invalid varlena header %0x",
+                                                               psprintf("toast 
value %" PRIu64 " chunk %d has invalid varlena header %0x",
                                                                                
 toast_valueid,
                                                                                
 chunk_seq, header));
                return;
@@ -1628,7 +1628,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
        if (chunk_seq > last_chunk_seq)
        {
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " chunk %d follows last expected chunk %d",
+                                                               psprintf("toast 
value %" PRIu64 " chunk %d follows last expected chunk %d",
                                                                                
 toast_valueid,
                                                                                
 chunk_seq, last_chunk_seq));
                return;
@@ -1639,7 +1639,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext 
*ctx,
 
        if (chunksize != expected_size)
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " chunk %d has size %u, but expected size %u",
+                                                               psprintf("toast 
value %" PRIu64 " chunk %d has size %u, but expected size %u",
                                                                                
 toast_valueid,
                                                                                
 chunk_seq, chunksize, expected_size));
 }
@@ -1785,7 +1785,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
        /* Toasted attributes too large to be untoasted should never be stored 
*/
        if (toast_pointer.va_rawsize > VARLENA_SIZE_LIMIT)
                report_corruption(ctx,
-                                                 psprintf("toast value " 
OID8_FORMAT " rawsize %d exceeds limit %d",
+                                                 psprintf("toast value %" 
PRIu64 " rawsize %d exceeds limit %d",
                                                                   
toast_pointer_valueid,
                                                                   
toast_pointer.va_rawsize,
                                                                   
VARLENA_SIZE_LIMIT));
@@ -1813,7 +1813,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
                }
                if (!valid)
                        report_corruption(ctx,
-                                                         psprintf("toast value 
" OID8_FORMAT " has invalid compression method id %d",
+                                                         psprintf("toast value 
%" PRIu64 " has invalid compression method id %d",
                                                                           
toast_pointer_valueid, cmid));
        }
 
@@ -1821,7 +1821,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
        if (!(infomask & HEAP_HASEXTERNAL))
        {
                report_corruption(ctx,
-                                                 psprintf("toast value " 
OID8_FORMAT " is external but tuple header flag HEAP_HASEXTERNAL not set",
+                                                 psprintf("toast value %" 
PRIu64 " is external but tuple header flag HEAP_HASEXTERNAL not set",
                                                                   
toast_pointer_valueid));
                return true;
        }
@@ -1830,7 +1830,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
        if (!ctx->rel->rd_rel->reltoastrelid)
        {
                report_corruption(ctx,
-                                                 psprintf("toast value " 
OID8_FORMAT " is external but relation has no toast relation",
+                                                 psprintf("toast value %" 
PRIu64 " is external but relation has no toast relation",
                                                                   
toast_pointer_valueid));
                return true;
        }
@@ -1912,11 +1912,11 @@ check_toasted_attribute(HeapCheckContext *ctx, 
ToastedAttribute *ta)
 
        if (!found_toasttup)
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " not found in toast table",
+                                                               psprintf("toast 
value %" PRIu64 " not found in toast table",
                                                                                
 toast_valueid));
        else if (expected_chunk_seq <= last_chunk_seq)
                report_toast_corruption(ctx, ta,
-                                                               psprintf("toast 
value " OID8_FORMAT " was expected to end at chunk %d, but ended while 
expecting chunk %d",
+                                                               psprintf("toast 
value %" PRIu64 " was expected to end at chunk %d, but ended while expecting 
chunk %d",
                                                                                
 toast_valueid,
                                                                                
 last_chunk_seq, expected_chunk_seq));
 }
-- 
2.55.0

Attachment: signature.asc
Description: PGP signature

Reply via email to