These were introduced (commit efdc7d74753) at the same time as we were moving to using the standard inttypes.h format macros (commit a0ed19e0a9e). It doesn't seem useful to keep a new already-deprecated interface like this with only a few users, so remove the new symbols again and have the callers use PRIx64.

(Also, INT64_HEX_FORMAT was kind of a misnomer, since hex formats all use unsigned types.)

[should be backpatched to PG18]
From 6cb3bd4b86d35d9ba67c0d8bbf1ed1fc76b07a5e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Sat, 2 Aug 2025 10:35:50 +0200
Subject: [PATCH] Remove INT64_HEX_FORMAT and UINT64_HEX_FORMAT

These were introduced (commit efdc7d74753) at the same time as we were
moving to using the standard inttypes.h format macros (commit
a0ed19e0a9e).  It doesn't seem useful to keep a new already-deprecated
interface like this with only a few users, so remove the new symbols
again and have the callers use PRIx64.

(Also, INT64_HEX_FORMAT was kind of a misnomer, since hex formats all
use unsigned types.)
---
 contrib/postgres_fdw/option.c                    | 2 +-
 src/backend/utils/error/csvlog.c                 | 2 +-
 src/backend/utils/error/elog.c                   | 4 ++--
 src/backend/utils/error/jsonlog.c                | 2 +-
 src/include/c.h                                  | 2 --
 src/test/modules/test_radixtree/test_radixtree.c | 2 +-
 6 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c
index d6fa89bad93..04788b7e8b3 100644
--- a/contrib/postgres_fdw/option.c
+++ b/contrib/postgres_fdw/option.c
@@ -522,7 +522,7 @@ process_pgfdw_appname(const char *appname)
                                appendStringInfoString(&buf, application_name);
                                break;
                        case 'c':
-                               appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", 
MyStartTime, MyProcPid);
+                               appendStringInfo(&buf, "%" PRIx64 ".%x", 
MyStartTime, MyProcPid);
                                break;
                        case 'C':
                                appendStringInfoString(&buf, cluster_name);
diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c
index fdac3c048e3..c3159ed7d97 100644
--- a/src/backend/utils/error/csvlog.c
+++ b/src/backend/utils/error/csvlog.c
@@ -120,7 +120,7 @@ write_csvlog(ErrorData *edata)
        appendStringInfoChar(&buf, ',');
 
        /* session id */
-       appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
+       appendStringInfo(&buf, "%" PRIx64 ".%x", MyStartTime, MyProcPid);
        appendStringInfoChar(&buf, ',');
 
        /* Line number */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 47af743990f..dc0b74dc30b 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2956,12 +2956,12 @@ log_status_format(StringInfo buf, const char *format, 
ErrorData *edata)
                                {
                                        char            strfbuf[128];
 
-                                       snprintf(strfbuf, sizeof(strfbuf) - 1, 
INT64_HEX_FORMAT ".%x",
+                                       snprintf(strfbuf, sizeof(strfbuf) - 1, 
"%" PRIx64 ".%x",
                                                         MyStartTime, 
MyProcPid);
                                        appendStringInfo(buf, "%*s", padding, 
strfbuf);
                                }
                                else
-                                       appendStringInfo(buf, INT64_HEX_FORMAT 
".%x", MyStartTime, MyProcPid);
+                                       appendStringInfo(buf, "%" PRIx64 ".%x", 
MyStartTime, MyProcPid);
                                break;
                        case 'p':
                                if (padding != 0)
diff --git a/src/backend/utils/error/jsonlog.c 
b/src/backend/utils/error/jsonlog.c
index 519eacf17f8..2619f499042 100644
--- a/src/backend/utils/error/jsonlog.c
+++ b/src/backend/utils/error/jsonlog.c
@@ -168,7 +168,7 @@ write_jsonlog(ErrorData *edata)
        }
 
        /* Session id */
-       appendJSONKeyValueFmt(&buf, "session_id", true, INT64_HEX_FORMAT ".%x",
+       appendJSONKeyValueFmt(&buf, "session_id", true, "%" PRIx64 ".%x",
                                                  MyStartTime, MyProcPid);
 
        /* Line number */
diff --git a/src/include/c.h b/src/include/c.h
index 6d4495bdd9f..bbdaa88c63a 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -530,8 +530,6 @@ typedef uint32 bits32;                      /* >= 32 bits */
 /* snprintf format strings to use for 64-bit integers */
 #define INT64_FORMAT "%" PRId64
 #define UINT64_FORMAT "%" PRIu64
-#define INT64_HEX_FORMAT "%" PRIx64
-#define UINT64_HEX_FORMAT "%" PRIx64
 
 /*
  * 128-bit signed and unsigned integers
diff --git a/src/test/modules/test_radixtree/test_radixtree.c 
b/src/test/modules/test_radixtree/test_radixtree.c
index 32de6a3123e..80ad0296164 100644
--- a/src/test/modules/test_radixtree/test_radixtree.c
+++ b/src/test/modules/test_radixtree/test_radixtree.c
@@ -44,7 +44,7 @@
                uint64          _expected = (expected_expr); \
                if (_result != _expected) \
                        elog(ERROR, \
-                                "%s yielded " UINT64_HEX_FORMAT ", expected " 
UINT64_HEX_FORMAT " (%s) in file \"%s\" line %u", \
+                                "%s yielded %" PRIx64 ", expected %" PRIx64 " 
(%s) in file \"%s\" line %u", \
                                 #result_expr, _result, _expected, 
#expected_expr, __FILE__, __LINE__); \
        } while (0)
 

base-commit: 3b3fa949009393541e552b8ae42cc2b03be25549
-- 
2.50.1

Reply via email to