Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit efdc7d7

Browse files
Add INT64_HEX_FORMAT and UINT64_HEX_FORMAT to c.h.
Like INT64_FORMAT and UINT64_FORMAT, these macros produce format strings for 64-bit integers. However, INT64_HEX_FORMAT and UINT64_HEX_FORMAT generate the output in hexadecimal instead of decimal. Besides introducing these macros, this commit makes use of them in several places. This was originally intended to be part of commit 5d6187d, but I left it out because I felt there was a nonzero chance that back-patching these new macros into c.h could cause problems with third-party code. We tend to be less cautious with such changes in new major versions. Note that UINT64_HEX_FORMAT was originally added in commit ee1b30f, but it was placed in test_radixtree.c, so it wasn't widely available. This commit moves UINT64_HEX_FORMAT to c.h. Discussion: https://postgr.es/m/ZwQvtUbPKaaRQezd%40nathan
1 parent 8589876 commit efdc7d7

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

contrib/postgres_fdw/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ process_pgfdw_appname(const char *appname)
521521
appendStringInfoString(&buf, application_name);
522522
break;
523523
case 'c':
524-
appendStringInfo(&buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
524+
appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
525525
break;
526526
case 'C':
527527
appendStringInfoString(&buf, cluster_name);

src/backend/utils/error/csvlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ write_csvlog(ErrorData *edata)
120120
appendStringInfoChar(&buf, ',');
121121

122122
/* session id */
123-
appendStringInfo(&buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
123+
appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
124124
appendStringInfoChar(&buf, ',');
125125

126126
/* Line number */

src/backend/utils/error/elog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,12 +2947,12 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
29472947
{
29482948
char strfbuf[128];
29492949

2950-
snprintf(strfbuf, sizeof(strfbuf) - 1, "%" INT64_MODIFIER "x.%x",
2950+
snprintf(strfbuf, sizeof(strfbuf) - 1, INT64_HEX_FORMAT ".%x",
29512951
MyStartTime, MyProcPid);
29522952
appendStringInfo(buf, "%*s", padding, strfbuf);
29532953
}
29542954
else
2955-
appendStringInfo(buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
2955+
appendStringInfo(buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
29562956
break;
29572957
case 'p':
29582958
if (padding != 0)

src/backend/utils/error/jsonlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ write_jsonlog(ErrorData *edata)
168168
}
169169

170170
/* Session id */
171-
appendJSONKeyValueFmt(&buf, "session_id", true, "%" INT64_MODIFIER "x.%x",
171+
appendJSONKeyValueFmt(&buf, "session_id", true, INT64_HEX_FORMAT ".%x",
172172
MyStartTime, MyProcPid);
173173

174174
/* Line number */

src/include/c.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ typedef unsigned long long int uint64;
550550
/* snprintf format strings to use for 64-bit integers */
551551
#define INT64_FORMAT "%" INT64_MODIFIER "d"
552552
#define UINT64_FORMAT "%" INT64_MODIFIER "u"
553+
#define INT64_HEX_FORMAT "%" INT64_MODIFIER "x"
554+
#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "x"
553555

554556
/*
555557
* 128-bit signed and unsigned integers

src/test/modules/test_radixtree/test_radixtree.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
/* uncomment to use shared memory for the tree */
2222
/* #define TEST_SHARED_RT */
2323

24-
#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "X"
25-
2624
/* Convenient macros to test results */
2725
#define EXPECT_TRUE(expr) \
2826
do { \

0 commit comments

Comments
 (0)