diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index aac8c74f546e..349e7bbfd7e0 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -1037,9 +1037,9 @@ bt_report_duplicate(BtreeCheckState *state, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("index uniqueness is violated for index \"%s\"", RelationGetRelationName(state->rel)), - errdetail("Index %s%s and%s%s (point to heap %s and %s) page lsn=%X/%X.", + errdetail("Index %s%s and%s%s (point to heap %s and %s) page lsn=%016" PRIX64 ".", itid, pposting, nitid, pnposting, htid, nhtid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* Check if current nbtree leaf entry complies with UNIQUE constraint */ @@ -1182,9 +1182,9 @@ bt_leftmost_ignoring_half_dead(BtreeCheckState *state, (errcode(ERRCODE_NO_DATA), errmsg_internal("harmless interrupted page deletion detected in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Block=%u right block=%u page lsn=%X/%X.", + errdetail_internal("Block=%u right block=%u page lsn=%016" PRIX64 ".", reached, reached_from, - LSN_FORMAT_ARGS(pagelsn)))); + pagelsn))); reached_from = reached; reached = reached_opaque->btpo_prev; @@ -1407,11 +1407,11 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("wrong number of high key index tuple attributes in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index block=%u natts=%u block type=%s page lsn=%X/%X.", + errdetail_internal("Index block=%u natts=%u block type=%s page lsn=%016" PRIX64 ".", state->targetblock, BTreeTupleGetNAtts(itup, state->rel), P_ISLEAF(topaque) ? "heap" : "index", - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } } @@ -1456,10 +1456,10 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("index tuple size does not equal lp_len in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=(%u,%u) tuple size=%zu lp_len=%u page lsn=%X/%X.", + errdetail_internal("Index tid=(%u,%u) tuple size=%zu lp_len=%u page lsn=%016" PRIX64 ".", state->targetblock, offset, tupsize, ItemIdGetLength(itemid), - LSN_FORMAT_ARGS(state->targetlsn)), + state->targetlsn), errhint("This could be a torn page problem."))); /* Check the number of index tuple attributes */ @@ -1480,12 +1480,12 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("wrong number of index tuple attributes in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=%s natts=%u points to %s tid=%s page lsn=%X/%X.", + errdetail_internal("Index tid=%s natts=%u points to %s tid=%s page lsn=%016" PRIX64 ".", itid, BTreeTupleGetNAtts(itup, state->rel), P_ISLEAF(topaque) ? "heap" : "index", htid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* @@ -1530,9 +1530,9 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("could not find tuple using search from root page in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=%s points to heap tid=%s page lsn=%X/%X.", + errdetail_internal("Index tid=%s points to heap tid=%s page lsn=%016" PRIX64 ".", itid, htid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* @@ -1559,9 +1559,9 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg_internal("posting list contains misplaced TID in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=%s posting list offset=%d page lsn=%X/%X.", + errdetail_internal("Index tid=%s posting list offset=%d page lsn=%016" PRIX64 ".", itid, i, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } ItemPointerCopy(current, &last); @@ -1613,11 +1613,11 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("index row size %zu exceeds maximum for index \"%s\"", tupsize, RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=%s points to %s tid=%s page lsn=%X/%X.", + errdetail_internal("Index tid=%s points to %s tid=%s page lsn=%016" PRIX64 ".", itid, P_ISLEAF(topaque) ? "heap" : "index", htid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* Fingerprint leaf page tuples (those that point to the heap) */ @@ -1720,11 +1720,11 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("high key invariant violated for index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Index tid=%s points to %s tid=%s page lsn=%X/%X.", + errdetail_internal("Index tid=%s points to %s tid=%s page lsn=%016" PRIX64 ".", itid, P_ISLEAF(topaque) ? "heap" : "index", htid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* Reset, in case scantid was set to (itup) posting tuple's max TID */ skey->scantid = scantid; @@ -1768,14 +1768,14 @@ bt_target_page_check(BtreeCheckState *state) RelationGetRelationName(state->rel)), errdetail_internal("Lower index tid=%s (points to %s tid=%s) " "higher index tid=%s (points to %s tid=%s) " - "page lsn=%X/%X.", + "page lsn=%016" PRIX64 ".", itid, P_ISLEAF(topaque) ? "heap" : "index", htid, nitid, P_ISLEAF(topaque) ? "heap" : "index", nhtid, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* @@ -1885,9 +1885,9 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("cross page item order invariant violated for index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Last item on page tid=(%u,%u) page lsn=%X/%X.", + errdetail_internal("Last item on page tid=(%u,%u) page lsn=%016" PRIX64 ".", state->targetblock, offset, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } /* @@ -1938,9 +1938,9 @@ bt_target_page_check(BtreeCheckState *state) (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("right block of leaf block is non-leaf for index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Block=%u page lsn=%X/%X.", + errdetail_internal("Block=%u page lsn=%016" PRIX64 ".", state->targetblock, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); itemid = PageGetItemIdCareful(state, rightblock_number, rightpage, @@ -2362,9 +2362,9 @@ bt_child_highkey_check(BtreeCheckState *state, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("the first child of leftmost target page is not leftmost of its level in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Target block=%u child block=%u target page lsn=%X/%X.", + errdetail_internal("Target block=%u child block=%u target page lsn=%016" PRIX64 ".", state->targetblock, blkno, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); /* Do level sanity check */ if ((!P_ISDELETED(opaque) || P_HAS_FULLXID(opaque)) && @@ -2448,9 +2448,9 @@ bt_child_highkey_check(BtreeCheckState *state, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("child high key is greater than rightmost pivot key on target level in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Target block=%u child block=%u target page lsn=%X/%X.", + errdetail_internal("Target block=%u child block=%u target page lsn=%016" PRIX64 ".", state->targetblock, blkno, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); pivotkey_offset = P_HIKEY; } itemid = PageGetItemIdCareful(state, state->targetblock, @@ -2478,9 +2478,9 @@ bt_child_highkey_check(BtreeCheckState *state, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("can't find left sibling high key in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Target block=%u child block=%u target page lsn=%X/%X.", + errdetail_internal("Target block=%u child block=%u target page lsn=%016" PRIX64 ".", state->targetblock, blkno, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); itup = state->lowkey; } @@ -2490,9 +2490,9 @@ bt_child_highkey_check(BtreeCheckState *state, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("mismatch between parent key and child high key in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Target block=%u child block=%u target page lsn=%X/%X.", + errdetail_internal("Target block=%u child block=%u target page lsn=%016" PRIX64 ".", state->targetblock, blkno, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } } @@ -2630,9 +2630,9 @@ bt_child_check(BtreeCheckState *state, BTScanInsert targetkey, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("downlink to deleted page found in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Parent block=%u child block=%u parent page lsn=%X/%X.", + errdetail_internal("Parent block=%u child block=%u parent page lsn=%016" PRIX64 ".", state->targetblock, childblock, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); for (offset = P_FIRSTDATAKEY(copaque); offset <= maxoffset; @@ -2671,9 +2671,9 @@ bt_child_check(BtreeCheckState *state, BTScanInsert targetkey, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("down-link lower bound invariant violated for index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Parent block=%u child index tid=(%u,%u) parent page lsn=%X/%X.", + errdetail_internal("Parent block=%u child index tid=(%u,%u) parent page lsn=%016" PRIX64 ".", state->targetblock, childblock, offset, - LSN_FORMAT_ARGS(state->targetlsn)))); + state->targetlsn))); } pfree(child); @@ -2741,10 +2741,10 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, (errcode(ERRCODE_NO_DATA), errmsg_internal("harmless interrupted page split detected in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Block=%u level=%u left sibling=%u page lsn=%X/%X.", + errdetail_internal("Block=%u level=%u left sibling=%u page lsn=%016" PRIX64 ".", blkno, opaque->btpo_level, opaque->btpo_prev, - LSN_FORMAT_ARGS(pagelsn)))); + pagelsn))); return; } @@ -2763,9 +2763,9 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("leaf index block lacks downlink in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Block=%u page lsn=%X/%X.", + errdetail_internal("Block=%u page lsn=%016" PRIX64 ".", blkno, - LSN_FORMAT_ARGS(pagelsn)))); + pagelsn))); /* Descend from the given page, which is an internal page */ elog(DEBUG1, "checking for interrupted multi-level deletion due to missing downlink in index \"%s\"", @@ -2829,9 +2829,9 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg_internal("downlink to deleted leaf page found in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Top parent/target block=%u leaf block=%u top parent/under check lsn=%X/%X.", + errdetail_internal("Top parent/target block=%u leaf block=%u top parent/under check lsn=%016" PRIX64 ".", blkno, childblk, - LSN_FORMAT_ARGS(pagelsn)))); + pagelsn))); /* * Iff leaf page is half-dead, its high key top parent link should point @@ -2855,9 +2855,9 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, (errcode(ERRCODE_INDEX_CORRUPTED), errmsg("internal index block lacks downlink in index \"%s\"", RelationGetRelationName(state->rel)), - errdetail_internal("Block=%u level=%u page lsn=%X/%X.", + errdetail_internal("Block=%u level=%u page lsn=%016" PRIX64 ".", blkno, opaque->btpo_level, - LSN_FORMAT_ARGS(pagelsn)))); + pagelsn))); } /* diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index bf707c812ede..5d9c09c5c4dc 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -794,8 +794,8 @@ fileIterateForeignScan(ForeignScanState *node) cstate->num_errors > cstate->opts.reject_limit) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("skipped more than REJECT_LIMIT (%lld) rows due to data type incompatibility", - (long long) cstate->opts.reject_limit))); + errmsg("skipped more than REJECT_LIMIT (%" PRId64 ") rows due to data type incompatibility", + cstate->opts.reject_limit))); /* Repeat NextCopyFrom() until no soft error occurs */ goto retry; @@ -851,10 +851,10 @@ fileEndForeignScan(ForeignScanState *node) festate->cstate->num_errors > 0 && festate->cstate->opts.log_verbosity >= COPY_LOG_VERBOSITY_DEFAULT) ereport(NOTICE, - errmsg_plural("%llu row was skipped due to data type incompatibility", - "%llu rows were skipped due to data type incompatibility", - (unsigned long long) festate->cstate->num_errors, - (unsigned long long) festate->cstate->num_errors)); + errmsg_plural("%" PRIu64 " row was skipped due to data type incompatibility", + "%" PRIu64 " rows were skipped due to data type incompatibility", + festate->cstate->num_errors, + festate->cstate->num_errors)); EndCopyFrom(festate->cstate); } @@ -1315,10 +1315,10 @@ file_acquire_sample_rows(Relation onerel, int elevel, cstate->num_errors > 0 && cstate->opts.log_verbosity >= COPY_LOG_VERBOSITY_DEFAULT) ereport(NOTICE, - errmsg_plural("%llu row was skipped due to data type incompatibility", - "%llu rows were skipped due to data type incompatibility", - (unsigned long long) cstate->num_errors, - (unsigned long long) cstate->num_errors)); + errmsg_plural("%" PRIu64 " row was skipped due to data type incompatibility", + "%" PRIu64 " rows were skipped due to data type incompatibility", + cstate->num_errors, + cstate->num_errors)); EndCopyFrom(cstate); diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c index 9cdc8e182b48..294821231fc3 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -206,14 +206,12 @@ check_relation_block_range(Relation rel, int64 blkno) if (blkno < 0 || blkno > MaxBlockNumber) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid block number %lld", - (long long) blkno))); + errmsg("invalid block number %" PRId64, blkno))); if ((BlockNumber) (blkno) >= RelationGetNumberOfBlocks(rel)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("block number %lld is out of range", - (long long) blkno))); + errmsg("block number %" PRId64 " is out of range", blkno))); } /* ----------------------------------------------- diff --git a/contrib/pageinspect/expected/gist.out b/contrib/pageinspect/expected/gist.out index 2b1d54a62794..a5169f4cae71 100644 --- a/contrib/pageinspect/expected/gist.out +++ b/contrib/pageinspect/expected/gist.out @@ -5,21 +5,21 @@ CREATE UNLOGGED TABLE test_gist AS SELECT point(i,i) p, i::text t FROM CREATE INDEX test_gist_idx ON test_gist USING gist (p); -- Page 0 is the root, the rest are leaf pages SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 0)); - lsn | nsn | rightlink | flags ------+-----+------------+------- - 0/1 | 0/0 | 4294967295 | {} + lsn | nsn | rightlink | flags +------------------+------------------+------------+------- + 0000000000000001 | 0000000000000000 | 4294967295 | {} (1 row) SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 1)); - lsn | nsn | rightlink | flags ------+-----+------------+-------- - 0/1 | 0/0 | 4294967295 | {leaf} + lsn | nsn | rightlink | flags +------------------+------------------+------------+-------- + 0000000000000001 | 0000000000000000 | 4294967295 | {leaf} (1 row) SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2)); - lsn | nsn | rightlink | flags ------+-----+-----------+-------- - 0/1 | 0/0 | 1 | {leaf} + lsn | nsn | rightlink | flags +------------------+------------------+-----------+-------- + 0000000000000001 | 0000000000000000 | 1 | {leaf} (1 row) SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx'); diff --git a/contrib/pageinspect/expected/page.out b/contrib/pageinspect/expected/page.out index e42fd9747fd1..86c57917365e 100644 --- a/contrib/pageinspect/expected/page.out +++ b/contrib/pageinspect/expected/page.out @@ -265,9 +265,9 @@ SELECT fsm_page_contents(decode(repeat('00', :block_size), 'hex')); (1 row) SELECT page_header(decode(repeat('00', :block_size), 'hex')); - page_header ------------------------ - (0/0,0,0,0,0,0,0,0,0) + page_header +------------------------------------ + (0000000000000000,0,0,0,0,0,0,0,0) (1 row) SELECT page_checksum(decode(repeat('00', :block_size), 'hex'), 1); diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c index d4a2a1d676ab..ca7f1f6e7410 100644 --- a/contrib/pageinspect/hashfuncs.c +++ b/contrib/pageinspect/hashfuncs.c @@ -436,8 +436,8 @@ hash_bitmap_info(PG_FUNCTION_ARGS) if (ovflblkno >= RelationGetNumberOfBlocks(indexRel)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("block number %lld is out of range for relation \"%s\"", - (long long int) ovflblkno, RelationGetRelationName(indexRel)))); + errmsg("block number %" PRId64 " is out of range for relation \"%s\"", + ovflblkno, RelationGetRelationName(indexRel)))); /* Read the metapage so we can determine which bitmap page to use */ metabuf = _hash_getbuf(indexRel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c index 617dff821a6d..0336ccb4ab67 100644 --- a/contrib/pageinspect/rawpage.c +++ b/contrib/pageinspect/rawpage.c @@ -279,7 +279,7 @@ page_header(PG_FUNCTION_ARGS) { char lsnchar[64]; - snprintf(lsnchar, sizeof(lsnchar), "%X/%X", LSN_FORMAT_ARGS(lsn)); + snprintf(lsnchar, sizeof(lsnchar), "%016" PRIX64, lsn); values[0] = CStringGetTextDatum(lsnchar); } else diff --git a/contrib/pg_prewarm/pg_prewarm.c b/contrib/pg_prewarm/pg_prewarm.c index a2f0ac4af0c9..8f96656c52a7 100644 --- a/contrib/pg_prewarm/pg_prewarm.c +++ b/contrib/pg_prewarm/pg_prewarm.c @@ -126,8 +126,8 @@ pg_prewarm(PG_FUNCTION_ARGS) if (first_block < 0 || first_block >= nblocks) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("starting block number must be between 0 and %lld", - (long long) (nblocks - 1)))); + errmsg("starting block number must be between 0 and %" PRId64, + (nblocks - 1)))); } if (PG_ARGISNULL(4)) last_block = nblocks - 1; @@ -137,8 +137,8 @@ pg_prewarm(PG_FUNCTION_ARGS) if (last_block < 0 || last_block >= nblocks) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("ending block number must be between 0 and %lld", - (long long) (nblocks - 1)))); + errmsg("ending block number must be between 0 and %" PRId64, + (nblocks - 1)))); } /* Now we're ready to do the real work. */ diff --git a/contrib/pg_walinspect/expected/pg_walinspect.out b/contrib/pg_walinspect/expected/pg_walinspect.out index c010eed8c5d6..037cd363c461 100644 --- a/contrib/pg_walinspect/expected/pg_walinspect.out +++ b/contrib/pg_walinspect/expected/pg_walinspect.out @@ -19,14 +19,14 @@ INSERT INTO sample_tbl SELECT * FROM generate_series(3, 4); -- =================================================================== -- Invalid input LSN. SELECT * FROM pg_get_wal_record_info('0/0'); -ERROR: could not read WAL at LSN 0/0 +ERROR: could not read WAL at LSN 0000000000000000 -- Invalid start LSN. SELECT * FROM pg_get_wal_records_info('0/0', :'wal_lsn1'); -ERROR: could not read WAL at LSN 0/0 +ERROR: could not read WAL at LSN 0000000000000000 SELECT * FROM pg_get_wal_stats('0/0', :'wal_lsn1'); -ERROR: could not read WAL at LSN 0/0 +ERROR: could not read WAL at LSN 0000000000000000 SELECT * FROM pg_get_wal_block_info('0/0', :'wal_lsn1'); -ERROR: could not read WAL at LSN 0/0 +ERROR: could not read WAL at LSN 0000000000000000 -- Start LSN > End LSN. SELECT * FROM pg_get_wal_records_info(:'wal_lsn2', :'wal_lsn1'); ERROR: WAL start LSN must be less than end LSN diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c index 9e6094157894..7dbfe4d8e793 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -102,8 +102,7 @@ InitXLogReaderState(XLogRecPtr lsn) if (lsn < XLOG_BLCKSZ) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("could not read WAL at LSN %X/%X", - LSN_FORMAT_ARGS(lsn)))); + errmsg("could not read WAL at LSN %016" PRIX64, lsn))); private_data = (ReadLocalXLogPageNoWaitPrivate *) palloc0(sizeof(ReadLocalXLogPageNoWaitPrivate)); @@ -125,8 +124,8 @@ InitXLogReaderState(XLogRecPtr lsn) if (XLogRecPtrIsInvalid(first_valid_record)) ereport(ERROR, - (errmsg("could not find a valid record after %X/%X", - LSN_FORMAT_ARGS(lsn)))); + (errmsg("could not find a valid record after %016" PRIX64, + lsn))); return xlogreader; } @@ -165,13 +164,13 @@ ReadNextXLogRecord(XLogReaderState *xlogreader) if (errormsg) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read WAL at %X/%X: %s", - LSN_FORMAT_ARGS(xlogreader->EndRecPtr), errormsg))); + errmsg("could not read WAL at %016" PRIX64 ": %s", + xlogreader->EndRecPtr, errormsg))); else ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read WAL at %X/%X", - LSN_FORMAT_ARGS(xlogreader->EndRecPtr)))); + errmsg("could not read WAL at %016" PRIX64, + xlogreader->EndRecPtr))); } return record; @@ -476,8 +475,9 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("WAL input LSN must be less than current LSN"), - errdetail("Current WAL LSN on the database system is at %X/%X.", - LSN_FORMAT_ARGS(curr_lsn)))); + errdetail("Current WAL LSN on the database system is at %016" + PRIX64 ".", + curr_lsn))); /* Build a tuple descriptor for our result type. */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) @@ -488,8 +488,8 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS) if (!ReadNextXLogRecord(xlogreader)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("could not read WAL at %X/%X", - LSN_FORMAT_ARGS(xlogreader->EndRecPtr)))); + errmsg("could not read WAL at %016" PRIX64, + xlogreader->EndRecPtr))); GetWALRecordInfo(xlogreader, values, nulls, PG_GET_WAL_RECORD_INFO_COLS); @@ -518,8 +518,9 @@ ValidateInputLSNs(XLogRecPtr start_lsn, XLogRecPtr *end_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("WAL start LSN must be less than current LSN"), - errdetail("Current WAL LSN on the database system is at %X/%X.", - LSN_FORMAT_ARGS(curr_lsn)))); + errdetail("Current WAL LSN on the database system is at %016" + PRIX64 ".", + curr_lsn))); if (start_lsn > *end_lsn) ereport(ERROR, @@ -824,8 +825,8 @@ pg_get_wal_records_info_till_end_of_wal(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("WAL start LSN must be less than current LSN"), - errdetail("Current WAL LSN on the database system is at %X/%X.", - LSN_FORMAT_ARGS(end_lsn)))); + errdetail("Current WAL LSN on the database system is at %016" PRIX64, + end_lsn))); GetWALRecordsInfo(fcinfo, start_lsn, end_lsn); @@ -843,8 +844,9 @@ pg_get_wal_stats_till_end_of_wal(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("WAL start LSN must be less than current LSN"), - errdetail("Current WAL LSN on the database system is at %X/%X.", - LSN_FORMAT_ARGS(end_lsn)))); + errdetail("Current WAL LSN on the database system is at %016" + PRIX64 ".", + end_lsn))); GetWalStats(fcinfo, start_lsn, end_lsn, stats_per_record); diff --git a/contrib/test_decoding/expected/replorigin.out b/contrib/test_decoding/expected/replorigin.out index c85e1a01b231..453fd9c8f95d 100644 --- a/contrib/test_decoding/expected/replorigin.out +++ b/contrib/test_decoding/expected/replorigin.out @@ -126,13 +126,13 @@ COMMIT; SELECT pg_replication_origin_session_progress(false); pg_replication_origin_session_progress ---------------------------------------- - 0/AABBCCDD + 00000000AABBCCDD (1 row) SELECT pg_replication_origin_session_progress(true); pg_replication_origin_session_progress ---------------------------------------- - 0/AABBCCDD + 00000000AABBCCDD (1 row) SELECT pg_replication_origin_session_reset(); @@ -142,22 +142,22 @@ SELECT pg_replication_origin_session_reset(); (1 row) SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origin_status; - local_id | external_id | remote_lsn | ?column? -----------+----------------------------------------+------------+---------- - 1 | regress_test_decoding: regression_slot | 0/AABBCCDD | t + local_id | external_id | remote_lsn | ?column? +----------+----------------------------------------+------------------+---------- + 1 | regress_test_decoding: regression_slot | 00000000AABBCCDD | t (1 row) -- check replication progress identified by name is correct SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', false); pg_replication_origin_progress -------------------------------- - 0/AABBCCDD + 00000000AABBCCDD (1 row) SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', true); pg_replication_origin_progress -------------------------------- - 0/AABBCCDD + 00000000AABBCCDD (1 row) -- ensure reset requires previously setup state diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index fb0506355515..8a771dc3d537 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -7977,7 +7977,7 @@ SCRAM-SHA-256$<iteration count>:&l Finish LSN of the transaction whose changes are to be skipped, if a valid - LSN; otherwise 0/0. + LSN; otherwise 0000000000000000. diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 09309ba0390b..5c31c331106e 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -5099,19 +5099,22 @@ WHERE ... Internally, an LSN is a 64-bit integer, representing a byte position in - the write-ahead log stream. It is printed as two hexadecimal numbers of - up to 8 digits each, separated by a slash; for example, - 16/B374D848. The pg_lsn type supports the - standard comparison operators, like = and - >. Two LSNs can be subtracted using the + the write-ahead log stream. It is printed as 16 hexadecimal digits; for + example 00000016B374D848. (Historically it was printed + as two 32-bit hexadecimal numbers separated by a slash, for example + 16/B374D848. This format is + still accepted as the pg_lsn as an input string.) + The pg_lsn type supports the standard comparison operators, + like = and >. Two LSNs can be + subtracted using the - operator; the result is the number of bytes separating those write-ahead log locations. Also the number of bytes can be added into and subtracted from LSN using the +(pg_lsn,numeric) and -(pg_lsn,numeric) operators, respectively. Note that the calculated LSN should be in the range of pg_lsn type, - i.e., between 0/0 and - FFFFFFFF/FFFFFFFF. + i.e., between 0000000000000000 and + FFFFFFFFFFFFFFFF. diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 3d18e507bbcd..457a324487a0 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -595,9 +595,9 @@ CREATE SUBSCRIPTION slot to create is same as the subscription name, e.g. "sub1". test_pub=# SELECT * FROM pg_create_logical_replication_slot('sub1', 'pgoutput'); - slot_name | lsn ------------+----------- - sub1 | 0/19404D0 + slot_name | lsn +-----------+------------------ + sub1 | 00000000019404D0 (1 row) @@ -640,9 +640,9 @@ CREATE SUBSCRIPTION specified during CREATE SUBSCRIPTION, e.g. "myslot". test_pub=# SELECT * FROM pg_create_logical_replication_slot('myslot', 'pgoutput'); - slot_name | lsn ------------+----------- - myslot | 0/19059A0 + slot_name | lsn +-----------+------------------ + myslot | 00000000019059A0 (1 row) @@ -681,9 +681,9 @@ CREATE SUBSCRIPTION On the publisher, manually create a slot using any name, e.g. "myslot". test_pub=# SELECT * FROM pg_create_logical_replication_slot('myslot', 'pgoutput'); - slot_name | lsn ------------+----------- - myslot | 0/1905930 + slot_name | lsn +-----------+------------------ + myslot | 0000000001905930 (1 row) @@ -2017,15 +2017,15 @@ DETAIL: detailed_explanation. ERROR: conflict detected on relation "public.test": conflict=insert_exists DETAIL: Key already exists in unique index "t_pkey", which was modified locally in transaction 740 at 2024-06-26 10:47:04.727375+08. Key (c)=(1); existing local tuple (1, 'local'); remote tuple (1, 'remote'). -CONTEXT: processing remote data for replication origin "pg_16395" during "INSERT" for replication target relation "public.test" in transaction 725 finished at 0/14C0378 +CONTEXT: processing remote data for replication origin "pg_16395" during "INSERT" for replication target relation "public.test" in transaction 725 finished at 00000000014C0378 The LSN of the transaction that contains the change violating the constraint and - the replication origin name can be found from the server log (LSN 0/14C0378 and + the replication origin name can be found from the server log (LSN 00000000014C0378 and replication origin pg_16395 in the above case). The transaction that produced the conflict can be skipped by using ALTER SUBSCRIPTION ... SKIP with the finish LSN - (i.e., LSN 0/14C0378). The finish LSN could be an LSN at which the transaction + (i.e., LSN 00000000014C0378). The finish LSN could be an LSN at which the transaction is committed or prepared on the publisher. Alternatively, the transaction can also be skipped by calling the pg_replication_origin_advance() function. @@ -2036,7 +2036,7 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER disable_on_error option. Then, you can use pg_replication_origin_advance() function with the node_name (i.e., pg_16395) - and the next LSN of the finish LSN (i.e., 0/14C0379). The current position of + and the next LSN of the finish LSN (i.e., 00000000014C0379). The current position of origins can be seen in the pg_replication_origin_status system view. Please note that skipping the whole transaction includes skipping changes that diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml index 1c4ae38f1b99..8a38930afe23 100644 --- a/doc/src/sgml/logicaldecoding.sgml +++ b/doc/src/sgml/logicaldecoding.sgml @@ -56,15 +56,15 @@ postgres=# -- Create a slot named 'regression_slot' using the output plugin 'test_decoding' postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding', false, true); - slot_name | lsn ------------------+----------- - regression_slot | 0/16B1970 + slot_name | lsn +-----------------+------------------ + regression_slot | 00000000016B1970 (1 row) postgres=# SELECT slot_name, plugin, slot_type, database, active, restart_lsn, confirmed_flush_lsn FROM pg_replication_slots; - slot_name | plugin | slot_type | database | active | restart_lsn | confirmed_flush_lsn ------------------+---------------+-----------+----------+--------+-------------+----------------- - regression_slot | test_decoding | logical | postgres | f | 0/16A4408 | 0/16A4440 + slot_name | plugin | slot_type | database | active | restart_lsn | confirmed_flush_lsn +-----------------+---------------+-----------+----------+--------+------------------+--------------------- + regression_slot | test_decoding | logical | postgres | f | 00000000016A4408 | 00000000016A4440 (1 row) postgres=# -- There are no changes to see yet @@ -78,10 +78,10 @@ CREATE TABLE postgres=# -- DDL isn't replicated, so all you'll see is the transaction postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-------+-------------- - 0/BA2DA58 | 10297 | BEGIN 10297 - 0/BA5A5A0 | 10297 | COMMIT 10297 + lsn | xid | data +------------------+-------+-------------- + 000000000BA2DA58 | 10297 | BEGIN 10297 + 000000000BA5A5A0 | 10297 | COMMIT 10297 (2 rows) postgres=# -- Once changes are read, they're consumed and not emitted @@ -97,41 +97,41 @@ postgres=*# INSERT INTO data(data) VALUES('2'); postgres=*# COMMIT; postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-------+--------------------------------------------------------- - 0/BA5A688 | 10298 | BEGIN 10298 - 0/BA5A6F0 | 10298 | table public.data: INSERT: id[integer]:1 data[text]:'1' - 0/BA5A7F8 | 10298 | table public.data: INSERT: id[integer]:2 data[text]:'2' - 0/BA5A8A8 | 10298 | COMMIT 10298 + lsn | xid | data +------------------+-------+--------------------------------------------------------- + 000000000BA5A688 | 10298 | BEGIN 10298 + 000000000BA5A6F0 | 10298 | table public.data: INSERT: id[integer]:1 data[text]:'1' + 000000000BA5A7F8 | 10298 | table public.data: INSERT: id[integer]:2 data[text]:'2' + 000000000BA5A8A8 | 10298 | COMMIT 10298 (4 rows) postgres=# INSERT INTO data(data) VALUES('3'); postgres=# -- You can also peek ahead in the change stream without consuming changes postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-------+--------------------------------------------------------- - 0/BA5A8E0 | 10299 | BEGIN 10299 - 0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' - 0/BA5A990 | 10299 | COMMIT 10299 + lsn | xid | data +------------------+-------+--------------------------------------------------------- + 000000000BA5A8E0 | 10299 | BEGIN 10299 + 000000000BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' + 000000000BA5A990 | 10299 | COMMIT 10299 (3 rows) postgres=# -- The next call to pg_logical_slot_peek_changes() returns the same changes again postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-------+--------------------------------------------------------- - 0/BA5A8E0 | 10299 | BEGIN 10299 - 0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' - 0/BA5A990 | 10299 | COMMIT 10299 + lsn | xid | data +------------------+-------+--------------------------------------------------------- + 000000000BA5A8E0 | 10299 | BEGIN 10299 + 000000000BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' + 000000000BA5A990 | 10299 | COMMIT 10299 (3 rows) postgres=# -- options can be passed to output plugin, to influence the formatting postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-timestamp', 'on'); - lsn | xid | data ------------+-------+--------------------------------------------------------- - 0/BA5A8E0 | 10299 | BEGIN 10299 - 0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' - 0/BA5A990 | 10299 | COMMIT 10299 (at 2017-05-10 12:07:21.272494-04) + lsn | xid | data +------------------+-------+--------------------------------------------------------- + 000000000BA5A8E0 | 10299 | BEGIN 10299 + 000000000BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3' + 000000000BA5A990 | 10299 | COMMIT 10299 (at 2017-05-10 12:07:21.272494-04) (3 rows) postgres=# -- Remember to destroy a slot you no longer need to stop it consuming @@ -200,18 +200,18 @@ postgres=*# INSERT INTO data(data) VALUES('5'); postgres=*# PREPARE TRANSACTION 'test_prepared1'; postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-----+--------------------------------------------------------- - 0/1689DC0 | 529 | BEGIN 529 - 0/1689DC0 | 529 | table public.data: INSERT: id[integer]:3 data[text]:'5' - 0/1689FC0 | 529 | PREPARE TRANSACTION 'test_prepared1', txid 529 + lsn | xid | data +------------------+-----+--------------------------------------------------------- + 0000000001689DC0 | 529 | BEGIN 529 + 0000000001689DC0 | 529 | table public.data: INSERT: id[integer]:3 data[text]:'5' + 0000000001689FC0 | 529 | PREPARE TRANSACTION 'test_prepared1', txid 529 (3 rows) postgres=# COMMIT PREPARED 'test_prepared1'; postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-----+-------------------------------------------- - 0/168A060 | 529 | COMMIT PREPARED 'test_prepared1', txid 529 + lsn | xid | data +------------------+-----+-------------------------------------------- + 000000000168A060 | 529 | COMMIT PREPARED 'test_prepared1', txid 529 (4 row) postgres=#-- you can also rollback a prepared transaction @@ -219,18 +219,18 @@ postgres=# BEGIN; postgres=*# INSERT INTO data(data) VALUES('6'); postgres=*# PREPARE TRANSACTION 'test_prepared2'; postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-----+--------------------------------------------------------- - 0/168A180 | 530 | BEGIN 530 - 0/168A1E8 | 530 | table public.data: INSERT: id[integer]:4 data[text]:'6' - 0/168A430 | 530 | PREPARE TRANSACTION 'test_prepared2', txid 530 + lsn | xid | data +------------------+-----+--------------------------------------------------------- + 000000000168A180 | 530 | BEGIN 530 + 000000000168A1E8 | 530 | table public.data: INSERT: id[integer]:4 data[text]:'6' + 000000000168A430 | 530 | PREPARE TRANSACTION 'test_prepared2', txid 530 (3 rows) postgres=# ROLLBACK PREPARED 'test_prepared2'; postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NULL); - lsn | xid | data ------------+-----+---------------------------------------------- - 0/168A4B8 | 530 | ROLLBACK PREPARED 'test_prepared2', txid 530 + lsn | xid | data +------------------+-----+---------------------------------------------- + 000000000168A4B8 | 530 | ROLLBACK PREPARED 'test_prepared2', txid 530 (1 row) diff --git a/doc/src/sgml/pageinspect.sgml b/doc/src/sgml/pageinspect.sgml index 487c5d758ffb..11b715b804c6 100644 --- a/doc/src/sgml/pageinspect.sgml +++ b/doc/src/sgml/pageinspect.sgml @@ -73,9 +73,9 @@ passed as argument. For example: test=# SELECT * FROM page_header(get_raw_page('pg_class', 0)); - lsn | checksum | flags | lower | upper | special | pagesize | version | prune_xid ------------+----------+--------+-------+-------+---------+----------+---------+----------- - 0/24A1B50 | 0 | 1 | 232 | 368 | 8192 | 8192 | 4 | 0 + lsn | checksum | flags | lower | upper | special | pagesize | version | prune_xid +------------------+----------+--------+-------+-------+---------+----------+---------+----------- + 00000000024A1B50 | 0 | 1 | 232 | 368 | 8192 | 8192 | 4 | 0 The returned columns correspond to the fields in the PageHeaderData struct. @@ -741,9 +741,9 @@ test=# SELECT first_tid, nbytes, tids[0:5] AS some_tids For example: test=# SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2)); - lsn | nsn | rightlink | flags ------+-----+-----------+-------- - 0/1 | 0/0 | 1 | {leaf} + lsn | nsn | rightlink | flags +------------------+------------------+-----------+-------- + 0000000000000001 | 0000000000000000 | 1 | {leaf} (1 row) diff --git a/doc/src/sgml/pglogicalinspect.sgml b/doc/src/sgml/pglogicalinspect.sgml index 4b111f961133..c319429750f1 100644 --- a/doc/src/sgml/pglogicalinspect.sgml +++ b/doc/src/sgml/pglogicalinspect.sgml @@ -86,16 +86,16 @@ size | 152 modification | 2024-08-14 16:36:32+00 postgres=# SELECT * FROM pg_get_logical_snapshot_info('0-40796E18.snap'); --[ RECORD 1 ]------------+----------- +-[ RECORD 1 ]------------+----------------- state | consistent xmin | 751 xmax | 751 -start_decoding_at | 0/40796AF8 -two_phase_at | 0/40796AF8 +start_decoding_at | 0000000040796AF8 +two_phase_at | 0000000040796AF8 initial_xmin_horizon | 0 building_full_snapshot | f in_slot_creation | f -last_serialized_snapshot | 0/0 +last_serialized_snapshot | 0000000000000000 next_phase_at | 0 committed_count | 0 committed_xip | @@ -104,17 +104,17 @@ catchange_xip | {751,752} postgres=# SELECT ss.name, info.* FROM pg_ls_logicalsnapdir() AS ss, pg_get_logical_snapshot_info(ss.name) AS info; --[ RECORD 1 ]------------+---------------- +-[ RECORD 1 ]------------+----------------- name | 0-40796E18.snap state | consistent xmin | 751 xmax | 751 -start_decoding_at | 0/40796AF8 -two_phase_at | 0/40796AF8 +start_decoding_at | 0000000040796AF8 +two_phase_at | 0000000040796AF8 initial_xmin_horizon | 0 building_full_snapshot | f in_slot_creation | f -last_serialized_snapshot | 0/0 +last_serialized_snapshot | 0000000000000000 next_phase_at | 0 committed_count | 0 committed_xip | diff --git a/doc/src/sgml/pgwalinspect.sgml b/doc/src/sgml/pgwalinspect.sgml index 3a8121c70f1f..c3b4a596228c 100644 --- a/doc/src/sgml/pgwalinspect.sgml +++ b/doc/src/sgml/pgwalinspect.sgml @@ -71,11 +71,11 @@ after the in_lsn argument. For example: -postgres=# SELECT * FROM pg_get_wal_record_info('0/E419E28'); +postgres=# SELECT * FROM pg_get_wal_record_info('000000000E419E28'); -[ RECORD 1 ]----+------------------------------------------------- -start_lsn | 0/E419E28 -end_lsn | 0/E419E68 -prev_lsn | 0/E419D78 +start_lsn | 000000000E419E28 +end_lsn | 000000000E419E68 +prev_lsn | 000000000E419D78 xid | 0 resource_manager | Heap2 record_type | VACUUM @@ -109,11 +109,11 @@ block_ref | blkref #0: rel 1663/16385/1249 fork main blk 364 start_lsn and end_lsn. Returns one row per WAL record. For example: -postgres=# SELECT * FROM pg_get_wal_records_info('0/1E913618', '0/1E913740') LIMIT 1; +postgres=# SELECT * FROM pg_get_wal_records_info('1E913618', '1E913740') LIMIT 1; -[ RECORD 1 ]----+-------------------------------------------------------------- -start_lsn | 0/1E913618 -end_lsn | 0/1E913650 -prev_lsn | 0/1E9135A0 +start_lsn | 000000001E913618 +end_lsn | 000000001E913650 +prev_lsn | 000000001E9135A0 xid | 0 resource_manager | Standby record_type | RUNNING_XACTS @@ -144,11 +144,11 @@ block_ref | references. Returns one row per block reference per WAL record. For example: -postgres=# SELECT * FROM pg_get_wal_block_info('0/1230278', '0/12302B8'); +postgres=# SELECT * FROM pg_get_wal_block_info('1230278', '12302B8'); -[ RECORD 1 ]-----+----------------------------------- -start_lsn | 0/1230278 -end_lsn | 0/12302B8 -prev_lsn | 0/122FD40 +start_lsn | 0000000001230278 +end_lsn | 00000000012302B8 +prev_lsn | 000000000122FD40 block_id | 0 reltablespace | 1663 reldatabase | 1 @@ -249,7 +249,7 @@ block_fpi_data | it returns one row per record_type. For example: -postgres=# SELECT * FROM pg_get_wal_stats('0/1E847D00', '0/1E84F500') +postgres=# SELECT * FROM pg_get_wal_stats('1E847D00', '1E84F500') WHERE count > 0 AND "resource_manager/record_type" = 'Transaction' LIMIT 1; diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 3bd9e68e6ce4..075614f83104 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -2402,13 +2402,13 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;" - START_REPLICATION [ SLOT slot_name ] [ PHYSICAL ] XXX/XXX [ TIMELINE tli ] + START_REPLICATION [ SLOT slot_name ] [ PHYSICAL ] XXXXXXXXXXXXXX [ TIMELINE tli ] START_REPLICATION Instructs server to start streaming WAL, starting at - WAL location XXX/XXX. + WAL location XXXXXXXXXXXXXXXX. If TIMELINE option is specified, streaming starts on timeline tli; otherwise, the server's current timeline is selected. The server can @@ -2714,12 +2714,12 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;" - START_REPLICATION SLOT slot_name LOGICAL XXX/XXX [ ( option_name [ option_value ] [, ...] ) ] + START_REPLICATION SLOT slot_name LOGICAL XXXXXXXXXXXXXXXX [ ( option_name [ option_value ] [, ...] ) ] Instructs server to start streaming WAL for logical replication, starting at either WAL location XXX/XXX or the slot's + class="parameter">XXXXXXXXXXXXXXXX or the slot's confirmed_flush_lsn (see ), whichever is greater. This behavior makes it easier for clients to avoid updating their local LSN @@ -2761,7 +2761,7 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;" - XXX/XXX + XXXXXXXXXXXXXXXX The WAL location to begin streaming at. diff --git a/doc/src/sgml/test-decoding.sgml b/doc/src/sgml/test-decoding.sgml index 5d1ae8f4f52e..426110b8b0cd 100644 --- a/doc/src/sgml/test-decoding.sgml +++ b/doc/src/sgml/test-decoding.sgml @@ -25,16 +25,16 @@ postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'include-xids', '0'); - lsn | xid | data ------------+-----+-------------------------------------------------- - 0/16D30F8 | 691 | BEGIN - 0/16D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg' - 0/16D32A0 | 691 | table public.data: INSERT: id[int4]:3 data[text]:'demo' - 0/16D32A0 | 691 | COMMIT - 0/16D32D8 | 692 | BEGIN - 0/16D3398 | 692 | table public.data: DELETE: id[int4]:2 - 0/16D3398 | 692 | table public.data: DELETE: id[int4]:3 - 0/16D3398 | 692 | COMMIT + lsn | xid | data +------------------+-----+--------------------------------------------------------- + 00000000016D30F8 | 691 | BEGIN + 00000000016D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg' + 00000000016D32A0 | 691 | table public.data: INSERT: id[int4]:3 data[text]:'demo' + 00000000016D32A0 | 691 | COMMIT + 00000000016D32D8 | 692 | BEGIN + 00000000016D3398 | 692 | table public.data: DELETE: id[int4]:2 + 00000000016D3398 | 692 | table public.data: DELETE: id[int4]:3 + 00000000016D3398 | 692 | COMMIT (8 rows) @@ -45,18 +45,18 @@ postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'i postgres[33712]=#* SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'stream-changes', '1'); - lsn | xid | data ------------+-----+-------------------------------------------------- - 0/16B21F8 | 503 | opening a streamed block for transaction TXN 503 - 0/16B21F8 | 503 | streaming change for TXN 503 - 0/16B2300 | 503 | streaming change for TXN 503 - 0/16B2408 | 503 | streaming change for TXN 503 - 0/16BEBA0 | 503 | closing a streamed block for transaction TXN 503 - 0/16B21F8 | 503 | opening a streamed block for transaction TXN 503 - 0/16BECA8 | 503 | streaming change for TXN 503 - 0/16BEDB0 | 503 | streaming change for TXN 503 - 0/16BEEB8 | 503 | streaming change for TXN 503 - 0/16BEBA0 | 503 | closing a streamed block for transaction TXN 503 + lsn | xid | data +-----------+-----+--------------------------------------------------------- + 00000000016B21F8 | 503 | opening a streamed block for transaction TXN 503 + 00000000016B21F8 | 503 | streaming change for TXN 503 + 00000000016B2300 | 503 | streaming change for TXN 503 + 00000000016B2408 | 503 | streaming change for TXN 503 + 00000000016BEBA0 | 503 | closing a streamed block for transaction TXN 503 + 00000000016B21F8 | 503 | opening a streamed block for transaction TXN 503 + 00000000016BECA8 | 503 | streaming change for TXN 503 + 00000000016BEDB0 | 503 | streaming change for TXN 503 + 00000000016BEEB8 | 503 | streaming change for TXN 503 + 00000000016BEBA0 | 503 | closing a streamed block for transaction TXN 503 (10 rows) diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index b01009c5d85e..4476d46e0c4c 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -1398,8 +1398,7 @@ brin_summarize_range(PG_FUNCTION_ARGS) if (heapBlk64 > BRIN_ALL_BLOCKRANGES || heapBlk64 < 0) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("block number out of range: %lld", - (long long) heapBlk64))); + errmsg("block number out of range: %" PRId64, heapBlk64))); heapBlk = (BlockNumber) heapBlk64; /* @@ -1506,8 +1505,8 @@ brin_desummarize_range(PG_FUNCTION_ARGS) if (heapBlk64 > MaxBlockNumber || heapBlk64 < 0) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("block number out of range: %lld", - (long long) heapBlk64))); + errmsg("block number out of range: %" PRId64, + heapBlk64))); heapBlk = (BlockNumber) heapBlk64; /* diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index e6d2b5fced19..be60cfc5c619 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -963,7 +963,7 @@ logical_rewrite_log_mapping(RewriteState state, TransactionId xid, snprintf(path, MAXPGPATH, "%s/" LOGICAL_REWRITE_FORMAT, PG_LOGICAL_MAPPINGS_DIR, dboid, relid, - LSN_FORMAT_ARGS(state->rs_begin_lsn), + state->rs_begin_lsn, xid, GetCurrentTransactionId()); dclist_init(&src->mappings); @@ -1083,7 +1083,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r) snprintf(path, MAXPGPATH, "%s/" LOGICAL_REWRITE_FORMAT, PG_LOGICAL_MAPPINGS_DIR, xlrec->mapped_db, xlrec->mapped_rel, - LSN_FORMAT_ARGS(xlrec->start_lsn), + xlrec->start_lsn, xlrec->mapped_xid, XLogRecGetXid(r)); fd = OpenTransientFile(path, @@ -1181,8 +1181,6 @@ CheckPointLogicalRewriteHeap(void) XLogRecPtr lsn; TransactionId rewrite_xid; TransactionId create_xid; - uint32 hi, - lo; PGFileType de_type; if (strcmp(mapping_de->d_name, ".") == 0 || @@ -1199,12 +1197,10 @@ CheckPointLogicalRewriteHeap(void) if (strncmp(mapping_de->d_name, "map-", 4) != 0) continue; - if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT, - &dboid, &relid, &hi, &lo, &rewrite_xid, &create_xid) != 6) + if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT_SCANF, + &dboid, &relid, &lsn, &rewrite_xid, &create_xid) != 5) elog(ERROR, "could not parse filename \"%s\"", mapping_de->d_name); - lsn = ((uint64) hi) << 32 | lo; - if (lsn < cutoff || cutoff == InvalidXLogRecPtr) { elog(DEBUG1, "removing logical rewrite file \"%s\"", path); diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 3b91d02605a0..27d334f45b22 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -1020,14 +1020,14 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, orig_rel_pages, vacrel->eager_scanned_pages); appendStringInfo(&buf, - _("tuples: %lld removed, %lld remain, %lld are dead but not yet removable\n"), - (long long) vacrel->tuples_deleted, - (long long) vacrel->new_rel_tuples, - (long long) vacrel->recently_dead_tuples); + _("tuples: %" PRId64 " removed, %" PRId64 " remain, %" PRId64 " are dead but not yet removable\n"), + vacrel->tuples_deleted, + (int64) vacrel->new_rel_tuples, + vacrel->recently_dead_tuples); 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, + _("tuples missed: %" PRId64 " dead from %u pages not removed due to cleanup lock contention\n"), + vacrel->missed_dead_tuples, vacrel->missed_dead_pages); diff = (int32) (ReadNextTransactionId() - vacrel->cutoffs.OldestXmin); @@ -1050,12 +1050,12 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, _("new relminmxid: %u, which is %d MXIDs ahead of previous value\n"), vacrel->NewRelminMxid, diff); } - appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %lld tuples frozen\n"), + appendStringInfo(&buf, _("frozen: %u pages from table (%.2f%% of total) had %" PRId64 " tuples frozen\n"), vacrel->new_frozen_tuple_pages, orig_rel_pages == 0 ? 100.0 : 100.0 * vacrel->new_frozen_tuple_pages / orig_rel_pages, - (long long) vacrel->tuples_frozen); + vacrel->tuples_frozen); appendStringInfo(&buf, _("visibility map: %u pages set all-visible, %u pages set all-frozen (%u were all-visible)\n"), @@ -1070,7 +1070,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, else appendStringInfoString(&buf, _("index scan needed: ")); - msgfmt = _("%u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n"); + msgfmt = _("%u pages from table (%.2f%% of total) had %" PRId64 " dead item identifiers removed\n"); } else { @@ -1079,13 +1079,13 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, else appendStringInfoString(&buf, _("index scan bypassed by failsafe: ")); - msgfmt = _("%u pages from table (%.2f%% of total) have %lld dead item identifiers\n"); + msgfmt = _("%u pages from table (%.2f%% of total) have %" PRId64 " dead item identifiers\n"); } appendStringInfo(&buf, msgfmt, vacrel->lpdead_item_pages, orig_rel_pages == 0 ? 100.0 : 100.0 * vacrel->lpdead_item_pages / orig_rel_pages, - (long long) vacrel->lpdead_items); + vacrel->lpdead_items); for (int i = 0; i < vacrel->nindexes; i++) { IndexBulkDeleteResult *istat = vacrel->indstats[i]; @@ -1130,16 +1130,16 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, appendStringInfo(&buf, _("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"), read_rate, write_rate); appendStringInfo(&buf, - _("buffer usage: %lld hits, %lld reads, %lld dirtied\n"), - (long long) total_blks_hit, - (long long) total_blks_read, - (long long) total_blks_dirtied); + _("buffer usage: %" PRId64 " hits, %" PRId64 " reads, %" PRId64 " dirtied\n"), + total_blks_hit, + total_blks_read, + total_blks_dirtied); appendStringInfo(&buf, - _("WAL usage: %lld records, %lld full page images, %llu bytes, %lld buffers full\n"), - (long long) walusage.wal_records, - (long long) walusage.wal_fpi, - (unsigned long long) walusage.wal_bytes, - (long long) walusage.wal_buffers_full); + _("WAL usage: %" PRId64 " records, %" PRId64 " full page images, %" PRIu64 " bytes, %" PRId64 " buffers full\n"), + walusage.wal_records, + walusage.wal_fpi, + walusage.wal_bytes, + walusage.wal_buffers_full); appendStringInfo(&buf, _("system usage: %s"), pg_rusage_show(&ru0)); ereport(verbose ? INFO : LOG, @@ -2799,8 +2799,8 @@ lazy_vacuum_heap_rel(LVRelState *vacrel) vacuumed_pages == vacrel->lpdead_item_pages)); ereport(DEBUG2, - (errmsg("table \"%s\": removed %lld dead item identifiers in %u pages", - vacrel->relname, (long long) vacrel->dead_items_info->num_items, + (errmsg("table \"%s\": removed %" PRId64 " dead item identifiers in %u pages", + vacrel->relname, vacrel->dead_items_info->num_items, vacuumed_pages))); /* Revert to the previous phase information for error traceback */ diff --git a/src/backend/access/rmgrdesc/clogdesc.c b/src/backend/access/rmgrdesc/clogdesc.c index f2d0ee7a023e..41bf28dcfd05 100644 --- a/src/backend/access/rmgrdesc/clogdesc.c +++ b/src/backend/access/rmgrdesc/clogdesc.c @@ -28,15 +28,15 @@ clog_desc(StringInfo buf, XLogReaderState *record) int64 pageno; memcpy(&pageno, rec, sizeof(pageno)); - appendStringInfo(buf, "page %lld", (long long) pageno); + appendStringInfo(buf, "page %" PRId64, pageno); } else if (info == CLOG_TRUNCATE) { xl_clog_truncate xlrec; memcpy(&xlrec, rec, sizeof(xl_clog_truncate)); - appendStringInfo(buf, "page %lld; oldestXact %u", - (long long) xlrec.pageno, xlrec.oldestXact); + appendStringInfo(buf, "page %" PRId64 "; oldestXact %u", + xlrec.pageno, xlrec.oldestXact); } } diff --git a/src/backend/access/rmgrdesc/committsdesc.c b/src/backend/access/rmgrdesc/committsdesc.c index c5e1c1b5bb3a..a6ab9dd78de1 100644 --- a/src/backend/access/rmgrdesc/committsdesc.c +++ b/src/backend/access/rmgrdesc/committsdesc.c @@ -28,14 +28,14 @@ commit_ts_desc(StringInfo buf, XLogReaderState *record) int64 pageno; memcpy(&pageno, rec, sizeof(pageno)); - appendStringInfo(buf, "%lld", (long long) pageno); + appendStringInfo(buf, "%" PRId64, pageno); } else if (info == COMMIT_TS_TRUNCATE) { xl_commit_ts_truncate *trunc = (xl_commit_ts_truncate *) rec; - appendStringInfo(buf, "pageno %lld, oldestXid %u", - (long long) trunc->pageno, trunc->oldestXid); + appendStringInfo(buf, "pageno %" PRId64 ", oldestXid %u", + trunc->pageno, trunc->oldestXid); } } diff --git a/src/backend/access/rmgrdesc/mxactdesc.c b/src/backend/access/rmgrdesc/mxactdesc.c index 8bd3d5b63c74..3ca0582db364 100644 --- a/src/backend/access/rmgrdesc/mxactdesc.c +++ b/src/backend/access/rmgrdesc/mxactdesc.c @@ -58,7 +58,7 @@ multixact_desc(StringInfo buf, XLogReaderState *record) int64 pageno; memcpy(&pageno, rec, sizeof(pageno)); - appendStringInfo(buf, "%lld", (long long) pageno); + appendStringInfo(buf, "%" PRId64, pageno); } else if (info == XLOG_MULTIXACT_CREATE_ID) { diff --git a/src/backend/access/rmgrdesc/replorigindesc.c b/src/backend/access/rmgrdesc/replorigindesc.c index 5dd742339969..4c6f9c538501 100644 --- a/src/backend/access/rmgrdesc/replorigindesc.c +++ b/src/backend/access/rmgrdesc/replorigindesc.c @@ -29,9 +29,9 @@ replorigin_desc(StringInfo buf, XLogReaderState *record) xlrec = (xl_replorigin_set *) rec; - appendStringInfo(buf, "set %u; lsn %X/%X; force: %d", + appendStringInfo(buf, "set %u; lsn %016" PRIX64 "; force: %d", xlrec->node_id, - LSN_FORMAT_ARGS(xlrec->remote_lsn), + xlrec->remote_lsn, xlrec->force); break; } diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c index 7f94810defc3..4b03c6ae9f8c 100644 --- a/src/backend/access/rmgrdesc/xactdesc.c +++ b/src/backend/access/rmgrdesc/xactdesc.c @@ -320,10 +320,10 @@ xact_desc_stats(StringInfo buf, const char *label, uint64 objid = ((uint64) dropped_stats[i].objid_hi) << 32 | dropped_stats[i].objid_lo; - appendStringInfo(buf, " %d/%u/%llu", + appendStringInfo(buf, " %d/%u/%" PRIu64, dropped_stats[i].kind, dropped_stats[i].dboid, - (unsigned long long) objid); + objid); } } } @@ -357,9 +357,9 @@ xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN) { - appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s", + appendStringInfo(buf, "; origin: node %u, lsn %016" PRIX64 ", at %s", origin_id, - LSN_FORMAT_ARGS(parsed.origin_lsn), + parsed.origin_lsn, timestamptz_to_str(parsed.origin_timestamp)); } } @@ -382,9 +382,9 @@ xact_desc_abort(StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId or if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN) { - appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s", + appendStringInfo(buf, "; origin: node %u, lsn %016" PRIX64 ", at %s", origin_id, - LSN_FORMAT_ARGS(parsed.origin_lsn), + parsed.origin_lsn, timestamptz_to_str(parsed.origin_timestamp)); } @@ -416,9 +416,9 @@ xact_desc_prepare(StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginI * way as PrepareRedoAdd(). */ if (origin_id != InvalidRepOriginId) - appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s", + appendStringInfo(buf, "; origin: node %u, lsn %016" PRIX64 ", at %s", origin_id, - LSN_FORMAT_ARGS(parsed.origin_lsn), + parsed.origin_lsn, timestamptz_to_str(parsed.origin_timestamp)); } diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c index 58040f28656f..bf2fa5664aa8 100644 --- a/src/backend/access/rmgrdesc/xlogdesc.c +++ b/src/backend/access/rmgrdesc/xlogdesc.c @@ -65,12 +65,12 @@ xlog_desc(StringInfo buf, XLogReaderState *record) { CheckPoint *checkpoint = (CheckPoint *) rec; - appendStringInfo(buf, "redo %X/%X; " + appendStringInfo(buf, "redo %016" PRIX64 "; " "tli %u; prev tli %u; fpw %s; wal_level %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", - LSN_FORMAT_ARGS(checkpoint->redo), + checkpoint->redo, checkpoint->ThisTimeLineID, checkpoint->PrevTimeLineID, checkpoint->fullPageWrites ? "true" : "false", @@ -111,7 +111,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record) XLogRecPtr startpoint; memcpy(&startpoint, rec, sizeof(XLogRecPtr)); - appendStringInfo(buf, "%X/%X", LSN_FORMAT_ARGS(startpoint)); + appendStringInfo(buf, "%016" PRIX64, startpoint); } else if (info == XLOG_PARAMETER_CHANGE) { @@ -156,8 +156,8 @@ xlog_desc(StringInfo buf, XLogReaderState *record) xl_overwrite_contrecord xlrec; memcpy(&xlrec, rec, sizeof(xl_overwrite_contrecord)); - appendStringInfo(buf, "lsn %X/%X; time %s", - LSN_FORMAT_ARGS(xlrec.overwritten_lsn), + appendStringInfo(buf, "lsn %016" PRIX64 "; time %s", + xlrec.overwritten_lsn, timestamptz_to_str(xlrec.overwrite_time)); } else if (info == XLOG_CHECKPOINT_REDO) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index c1e2c42e1bb6..9d25a7df0d32 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -3058,8 +3058,8 @@ PerformMembersTruncation(MultiXactOffset oldestOffset, MultiXactOffset newOldest */ while (segment != endsegment) { - elog(DEBUG2, "truncating multixact members segment %llx", - (unsigned long long) segment); + elog(DEBUG2, "truncating multixact members segment %" PRIx64, + segment); SlruDeleteSegment(MultiXactMemberCtl, segment); /* move to next segment, handling wraparound correctly */ @@ -3210,14 +3210,14 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB) } elog(DEBUG1, "performing multixact truncation: " - "offsets [%u, %u), offsets segments [%llx, %llx), " - "members [%u, %u), members segments [%llx, %llx)", + "offsets [%u, %u), offsets segments [%" PRIx64 ", %" PRIx64 "), " + "members [%u, %u), members segments [%" PRIx64 ", %" PRIx64 ")", oldestMulti, newOldestMulti, - (unsigned long long) MultiXactIdToOffsetSegment(oldestMulti), - (unsigned long long) MultiXactIdToOffsetSegment(newOldestMulti), + MultiXactIdToOffsetSegment(oldestMulti), + MultiXactIdToOffsetSegment(newOldestMulti), oldestOffset, newOldestOffset, - (unsigned long long) MXOffsetToMemberSegment(oldestOffset), - (unsigned long long) MXOffsetToMemberSegment(newOldestOffset)); + MXOffsetToMemberSegment(oldestOffset), + MXOffsetToMemberSegment(newOldestOffset)); /* * Do truncation, and the WAL logging of the truncation, in a critical @@ -3470,14 +3470,14 @@ multixact_redo(XLogReaderState *record) SizeOfMultiXactTruncate); elog(DEBUG1, "replaying multixact truncation: " - "offsets [%u, %u), offsets segments [%llx, %llx), " - "members [%u, %u), members segments [%llx, %llx)", + "offsets [%u, %u), offsets segments [%" PRIx64 ", %" PRIx64 "), " + "members [%u, %u), members segments [%" PRIx64 ", %" PRIx64 ")", xlrec.startTruncOff, xlrec.endTruncOff, - (unsigned long long) MultiXactIdToOffsetSegment(xlrec.startTruncOff), - (unsigned long long) MultiXactIdToOffsetSegment(xlrec.endTruncOff), + MultiXactIdToOffsetSegment(xlrec.startTruncOff), + MultiXactIdToOffsetSegment(xlrec.endTruncOff), xlrec.startTruncMemb, xlrec.endTruncMemb, - (unsigned long long) MXOffsetToMemberSegment(xlrec.startTruncMemb), - (unsigned long long) MXOffsetToMemberSegment(xlrec.endTruncMemb)); + MXOffsetToMemberSegment(xlrec.startTruncMemb), + 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 9ce628e62a5c..fe56286d9a97 100644 --- a/src/backend/access/transam/slru.c +++ b/src/backend/access/transam/slru.c @@ -100,8 +100,7 @@ SlruFileName(SlruCtl ctl, char *path, int64 segno) * 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); + return snprintf(path, MAXPGPATH, "%s/%015" PRIX64, ctl->Dir, segno); } else { diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c index a27f27cc037d..0ccadc0b9816 100644 --- a/src/backend/access/transam/timeline.c +++ b/src/backend/access/transam/timeline.c @@ -128,8 +128,7 @@ readTimeLineHistory(TimeLineID targetTLI) char *res; char *ptr; TimeLineID tli; - uint32 switchpoint_hi; - uint32 switchpoint_lo; + XLogRecPtr switchpoint; int nfields; pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_READ); @@ -154,7 +153,7 @@ readTimeLineHistory(TimeLineID targetTLI) if (*ptr == '\0' || *ptr == '#') continue; - nfields = sscanf(fline, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo); + nfields = sscanf(fline, "%u\t%" SCNx64, &tli, &switchpoint); if (nfields < 1) { @@ -163,7 +162,7 @@ readTimeLineHistory(TimeLineID targetTLI) (errmsg("syntax error in history file: %s", fline), errhint("Expected a numeric timeline ID."))); } - if (nfields != 3) + if (nfields != 2) ereport(FATAL, (errmsg("syntax error in history file: %s", fline), errhint("Expected a write-ahead log switchpoint location."))); @@ -178,7 +177,7 @@ readTimeLineHistory(TimeLineID targetTLI) entry = (TimeLineHistoryEntry *) palloc(sizeof(TimeLineHistoryEntry)); entry->tli = tli; entry->begin = prevend; - entry->end = ((uint64) (switchpoint_hi)) << 32 | (uint64) switchpoint_lo; + entry->end = switchpoint; prevend = entry->end; /* Build list with newest item first */ @@ -399,10 +398,10 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, * parent file failed to end with one. */ snprintf(buffer, sizeof(buffer), - "%s%u\t%X/%X\t%s\n", + "%s%u\t%016" PRIX64 "\t%s\n", (srcfd < 0) ? "" : "\n", parentTLI, - LSN_FORMAT_ARGS(switchpoint), + switchpoint, reason); nbytes = strlen(buffer); diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 73a80559194e..cbe7d4abe323 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1326,10 +1326,10 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok) stat.st_size > MaxAllocSize) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg_plural("incorrect size of file \"%s\": %lld byte", - "incorrect size of file \"%s\": %lld bytes", - (long long int) stat.st_size, path, - (long long int) stat.st_size))); + errmsg_plural("incorrect size of file \"%s\": %" PRId64 " byte", + "incorrect size of file \"%s\": %" PRId64 " bytes", + (pgoff_t) stat.st_size, path, + (pgoff_t) stat.st_size))); crc_offset = stat.st_size - sizeof(pg_crc32c); if (crc_offset != MAXALIGN(crc_offset)) @@ -1353,8 +1353,8 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok) errmsg("could not read file \"%s\": %m", path))); else ereport(ERROR, - (errmsg("could not read file \"%s\": read %d of %lld", - path, r, (long long int) stat.st_size))); + (errmsg("could not read file \"%s\": read %d of %" PRId64, + path, r, (pgoff_t) stat.st_size))); } pgstat_report_wait_end(); @@ -1426,21 +1426,21 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len) if (errormsg) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read two-phase state from WAL at %X/%X: %s", - LSN_FORMAT_ARGS(lsn), errormsg))); + errmsg("could not read two-phase state from WAL at %016" PRIX64 ": %s", + lsn, errormsg))); else ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read two-phase state from WAL at %X/%X", - LSN_FORMAT_ARGS(lsn)))); + errmsg("could not read two-phase state from WAL at %016" PRIX64, + lsn))); } if (XLogRecGetRmid(xlogreader) != RM_XACT_ID || (XLogRecGetInfo(xlogreader) & XLOG_XACT_OPMASK) != XLOG_XACT_PREPARE) ereport(ERROR, (errcode_for_file_access(), - errmsg("expected two-phase state data is not present in WAL at %X/%X", - LSN_FORMAT_ARGS(lsn)))); + errmsg("expected two-phase state data is not present in WAL at %016" PRIX64, + lsn))); if (len != NULL) *len = XLogRecGetDataLen(xlogreader); @@ -2512,8 +2512,8 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, ereport(reachedConsistency ? ERROR : WARNING, (errmsg("could not recover two-phase state file for transaction %u", hdr->xid), - errdetail("Two-phase state file has been found in WAL record %X/%X, but this transaction has already been restored from disk.", - LSN_FORMAT_ARGS(start_lsn)))); + errdetail("Two-phase state file has been found in WAL record %016" PRIX64 ", but this transaction has already been restored from disk.", + start_lsn))); return; } diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 799fc739e18c..9f0986fcccc7 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1017,7 +1017,7 @@ XLogInsertRecord(XLogRecData *rdata, oldCxt = MemoryContextSwitchTo(walDebugCxt); initStringInfo(&buf); - appendStringInfo(&buf, "INSERT @ %X/%X: ", LSN_FORMAT_ARGS(EndPos)); + appendStringInfo(&buf, "INSERT @ %016" PRIX64 ": ", EndPos); /* * We have to piece together the WAL record data from the XLogRecData @@ -1538,8 +1538,9 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto) if (upto > reservedUpto) { ereport(LOG, - (errmsg("request to flush past end of generated WAL; request %X/%X, current position %X/%X", - LSN_FORMAT_ARGS(upto), LSN_FORMAT_ARGS(reservedUpto)))); + (errmsg("request to flush past end of generated WAL; request %016" + PRIX64 ", current position %016" PRIX64, + upto, reservedUpto))); upto = reservedUpto; } @@ -1705,8 +1706,7 @@ GetXLogBuffer(XLogRecPtr ptr, TimeLineID tli) endptr = pg_atomic_read_u64(&XLogCtl->xlblocks[idx]); if (expectedEndPtr != endptr) - elog(PANIC, "could not find WAL buffer for %X/%X", - LSN_FORMAT_ARGS(ptr)); + elog(PANIC, "could not find WAL buffer for %016" PRIX64, ptr); } else { @@ -1765,9 +1765,10 @@ WALReadFromBuffers(char *dstbuf, XLogRecPtr startptr, Size count, inserted = pg_atomic_read_u64(&XLogCtl->logInsertResult); if (startptr + count > inserted) ereport(ERROR, - errmsg("cannot read past end of generated WAL: requested %X/%X, current position %X/%X", - LSN_FORMAT_ARGS(startptr + count), - LSN_FORMAT_ARGS(inserted))); + errmsg("cannot read past end of generated WAL: requested %016" + PRIX64 ", current position %016" PRIX64, + startptr + count, + inserted)); /* * Loop through the buffers without a lock. For each buffer, atomically @@ -2148,8 +2149,8 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic) #ifdef WAL_DEBUG if (XLOG_DEBUG && npages > 0) { - elog(DEBUG1, "initialized %d pages, up to %X/%X", - npages, LSN_FORMAT_ARGS(NewPageEndPtr)); + elog(DEBUG1, "initialized %d pages, up to %016" PRIX64, + npages, NewPageEndPtr); } #endif } @@ -2359,9 +2360,10 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible) XLogRecPtr EndPtr = pg_atomic_read_u64(&XLogCtl->xlblocks[curridx]); if (LogwrtResult.Write >= EndPtr) - elog(PANIC, "xlog write request %X/%X is past end of log %X/%X", - LSN_FORMAT_ARGS(LogwrtResult.Write), - LSN_FORMAT_ARGS(EndPtr)); + elog(PANIC, "xlog write request %016" PRIX64 + " is past end of log %016" PRIX64, + LogwrtResult.Write, + EndPtr); /* Advance LogwrtResult.Write to end of current buffer page */ LogwrtResult.Write = EndPtr; @@ -2759,8 +2761,9 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force) newMinRecoveryPoint = GetCurrentReplayRecPtr(&newMinRecoveryPointTLI); if (!force && newMinRecoveryPoint < lsn) elog(WARNING, - "xlog min recovery request %X/%X is past current point %X/%X", - LSN_FORMAT_ARGS(lsn), LSN_FORMAT_ARGS(newMinRecoveryPoint)); + "xlog min recovery request %016" PRIX64 + " is past current point %016" PRIX64, + lsn, newMinRecoveryPoint); /* update control file */ if (ControlFile->minRecoveryPoint < newMinRecoveryPoint) @@ -2772,8 +2775,9 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force) LocalMinRecoveryPointTLI = newMinRecoveryPointTLI; ereport(DEBUG2, - (errmsg_internal("updated min recovery point to %X/%X on timeline %u", - LSN_FORMAT_ARGS(newMinRecoveryPoint), + (errmsg_internal("updated min recovery point to %016" PRIX64 + " on timeline %u", + newMinRecoveryPoint, newMinRecoveryPointTLI))); } } @@ -2812,10 +2816,11 @@ XLogFlush(XLogRecPtr record) #ifdef WAL_DEBUG if (XLOG_DEBUG) - elog(LOG, "xlog flush request %X/%X; write %X/%X; flush %X/%X", - LSN_FORMAT_ARGS(record), - LSN_FORMAT_ARGS(LogwrtResult.Write), - LSN_FORMAT_ARGS(LogwrtResult.Flush)); + elog(LOG, "xlog flush request %016" PRIX64 "; write %016" PRIX64 + "; flush %016" PRIX64, + record, + LogwrtResult.Write, + LogwrtResult.Flush); #endif START_CRIT_SECTION(); @@ -2945,9 +2950,9 @@ XLogFlush(XLogRecPtr record) */ if (LogwrtResult.Flush < record) elog(ERROR, - "xlog flush request %X/%X is not satisfied --- flushed only to %X/%X", - LSN_FORMAT_ARGS(record), - LSN_FORMAT_ARGS(LogwrtResult.Flush)); + "xlog flush request %016" PRIX64 " is not satisfied --- flushed only to %016" PRIX64, + record, + LogwrtResult.Flush); } /* @@ -3072,11 +3077,12 @@ XLogBackgroundFlush(void) #ifdef WAL_DEBUG if (XLOG_DEBUG) - elog(LOG, "xlog bg flush request write %X/%X; flush: %X/%X, current is write %X/%X; flush %X/%X", - LSN_FORMAT_ARGS(WriteRqst.Write), - LSN_FORMAT_ARGS(WriteRqst.Flush), - LSN_FORMAT_ARGS(LogwrtResult.Write), - LSN_FORMAT_ARGS(LogwrtResult.Flush)); + elog(LOG, "xlog bg flush request write %016" PRIX64 "; flush: %016" PRIX64 + ", current is write %016" PRIX64 "; flush %016" PRIX6, + WriteRqst.Write, + WriteRqst.Flush, + LogwrtResult.Write, + LogwrtResult.Flush); #endif START_CRIT_SECTION(); @@ -6779,7 +6785,7 @@ LogCheckpointEnd(bool restartpoint) "%d removed, %d recycled; write=%ld.%03d s, " "sync=%ld.%03d s, total=%ld.%03d s; sync files=%d, " "longest=%ld.%03d s, average=%ld.%03d s; distance=%d kB, " - "estimate=%d kB; lsn=%X/%X, redo lsn=%X/%X", + "estimate=%d kB; lsn=%016" PRIX64 ", redo lsn=%016" PRIX64, CheckpointStats.ckpt_bufs_written, (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers, CheckpointStats.ckpt_slru_written, @@ -6794,8 +6800,8 @@ LogCheckpointEnd(bool restartpoint) average_msecs / 1000, (int) (average_msecs % 1000), (int) (PrevCheckPointDistance / 1024.0), (int) (CheckPointDistanceEstimate / 1024.0), - LSN_FORMAT_ARGS(ControlFile->checkPoint), - LSN_FORMAT_ARGS(ControlFile->checkPointCopy.redo)))); + ControlFile->checkPoint, + ControlFile->checkPointCopy.redo))); else ereport(LOG, (errmsg("checkpoint complete: wrote %d buffers (%.1f%%), " @@ -6803,7 +6809,7 @@ LogCheckpointEnd(bool restartpoint) "%d removed, %d recycled; write=%ld.%03d s, " "sync=%ld.%03d s, total=%ld.%03d s; sync files=%d, " "longest=%ld.%03d s, average=%ld.%03d s; distance=%d kB, " - "estimate=%d kB; lsn=%X/%X, redo lsn=%X/%X", + "estimate=%d kB; lsn=%016" PRIX64 ", redo lsn=%016" PRIX64, CheckpointStats.ckpt_bufs_written, (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers, CheckpointStats.ckpt_slru_written, @@ -6818,8 +6824,8 @@ LogCheckpointEnd(bool restartpoint) average_msecs / 1000, (int) (average_msecs % 1000), (int) (PrevCheckPointDistance / 1024.0), (int) (CheckPointDistanceEstimate / 1024.0), - LSN_FORMAT_ARGS(ControlFile->checkPoint), - LSN_FORMAT_ARGS(ControlFile->checkPointCopy.redo)))); + ControlFile->checkPoint, + ControlFile->checkPointCopy.redo))); } /* @@ -7495,8 +7501,9 @@ CreateOverwriteContrecordRecord(XLogRecPtr aborted_lsn, XLogRecPtr pagePtr, if (!RecoveryInProgress()) elog(ERROR, "can only be used at end of recovery"); if (pagePtr % XLOG_BLCKSZ != 0) - elog(ERROR, "invalid position for missing continuation record %X/%X", - LSN_FORMAT_ARGS(pagePtr)); + elog(ERROR, + "invalid position for missing continuation record %016" PRIX64, + pagePtr); /* The current WAL insert position should be right after the page header */ startPos = pagePtr; @@ -7506,8 +7513,9 @@ CreateOverwriteContrecordRecord(XLogRecPtr aborted_lsn, XLogRecPtr pagePtr, startPos += SizeOfXLogShortPHD; recptr = GetXLogInsertRecPtr(); if (recptr != startPos) - elog(ERROR, "invalid WAL insert position %X/%X for OVERWRITE_CONTRECORD", - LSN_FORMAT_ARGS(recptr)); + elog(ERROR, "invalid WAL insert position %016" PRIX64 + " for OVERWRITE_CONTRECORD", + recptr); START_CRIT_SECTION(); @@ -7536,8 +7544,10 @@ CreateOverwriteContrecordRecord(XLogRecPtr aborted_lsn, XLogRecPtr pagePtr, /* check that the record was inserted to the right place */ if (ProcLastRecPtr != startPos) - elog(ERROR, "OVERWRITE_CONTRECORD was inserted to unexpected position %X/%X", - LSN_FORMAT_ARGS(ProcLastRecPtr)); + elog(ERROR, + "OVERWRITE_CONTRECORD was inserted to unexpected position %016" + PRIX64, + ProcLastRecPtr); XLogFlush(recptr); @@ -7605,9 +7615,9 @@ RecoveryRestartPoint(const CheckPoint *checkPoint, XLogReaderState *record) if (XLogHaveInvalidPages()) { elog(DEBUG2, - "could not record restart point at %X/%X because there " + "could not record restart point at %016" PRIX64 " because there " "are unresolved references to invalid pages", - LSN_FORMAT_ARGS(checkPoint->redo)); + checkPoint->redo); return; } @@ -7686,8 +7696,9 @@ CreateRestartPoint(int flags) lastCheckPoint.redo <= ControlFile->checkPointCopy.redo) { ereport(DEBUG2, - (errmsg_internal("skipping restartpoint, already performed at %X/%X", - LSN_FORMAT_ARGS(lastCheckPoint.redo)))); + (errmsg_internal("skipping restartpoint, already performed at %016" + PRIX64, + lastCheckPoint.redo))); UpdateMinRecoveryPoint(InvalidXLogRecPtr, true); if (flags & CHECKPOINT_IS_SHUTDOWN) @@ -7871,8 +7882,8 @@ CreateRestartPoint(int flags) xtime = GetLatestXTime(); ereport((log_checkpoints ? LOG : DEBUG2), - (errmsg("recovery restart point at %X/%X", - LSN_FORMAT_ARGS(lastCheckPoint.redo)), + (errmsg("recovery restart point at %016" PRIX64, + lastCheckPoint.redo), xtime ? errdetail("Last completed transaction was at log time %s.", timestamptz_to_str(xtime)) : 0)); @@ -8135,8 +8146,8 @@ XLogRestorePoint(const char *rpName) RecPtr = XLogInsert(RM_XLOG_ID, XLOG_RESTORE_POINT); ereport(LOG, - (errmsg("restore point \"%s\" created at %X/%X", - rpName, LSN_FORMAT_ARGS(RecPtr)))); + (errmsg("restore point \"%s\" created at %016" PRIX64, + rpName, RecPtr))); return RecPtr; } diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c index 1ef1713c91a4..5971069f1d11 100644 --- a/src/backend/access/transam/xlogarchive.c +++ b/src/backend/access/transam/xlogarchive.c @@ -210,10 +210,10 @@ RestoreArchivedFile(char *path, const char *xlogfname, else elevel = FATAL; ereport(elevel, - (errmsg("archive file \"%s\" has wrong size: %lld instead of %lld", + (errmsg("archive file \"%s\" has wrong size: %" PRId64 " instead of %" PRId64, xlogfname, - (long long int) stat_buf.st_size, - (long long int) expectedSize))); + (pgoff_t) stat_buf.st_size, + (pgoff_t) expectedSize))); return false; } else diff --git a/src/backend/access/transam/xlogbackup.c b/src/backend/access/transam/xlogbackup.c index 342590e0a46d..b300057c7b15 100644 --- a/src/backend/access/transam/xlogbackup.c +++ b/src/backend/access/transam/xlogbackup.c @@ -42,8 +42,8 @@ build_backup_content(BackupState *state, bool ishistoryfile) XLByteToSeg(state->startpoint, startsegno, wal_segment_size); XLogFileName(startxlogfile, state->starttli, startsegno, wal_segment_size); - appendStringInfo(result, "START WAL LOCATION: %X/%X (file %s)\n", - LSN_FORMAT_ARGS(state->startpoint), startxlogfile); + appendStringInfo(result, "START WAL LOCATION: %016" PRIX64 " (file %s)\n", + state->startpoint, startxlogfile); if (ishistoryfile) { @@ -52,12 +52,12 @@ build_backup_content(BackupState *state, bool ishistoryfile) XLByteToSeg(state->stoppoint, stopsegno, wal_segment_size); XLogFileName(stopxlogfile, state->stoptli, stopsegno, wal_segment_size); - appendStringInfo(result, "STOP WAL LOCATION: %X/%X (file %s)\n", - LSN_FORMAT_ARGS(state->stoppoint), stopxlogfile); + appendStringInfo(result, "STOP WAL LOCATION: %016" PRIX64 " (file %s)\n", + state->stoppoint, stopxlogfile); } - appendStringInfo(result, "CHECKPOINT LOCATION: %X/%X\n", - LSN_FORMAT_ARGS(state->checkpointloc)); + appendStringInfo(result, "CHECKPOINT LOCATION: %016" PRIX64 "\n", + state->checkpointloc); appendStringInfoString(result, "BACKUP METHOD: streamed\n"); appendStringInfo(result, "BACKUP FROM: %s\n", state->started_in_recovery ? "standby" : "primary"); @@ -81,8 +81,8 @@ build_backup_content(BackupState *state, bool ishistoryfile) Assert(XLogRecPtrIsInvalid(state->istartpoint) == (state->istarttli == 0)); if (!XLogRecPtrIsInvalid(state->istartpoint)) { - appendStringInfo(result, "INCREMENTAL FROM LSN: %X/%X\n", - LSN_FORMAT_ARGS(state->istartpoint)); + appendStringInfo(result, "INCREMENTAL FROM LSN: %016" PRIX64 "\n", + state->istartpoint); appendStringInfo(result, "INCREMENTAL FROM TLI: %u\n", state->istarttli); } diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 14d583ae7ae2..5ee9d0b028ea 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -869,8 +869,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, if (mainrdata_len > PG_UINT32_MAX) ereport(ERROR, (errmsg_internal("too much WAL data"), - errdetail_internal("Main data length is %llu bytes for a maximum of %u bytes.", - (unsigned long long) mainrdata_len, + errdetail_internal("Main data length is %" PRIu64 " bytes for a maximum of %u bytes.", + mainrdata_len, PG_UINT32_MAX))); mainrdata_len_4b = (uint32) mainrdata_len; @@ -915,8 +915,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, if (total_len > XLogRecordMaxSize) ereport(ERROR, (errmsg_internal("oversized WAL record"), - errdetail_internal("WAL record would be %llu bytes (of maximum %u bytes); rmid %u flags %u.", - (unsigned long long) total_len, XLogRecordMaxSize, rmid, info))); + errdetail_internal("WAL record would be %" PRIu64 " bytes (of maximum %u bytes); rmid %u flags %u.", + total_len, XLogRecordMaxSize, rmid, info))); /* * Fill in the fields in the record header. Prev-link is filled in later, diff --git a/src/backend/access/transam/xlogprefetcher.c b/src/backend/access/transam/xlogprefetcher.c index 7735562db01d..8a8a1807d9a5 100644 --- a/src/backend/access/transam/xlogprefetcher.c +++ b/src/backend/access/transam/xlogprefetcher.c @@ -546,8 +546,8 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing all readahead until %X/%X is replayed due to possible TLI change", - LSN_FORMAT_ARGS(record->lsn)); + "suppressing all readahead until %016" PRIX64 " is replayed due to possible TLI change", + record->lsn); #endif /* Fall through so we move past this record. */ @@ -579,9 +579,10 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing prefetch in database %u until %X/%X is replayed due to raw file copy", + "suppressing prefetch in database %u until %016" PRIX64 + " is replayed due to raw file copy", rlocator.dbOid, - LSN_FORMAT_ARGS(record->lsn)); + record->lsn); #endif } } @@ -607,11 +608,12 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing prefetch in relation %u/%u/%u until %X/%X is replayed, which creates the relation", + "suppressing prefetch in relation %u/%u/%u until %016" + PRIX64 " is replayed, which creates the relation", xlrec->rlocator.spcOid, xlrec->rlocator.dbOid, xlrec->rlocator.relNumber, - LSN_FORMAT_ARGS(record->lsn)); + record->lsn); #endif } } @@ -630,12 +632,13 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, which truncates the relation", + "suppressing prefetch in relation %u/%u/%u from block %u until %016" + PRIX64 " is replayed, which truncates the relation", xlrec->rlocator.spcOid, xlrec->rlocator.dbOid, xlrec->rlocator.relNumber, xlrec->blkno, - LSN_FORMAT_ARGS(record->lsn)); + record->lsn); #endif } } @@ -729,11 +732,11 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) { #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing all prefetch in relation %u/%u/%u until %X/%X is replayed, because the relation does not exist on disk", + "suppressing all prefetch in relation %u/%u/%u until %016" PRIX64 " is replayed, because the relation does not exist on disk", reln->smgr_rlocator.locator.spcOid, reln->smgr_rlocator.locator.dbOid, reln->smgr_rlocator.locator.relNumber, - LSN_FORMAT_ARGS(record->lsn)); + record->lsn); #endif XLogPrefetcherAddFilter(prefetcher, block->rlocator, 0, record->lsn); @@ -750,12 +753,12 @@ XLogPrefetcherNextBlock(uintptr_t pgsr_private, XLogRecPtr *lsn) { #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "suppressing prefetch in relation %u/%u/%u from block %u until %X/%X is replayed, because the relation is too small", + "suppressing prefetch in relation %u/%u/%u from block %u until %016" PRIX64 " is replayed, because the relation is too small", reln->smgr_rlocator.locator.spcOid, reln->smgr_rlocator.locator.dbOid, reln->smgr_rlocator.locator.relNumber, block->blkno, - LSN_FORMAT_ARGS(record->lsn)); + record->lsn); #endif XLogPrefetcherAddFilter(prefetcher, block->rlocator, block->blkno, record->lsn); @@ -928,9 +931,9 @@ XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileLocator rlocator, { #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (blocks >= %u filtered)", + "prefetch of %u/%u/%u block %u suppressed; filtering until LSN %016" PRIX64 " is replayed (blocks >= %u filtered)", rlocator.spcOid, rlocator.dbOid, rlocator.relNumber, blockno, - LSN_FORMAT_ARGS(filter->filter_until_replayed), + filter->filter_until_replayed, filter->filter_from_block); #endif return true; @@ -944,9 +947,9 @@ XLogPrefetcherIsFiltered(XLogPrefetcher *prefetcher, RelFileLocator rlocator, { #ifdef XLOGPREFETCHER_DEBUG_LEVEL elog(XLOGPREFETCHER_DEBUG_LEVEL, - "prefetch of %u/%u/%u block %u suppressed; filtering until LSN %X/%X is replayed (whole database)", + "prefetch of %u/%u/%u block %u suppressed; filtering until LSN %016" PRIX64 " is replayed (whole database)", rlocator.spcOid, rlocator.dbOid, rlocator.relNumber, blockno, - LSN_FORMAT_ARGS(filter->filter_until_replayed)); + filter->filter_until_replayed); #endif return true; } diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 5483d4f0dd2b..3da34f7d7113 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -617,8 +617,8 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking) } else if (targetRecOff < pageHeaderSize) { - report_invalid_record(state, "invalid record offset at %X/%X: expected at least %u, got %u", - LSN_FORMAT_ARGS(RecPtr), + report_invalid_record(state, "invalid record offset at %016" PRIX64 ": expected at least %u, got %u", + RecPtr, pageHeaderSize, targetRecOff); goto err; } @@ -626,8 +626,8 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking) if ((((XLogPageHeader) state->readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD) && targetRecOff == pageHeaderSize) { - report_invalid_record(state, "contrecord is requested by %X/%X", - LSN_FORMAT_ARGS(RecPtr)); + report_invalid_record(state, "contrecord is requested by %016" PRIX64, + RecPtr); goto err; } @@ -667,8 +667,8 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking) if (total_len < SizeOfXLogRecord) { report_invalid_record(state, - "invalid record length at %X/%X: expected at least %u, got %u", - LSN_FORMAT_ARGS(RecPtr), + "invalid record length at %016" PRIX64 ": expected at least %u, got %u", + RecPtr, (uint32) SizeOfXLogRecord, total_len); goto err; } @@ -756,8 +756,9 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking) if (!(pageHeader->xlp_info & XLP_FIRST_IS_CONTRECORD)) { report_invalid_record(state, - "there is no contrecord flag at %X/%X", - LSN_FORMAT_ARGS(RecPtr)); + "there is no contrecord flag at %016" + PRIX64, + RecPtr); goto err; } @@ -769,10 +770,10 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking) total_len != (pageHeader->xlp_rem_len + gotlen)) { report_invalid_record(state, - "invalid contrecord length %u (expected %lld) at %X/%X", + "invalid contrecord length %u (expected %u) at %016" PRIX64, pageHeader->xlp_rem_len, - ((long long) total_len) - gotlen, - LSN_FORMAT_ARGS(RecPtr)); + total_len - gotlen, + RecPtr); goto err; } @@ -1132,16 +1133,16 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr, if (record->xl_tot_len < SizeOfXLogRecord) { report_invalid_record(state, - "invalid record length at %X/%X: expected at least %u, got %u", - LSN_FORMAT_ARGS(RecPtr), + "invalid record length at %016" PRIX64 ": expected at least %u, got %u", + RecPtr, (uint32) SizeOfXLogRecord, record->xl_tot_len); return false; } if (!RmgrIdIsValid(record->xl_rmid)) { report_invalid_record(state, - "invalid resource manager ID %u at %X/%X", - record->xl_rmid, LSN_FORMAT_ARGS(RecPtr)); + "invalid resource manager ID %u at %016" PRIX64, + record->xl_rmid, RecPtr); return false; } if (randAccess) @@ -1153,9 +1154,10 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr, if (!(record->xl_prev < RecPtr)) { report_invalid_record(state, - "record with incorrect prev-link %X/%X at %X/%X", - LSN_FORMAT_ARGS(record->xl_prev), - LSN_FORMAT_ARGS(RecPtr)); + "record with incorrect prev-link %016" PRIX64 + " at %016" PRIX64, + record->xl_prev, + RecPtr); return false; } } @@ -1169,9 +1171,10 @@ ValidXLogRecordHeader(XLogReaderState *state, XLogRecPtr RecPtr, if (record->xl_prev != PrevRecPtr) { report_invalid_record(state, - "record with incorrect prev-link %X/%X at %X/%X", - LSN_FORMAT_ARGS(record->xl_prev), - LSN_FORMAT_ARGS(RecPtr)); + "record with incorrect prev-link %016" PRIX64 + " at %016" PRIX64, + record->xl_prev, + RecPtr); return false; } } @@ -1207,8 +1210,8 @@ ValidXLogRecord(XLogReaderState *state, XLogRecord *record, XLogRecPtr recptr) if (!EQ_CRC32C(record->xl_crc, crc)) { report_invalid_record(state, - "incorrect resource manager data checksum in record at %X/%X", - LSN_FORMAT_ARGS(recptr)); + "incorrect resource manager data checksum in record at %016" PRIX64, + recptr); return false; } @@ -1241,10 +1244,10 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize); report_invalid_record(state, - "invalid magic number %04X in WAL segment %s, LSN %X/%X, offset %u", + "invalid magic number %04X in WAL segment %s, LSN %016" PRIX64 ", offset %u", hdr->xlp_magic, fname, - LSN_FORMAT_ARGS(recptr), + recptr, offset); return false; } @@ -1256,10 +1259,10 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize); report_invalid_record(state, - "invalid info bits %04X in WAL segment %s, LSN %X/%X, offset %u", + "invalid info bits %04X in WAL segment %s, LSN %016" PRIX64 ", offset %u", hdr->xlp_info, fname, - LSN_FORMAT_ARGS(recptr), + recptr, offset); return false; } @@ -1272,9 +1275,9 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, longhdr->xlp_sysid != state->system_identifier) { report_invalid_record(state, - "WAL file is from different database system: WAL file database system identifier is %llu, pg_control database system identifier is %llu", - (unsigned long long) longhdr->xlp_sysid, - (unsigned long long) state->system_identifier); + "WAL file is from different database system: WAL file database system identifier is %" PRIu64 ", pg_control database system identifier is %" PRIu64, + longhdr->xlp_sysid, + state->system_identifier); return false; } else if (longhdr->xlp_seg_size != state->segcxt.ws_segsize) @@ -1298,10 +1301,10 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, /* hmm, first page of file doesn't have a long header? */ report_invalid_record(state, - "invalid info bits %04X in WAL segment %s, LSN %X/%X, offset %u", + "invalid info bits %04X in WAL segment %s, LSN %016" PRIX64 ", offset %u", hdr->xlp_info, fname, - LSN_FORMAT_ARGS(recptr), + recptr, offset); return false; } @@ -1318,10 +1321,10 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize); report_invalid_record(state, - "unexpected pageaddr %X/%X in WAL segment %s, LSN %X/%X, offset %u", - LSN_FORMAT_ARGS(hdr->xlp_pageaddr), + "unexpected pageaddr %016" PRIX64 " in WAL segment %s, LSN %016" PRIX64 ", offset %u", + hdr->xlp_pageaddr, fname, - LSN_FORMAT_ARGS(recptr), + recptr, offset); return false; } @@ -1344,11 +1347,11 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr, XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize); report_invalid_record(state, - "out-of-sequence timeline ID %u (after %u) in WAL segment %s, LSN %X/%X, offset %u", + "out-of-sequence timeline ID %u (after %u) in WAL segment %s, LSN %016" PRIX64 ", offset %u", hdr->xlp_tli, state->latestPageTLI, fname, - LSN_FORMAT_ARGS(recptr), + recptr, offset); return false; } @@ -1756,9 +1759,9 @@ DecodeXLogRecord(XLogReaderState *state, if (block_id <= decoded->max_block_id) { report_invalid_record(state, - "out-of-order block_id %u at %X/%X", + "out-of-order block_id %u at %016" PRIX64, block_id, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } decoded->max_block_id = block_id; @@ -1780,16 +1783,16 @@ DecodeXLogRecord(XLogReaderState *state, if (blk->has_data && blk->data_len == 0) { report_invalid_record(state, - "BKPBLOCK_HAS_DATA set, but no data included at %X/%X", - LSN_FORMAT_ARGS(state->ReadRecPtr)); + "BKPBLOCK_HAS_DATA set, but no data included at %016" PRIX64, + state->ReadRecPtr); goto err; } if (!blk->has_data && blk->data_len != 0) { report_invalid_record(state, - "BKPBLOCK_HAS_DATA not set, but data length is %u at %X/%X", + "BKPBLOCK_HAS_DATA not set, but data length is %u at %016" PRIX64, (unsigned int) blk->data_len, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } datatotal += blk->data_len; @@ -1823,11 +1826,11 @@ DecodeXLogRecord(XLogReaderState *state, blk->bimg_len == BLCKSZ)) { report_invalid_record(state, - "BKPIMAGE_HAS_HOLE set, but hole offset %u length %u block image length %u at %X/%X", + "BKPIMAGE_HAS_HOLE set, but hole offset %u length %u block image length %u at %016" PRIX64, (unsigned int) blk->hole_offset, (unsigned int) blk->hole_length, (unsigned int) blk->bimg_len, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } @@ -1839,10 +1842,10 @@ DecodeXLogRecord(XLogReaderState *state, (blk->hole_offset != 0 || blk->hole_length != 0)) { report_invalid_record(state, - "BKPIMAGE_HAS_HOLE not set, but hole offset %u length %u at %X/%X", + "BKPIMAGE_HAS_HOLE not set, but hole offset %u length %u at %016" PRIX64, (unsigned int) blk->hole_offset, (unsigned int) blk->hole_length, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } @@ -1853,9 +1856,9 @@ DecodeXLogRecord(XLogReaderState *state, blk->bimg_len == BLCKSZ) { report_invalid_record(state, - "BKPIMAGE_COMPRESSED set, but block image length %u at %X/%X", + "BKPIMAGE_COMPRESSED set, but block image length %u at %016" PRIX64, (unsigned int) blk->bimg_len, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } @@ -1868,9 +1871,9 @@ DecodeXLogRecord(XLogReaderState *state, blk->bimg_len != BLCKSZ) { report_invalid_record(state, - "neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %X/%X", + "neither BKPIMAGE_HAS_HOLE nor BKPIMAGE_COMPRESSED set, but block image length is %u at %016" PRIX64, (unsigned int) blk->data_len, - LSN_FORMAT_ARGS(state->ReadRecPtr)); + state->ReadRecPtr); goto err; } } @@ -1884,8 +1887,8 @@ DecodeXLogRecord(XLogReaderState *state, if (rlocator == NULL) { report_invalid_record(state, - "BKPBLOCK_SAME_REL set but no previous rel at %X/%X", - LSN_FORMAT_ARGS(state->ReadRecPtr)); + "BKPBLOCK_SAME_REL set but no previous rel at %016" PRIX64, + state->ReadRecPtr); goto err; } @@ -1896,8 +1899,8 @@ DecodeXLogRecord(XLogReaderState *state, else { report_invalid_record(state, - "invalid block_id %u at %X/%X", - block_id, LSN_FORMAT_ARGS(state->ReadRecPtr)); + "invalid block_id %u at %016" PRIX64, + block_id, state->ReadRecPtr); goto err; } } @@ -1963,8 +1966,8 @@ DecodeXLogRecord(XLogReaderState *state, shortdata_err: report_invalid_record(state, - "record with invalid length at %X/%X", - LSN_FORMAT_ARGS(state->ReadRecPtr)); + "record with invalid length at %016" PRIX64, + state->ReadRecPtr); err: *errormsg = state->errormsg_buf; @@ -2073,15 +2076,17 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) !record->record->blocks[block_id].in_use) { report_invalid_record(record, - "could not restore image at %X/%X with invalid block %d specified", - LSN_FORMAT_ARGS(record->ReadRecPtr), + "could not restore image at %016" PRIX64 + " with invalid block %d specified", + record->ReadRecPtr, block_id); return false; } if (!record->record->blocks[block_id].has_image) { - report_invalid_record(record, "could not restore image at %X/%X with invalid state, block %d", - LSN_FORMAT_ARGS(record->ReadRecPtr), + report_invalid_record(record, "could not restore image at %016" PRIX64 + " with invalid state, block %d", + record->ReadRecPtr, block_id); return false; } @@ -2107,8 +2112,9 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) bkpb->bimg_len, BLCKSZ - bkpb->hole_length) <= 0) decomp_success = false; #else - report_invalid_record(record, "could not restore image at %X/%X compressed with %s not supported by build, block %d", - LSN_FORMAT_ARGS(record->ReadRecPtr), + report_invalid_record(record, "could not restore image at %016" PRIX64 + " compressed with %s not supported by build, block %d", + record->ReadRecPtr, "LZ4", block_id); return false; @@ -2124,8 +2130,9 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) if (ZSTD_isError(decomp_result)) decomp_success = false; #else - report_invalid_record(record, "could not restore image at %X/%X compressed with %s not supported by build, block %d", - LSN_FORMAT_ARGS(record->ReadRecPtr), + report_invalid_record(record, "could not restore image at %016" + PRIX64 " compressed with %s not supported by build, block %d", + record->ReadRecPtr, "zstd", block_id); return false; @@ -2133,16 +2140,18 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page) } else { - report_invalid_record(record, "could not restore image at %X/%X compressed with unknown method, block %d", - LSN_FORMAT_ARGS(record->ReadRecPtr), + report_invalid_record(record, "could not restore image at %016" PRIX64 + " compressed with unknown method, block %d", + record->ReadRecPtr, block_id); return false; } if (!decomp_success) { - report_invalid_record(record, "could not decompress image at %X/%X, block %d", - LSN_FORMAT_ARGS(record->ReadRecPtr), + report_invalid_record(record, "could not decompress image at %016" PRIX64 + ", block %d", + record->ReadRecPtr, block_id); return false; } diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index a829a055a97f..0ee2d32cbff3 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -615,9 +615,11 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, * than ControlFile->checkPoint is used. */ ereport(LOG, - (errmsg("starting backup recovery with redo LSN %X/%X, checkpoint LSN %X/%X, on timeline ID %u", - LSN_FORMAT_ARGS(RedoStartLSN), - LSN_FORMAT_ARGS(CheckPointLoc), + (errmsg("starting backup recovery with redo LSN %016" + PRIX64 ", checkpoint LSN %016" PRIX64 + ", on timeline ID %u", + RedoStartLSN, + CheckPointLoc, CheckPointTLI))); /* @@ -631,8 +633,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint)); wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN); ereport(DEBUG1, - (errmsg_internal("checkpoint record is at %X/%X", - LSN_FORMAT_ARGS(CheckPointLoc)))); + (errmsg_internal("checkpoint record is at %016" PRIX64, + CheckPointLoc))); InRecovery = true; /* force recovery even if SHUTDOWNED */ /* @@ -647,8 +649,10 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, if (!ReadRecord(xlogprefetcher, LOG, false, checkPoint.ThisTimeLineID)) ereport(FATAL, - (errmsg("could not find redo location %X/%X referenced by checkpoint record at %X/%X", - LSN_FORMAT_ARGS(checkPoint.redo), LSN_FORMAT_ARGS(CheckPointLoc)), + (errmsg("could not find redo location %016" PRIX64 + " referenced by checkpoint record at %016" + PRIX64, + checkPoint.redo, CheckPointLoc), errhint("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n" "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n" "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.", @@ -658,8 +662,9 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, else { ereport(FATAL, - (errmsg("could not locate required checkpoint record at %X/%X", - LSN_FORMAT_ARGS(CheckPointLoc)), + (errmsg("could not locate required checkpoint record at %016" + PRIX64, + CheckPointLoc), errhint("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n" "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n" "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup.", @@ -768,8 +773,9 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, */ if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint)) ereport(LOG, - (errmsg("restarting backup recovery with redo LSN %X/%X", - LSN_FORMAT_ARGS(ControlFile->backupStartPoint)))); + (errmsg("restarting backup recovery with redo LSN %016" + PRIX64, + ControlFile->backupStartPoint))); /* Get the last valid checkpoint record. */ CheckPointLoc = ControlFile->checkPoint; @@ -781,8 +787,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, if (record != NULL) { ereport(DEBUG1, - (errmsg_internal("checkpoint record is at %X/%X", - LSN_FORMAT_ARGS(CheckPointLoc)))); + (errmsg_internal("checkpoint record is at %016" PRIX64, + CheckPointLoc))); } else { @@ -793,8 +799,9 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, * simplify processing around checkpoints. */ ereport(PANIC, - (errmsg("could not locate a valid checkpoint record at %X/%X", - LSN_FORMAT_ARGS(CheckPointLoc)))); + (errmsg("could not locate a valid checkpoint record at %016" + PRIX64, + CheckPointLoc))); } memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint)); wasShutdown = ((record->xl_info & ~XLR_INFO_MASK) == XLOG_CHECKPOINT_SHUTDOWN); @@ -819,8 +826,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, recoveryTargetName))); else if (recoveryTarget == RECOVERY_TARGET_LSN) ereport(LOG, - (errmsg("starting point-in-time recovery to WAL location (LSN) \"%X/%X\"", - LSN_FORMAT_ARGS(recoveryTargetLSN)))); + (errmsg("starting point-in-time recovery to WAL location (LSN) \"%016" PRIX64 "\"", + recoveryTargetLSN))); else if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE) ereport(LOG, (errmsg("starting point-in-time recovery to earliest consistent point"))); @@ -850,11 +857,11 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, (errmsg("requested timeline %u is not a child of this server's history", recoveryTargetTLI), /* translator: %s is a backup_label file or a pg_control file */ - errdetail("Latest checkpoint in file \"%s\" is at %X/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X/%X.", + errdetail("Latest checkpoint in file \"%s\" is at %016" PRIX64 " on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %016" PRIX64 ".", haveBackupLabel ? "backup_label" : "pg_control", - LSN_FORMAT_ARGS(CheckPointLoc), + CheckPointLoc, CheckPointTLI, - LSN_FORMAT_ARGS(switchpoint)))); + switchpoint))); } /* @@ -865,14 +872,14 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr, tliOfPointInHistory(ControlFile->minRecoveryPoint - 1, expectedTLEs) != ControlFile->minRecoveryPointTLI) ereport(FATAL, - (errmsg("requested timeline %u does not contain minimum recovery point %X/%X on timeline %u", + (errmsg("requested timeline %u does not contain minimum recovery point %016" PRIX64 " on timeline %u", recoveryTargetTLI, - LSN_FORMAT_ARGS(ControlFile->minRecoveryPoint), + ControlFile->minRecoveryPoint, ControlFile->minRecoveryPointTLI))); ereport(DEBUG1, - (errmsg_internal("redo record is at %X/%X; shutdown %s", - LSN_FORMAT_ARGS(checkPoint.redo), + (errmsg_internal("redo record is at %016" PRIX64 "; shutdown %s", + checkPoint.redo, wasShutdown ? "true" : "false"))); ereport(DEBUG1, (errmsg_internal("next transaction ID: " UINT64_FORMAT "; next OID: %u", @@ -1220,8 +1227,7 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI, char backupfrom[20]; char backuplabel[MAXPGPATH]; char backuptime[128]; - uint32 hi, - lo; + XLogRecPtr dummy_lsn; /* suppress possible uninitialized-variable warnings */ *checkPointLoc = InvalidXLogRecPtr; @@ -1248,19 +1254,17 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI, * is pretty crude, but we are not expecting any variability in the file * format). */ - if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %08X%16s)%c", - &hi, &lo, &tli_from_walseg, startxlogfilename, &ch) != 5 || ch != '\n') + if (fscanf(lfp, "START WAL LOCATION: %" SCNx64 " (file %08X%16s)%c", + &RedoStartLSN, &tli_from_walseg, startxlogfilename, &ch) != 4 || ch != '\n') ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE))); - RedoStartLSN = ((uint64) hi) << 32 | lo; RedoStartTLI = tli_from_walseg; - if (fscanf(lfp, "CHECKPOINT LOCATION: %X/%X%c", - &hi, &lo, &ch) != 3 || ch != '\n') + if (fscanf(lfp, "CHECKPOINT LOCATION: %" SCNx64 "%c", + checkPointLoc, &ch) != 2 || ch != '\n') ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE))); - *checkPointLoc = ((uint64) hi) << 32 | lo; *backupLabelTLI = tli_from_walseg; /* @@ -1327,7 +1331,7 @@ read_backup_label(XLogRecPtr *checkPointLoc, TimeLineID *backupLabelTLI, tli_from_file, BACKUP_LABEL_FILE))); } - if (fscanf(lfp, "INCREMENTAL FROM LSN: %X/%X\n", &hi, &lo) > 0) + if (fscanf(lfp, "INCREMENTAL FROM LSN: %" SCNx64 "\n", &dummy_lsn) > 0) ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("this is an incremental backup, not a data directory"), @@ -1717,8 +1721,9 @@ PerformWalRecovery(void) if (record->xl_rmid != RM_XLOG_ID || (record->xl_info & ~XLR_INFO_MASK) != XLOG_CHECKPOINT_REDO) ereport(FATAL, - (errmsg("unexpected record type found at redo point %X/%X", - LSN_FORMAT_ARGS(xlogreader->ReadRecPtr)))); + (errmsg("unexpected record type found at redo point %016" + PRIX64, + xlogreader->ReadRecPtr))); } else { @@ -1740,8 +1745,7 @@ PerformWalRecovery(void) RmgrStartup(); ereport(LOG, - (errmsg("redo starts at %X/%X", - LSN_FORMAT_ARGS(xlogreader->ReadRecPtr)))); + (errmsg("redo starts at %016" PRIX64, xlogreader->ReadRecPtr))); /* Prepare to report progress of the redo phase. */ if (!StandbyMode) @@ -1753,8 +1757,8 @@ PerformWalRecovery(void) do { if (!StandbyMode) - ereport_startup_progress("redo in progress, elapsed time: %ld.%02d s, current LSN: %X/%X", - LSN_FORMAT_ARGS(xlogreader->ReadRecPtr)); + ereport_startup_progress("redo in progress, elapsed time: %ld.%02d s, current LSN: %016" PRIX64, + xlogreader->ReadRecPtr); #ifdef WAL_DEBUG if (XLOG_DEBUG) @@ -1762,9 +1766,9 @@ PerformWalRecovery(void) StringInfoData buf; initStringInfo(&buf); - appendStringInfo(&buf, "REDO @ %X/%X; LSN %X/%X: ", - LSN_FORMAT_ARGS(xlogreader->ReadRecPtr), - LSN_FORMAT_ARGS(xlogreader->EndRecPtr)); + appendStringInfo(&buf, "REDO @ %016" PRIX64 "; LSN %016" PRIX64 ": ", + xlogreader->ReadRecPtr, + xlogreader->EndRecPtr); xlog_outrec(&buf, xlogreader); appendStringInfoString(&buf, " - "); xlog_outdesc(&buf, xlogreader); @@ -1875,8 +1879,8 @@ PerformWalRecovery(void) RmgrCleanup(); ereport(LOG, - (errmsg("redo done at %X/%X system usage: %s", - LSN_FORMAT_ARGS(xlogreader->ReadRecPtr), + (errmsg("redo done at %016" PRIX64 " system usage: %s", + xlogreader->ReadRecPtr, pg_rusage_show(&ru0)))); xtime = GetLatestXTime(); if (xtime) @@ -2087,17 +2091,18 @@ xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI) memcpy(&xlrec, XLogRecGetData(record), sizeof(xl_overwrite_contrecord)); if (xlrec.overwritten_lsn != record->overwrittenRecPtr) - elog(FATAL, "mismatching overwritten LSN %X/%X -> %X/%X", - LSN_FORMAT_ARGS(xlrec.overwritten_lsn), - LSN_FORMAT_ARGS(record->overwrittenRecPtr)); + elog(FATAL, "mismatching overwritten LSN %016" PRIX64 " -> %016" PRIX64, + xlrec.overwritten_lsn, + record->overwrittenRecPtr); /* We have safely skipped the aborted record */ abortedRecPtr = InvalidXLogRecPtr; missingContrecPtr = InvalidXLogRecPtr; ereport(LOG, - (errmsg("successfully skipped missing contrecord at %X/%X, overwritten at %s", - LSN_FORMAT_ARGS(xlrec.overwritten_lsn), + (errmsg("successfully skipped missing contrecord at %016" PRIX64 + ", overwritten at %s", + xlrec.overwritten_lsn, timestamptz_to_str(xlrec.overwrite_time)))); /* Verifying the record should only happen once */ @@ -2124,8 +2129,9 @@ xlogrecovery_redo(XLogReaderState *record, TimeLineID replayTLI) backupEndPoint = lsn; } else - elog(DEBUG1, "saw end-of-backup record for backup starting at %X/%X, waiting for %X/%X", - LSN_FORMAT_ARGS(startpoint), LSN_FORMAT_ARGS(backupStartPoint)); + elog(DEBUG1, "saw end-of-backup record for backup starting at %016" + PRIX64 ", waiting for %016" PRIX64, + startpoint, backupStartPoint); } } @@ -2219,9 +2225,10 @@ CheckRecoveryConsistency(void) backupEndRequired = false; ereport(LOG, - (errmsg("completed backup recovery with redo LSN %X/%X and end LSN %X/%X", - LSN_FORMAT_ARGS(saveBackupStartPoint), - LSN_FORMAT_ARGS(saveBackupEndPoint)))); + (errmsg("completed backup recovery with redo LSN %016" PRIX64 + " and end LSN %016" PRIX64, + saveBackupStartPoint, + saveBackupEndPoint))); } /* @@ -2249,8 +2256,8 @@ CheckRecoveryConsistency(void) reachedConsistency = true; ereport(LOG, - (errmsg("consistent recovery state reached at %X/%X", - LSN_FORMAT_ARGS(lastReplayedEndRecPtr)))); + (errmsg("consistent recovery state reached at %016" PRIX64, + lastReplayedEndRecPtr))); } /* @@ -2287,8 +2294,8 @@ rm_redo_error_callback(void *arg) xlog_block_info(&buf, record); /* translator: %s is a WAL record description */ - errcontext("WAL redo at %X/%X for %s", - LSN_FORMAT_ARGS(record->ReadRecPtr), + errcontext("WAL redo at %016" PRIX64 " for %s", + record->ReadRecPtr, buf.data); pfree(buf.data); @@ -2322,8 +2329,8 @@ xlog_outdesc(StringInfo buf, XLogReaderState *record) static void xlog_outrec(StringInfo buf, XLogReaderState *record) { - appendStringInfo(buf, "prev %X/%X; xid %u", - LSN_FORMAT_ARGS(XLogRecGetPrev(record)), + appendStringInfo(buf, "prev %016" PRIX64 "; xid %u", + XLogRecGetPrev(record), XLogRecGetXid(record)); appendStringInfo(buf, "; len %u", @@ -2410,9 +2417,9 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI, lsn < minRecoveryPoint && newTLI > minRecoveryPointTLI) ereport(PANIC, - (errmsg("unexpected timeline ID %u in checkpoint record, before reaching minimum recovery point %X/%X on timeline %u", + (errmsg("unexpected timeline ID %u in checkpoint record, before reaching minimum recovery point %016" PRIX64 " on timeline %u", newTLI, - LSN_FORMAT_ARGS(minRecoveryPoint), + minRecoveryPoint, minRecoveryPointTLI))); /* Looks good */ @@ -2615,8 +2622,9 @@ recoveryStopsBefore(XLogReaderState *record) recoveryStopTime = 0; recoveryStopName[0] = '\0'; ereport(LOG, - (errmsg("recovery stopping before WAL location (LSN) \"%X/%X\"", - LSN_FORMAT_ARGS(recoveryStopLSN)))); + (errmsg("recovery stopping before WAL location (LSN) \"%016" + PRIX64 "\"", + recoveryStopLSN))); return true; } @@ -2783,8 +2791,9 @@ recoveryStopsAfter(XLogReaderState *record) recoveryStopTime = 0; recoveryStopName[0] = '\0'; ereport(LOG, - (errmsg("recovery stopping after WAL location (LSN) \"%X/%X\"", - LSN_FORMAT_ARGS(recoveryStopLSN)))); + (errmsg("recovery stopping after WAL location (LSN) \"%016" + PRIX64 "\"", + recoveryStopLSN))); return true; } @@ -2904,9 +2913,9 @@ getRecoveryStopReason(void) timestamptz_to_str(recoveryStopTime)); else if (recoveryTarget == RECOVERY_TARGET_LSN) snprintf(reason, sizeof(reason), - "%s LSN %X/%X\n", + "%s LSN %016" PRIX64 "\n", recoveryStopAfter ? "after" : "before", - LSN_FORMAT_ARGS(recoveryStopLSN)); + recoveryStopLSN); else if (recoveryTarget == RECOVERY_TARGET_NAME) snprintf(reason, sizeof(reason), "at restore point \"%s\"", @@ -3207,10 +3216,10 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode, XLogFileName(fname, xlogreader->seg.ws_tli, segno, wal_segment_size); ereport(emode_for_corrupt_record(emode, xlogreader->EndRecPtr), - (errmsg("unexpected timeline ID %u in WAL segment %s, LSN %X/%X, offset %u", + (errmsg("unexpected timeline ID %u in WAL segment %s, LSN %016" PRIX64 ", offset %u", xlogreader->latestPageTLI, fname, - LSN_FORMAT_ARGS(xlogreader->latestPagePtr), + xlogreader->latestPagePtr, offset))); record = NULL; } @@ -3423,15 +3432,17 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, errno = save_errno; ereport(emode_for_corrupt_record(emode, targetPagePtr + reqLen), (errcode_for_file_access(), - errmsg("could not read from WAL segment %s, LSN %X/%X, offset %u: %m", - fname, LSN_FORMAT_ARGS(targetPagePtr), + errmsg("could not read from WAL segment %s, LSN %016" PRIX64 + ", offset %u: %m", + fname, targetPagePtr, readOff))); } else ereport(emode_for_corrupt_record(emode, targetPagePtr + reqLen), (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("could not read from WAL segment %s, LSN %X/%X, offset %u: read %d of %zu", - fname, LSN_FORMAT_ARGS(targetPagePtr), + errmsg("could not read from WAL segment %s, LSN %016" PRIX64 + ", offset %u: read %d of %zu", + fname, targetPagePtr, readOff, r, (Size) XLOG_BLCKSZ))); goto next_record_is_invalid; } @@ -3712,8 +3723,9 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, wait_time = wal_retrieve_retry_interval - TimestampDifferenceMilliseconds(last_fail_time, now); - elog(LOG, "waiting for WAL to become available at %X/%X", - LSN_FORMAT_ARGS(RecPtr)); + elog(LOG, "waiting for WAL to become available at %016" + PRIX64, + RecPtr); /* Do background tasks that might benefit us later. */ KnownAssignedTransactionIdsIdleMaintenance(); @@ -3858,8 +3870,8 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, tli = tliOfPointInHistory(tliRecPtr, expectedTLEs); if (curFileTLI > 0 && tli < curFileTLI) - elog(ERROR, "according to history file, WAL location %X/%X belongs to timeline %u, but previous recovered WAL file came from timeline %u", - LSN_FORMAT_ARGS(tliRecPtr), + elog(ERROR, "according to history file, WAL location %016" PRIX64 " belongs to timeline %u, but previous recovered WAL file came from timeline %u", + tliRecPtr, tli, curFileTLI); } curFileTLI = tli; @@ -4171,10 +4183,10 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN) if (currentTle->end < replayLSN) { ereport(LOG, - (errmsg("new timeline %u forked off current database system timeline %u before current recovery point %X/%X", + (errmsg("new timeline %u forked off current database system timeline %u before current recovery point %016" PRIX64, newtarget, replayTLI, - LSN_FORMAT_ARGS(replayLSN)))); + replayLSN))); return false; } diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index c389b27f77d4..ddf879968030 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -795,9 +795,9 @@ XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, list_free_deep(timelineHistory); - elog(DEBUG3, "switched to timeline %u valid until %X/%X", + elog(DEBUG3, "switched to timeline %u valid until %016" PRIX64, state->currTLI, - LSN_FORMAT_ARGS(state->currTLIValidUntil)); + state->currTLIValidUntil); } } diff --git a/src/backend/backup/backup_manifest.c b/src/backend/backup/backup_manifest.c index 22e2be37c95c..dd8eb2ff5a2c 100644 --- a/src/backend/backup/backup_manifest.c +++ b/src/backend/backup/backup_manifest.c @@ -281,11 +281,11 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr, } AppendToManifest(manifest, - "%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }", + "%s{ \"Timeline\": %u, \"Start-LSN\": \"%016" PRIX64 "\", \"End-LSN\": \"%016" PRIX64 "\" }", first_wal_range ? "" : ",\n", entry->tli, - LSN_FORMAT_ARGS(tl_beginptr), - LSN_FORMAT_ARGS(endptr)); + tl_beginptr, + endptr); if (starttli == entry->tli) { diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c index 3f8a3c55725f..c41023b6a3fd 100644 --- a/src/backend/backup/basebackup.c +++ b/src/backend/backup/basebackup.c @@ -123,7 +123,7 @@ static ssize_t basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offs static bool backup_started_in_recovery = false; /* Total number of checksum failures during base backup. */ -static long long int total_checksum_failures; +static int64 total_checksum_failures; /* Do not verify checksums. */ static bool noverify_checksums = false; @@ -655,8 +655,8 @@ perform_base_backup(basebackup_options *opt, bbsink *sink, { if (total_checksum_failures > 1) ereport(WARNING, - (errmsg_plural("%lld total checksum verification failure", - "%lld total checksum verification failures", + (errmsg_plural("%" PRId64 " total checksum verification failure", + "%" PRId64 " total checksum verification failures", total_checksum_failures, total_checksum_failures))); diff --git a/src/backend/backup/basebackup_copy.c b/src/backend/backup/basebackup_copy.c index a284ce318ff7..5fd6e0c00725 100644 --- a/src/backend/backup/basebackup_copy.c +++ b/src/backend/backup/basebackup_copy.c @@ -361,7 +361,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli) tstate = begin_tup_output_tupdesc(dest, tupdesc, &TTSOpsVirtual); /* Data row */ - values[0] = CStringGetTextDatum(psprintf("%X/%X", LSN_FORMAT_ARGS(ptr))); + values[0] = CStringGetTextDatum(psprintf("%016" PRIX64, ptr)); values[1] = Int64GetDatum(tli); do_tup_output(tstate, values, nulls); diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c index c2b7a55e347d..a7bc0dc8bc17 100644 --- a/src/backend/backup/basebackup_incremental.c +++ b/src/backend/backup/basebackup_incremental.c @@ -409,20 +409,20 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib, if (range->start_lsn < tlep[i]->begin) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("manifest requires WAL from initial timeline %u starting at %X/%X, but that timeline begins at %X/%X", + errmsg("manifest requires WAL from initial timeline %u starting at %016" PRIX64 ", but that timeline begins at %016" PRIX64, range->tli, - LSN_FORMAT_ARGS(range->start_lsn), - LSN_FORMAT_ARGS(tlep[i]->begin)))); + range->start_lsn, + tlep[i]->begin))); } else { if (range->start_lsn != tlep[i]->begin) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("manifest requires WAL from continuation timeline %u starting at %X/%X, but that timeline begins at %X/%X", + errmsg("manifest requires WAL from continuation timeline %u starting at %016" PRIX64 ", but that timeline begins at %016" PRIX64, range->tli, - LSN_FORMAT_ARGS(range->start_lsn), - LSN_FORMAT_ARGS(tlep[i]->begin)))); + range->start_lsn, + tlep[i]->begin))); } if (range->tli == latest_wal_range_tli) @@ -430,10 +430,10 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib, if (range->end_lsn > backup_state->startpoint) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("manifest requires WAL from final timeline %u ending at %X/%X, but this backup starts at %X/%X", + errmsg("manifest requires WAL from final timeline %u ending at %016" PRIX64 ", but this backup starts at %016" PRIX64, range->tli, - LSN_FORMAT_ARGS(range->end_lsn), - LSN_FORMAT_ARGS(backup_state->startpoint)), + range->end_lsn, + backup_state->startpoint), errhint("This can happen for incremental backups on a standby if there was little activity since the previous backup."))); } else @@ -441,10 +441,10 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib, if (range->end_lsn != tlep[i]->end) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("manifest requires WAL from non-final timeline %u ending at %X/%X, but this server switched timelines at %X/%X", + errmsg("manifest requires WAL from non-final timeline %u ending at %016" PRIX64 ", but this server switched timelines at %016" PRIX64, range->tli, - LSN_FORMAT_ARGS(range->end_lsn), - LSN_FORMAT_ARGS(tlep[i]->end)))); + range->end_lsn, + tlep[i]->end))); } } @@ -522,19 +522,19 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib, if (XLogRecPtrIsInvalid(tli_missing_lsn)) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but no summaries for that timeline and LSN range exist", + errmsg("WAL summaries are required on timeline %u from %016" PRIX64 " to %016" PRIX64 ", but no summaries for that timeline and LSN range exist", tle->tli, - LSN_FORMAT_ARGS(tli_start_lsn), - LSN_FORMAT_ARGS(tli_end_lsn)))); + tli_start_lsn, + tli_end_lsn))); else ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but the summaries for that timeline and LSN range are incomplete", + errmsg("WAL summaries are required on timeline %u from %016" PRIX64 " to %016" PRIX64 ", but the summaries for that timeline and LSN range are incomplete", tle->tli, - LSN_FORMAT_ARGS(tli_start_lsn), - LSN_FORMAT_ARGS(tli_end_lsn)), - errdetail("The first unsummarized LSN in this range is %X/%X.", - LSN_FORMAT_ARGS(tli_missing_lsn)))); + tli_start_lsn, + tli_end_lsn), + errdetail("The first unsummarized LSN in this range is %016" PRIX64 ".", + tli_missing_lsn))); } /* @@ -949,9 +949,9 @@ manifest_process_system_identifier(JsonManifestParseContext *context, if (manifest_system_identifier != system_identifier) context->error_cb(context, - "system identifier in backup manifest is %llu, but database system identifier is %llu", - (unsigned long long) manifest_system_identifier, - (unsigned long long) system_identifier); + "system identifier in backup manifest is %" PRIu64 ", but database system identifier is %" PRIu64, + manifest_system_identifier, + system_identifier); } /* diff --git a/src/backend/backup/walsummary.c b/src/backend/backup/walsummary.c index c7a2c65cc6a7..4805ed5ef381 100644 --- a/src/backend/backup/walsummary.c +++ b/src/backend/backup/walsummary.c @@ -208,10 +208,10 @@ OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok) File file; snprintf(path, MAXPGPATH, - XLOGDIR "/summaries/%08X%08X%08X%08X%08X.summary", + XLOGDIR "/summaries/%08X%016" PRIX64 "%016" PRIX64 ".summary", ws->tli, - LSN_FORMAT_ARGS(ws->start_lsn), - LSN_FORMAT_ARGS(ws->end_lsn)); + ws->start_lsn, + ws->end_lsn); file = PathNameOpenFile(path, O_RDONLY); if (file < 0 && (errno != EEXIST || !missing_ok)) @@ -233,10 +233,10 @@ RemoveWalSummaryIfOlderThan(WalSummaryFile *ws, time_t cutoff_time) struct stat statbuf; snprintf(path, MAXPGPATH, - XLOGDIR "/summaries/%08X%08X%08X%08X%08X.summary", + XLOGDIR "/summaries/%08X%016" PRIX64 "%016" PRIX64 ".summary", ws->tli, - LSN_FORMAT_ARGS(ws->start_lsn), - LSN_FORMAT_ARGS(ws->end_lsn)); + ws->start_lsn, + ws->end_lsn); if (lstat(path, &statbuf) != 0) { diff --git a/src/backend/backup/walsummaryfuncs.c b/src/backend/backup/walsummaryfuncs.c index 9811b79d62a4..d6dd131da145 100644 --- a/src/backend/backup/walsummaryfuncs.c +++ b/src/backend/backup/walsummaryfuncs.c @@ -92,7 +92,7 @@ pg_wal_summary_contents(PG_FUNCTION_ARGS) if (raw_tli < 1 || raw_tli > PG_INT32_MAX) ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid timeline %lld", (long long) raw_tli)); + errmsg("invalid timeline %" PRId64, raw_tli)); /* Prepare to read the specified WAL summary file. */ ws.tli = (TimeLineID) raw_tli; diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 8436e312d4d2..a6edf614606e 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -474,10 +474,10 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn) ereport(LOG, (errmsg("still searching for an unused OID in relation \"%s\"", RelationGetRelationName(relation)), - errdetail_plural("OID candidates have been checked %llu time, but no unused OID has been found yet.", - "OID candidates have been checked %llu times, but no unused OID has been found yet.", + errdetail_plural("OID candidates have been checked %" PRIu64 " time, but no unused OID has been found yet.", + "OID candidates have been checked %" PRIu64 " times, but no unused OID has been found yet.", retries, - (unsigned long long) retries))); + retries))); /* * Double the number of retries to do before logging next until it @@ -499,10 +499,10 @@ GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn) if (retries > GETNEWOID_LOG_THRESHOLD) { ereport(LOG, - (errmsg_plural("new OID has been assigned in relation \"%s\" after %llu retry", - "new OID has been assigned in relation \"%s\" after %llu retries", + (errmsg_plural("new OID has been assigned in relation \"%s\" after %" PRIu64 " retry", + "new OID has been assigned in relation \"%s\" after %" PRIu64 " retries", retries, - RelationGetRelationName(relation), (unsigned long long) retries))); + RelationGetRelationName(relation), retries))); } return newOid; diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 2b5fbdcbd82b..ca76c0d26680 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -827,16 +827,16 @@ do_analyze_rel(Relation onerel, VacuumParams *params, } appendStringInfo(&buf, _("avg read rate: %.3f MB/s, avg write rate: %.3f MB/s\n"), read_rate, write_rate); - appendStringInfo(&buf, _("buffer usage: %lld hits, %lld reads, %lld dirtied\n"), - (long long) total_blks_hit, - (long long) total_blks_read, - (long long) total_blks_dirtied); + appendStringInfo(&buf, _("buffer usage: %" PRId64 " hits, %" PRId64 " reads, %" PRId64 " dirtied\n"), + total_blks_hit, + total_blks_read, + total_blks_dirtied); appendStringInfo(&buf, - _("WAL usage: %lld records, %lld full page images, %llu bytes, %lld buffers full\n"), - (long long) walusage.wal_records, - (long long) walusage.wal_fpi, - (unsigned long long) walusage.wal_bytes, - (long long) walusage.wal_buffers_full); + _("WAL usage: %" PRId64 " records, %" PRId64 " full page images, %" PRIu64 " bytes, %" PRId64 " buffers full\n"), + walusage.wal_records, + walusage.wal_fpi, + walusage.wal_bytes, + walusage.wal_buffers_full); appendStringInfo(&buf, _("system usage: %s"), pg_rusage_show(&ru0)); ereport(verbose ? INFO : LOG, diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index cfca9d9dc29d..74ae42b19a71 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -443,8 +443,8 @@ defGetCopyRejectLimitOption(DefElem *def) if (reject_limit <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("REJECT_LIMIT (%lld) must be greater than zero", - (long long) reject_limit))); + errmsg("REJECT_LIMIT (%" PRId64 ") must be greater than zero", + reject_limit))); return reject_limit; } diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c index bcf66f0adf89..fbbbc09a97b1 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -265,14 +265,14 @@ CopyFromErrorCallback(void *arg) { /* can't usefully display the data */ if (cstate->cur_attname) - errcontext("COPY %s, line %llu, column %s", + errcontext("COPY %s, line %" PRIu64 ", column %s", cstate->cur_relname, - (unsigned long long) cstate->cur_lineno, + cstate->cur_lineno, cstate->cur_attname); else - errcontext("COPY %s, line %llu", + errcontext("COPY %s, line %" PRIu64, cstate->cur_relname, - (unsigned long long) cstate->cur_lineno); + cstate->cur_lineno); } else { @@ -282,9 +282,9 @@ CopyFromErrorCallback(void *arg) char *attval; attval = CopyLimitPrintoutLength(cstate->cur_attval); - errcontext("COPY %s, line %llu, column %s: \"%s\"", + errcontext("COPY %s, line %" PRIu64 ", column %s: \"%s\"", cstate->cur_relname, - (unsigned long long) cstate->cur_lineno, + cstate->cur_lineno, cstate->cur_attname, attval); pfree(attval); @@ -292,9 +292,9 @@ CopyFromErrorCallback(void *arg) else if (cstate->cur_attname) { /* error is relevant to a particular column, value is NULL */ - errcontext("COPY %s, line %llu, column %s: null input", + errcontext("COPY %s, line %" PRIu64 ", column %s: null input", cstate->cur_relname, - (unsigned long long) cstate->cur_lineno, + cstate->cur_lineno, cstate->cur_attname); } else @@ -309,16 +309,16 @@ CopyFromErrorCallback(void *arg) char *lineval; lineval = CopyLimitPrintoutLength(cstate->line_buf.data); - errcontext("COPY %s, line %llu: \"%s\"", + errcontext("COPY %s, line %" PRIu64 ": \"%s\"", cstate->cur_relname, - (unsigned long long) cstate->cur_lineno, lineval); + cstate->cur_lineno, lineval); pfree(lineval); } else { - errcontext("COPY %s, line %llu", + errcontext("COPY %s, line %" PRIu64, cstate->cur_relname, - (unsigned long long) cstate->cur_lineno); + cstate->cur_lineno); } } } @@ -1168,8 +1168,8 @@ CopyFrom(CopyFromState cstate) cstate->num_errors > cstate->opts.reject_limit) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("skipped more than REJECT_LIMIT (%lld) rows due to data type incompatibility", - (long long) cstate->opts.reject_limit))); + errmsg("skipped more than REJECT_LIMIT (%" PRId64 ") rows due to data type incompatibility", + cstate->opts.reject_limit))); /* Repeat NextCopyFrom() until no soft error occurs */ continue; @@ -1471,10 +1471,10 @@ CopyFrom(CopyFromState cstate) cstate->num_errors > 0 && cstate->opts.log_verbosity >= COPY_LOG_VERBOSITY_DEFAULT) ereport(NOTICE, - errmsg_plural("%llu row was skipped due to data type incompatibility", - "%llu rows were skipped due to data type incompatibility", - (unsigned long long) cstate->num_errors, - (unsigned long long) cstate->num_errors)); + errmsg_plural("%" PRIu64 " row was skipped due to data type incompatibility", + "%" PRIu64 " rows were skipped due to data type incompatibility", + cstate->num_errors, + cstate->num_errors)); if (bistate != NULL) FreeBulkInsertState(bistate); diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index e8128f85e6b5..f5fc346e2013 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -1053,16 +1053,16 @@ CopyFromTextLikeOneRow(CopyFromState cstate, ExprContext *econtext, attval = CopyLimitPrintoutLength(cstate->cur_attval); ereport(NOTICE, - errmsg("skipping row due to data type incompatibility at line %llu for column \"%s\": \"%s\"", - (unsigned long long) cstate->cur_lineno, + errmsg("skipping row due to data type incompatibility at line %" PRIu64 " for column \"%s\": \"%s\"", + cstate->cur_lineno, cstate->cur_attname, attval)); pfree(attval); } else ereport(NOTICE, - errmsg("skipping row due to data type incompatibility at line %llu for column \"%s\": null input", - (unsigned long long) cstate->cur_lineno, + errmsg("skipping row due to data type incompatibility at line %" PRIu64 " for column \"%s\": null input", + cstate->cur_lineno, cstate->cur_attname)); /* reset relname_only */ diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index d8a7232cedbf..93cb2768bc68 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -4080,17 +4080,17 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage) { appendStringInfoString(es->str, " shared"); if (usage->shared_blks_hit > 0) - appendStringInfo(es->str, " hit=%lld", - (long long) usage->shared_blks_hit); + appendStringInfo(es->str, " hit=%" PRId64, + usage->shared_blks_hit); if (usage->shared_blks_read > 0) - appendStringInfo(es->str, " read=%lld", - (long long) usage->shared_blks_read); + appendStringInfo(es->str, " read=%" PRId64, + usage->shared_blks_read); if (usage->shared_blks_dirtied > 0) - appendStringInfo(es->str, " dirtied=%lld", - (long long) usage->shared_blks_dirtied); + appendStringInfo(es->str, " dirtied=%" PRId64, + usage->shared_blks_dirtied); if (usage->shared_blks_written > 0) - appendStringInfo(es->str, " written=%lld", - (long long) usage->shared_blks_written); + appendStringInfo(es->str, " written=%" PRId64, + usage->shared_blks_written); if (has_local || has_temp) appendStringInfoChar(es->str, ','); } @@ -4098,17 +4098,17 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage) { appendStringInfoString(es->str, " local"); if (usage->local_blks_hit > 0) - appendStringInfo(es->str, " hit=%lld", - (long long) usage->local_blks_hit); + appendStringInfo(es->str, " hit=%" PRId64, + usage->local_blks_hit); if (usage->local_blks_read > 0) - appendStringInfo(es->str, " read=%lld", - (long long) usage->local_blks_read); + appendStringInfo(es->str, " read=%" PRId64, + usage->local_blks_read); if (usage->local_blks_dirtied > 0) - appendStringInfo(es->str, " dirtied=%lld", - (long long) usage->local_blks_dirtied); + appendStringInfo(es->str, " dirtied=%" PRId64, + usage->local_blks_dirtied); if (usage->local_blks_written > 0) - appendStringInfo(es->str, " written=%lld", - (long long) usage->local_blks_written); + appendStringInfo(es->str, " written=%" PRId64, + usage->local_blks_written); if (has_temp) appendStringInfoChar(es->str, ','); } @@ -4116,11 +4116,11 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage) { appendStringInfoString(es->str, " temp"); if (usage->temp_blks_read > 0) - appendStringInfo(es->str, " read=%lld", - (long long) usage->temp_blks_read); + appendStringInfo(es->str, " read=%" PRId64, + usage->temp_blks_read); if (usage->temp_blks_written > 0) - appendStringInfo(es->str, " written=%lld", - (long long) usage->temp_blks_written); + appendStringInfo(es->str, " written=%" PRId64, + usage->temp_blks_written); } appendStringInfoChar(es->str, '\n'); } @@ -4230,17 +4230,17 @@ show_wal_usage(ExplainState *es, const WalUsage *usage) appendStringInfoString(es->str, "WAL:"); if (usage->wal_records > 0) - appendStringInfo(es->str, " records=%lld", - (long long) usage->wal_records); + appendStringInfo(es->str, " records=%" PRId64, + usage->wal_records); if (usage->wal_fpi > 0) - appendStringInfo(es->str, " fpi=%lld", - (long long) usage->wal_fpi); + appendStringInfo(es->str, " fpi=%" PRId64, + usage->wal_fpi); if (usage->wal_bytes > 0) - appendStringInfo(es->str, " bytes=" UINT64_FORMAT, + appendStringInfo(es->str, " bytes=%" PRIu64, usage->wal_bytes); if (usage->wal_buffers_full > 0) - appendStringInfo(es->str, " buffers full=%lld", - (long long) usage->wal_buffers_full); + appendStringInfo(es->str, " buffers full=%" PRId64, + usage->wal_buffers_full); appendStringInfoChar(es->str, '\n'); } } diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 4b7c5113aabe..451ae6f7f694 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -745,9 +745,9 @@ nextval_internal(Oid relid, bool check_permissions) if (!cycle) ereport(ERROR, (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED), - errmsg("nextval: reached maximum value of sequence \"%s\" (%lld)", + errmsg("nextval: reached maximum value of sequence \"%s\" (%" PRId64 ")", RelationGetRelationName(seqrel), - (long long) maxv))); + maxv))); next = minv; } else @@ -764,9 +764,9 @@ nextval_internal(Oid relid, bool check_permissions) if (!cycle) ereport(ERROR, (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED), - errmsg("nextval: reached minimum value of sequence \"%s\" (%lld)", + errmsg("nextval: reached minimum value of sequence \"%s\" (%" PRId64 ")", RelationGetRelationName(seqrel), - (long long) minv))); + minv))); next = maxv; } else @@ -988,9 +988,9 @@ do_setval(Oid relid, int64 next, bool iscalled) if ((next < minv) || (next > maxv)) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("setval: value %lld is out of bounds for sequence \"%s\" (%lld..%lld)", - (long long) next, RelationGetRelationName(seqrel), - (long long) minv, (long long) maxv))); + errmsg("setval: value %" PRId64 " is out of bounds for sequence \"%s\" (%" PRId64 "..%" PRId64 ")", + next, RelationGetRelationName(seqrel), + minv, maxv))); /* Set the currval() state only if iscalled = true */ if (iscalled) @@ -1463,8 +1463,8 @@ init_params(ParseState *pstate, List *options, bool for_identity, || (seqform->seqtypid == INT4OID && (seqform->seqmax < PG_INT32_MIN || seqform->seqmax > PG_INT32_MAX))) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("MAXVALUE (%lld) is out of range for sequence data type %s", - (long long) seqform->seqmax, + errmsg("MAXVALUE (%" PRId64 ") is out of range for sequence data type %s", + seqform->seqmax, format_type_be(seqform->seqtypid)))); /* MINVALUE (null arg means NO MINVALUE) */ @@ -1495,17 +1495,17 @@ init_params(ParseState *pstate, List *options, bool for_identity, || (seqform->seqtypid == INT4OID && (seqform->seqmin < PG_INT32_MIN || seqform->seqmin > PG_INT32_MAX))) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("MINVALUE (%lld) is out of range for sequence data type %s", - (long long) seqform->seqmin, + errmsg("MINVALUE (%" PRId64 ") is out of range for sequence data type %s", + seqform->seqmin, format_type_be(seqform->seqtypid)))); /* crosscheck min/max */ if (seqform->seqmin >= seqform->seqmax) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("MINVALUE (%lld) must be less than MAXVALUE (%lld)", - (long long) seqform->seqmin, - (long long) seqform->seqmax))); + errmsg("MINVALUE (%" PRId64 ") must be less than MAXVALUE (%" PRId64 ")", + seqform->seqmin, + seqform->seqmax))); /* START WITH */ if (start_value != NULL) @@ -1524,15 +1524,15 @@ init_params(ParseState *pstate, List *options, bool for_identity, if (seqform->seqstart < seqform->seqmin) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("START value (%lld) cannot be less than MINVALUE (%lld)", - (long long) seqform->seqstart, - (long long) seqform->seqmin))); + errmsg("START value (%" PRId64 ") cannot be less than MINVALUE (%" PRId64 ")", + seqform->seqstart, + seqform->seqmin))); if (seqform->seqstart > seqform->seqmax) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("START value (%lld) cannot be greater than MAXVALUE (%lld)", - (long long) seqform->seqstart, - (long long) seqform->seqmax))); + errmsg("START value (%" PRId64 ") cannot be greater than MAXVALUE (%" PRId64 ")", + seqform->seqstart, + seqform->seqmax))); /* RESTART [WITH] */ if (restart_value != NULL) @@ -1554,15 +1554,15 @@ init_params(ParseState *pstate, List *options, bool for_identity, if (seqdataform->last_value < seqform->seqmin) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("RESTART value (%lld) cannot be less than MINVALUE (%lld)", - (long long) seqdataform->last_value, - (long long) seqform->seqmin))); + errmsg("RESTART value (%" PRId64 ") cannot be less than MINVALUE (%" PRId64 ")", + seqdataform->last_value, + seqform->seqmin))); if (seqdataform->last_value > seqform->seqmax) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("RESTART value (%lld) cannot be greater than MAXVALUE (%lld)", - (long long) seqdataform->last_value, - (long long) seqform->seqmax))); + errmsg("RESTART value (%" PRId64 ") cannot be greater than MAXVALUE (%" PRId64 ")", + seqdataform->last_value, + seqform->seqmax))); /* CACHE */ if (cache_value != NULL) @@ -1571,8 +1571,8 @@ init_params(ParseState *pstate, List *options, bool for_identity, if (seqform->seqcache <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("CACHE (%lld) must be greater than zero", - (long long) seqform->seqcache))); + errmsg("CACHE (%" PRId64 ") must be greater than zero", + seqform->seqcache))); seqdataform->log_cnt = 0; } else if (isInit) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 4aec73bcc6bb..826db2eb450b 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -1539,9 +1539,9 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, if (!XLogRecPtrIsInvalid(remote_lsn) && opts.lsn < remote_lsn) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("skip WAL location (LSN %X/%X) must be greater than origin LSN %X/%X", - LSN_FORMAT_ARGS(opts.lsn), - LSN_FORMAT_ARGS(remote_lsn)))); + errmsg("skip WAL location (LSN %016" PRIX64 ") must be greater than origin LSN %016" PRIX64, + opts.lsn, + remote_lsn))); } values[Anum_pg_subscription_subskiplsn - 1] = LSNGetDatum(opts.lsn); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index e81c9a8aba3e..cc9e70e2e6df 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -2605,9 +2605,9 @@ vac_bulkdel_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat, dead_items); ereport(ivinfo->message_level, - (errmsg("scanned index \"%s\" to remove %lld row versions", + (errmsg("scanned index \"%s\" to remove %" PRId64 " row versions", RelationGetRelationName(ivinfo->index), - (long long) dead_items_info->num_items))); + dead_items_info->num_items))); return istat; } diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c index ccba0f84e6e2..8bac0ea07a5b 100644 --- a/src/backend/postmaster/walsummarizer.c +++ b/src/backend/postmaster/walsummarizer.c @@ -383,8 +383,8 @@ WalSummarizerMain(const void *startup_data, size_t startup_data_len) switch_lsn = tliSwitchPoint(current_tli, tles, &switch_tli); ereport(DEBUG1, - errmsg_internal("switch point from TLI %u to TLI %u is at %X/%X", - current_tli, switch_tli, LSN_FORMAT_ARGS(switch_lsn))); + errmsg_internal("switch point from TLI %u to TLI %u is at %016" PRIX64, + current_tli, switch_tli, switch_lsn)); } /* @@ -739,10 +739,10 @@ WaitForWalSummarization(XLogRecPtr lsn) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("WAL summarization is not progressing"), - errdetail("Summarization is needed through %X/%X, but is stuck at %X/%X on disk and %X/%X in memory.", - LSN_FORMAT_ARGS(lsn), - LSN_FORMAT_ARGS(summarized_lsn), - LSN_FORMAT_ARGS(pending_lsn)))); + errdetail("Summarization is needed through %016" PRIX64 ", but is stuck at %016" PRIX64 " on disk and %016" PRIX64 " in memory.", + lsn, + summarized_lsn, + pending_lsn))); /* @@ -753,14 +753,14 @@ WaitForWalSummarization(XLogRecPtr lsn) current_time) / 1000; ereport(WARNING, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg_plural("still waiting for WAL summarization through %X/%X after %ld second", - "still waiting for WAL summarization through %X/%X after %ld seconds", + errmsg_plural("still waiting for WAL summarization through %016" PRIX64 " after %ld second", + "still waiting for WAL summarization through %016" PRIX64 " after %ld seconds", elapsed_seconds, - LSN_FORMAT_ARGS(lsn), + lsn, elapsed_seconds), - errdetail("Summarization has reached %X/%X on disk and %X/%X in memory.", - LSN_FORMAT_ARGS(summarized_lsn), - LSN_FORMAT_ARGS(pending_lsn)))); + errdetail("Summarization has reached %016" PRIX64 " on disk and %016" PRIX64 " in memory.", + summarized_lsn, + pending_lsn))); } /* @@ -979,10 +979,10 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, if (private_data->end_of_wal) { ereport(DEBUG1, - errmsg_internal("could not read WAL from timeline %u at %X/%X: end of WAL at %X/%X", + errmsg_internal("could not read WAL from timeline %u at %016" PRIX64 ": end of WAL at %016" PRIX64, tli, - LSN_FORMAT_ARGS(start_lsn), - LSN_FORMAT_ARGS(private_data->read_upto))); + start_lsn, + private_data->read_upto)); /* * The timeline ends at or after start_lsn, without containing @@ -998,8 +998,8 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, } else ereport(ERROR, - (errmsg("could not find a valid record after %X/%X", - LSN_FORMAT_ARGS(start_lsn)))); + (errmsg("could not find a valid record after %016" PRIX64, + start_lsn))); } /* We shouldn't go backward. */ @@ -1032,10 +1032,10 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, * able to read a complete record. */ ereport(DEBUG1, - errmsg_internal("could not read WAL from timeline %u at %X/%X: end of WAL at %X/%X", + errmsg_internal("could not read WAL from timeline %u at %016" PRIX64 ": end of WAL at %016" PRIX64, tli, - LSN_FORMAT_ARGS(xlogreader->EndRecPtr), - LSN_FORMAT_ARGS(private_data->read_upto))); + xlogreader->EndRecPtr, + private_data->read_upto)); /* Summary ends at end of WAL. */ summary_end_lsn = private_data->read_upto; break; @@ -1043,14 +1043,16 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, if (errormsg) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read WAL from timeline %u at %X/%X: %s", - tli, LSN_FORMAT_ARGS(xlogreader->EndRecPtr), + errmsg("could not read WAL from timeline %u at %016" + PRIX64 ": %s", + tli, xlogreader->EndRecPtr, errormsg))); else ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read WAL from timeline %u at %X/%X", - tli, LSN_FORMAT_ARGS(xlogreader->EndRecPtr)))); + errmsg("could not read WAL from timeline %u at %016" + PRIX64, + tli, xlogreader->EndRecPtr))); } /* We shouldn't go backward. */ @@ -1199,10 +1201,10 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, snprintf(temp_path, MAXPGPATH, XLOGDIR "/summaries/temp.summary"); snprintf(final_path, MAXPGPATH, - XLOGDIR "/summaries/%08X%08X%08X%08X%08X.summary", + XLOGDIR "/summaries/%08X%016" PRIX64 "%016" PRIX64 ".summary", tli, - LSN_FORMAT_ARGS(summary_start_lsn), - LSN_FORMAT_ARGS(summary_end_lsn)); + summary_start_lsn, + summary_end_lsn); /* Open the temporary file for writing. */ io.filepos = 0; @@ -1220,10 +1222,11 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, /* Tell the user what we did. */ ereport(DEBUG1, - errmsg_internal("summarized WAL on TLI %u from %X/%X to %X/%X", + errmsg_internal("summarized WAL on TLI %u from %016" PRIX64 + " to %016" PRIX64, tli, - LSN_FORMAT_ARGS(summary_start_lsn), - LSN_FORMAT_ARGS(summary_end_lsn))); + summary_start_lsn, + summary_end_lsn)); /* Durably rename the new summary into place. */ durable_rename(temp_path, final_path, ERROR); @@ -1232,10 +1235,11 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, /* If we skipped a non-zero amount of WAL, log a debug message. */ if (summary_end_lsn > summary_start_lsn && fast_forward) ereport(DEBUG1, - errmsg_internal("skipped summarizing WAL on TLI %u from %X/%X to %X/%X", + errmsg_internal("skipped summarizing WAL on TLI %u from %016" + PRIX64 " to %016" PRIX64, tli, - LSN_FORMAT_ARGS(summary_start_lsn), - LSN_FORMAT_ARGS(summary_end_lsn))); + summary_start_lsn, + summary_end_lsn)); return summary_end_lsn; } @@ -1578,8 +1582,9 @@ summarizer_read_local_xlog_page(XLogReaderState *state, /* Debugging output. */ ereport(DEBUG1, - errmsg_internal("timeline %u became historic, can read up to %X/%X", - private_data->tli, LSN_FORMAT_ARGS(private_data->read_upto))); + errmsg_internal("timeline %u became historic, can read up to %016" PRIX64, + private_data->tli, + private_data->read_upto)); } /* Go around and try again. */ diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c index c650935ef5d7..6593e827f047 100644 --- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c +++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c @@ -569,7 +569,7 @@ libpqrcv_startstreaming(WalReceiverConn *conn, if (options->logical) appendStringInfoString(&cmd, " LOGICAL"); - appendStringInfo(&cmd, " %X/%X", LSN_FORMAT_ARGS(options->startpoint)); + appendStringInfo(&cmd, " %016" PRIX64, options->startpoint); /* * Additional options are different depending on if we are doing logical diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 8ea846bfc3b6..e72a25613339 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -565,9 +565,10 @@ CreateDecodingContext(XLogRecPtr start_lsn, * kinds of client errors; so the client may wish to check that * confirmed_flush_lsn matches its expectations. */ - elog(LOG, "%X/%X has been already streamed, forwarding to %X/%X", - LSN_FORMAT_ARGS(start_lsn), - LSN_FORMAT_ARGS(slot->data.confirmed_flush)); + elog(LOG, "%016" PRIX64 + " has been already streamed, forwarding to %016" PRIX64, + start_lsn, + slot->data.confirmed_flush); start_lsn = slot->data.confirmed_flush; } @@ -608,9 +609,10 @@ CreateDecodingContext(XLogRecPtr start_lsn, ereport(LOG, (errmsg("starting logical decoding for slot \"%s\"", NameStr(slot->data.name)), - errdetail("Streaming transactions committing after %X/%X, reading WAL from %X/%X.", - LSN_FORMAT_ARGS(slot->data.confirmed_flush), - LSN_FORMAT_ARGS(slot->data.restart_lsn)))); + errdetail("Streaming transactions committing after %016" PRIX64 + ", reading WAL from %016" PRIX64 ".", + slot->data.confirmed_flush, + slot->data.restart_lsn))); return ctx; } @@ -635,8 +637,8 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx) /* Initialize from where to start reading WAL. */ XLogBeginRead(ctx->reader, slot->data.restart_lsn); - elog(DEBUG1, "searching for logical decoding starting point, starting at %X/%X", - LSN_FORMAT_ARGS(slot->data.restart_lsn)); + elog(DEBUG1, "searching for logical decoding starting point, starting at %016" PRIX64, + slot->data.restart_lsn); /* Wait for a consistent starting point */ for (;;) @@ -756,11 +758,11 @@ output_plugin_error_callback(void *arg) /* not all callbacks have an associated LSN */ if (state->report_location != InvalidXLogRecPtr) - errcontext("slot \"%s\", output plugin \"%s\", in the %s callback, associated LSN %X/%X", + errcontext("slot \"%s\", output plugin \"%s\", in the %s callback, associated LSN %016" PRIX64, NameStr(state->ctx->slot->data.name), NameStr(state->ctx->slot->data.plugin), state->callback_name, - LSN_FORMAT_ARGS(state->report_location)); + state->report_location); else errcontext("slot \"%s\", output plugin \"%s\", in the %s callback", NameStr(state->ctx->slot->data.name), @@ -1723,8 +1725,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 %u at %016" PRIX64, xmin, + current_lsn); /* candidate already valid with the current flush position, apply */ if (updated_xmin) @@ -1783,9 +1785,9 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart slot->candidate_restart_lsn = restart_lsn; SpinLockRelease(&slot->mutex); - elog(DEBUG1, "got new restart lsn %X/%X at %X/%X", - LSN_FORMAT_ARGS(restart_lsn), - LSN_FORMAT_ARGS(current_lsn)); + elog(DEBUG1, "got new restart lsn %016" PRIX64 " at %016" PRIX64, + restart_lsn, + current_lsn); } else { @@ -1798,12 +1800,14 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart confirmed_flush = slot->data.confirmed_flush; SpinLockRelease(&slot->mutex); - elog(DEBUG1, "failed to increase restart lsn: proposed %X/%X, after %X/%X, current candidate %X/%X, current after %X/%X, flushed up to %X/%X", - LSN_FORMAT_ARGS(restart_lsn), - LSN_FORMAT_ARGS(current_lsn), - LSN_FORMAT_ARGS(candidate_restart_lsn), - LSN_FORMAT_ARGS(candidate_restart_valid), - LSN_FORMAT_ARGS(confirmed_flush)); + elog(DEBUG1, "failed to increase restart lsn: proposed %016" PRIX64 + ", after %016" PRIX64 ", current candidate %016" PRIX64 + ", current after %016" PRIX64 ", flushed up to %016" PRIX64, + restart_lsn, + current_lsn, + candidate_restart_lsn, + candidate_restart_valid, + confirmed_flush); } /* candidates are already valid with the current flush position, apply */ @@ -1921,16 +1925,16 @@ UpdateDecodingStats(LogicalDecodingContext *ctx) if (rb->spillBytes <= 0 && rb->streamBytes <= 0 && rb->totalBytes <= 0) return; - elog(DEBUG2, "UpdateDecodingStats: updating stats %p %lld %lld %lld %lld %lld %lld %lld %lld", + elog(DEBUG2, "UpdateDecodingStats: updating stats %p %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64, rb, - (long long) rb->spillTxns, - (long long) rb->spillCount, - (long long) rb->spillBytes, - (long long) rb->streamTxns, - (long long) rb->streamCount, - (long long) rb->streamBytes, - (long long) rb->totalTxns, - (long long) rb->totalBytes); + rb->spillTxns, + rb->spillCount, + rb->spillBytes, + rb->streamTxns, + rb->streamCount, + rb->streamBytes, + rb->totalTxns, + rb->totalBytes); repSlotStat.spill_txns = rb->spillTxns; repSlotStat.spill_count = rb->spillCount; diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index c3c1d7a2a518..90f4a7b0833b 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -807,9 +807,9 @@ StartupReplicationOrigin(void) last_state++; ereport(LOG, - (errmsg("recovered replication state of node %d to %X/%X", + (errmsg("recovered replication state of node %d to %016" PRIX64, disk_state.roident, - LSN_FORMAT_ARGS(disk_state.remote_lsn)))); + disk_state.remote_lsn))); } /* now check checksum */ diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 5186ad2a3970..4ff1bcc21122 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -4764,10 +4764,10 @@ ReorderBufferSerializedPath(char *path, ReplicationSlot *slot, TransactionId xid XLogSegNoOffsetToRecPtr(segno, 0, wal_segment_size, recptr); - snprintf(path, MAXPGPATH, "%s/%s/xid-%u-lsn-%X-%X.spill", + snprintf(path, MAXPGPATH, "%s/%s/xid-%u-lsn-%016" PRIX64 ".spill", PG_REPLSLOT_DIR, NameStr(MyReplicationSlot->data.name), - xid, LSN_FORMAT_ARGS(recptr)); + xid, recptr); } /* @@ -5333,8 +5333,6 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot) TransactionId f_mapped_xid; TransactionId f_create_xid; XLogRecPtr f_lsn; - uint32 f_hi, - f_lo; RewriteMappingFile *f; if (strcmp(mapping_de->d_name, ".") == 0 || @@ -5345,13 +5343,11 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot) if (strncmp(mapping_de->d_name, "map-", 4) != 0) 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) + if (sscanf(mapping_de->d_name, LOGICAL_REWRITE_FORMAT_SCANF, + &f_dboid, &f_relid, &f_lsn, + &f_mapped_xid, &f_create_xid) != 5) elog(ERROR, "could not parse filename \"%s\"", mapping_de->d_name); - f_lsn = ((uint64) f_hi) << 32 | f_lo; - /* mapping for another database */ if (f_dboid != dboid) continue; diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c index 2c0a7439be41..9bf6934b7fab 100644 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@ -212,10 +212,10 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid, ereport(slot->data.persistency == RS_TEMPORARY ? LOG : DEBUG1, errmsg("could not synchronize replication slot \"%s\" because remote slot precedes local slot", remote_slot->name), - errdetail("The remote slot has LSN %X/%X and catalog xmin %u, but the local slot has LSN %X/%X and catalog xmin %u.", - LSN_FORMAT_ARGS(remote_slot->restart_lsn), + errdetail("The remote slot has LSN %016" PRIX64 " and catalog xmin %u, but the local slot has LSN %016" PRIX64 " and catalog xmin %u.", + remote_slot->restart_lsn, remote_slot->catalog_xmin, - LSN_FORMAT_ARGS(slot->data.restart_lsn), + slot->data.restart_lsn, slot->data.catalog_xmin)); if (remote_slot_precedes) @@ -265,9 +265,9 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid, ereport(ERROR, errmsg_internal("synchronized confirmed_flush for slot \"%s\" differs from remote slot", remote_slot->name), - errdetail_internal("Remote slot has LSN %X/%X but local slot has LSN %X/%X.", - LSN_FORMAT_ARGS(remote_slot->confirmed_lsn), - LSN_FORMAT_ARGS(slot->data.confirmed_flush))); + errdetail_internal("Remote slot has LSN %016" PRIX64 " but local slot has LSN %016" PRIX64 ".", + remote_slot->confirmed_lsn, + slot->data.confirmed_flush)); } updated_xmin_or_lsn = true; @@ -575,8 +575,8 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid) { ereport(LOG, errmsg("could not synchronize replication slot \"%s\"", remote_slot->name), - errdetail("Logical decoding could not find consistent point from local slot's LSN %X/%X.", - LSN_FORMAT_ARGS(slot->data.restart_lsn))); + errdetail("Logical decoding could not find consistent point from local slot's LSN %016" PRIX64 ".", + slot->data.restart_lsn)); return false; } @@ -624,10 +624,10 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid) ereport(AmLogicalSlotSyncWorkerProcess() ? LOG : ERROR, errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("skipping slot synchronization because the received slot sync" - " LSN %X/%X for slot \"%s\" is ahead of the standby position %X/%X", - LSN_FORMAT_ARGS(remote_slot->confirmed_lsn), + " LSN %016" PRIX64 " for slot \"%s\" is ahead of the standby position %016" PRIX64, + remote_slot->confirmed_lsn, remote_slot->name, - LSN_FORMAT_ARGS(latestFlushPtr))); + latestFlushPtr)); return false; } @@ -715,9 +715,9 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid) ereport(ERROR, errmsg_internal("cannot synchronize local slot \"%s\"", remote_slot->name), - errdetail_internal("Local slot's start streaming location LSN(%X/%X) is ahead of remote slot's LSN(%X/%X).", - LSN_FORMAT_ARGS(slot->data.confirmed_flush), - LSN_FORMAT_ARGS(remote_slot->confirmed_lsn))); + errdetail_internal("Local slot's start streaming location LSN(%016" PRIX64 ") is ahead of remote slot's LSN(%016" PRIX64 ").", + slot->data.confirmed_flush, + remote_slot->confirmed_lsn)); slot_updated = update_local_synced_slot(remote_slot, remote_dbid, NULL, NULL); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index bd0680dcbe55..c8b320edcfc7 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -764,8 +764,8 @@ SnapBuildDistributeNewCatalogSnapshot(SnapBuild *builder, XLogRecPtr lsn) if (rbtxn_is_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 %u at %016" PRIX64, + txn->xid, lsn); /* * increase the snapshot's refcount for the transaction we are handing @@ -1223,8 +1223,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn builder->initial_xmin_horizon)) { ereport(DEBUG1, - (errmsg_internal("skipping snapshot at %X/%X while building logical decoding snapshot, xmin horizon too low", - LSN_FORMAT_ARGS(lsn)), + (errmsg_internal("skipping snapshot at %016" PRIX64 " while building logical decoding snapshot, xmin horizon too low", + lsn), errdetail_internal("initial xmin horizon of %u vs the snapshot's %u", builder->initial_xmin_horizon, running->oldestRunningXid))); @@ -1262,8 +1262,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn builder->next_phase_at = InvalidTransactionId; ereport(LOG, - (errmsg("logical decoding found consistent point at %X/%X", - LSN_FORMAT_ARGS(lsn)), + (errmsg("logical decoding found consistent point at %016" PRIX64, + lsn), errdetail("There are no running transactions."))); return false; @@ -1311,8 +1311,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn Assert(TransactionIdIsNormal(builder->xmax)); ereport(LOG, - (errmsg("logical decoding found initial starting point at %X/%X", - LSN_FORMAT_ARGS(lsn)), + (errmsg("logical decoding found initial starting point at %016" PRIX64, + lsn), errdetail("Waiting for transactions (approximately %d) older than %u to end.", running->xcnt, running->nextXid))); @@ -1335,8 +1335,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn builder->next_phase_at = running->nextXid; ereport(LOG, - (errmsg("logical decoding found initial consistent point at %X/%X", - LSN_FORMAT_ARGS(lsn)), + (errmsg("logical decoding found initial consistent point at %016" PRIX64, + lsn), errdetail("Waiting for transactions (approximately %d) older than %u to end.", running->xcnt, running->nextXid))); @@ -1359,8 +1359,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn builder->next_phase_at = InvalidTransactionId; ereport(LOG, - (errmsg("logical decoding found consistent point at %X/%X", - LSN_FORMAT_ARGS(lsn)), + (errmsg("logical decoding found consistent point at %016" PRIX64, + lsn), errdetail("There are no old transactions anymore."))); } @@ -1481,9 +1481,9 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) * unless the user used pg_resetwal or similar. If a user did so, there's * no hope continuing to decode anyway. */ - sprintf(path, "%s/%X-%X.snap", + sprintf(path, "%s/%016" PRIX64 ".snap", PG_LOGICAL_SNAPSHOTS_DIR, - LSN_FORMAT_ARGS(lsn)); + lsn); /* * first check whether some other backend already has written the snapshot @@ -1525,9 +1525,9 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) elog(DEBUG1, "serializing snapshot to %s", path); /* to make sure only we will write to this tempfile, include pid */ - sprintf(tmppath, "%s/%X-%X.snap.%d.tmp", + sprintf(tmppath, "%s/%016" PRIX64 ".snap.%d.tmp", PG_LOGICAL_SNAPSHOTS_DIR, - LSN_FORMAT_ARGS(lsn), MyProcPid); + lsn, MyProcPid); /* * Unlink temporary file if it already exists, needs to have been before a @@ -1794,9 +1794,9 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn) if (builder->state == SNAPBUILD_CONSISTENT) return false; - sprintf(path, "%s/%X-%X.snap", + sprintf(path, "%s/%016" PRIX64 ".snap", PG_LOGICAL_SNAPSHOTS_DIR, - LSN_FORMAT_ARGS(lsn)); + lsn); /* validate and restore the snapshot to 'ondisk' */ if (!SnapBuildRestoreSnapshot(&ondisk, path, builder->context, true)) @@ -1865,8 +1865,8 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn) Assert(builder->state == SNAPBUILD_CONSISTENT); ereport(LOG, - (errmsg("logical decoding found consistent point at %X/%X", - LSN_FORMAT_ARGS(lsn)), + (errmsg("logical decoding found consistent point at %016" PRIX64, + lsn), errdetail("Logical decoding will begin using saved snapshot."))); return true; @@ -2013,9 +2013,9 @@ SnapBuildSnapshotExists(XLogRecPtr lsn) int ret; struct stat stat_buf; - sprintf(path, "%s/%X-%X.snap", + sprintf(path, "%s/%016" PRIX64 ".snap", PG_LOGICAL_SNAPSHOTS_DIR, - LSN_FORMAT_ARGS(lsn)); + lsn); ret = stat(path, &stat_buf); diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 6af5c9fe16c4..b251877f79a6 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -1549,8 +1549,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos) copy_table_done: elog(DEBUG1, - "LogicalRepSyncTableStart: '%s' origin_startpos lsn %X/%X", - originname, LSN_FORMAT_ARGS(*origin_startpos)); + "LogicalRepSyncTableStart: '%s' origin_startpos lsn %016" PRIX64, + originname, *origin_startpos); /* * We are done with the initial data synchronization, update the state. diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 31ab69ea13a6..dfc5592c130f 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1021,9 +1021,9 @@ apply_handle_commit(StringInfo s) if (commit_data.commit_lsn != remote_final_lsn) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg_internal("incorrect commit LSN %X/%X in commit message (expected %X/%X)", - LSN_FORMAT_ARGS(commit_data.commit_lsn), - LSN_FORMAT_ARGS(remote_final_lsn)))); + errmsg_internal("incorrect commit LSN %016" PRIX64 " in commit message (expected %016" PRIX64 ")", + commit_data.commit_lsn, + remote_final_lsn))); apply_handle_commit_internal(&commit_data); @@ -1113,9 +1113,9 @@ apply_handle_prepare(StringInfo s) if (prepare_data.prepare_lsn != remote_final_lsn) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg_internal("incorrect prepare LSN %X/%X in prepare message (expected %X/%X)", - LSN_FORMAT_ARGS(prepare_data.prepare_lsn), - LSN_FORMAT_ARGS(remote_final_lsn)))); + errmsg_internal("incorrect prepare LSN %016" PRIX64 " in prepare message (expected %016" PRIX64 ")", + prepare_data.prepare_lsn, + remote_final_lsn))); /* * Unlike commit, here, we always prepare the transaction even though no @@ -3912,11 +3912,11 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply) pq_sendint64(reply_message, now); /* sendTime */ pq_sendbyte(reply_message, requestReply); /* replyRequested */ - elog(DEBUG2, "sending feedback (force %d) to recv %X/%X, write %X/%X, flush %X/%X", + elog(DEBUG2, "sending feedback (force %d) to recv %016" PRIX64 ", write %016" PRIX64 ", flush %016" PRIX64, force, - LSN_FORMAT_ARGS(recvpos), - LSN_FORMAT_ARGS(writepos), - LSN_FORMAT_ARGS(flushpos)); + recvpos, + writepos, + flushpos); walrcv_send(LogRepWorkerWalRcvConn, reply_message->data, reply_message->len); @@ -4894,8 +4894,8 @@ maybe_start_skipping_changes(XLogRecPtr finish_lsn) skip_xact_finish_lsn = finish_lsn; ereport(LOG, - errmsg("logical replication starts skipping transaction at LSN %X/%X", - LSN_FORMAT_ARGS(skip_xact_finish_lsn))); + errmsg("logical replication starts skipping transaction at LSN %016" PRIX64, + skip_xact_finish_lsn)); } /* @@ -4908,8 +4908,8 @@ stop_skipping_changes(void) return; ereport(LOG, - (errmsg("logical replication completed skipping transaction at LSN %X/%X", - LSN_FORMAT_ARGS(skip_xact_finish_lsn)))); + (errmsg("logical replication completed skipping transaction at LSN %016" PRIX64, + skip_xact_finish_lsn))); /* Stop skipping changes */ skip_xact_finish_lsn = InvalidXLogRecPtr; @@ -4991,9 +4991,9 @@ clear_subscription_skip_lsn(XLogRecPtr finish_lsn) if (myskiplsn != finish_lsn) ereport(WARNING, errmsg("skip-LSN of subscription \"%s\" cleared", MySubscription->name), - errdetail("Remote transaction's finish WAL location (LSN) %X/%X did not match skip-LSN %X/%X.", - LSN_FORMAT_ARGS(finish_lsn), - LSN_FORMAT_ARGS(myskiplsn))); + errdetail("Remote transaction's finish WAL location (LSN) %016" PRIX64 " did not match skip-LSN %016" PRIX64 ".", + finish_lsn, + myskiplsn)); } heap_freetuple(tup); @@ -5037,11 +5037,11 @@ apply_error_callback(void *arg) logicalrep_message_type(errarg->command), 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 %u, finished at %016" PRIX64, errarg->origin_name, logicalrep_message_type(errarg->command), errarg->remote_xid, - LSN_FORMAT_ARGS(errarg->finish_lsn)); + errarg->finish_lsn); } else { @@ -5055,13 +5055,13 @@ apply_error_callback(void *arg) errarg->rel->remoterel.relname, errarg->remote_xid); else - 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 %u, finished at %016" PRIX64, errarg->origin_name, logicalrep_message_type(errarg->command), errarg->rel->remoterel.nspname, errarg->rel->remoterel.relname, errarg->remote_xid, - LSN_FORMAT_ARGS(errarg->finish_lsn)); + errarg->finish_lsn); } else { @@ -5074,14 +5074,14 @@ apply_error_callback(void *arg) errarg->rel->remoterel.attnames[errarg->remote_attnum], errarg->remote_xid); 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 %u, finished at %016" PRIX64, 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, - LSN_FORMAT_ARGS(errarg->finish_lsn)); + errarg->finish_lsn); } } } diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y index 7440aae5a1a7..e4b7a14f31bc 100644 --- a/src/backend/replication/repl_gram.y +++ b/src/backend/replication/repl_gram.y @@ -279,7 +279,7 @@ alter_replication_slot: ; /* - * START_REPLICATION [SLOT slot] [PHYSICAL] %X/%X [TIMELINE %u] + * START_REPLICATION [SLOT slot] [PHYSICAL] startpoint [TIMELINE %u] */ start_replication: K_START_REPLICATION opt_slot opt_physical RECPTR opt_timeline @@ -295,7 +295,7 @@ start_replication: } ; -/* START_REPLICATION SLOT slot LOGICAL %X/%X options */ +/* START_REPLICATION SLOT slot LOGICAL startpoint options */ start_logical_replication: K_START_REPLICATION K_SLOT IDENT K_LOGICAL RECPTR plugin_options { diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index 014ea8d25c6b..7c82d4067d26 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -147,17 +147,14 @@ UPLOAD_MANIFEST { return K_UPLOAD_MANIFEST; } {space}+ { /* do nothing */ } -{digit}+ { +{digit}{1,10} { yylval->uintval = strtoul(yytext, NULL, 10); return UCONST; } -{hexdigit}+\/{hexdigit}+ { - uint32 hi, - lo; - if (sscanf(yytext, "%X/%X", &hi, &lo) != 2) +{hexdigit}{16} { + if (sscanf(yytext, "%" SCNx64, &yylval->recptr) != 1) replication_yyerror(NULL, yyscanner, "invalid streaming start location"); - yylval->recptr = ((uint64) hi) << 32 | lo; return RECPTR; } diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index 719e531eb907..ecb885d1341c 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -1544,13 +1544,13 @@ ReportSlotInvalidation(ReplicationSlotInvalidationCause cause, { case RS_INVAL_WAL_REMOVED: { - unsigned long long ex = oldestLSN - restart_lsn; + uint64 ex = oldestLSN - restart_lsn; appendStringInfo(&err_detail, - ngettext("The slot's restart_lsn %X/%X exceeds the limit by %llu byte.", - "The slot's restart_lsn %X/%X exceeds the limit by %llu bytes.", + ngettext("The slot's restart_lsn %016" PRIX64 " exceeds the limit by %" PRIu64 " byte.", + "The slot's restart_lsn %016" PRIX64 " exceeds the limit by %" PRIu64 " bytes.", ex), - LSN_FORMAT_ARGS(restart_lsn), + restart_lsn, ex); /* translator: %s is a GUC variable name */ appendStringInfo(&err_hint, _("You might need to increase \"%s\"."), diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 146eef5871e2..486df3ee66f3 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -560,8 +560,8 @@ pg_replication_slot_advance(PG_FUNCTION_ARGS) if (moveto < minlsn) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("cannot advance replication slot to %X/%X, minimum is %X/%X", - LSN_FORMAT_ARGS(moveto), LSN_FORMAT_ARGS(minlsn)))); + errmsg("cannot advance replication slot to %016" PRIX64 ", minimum is %016" PRIX64, + moveto, minlsn))); /* Do the actual slot update, depending on the slot type */ if (OidIsValid(MyReplicationSlot->data.database)) diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index d75e39680355..f1f84bd88502 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -215,7 +215,7 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit) { char buffer[32]; - sprintf(buffer, "waiting for %X/%X", LSN_FORMAT_ARGS(lsn)); + sprintf(buffer, "waiting for %016" PRIX64, lsn); set_ps_display_suffix(buffer); } @@ -523,10 +523,10 @@ SyncRepReleaseWaiters(void) LWLockRelease(SyncRepLock); - elog(DEBUG3, "released %d procs up to write %X/%X, %d procs up to flush %X/%X, %d procs up to apply %X/%X", - numwrite, LSN_FORMAT_ARGS(writePtr), - numflush, LSN_FORMAT_ARGS(flushPtr), - numapply, LSN_FORMAT_ARGS(applyPtr)); + elog(DEBUG3, "released %d procs up to write %016" PRIX64 ", %d procs up to flush %016" PRIX64 ", %d procs up to apply %016" PRIX64, + numwrite, writePtr, + numflush, flushPtr, + numapply, applyPtr); } /* diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 2e5dd6deb2c2..0dd04d4bbaed 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -387,8 +387,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len) if (is_temp_slot) { snprintf(slotname, sizeof(slotname), - "pg_walreceiver_%lld", - (long long int) walrcv_get_backend_pid(wrconn)); + "pg_walreceiver_%" PRId64, + (int64) walrcv_get_backend_pid(wrconn)); walrcv_create_slot(wrconn, slotname, true, false, false, 0, NULL); @@ -417,12 +417,12 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len) { if (first_stream) ereport(LOG, - (errmsg("started streaming WAL from primary at %X/%X on timeline %u", - LSN_FORMAT_ARGS(startpoint), startpointTLI))); + (errmsg("started streaming WAL from primary at %016" PRIX64 " on timeline %u", + startpoint, startpointTLI))); else ereport(LOG, - (errmsg("restarted WAL streaming at %X/%X on timeline %u", - LSN_FORMAT_ARGS(startpoint), startpointTLI))); + (errmsg("restarted WAL streaming at %016" PRIX64 " on timeline %u", + startpoint, startpointTLI))); first_stream = false; /* Initialize LogstreamResult and buffers for processing messages */ @@ -501,9 +501,9 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len) { ereport(LOG, (errmsg("replication terminated by primary server"), - errdetail("End of WAL reached on timeline %u at %X/%X.", + errdetail("End of WAL reached on timeline %u at %016" PRIX64 ".", startpointTLI, - LSN_FORMAT_ARGS(LogstreamResult.Write)))); + LogstreamResult.Write))); endofwal = true; break; } @@ -742,8 +742,8 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI) { char activitymsg[50]; - snprintf(activitymsg, sizeof(activitymsg), "restarting at %X/%X", - LSN_FORMAT_ARGS(*startpoint)); + snprintf(activitymsg, sizeof(activitymsg), "restarting at %016" PRIX64, + *startpoint); set_ps_display(activitymsg); } } @@ -1045,8 +1045,8 @@ XLogWalRcvFlush(bool dying, TimeLineID tli) { char activitymsg[50]; - snprintf(activitymsg, sizeof(activitymsg), "streaming %X/%X", - LSN_FORMAT_ARGS(LogstreamResult.Write)); + snprintf(activitymsg, sizeof(activitymsg), "streaming %016" PRIX64, + LogstreamResult.Write); set_ps_display(activitymsg); } @@ -1169,10 +1169,10 @@ XLogWalRcvSendReply(bool force, bool requestReply) pq_sendbyte(&reply_message, requestReply ? 1 : 0); /* Send it */ - elog(DEBUG2, "sending write %X/%X flush %X/%X apply %X/%X%s", - LSN_FORMAT_ARGS(writePtr), - LSN_FORMAT_ARGS(flushPtr), - LSN_FORMAT_ARGS(applyPtr), + elog(DEBUG2, "sending write %016" PRIX64 " flush %016" PRIX64 " apply %016" PRIX64 "%s", + writePtr, + flushPtr, + applyPtr, requestReply ? " (reply requested)" : ""); walrcv_send(wrconn, reply_message.data, reply_message.len); diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 446d10c1a7d7..f9c159145549 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -402,7 +402,7 @@ IdentifySystem(void) else logptr = GetFlushRecPtr(&currTLI); - snprintf(xloc, sizeof(xloc), "%X/%X", LSN_FORMAT_ARGS(logptr)); + snprintf(xloc, sizeof(xloc), "%016" PRIX64, logptr); if (MyDatabaseId != InvalidOid) { @@ -509,8 +509,8 @@ ReadReplicationSlot(ReadReplicationSlotCmd *cmd) { char xloc[64]; - snprintf(xloc, sizeof(xloc), "%X/%X", - LSN_FORMAT_ARGS(slot_contents.data.restart_lsn)); + snprintf(xloc, sizeof(xloc), "%016" PRIX64, + slot_contents.data.restart_lsn); values[i] = CStringGetTextDatum(xloc); nulls[i] = false; } @@ -886,12 +886,12 @@ StartReplication(StartReplicationCmd *cmd) switchpoint < cmd->startpoint) { ereport(ERROR, - (errmsg("requested starting point %X/%X on timeline %u is not in this server's history", - LSN_FORMAT_ARGS(cmd->startpoint), + (errmsg("requested starting point %016" PRIX64 " on timeline %u is not in this server's history", + cmd->startpoint, cmd->timeline), - errdetail("This server's history forked from timeline %u at %X/%X.", + errdetail("This server's history forked from timeline %u at %016" PRIX64 ".", cmd->timeline, - LSN_FORMAT_ARGS(switchpoint)))); + switchpoint))); } sendTimeLineValidUpto = switchpoint; } @@ -933,9 +933,9 @@ StartReplication(StartReplicationCmd *cmd) if (FlushPtr < cmd->startpoint) { ereport(ERROR, - (errmsg("requested starting point %X/%X is ahead of the WAL flush position of this server %X/%X", - LSN_FORMAT_ARGS(cmd->startpoint), - LSN_FORMAT_ARGS(FlushPtr)))); + (errmsg("requested starting point %016" PRIX64 " is ahead of the WAL flush position of this server %016" PRIX64, + cmd->startpoint, + FlushPtr))); } /* Start streaming from the requested point */ @@ -977,8 +977,8 @@ StartReplication(StartReplicationCmd *cmd) Datum values[2]; bool nulls[2] = {0}; - snprintf(startpos_str, sizeof(startpos_str), "%X/%X", - LSN_FORMAT_ARGS(sendTimeLineValidUpto)); + snprintf(startpos_str, sizeof(startpos_str), "%016" PRIX64, + sendTimeLineValidUpto); dest = CreateDestReceiver(DestRemoteSimple); @@ -1318,8 +1318,8 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd) ReplicationSlotPersist(); } - snprintf(xloc, sizeof(xloc), "%X/%X", - LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush)); + snprintf(xloc, sizeof(xloc), "%016" PRIX64, + MyReplicationSlot->data.confirmed_flush); dest = CreateDestReceiver(DestRemoteSimple); @@ -1958,6 +1958,7 @@ exec_replication_command(const char *cmd_string) MemoryContext cmd_context; MemoryContext old_context; +elog(LOG, "XXX: %s", cmd_string); /* * If WAL sender has been told that shutdown is getting close, switch its * status accordingly to handle the next replication commands correctly. @@ -2387,10 +2388,10 @@ ProcessStandbyReplyMessage(void) /* Copy because timestamptz_to_str returns a static buffer */ replyTimeStr = pstrdup(timestamptz_to_str(replyTime)); - elog(DEBUG2, "write %X/%X flush %X/%X apply %X/%X%s reply_time %s", - LSN_FORMAT_ARGS(writePtr), - LSN_FORMAT_ARGS(flushPtr), - LSN_FORMAT_ARGS(applyPtr), + elog(DEBUG2, "write %016" PRIX64 " flush %016" PRIX64 " apply %016" PRIX64 "%s reply_time %s", + writePtr, + flushPtr, + applyPtr, replyRequested ? " (reply requested)" : "", replyTimeStr); @@ -3193,9 +3194,9 @@ XLogSendPhysical(void) WalSndCaughtUp = true; - elog(DEBUG1, "walsender reached end of timeline at %X/%X (sent up to %X/%X)", - LSN_FORMAT_ARGS(sendTimeLineValidUpto), - LSN_FORMAT_ARGS(sentPtr)); + elog(DEBUG1, "walsender reached end of timeline at %016" PRIX64 " (sent up to %016" PRIX64 ")", + sendTimeLineValidUpto, + sentPtr); return; } @@ -3334,8 +3335,8 @@ XLogSendPhysical(void) { char activitymsg[50]; - snprintf(activitymsg, sizeof(activitymsg), "streaming %X/%X", - LSN_FORMAT_ARGS(sentPtr)); + snprintf(activitymsg, sizeof(activitymsg), "streaming %016" PRIX64, + sentPtr); set_ps_display(activitymsg); } } diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index e4d5b944e12f..2704e80b3a7d 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -399,8 +399,8 @@ cancel_before_shmem_exit(pg_on_exit_callback function, Datum arg) before_shmem_exit_list[before_shmem_exit_index - 1].arg == arg) --before_shmem_exit_index; else - elog(ERROR, "before_shmem_exit callback (%p,0x%llx) is not the latest entry", - function, (long long) arg); + elog(ERROR, "before_shmem_exit callback (%p,0x%" PRIx64 ") is not the latest entry", + function, arg); } /* ---------------------------------------------------------------- diff --git a/src/backend/storage/ipc/signalfuncs.c b/src/backend/storage/ipc/signalfuncs.c index bebc97ecffd8..a3a670ba2474 100644 --- a/src/backend/storage/ipc/signalfuncs.c +++ b/src/backend/storage/ipc/signalfuncs.c @@ -215,10 +215,10 @@ pg_wait_until_termination(int pid, int64 timeout) } while (remainingtime > 0); ereport(WARNING, - (errmsg_plural("backend with PID %d did not terminate within %lld millisecond", - "backend with PID %d did not terminate within %lld milliseconds", + (errmsg_plural("backend with PID %d did not terminate within %" PRId64 " millisecond", + "backend with PID %d did not terminate within %" PRId64 " milliseconds", timeout, - pid, (long long int) timeout))); + pid, timeout))); return false; } diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c index 5acb4508f850..393380856a5d 100644 --- a/src/backend/storage/ipc/standby.c +++ b/src/backend/storage/ipc/standby.c @@ -1364,17 +1364,17 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts) if (xlrec.subxid_overflow) elog(DEBUG2, - "snapshot of %d running transactions overflowed (lsn %X/%X oldest xid %u latest complete %u next xid %u)", + "snapshot of %d running transactions overflowed (lsn %016" PRIX64 " oldest xid %u latest complete %u next xid %u)", CurrRunningXacts->xcnt, - LSN_FORMAT_ARGS(recptr), + recptr, CurrRunningXacts->oldestRunningXid, CurrRunningXacts->latestCompletedXid, CurrRunningXacts->nextXid); else elog(DEBUG2, - "snapshot of %d+%d running transaction ids (lsn %X/%X oldest xid %u latest complete %u next xid %u)", + "snapshot of %d+%d running transaction ids (lsn %016" PRIX64 " oldest xid %u latest complete %u next xid %u)", CurrRunningXacts->xcnt, CurrRunningXacts->subxcnt, - LSN_FORMAT_ARGS(recptr), + recptr, CurrRunningXacts->oldestRunningXid, CurrRunningXacts->latestCompletedXid, CurrRunningXacts->nextXid); diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index 3168b825e25f..d2f961586578 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -1602,8 +1602,8 @@ pgstat_write_statsfile(XLogRecPtr redo) /* we're shutting down, so it's ok to just override this */ pgstat_fetch_consistency = PGSTAT_FETCH_CONSISTENCY_NONE; - elog(DEBUG2, "writing stats file \"%s\" with redo %X/%X", statfile, - LSN_FORMAT_ARGS(redo)); + elog(DEBUG2, "writing stats file \"%s\" with redo %016" PRIX64, statfile, + redo); /* * Open the statistics temp file to write out the current values. @@ -1684,9 +1684,9 @@ pgstat_write_statsfile(XLogRecPtr redo) */ if (!pgstat_is_kind_valid(ps->key.kind)) { - elog(WARNING, "found unknown stats entry %u/%u/%llu", + elog(WARNING, "found unknown stats entry %u/%u/%" PRIu64, ps->key.kind, ps->key.dboid, - (unsigned long long) ps->key.objid); + ps->key.objid); continue; } @@ -1785,8 +1785,8 @@ pgstat_read_statsfile(XLogRecPtr redo) /* shouldn't be called from postmaster */ Assert(IsUnderPostmaster || !IsPostmasterEnvironment); - elog(DEBUG2, "reading stats file \"%s\" with redo %X/%X", statfile, - LSN_FORMAT_ARGS(redo)); + elog(DEBUG2, "reading stats file \"%s\" with redo %016" PRIX64, statfile, + redo); /* * Try to open the stats file. If it doesn't exist, the backends simply @@ -1835,8 +1835,8 @@ pgstat_read_statsfile(XLogRecPtr redo) if (file_redo != redo) { - elog(WARNING, "found incorrect redo LSN %X/%X (expected %X/%X)", - LSN_FORMAT_ARGS(file_redo), LSN_FORMAT_ARGS(redo)); + elog(WARNING, "found incorrect redo LSN %016" PRIX64 " (expected %016" PRIX64 ")", + file_redo, redo); goto error; } @@ -1926,9 +1926,9 @@ pgstat_read_statsfile(XLogRecPtr redo) if (!pgstat_is_kind_valid(key.kind)) { - elog(WARNING, "invalid stats kind for entry %u/%u/%llu of type %c", + elog(WARNING, "invalid stats kind for entry %u/%u/%" PRIu64 " of type %c", key.kind, key.dboid, - (unsigned long long) key.objid, t); + key.objid, t); goto error; } } @@ -1999,9 +1999,9 @@ pgstat_read_statsfile(XLogRecPtr redo) if (found) { dshash_release_lock(pgStatLocal.shared_hash, p); - elog(WARNING, "found duplicate stats entry %u/%u/%llu of type %c", + elog(WARNING, "found duplicate stats entry %u/%u/%" PRIu64 " of type %c", key.kind, key.dboid, - (unsigned long long) key.objid, t); + key.objid, t); goto error; } @@ -2012,9 +2012,9 @@ pgstat_read_statsfile(XLogRecPtr redo) pgstat_get_entry_data(key.kind, header), pgstat_get_entry_len(key.kind))) { - elog(WARNING, "could not read data for entry %u/%u/%llu of type %c", + elog(WARNING, "could not read data for entry %u/%u/%" PRIu64 " of type %c", key.kind, key.dboid, - (unsigned long long) key.objid, t); + key.objid, t); goto error; } diff --git a/src/backend/utils/activity/pgstat_replslot.c b/src/backend/utils/activity/pgstat_replslot.c index cd56cb328610..ccfb11c49bf8 100644 --- a/src/backend/utils/activity/pgstat_replslot.c +++ b/src/backend/utils/activity/pgstat_replslot.c @@ -194,8 +194,8 @@ pgstat_replslot_to_serialized_name_cb(const PgStat_HashKey *key, const PgStatSha * at the offset. */ if (!ReplicationSlotName(key->objid, name)) - elog(ERROR, "could not find name for replication slot index %llu", - (unsigned long long) key->objid); + elog(ERROR, "could not find name for replication slot index %" PRIu64, + key->objid); } bool diff --git a/src/backend/utils/activity/pgstat_shmem.c b/src/backend/utils/activity/pgstat_shmem.c index 770d62425c5d..5cd243037551 100644 --- a/src/backend/utils/activity/pgstat_shmem.c +++ b/src/backend/utils/activity/pgstat_shmem.c @@ -864,10 +864,10 @@ pgstat_drop_entry_internal(PgStatShared_HashEntry *shent, */ if (shent->dropped) elog(ERROR, - "trying to drop stats entry already dropped: kind=%s dboid=%u objid=%llu refcount=%u", + "trying to drop stats entry already dropped: kind=%s dboid=%u objid=%" PRIu64 " refcount=%u", pgstat_get_kind_info(shent->key.kind)->name, shent->key.dboid, - (unsigned long long) shent->key.objid, + shent->key.objid, pg_atomic_read_u32(&shent->refcount)); shent->dropped = true; diff --git a/src/backend/utils/activity/pgstat_xact.c b/src/backend/utils/activity/pgstat_xact.c index 76a4f24aa82b..bc9864bd8d9d 100644 --- a/src/backend/utils/activity/pgstat_xact.c +++ b/src/backend/utils/activity/pgstat_xact.c @@ -363,9 +363,9 @@ pgstat_create_transactional(PgStat_Kind kind, Oid dboid, uint64 objid) if (pgstat_get_entry_ref(kind, dboid, objid, false, NULL)) { ereport(WARNING, - errmsg("resetting existing statistics for kind %s, db=%u, oid=%llu", + errmsg("resetting existing statistics for kind %s, db=%u, oid=%" PRIu64, (pgstat_get_kind_info(kind))->name, dboid, - (unsigned long long) objid)); + objid)); pgstat_reset(kind, dboid, objid); } diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 5d893cff50c8..793d8a9adccd 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -4630,7 +4630,7 @@ AddISO8601IntPart(char *cp, int64 value, char units) { if (value == 0) return cp; - sprintf(cp, "%lld%c", (long long) value, units); + sprintf(cp, "%" PRId64 "%c", value, units); return cp + strlen(cp); } @@ -4641,10 +4641,10 @@ AddPostgresIntPart(char *cp, int64 value, const char *units, { if (value == 0) return cp; - sprintf(cp, "%s%s%lld %s%s", + sprintf(cp, "%s%s%" PRId64 " %s%s", (!*is_zero) ? " " : "", (*is_before && value > 0) ? "+" : "", - (long long) value, + value, units, (value != 1) ? "s" : ""); @@ -4672,7 +4672,7 @@ AddVerboseIntPart(char *cp, int64 value, const char *units, } else if (*is_before) value = -value; - sprintf(cp, " %lld %s%s", (long long) value, units, (value == 1) ? "" : "s"); + sprintf(cp, " %" PRId64 " %s%s", value, units, (value == 1) ? "" : "s"); *is_zero = false; return cp + strlen(cp); } @@ -4767,10 +4767,10 @@ EncodeInterval(struct pg_itm *itm, int style, char *str) char sec_sign = (hour < 0 || min < 0 || sec < 0 || fsec < 0) ? '-' : '+'; - sprintf(cp, "%c%d-%d %c%lld %c%lld:%02d:", + sprintf(cp, "%c%d-%d %c%" PRId64 " %c%" PRId64 ":%02d:", year_sign, abs(year), abs(mon), - day_sign, (long long) i64abs(mday), - sec_sign, (long long) i64abs(hour), abs(min)); + day_sign, i64abs(mday), + sec_sign, i64abs(hour), abs(min)); cp += strlen(cp); cp = AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true); *cp = '\0'; @@ -4781,15 +4781,15 @@ EncodeInterval(struct pg_itm *itm, int style, char *str) } else if (has_day) { - sprintf(cp, "%lld %lld:%02d:", - (long long) mday, (long long) hour, min); + sprintf(cp, "%" PRId64 " %" PRId64 ":%02d:", + mday, hour, min); cp += strlen(cp); cp = AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true); *cp = '\0'; } else { - sprintf(cp, "%lld:%02d:", (long long) hour, min); + sprintf(cp, "%" PRId64 ":%02d:", hour, min); cp += strlen(cp); cp = AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true); *cp = '\0'; @@ -4839,10 +4839,10 @@ EncodeInterval(struct pg_itm *itm, int style, char *str) { bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0); - sprintf(cp, "%s%s%02lld:%02d:", + sprintf(cp, "%s%s%02" PRId64 ":%02d:", is_zero ? "" : " ", (minus ? "-" : (is_before ? "+" : "")), - (long long) i64abs(hour), abs(min)); + i64abs(hour), abs(min)); cp += strlen(cp); cp = AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true); *cp = '\0'; diff --git a/src/backend/utils/adt/pg_lsn.c b/src/backend/utils/adt/pg_lsn.c index 16311590a14a..12af92e8acf6 100644 --- a/src/backend/utils/adt/pg_lsn.c +++ b/src/backend/utils/adt/pg_lsn.c @@ -18,6 +18,7 @@ #include "utils/numeric.h" #include "utils/pg_lsn.h" +/* These values are used for the legacy format with a slash. */ #define MAXPG_LSNLEN 17 #define MAXPG_LSNCOMPONENT 8 @@ -33,10 +34,17 @@ pg_lsn_in_internal(const char *str, bool *have_error) uint32 id, off; XLogRecPtr result; + char dummy; Assert(have_error != NULL); *have_error = false; + /* Try to parse it directly as a simple hex value. */ + if (sscanf(str, "%" SCNx64 "%c", &result, &dummy) == 1) + return result; + + /* Otherwise try to parse the legacy format. */ + /* Sanity check input format. */ len1 = strspn(str, "0123456789abcdefABCDEF"); if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/') @@ -83,7 +91,7 @@ pg_lsn_out(PG_FUNCTION_ARGS) char buf[MAXPG_LSNLEN + 1]; char *result; - snprintf(buf, sizeof buf, "%X/%X", LSN_FORMAT_ARGS(lsn)); + snprintf(buf, sizeof buf, "%016" PRIX64, lsn); result = pstrdup(buf); PG_RETURN_CSTRING(result); } diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index cdf185ea00b5..1d242b0b355b 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -3296,8 +3296,8 @@ byteaGetBit(PG_FUNCTION_ARGS) if (n < 0 || n >= (int64) len * 8) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("index %lld out of valid range, 0..%lld", - (long long) n, (long long) len * 8 - 1))); + errmsg("index %" PRId64 " out of valid range, 0..%" PRId64, + n, (int64) len * 8 - 1))); /* n/8 is now known < len, so safe to cast to int */ byteNo = (int) (n / 8); @@ -3368,8 +3368,8 @@ byteaSetBit(PG_FUNCTION_ARGS) if (n < 0 || n >= (int64) len * 8) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("index %lld out of valid range, 0..%lld", - (long long) n, (long long) len * 8 - 1))); + errmsg("index %" PRId64 " out of valid range, 0..%" PRId64, + n, (int64) len * 8 - 1))); /* n/8 is now known < len, so safe to cast to int */ byteNo = (int) (n / 8); diff --git a/src/backend/utils/adt/xid8funcs.c b/src/backend/utils/adt/xid8funcs.c index 88d798fbf4bc..1da3964ca6fb 100644 --- a/src/backend/utils/adt/xid8funcs.c +++ b/src/backend/utils/adt/xid8funcs.c @@ -117,8 +117,8 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid) if (!FullTransactionIdPrecedes(fxid, now_fullxid)) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("transaction ID %llu is in the future", - (unsigned long long) U64FromFullTransactionId(fxid)))); + errmsg("transaction ID %" PRIu64 " is in the future", + U64FromFullTransactionId(fxid)))); /* * TransamVariables->oldestClogXid is protected by XactTruncationLock, but diff --git a/src/backend/utils/error/csvlog.c b/src/backend/utils/error/csvlog.c index 8e9fbcb999b6..fdac3c048e36 100644 --- a/src/backend/utils/error/csvlog.c +++ b/src/backend/utils/error/csvlog.c @@ -248,7 +248,7 @@ write_csvlog(ErrorData *edata) appendStringInfoChar(&buf, ','); /* query id */ - appendStringInfo(&buf, "%lld", (long long) pgstat_get_my_query_id()); + appendStringInfo(&buf, "%" PRId64, pgstat_get_my_query_id()); appendStringInfoChar(&buf, '\n'); diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 860bbd40d42b..a377565ac351 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -3148,11 +3148,11 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata) break; case 'Q': if (padding != 0) - appendStringInfo(buf, "%*lld", padding, - (long long) pgstat_get_my_query_id()); + appendStringInfo(buf, "%*" PRId64, padding, + pgstat_get_my_query_id()); else - appendStringInfo(buf, "%lld", - (long long) pgstat_get_my_query_id()); + appendStringInfo(buf, "%" PRId64, + pgstat_get_my_query_id()); break; default: /* format error - ignore it */ diff --git a/src/backend/utils/error/jsonlog.c b/src/backend/utils/error/jsonlog.c index 549e0f48ee82..519eacf17f83 100644 --- a/src/backend/utils/error/jsonlog.c +++ b/src/backend/utils/error/jsonlog.c @@ -284,8 +284,8 @@ write_jsonlog(ErrorData *edata) } /* query id */ - appendJSONKeyValueFmt(&buf, "query_id", false, "%lld", - (long long) pgstat_get_my_query_id()); + appendJSONKeyValueFmt(&buf, "query_id", false, "%" PRId64, + pgstat_get_my_query_id()); /* Finish string */ appendStringInfoChar(&buf, '}'); diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 91060de0ab7a..d98ae9db6bec 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -285,31 +285,31 @@ MemoryContextTraverseNext(MemoryContext curr, MemoryContext top) static void BogusFree(void *pointer) { - elog(ERROR, "pfree called with invalid pointer %p (header 0x%016llx)", - pointer, (unsigned long long) GetMemoryChunkHeader(pointer)); + elog(ERROR, "pfree called with invalid pointer %p (header 0x%016" PRIx64 ")", + pointer, GetMemoryChunkHeader(pointer)); } static void * BogusRealloc(void *pointer, Size size, int flags) { - elog(ERROR, "repalloc called with invalid pointer %p (header 0x%016llx)", - pointer, (unsigned long long) GetMemoryChunkHeader(pointer)); + elog(ERROR, "repalloc called with invalid pointer %p (header 0x%016" PRIx64 ")", + pointer, GetMemoryChunkHeader(pointer)); return NULL; /* keep compiler quiet */ } static MemoryContext BogusGetChunkContext(void *pointer) { - elog(ERROR, "GetMemoryChunkContext called with invalid pointer %p (header 0x%016llx)", - pointer, (unsigned long long) GetMemoryChunkHeader(pointer)); + elog(ERROR, "GetMemoryChunkContext called with invalid pointer %p (header 0x%016" PRIx64 ")", + pointer, GetMemoryChunkHeader(pointer)); return NULL; /* keep compiler quiet */ } static Size BogusGetChunkSpace(void *pointer) { - elog(ERROR, "GetMemoryChunkSpace called with invalid pointer %p (header 0x%016llx)", - pointer, (unsigned long long) GetMemoryChunkHeader(pointer)); + elog(ERROR, "GetMemoryChunkSpace called with invalid pointer %p (header 0x%016" PRIx64 ")", + pointer, GetMemoryChunkHeader(pointer)); return 0; /* keep compiler quiet */ } diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c index 47e601ef62c8..7ee2bdde5565 100644 --- a/src/backend/utils/sort/logtape.c +++ b/src/backend/utils/sort/logtape.c @@ -263,8 +263,8 @@ ltsWriteBlock(LogicalTapeSet *lts, int64 blocknum, const void *buffer) if (BufFileSeekBlock(lts->pfile, blocknum) != 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not seek to block %lld of temporary file", - (long long) blocknum))); + errmsg("could not seek to block %" PRId64 " of temporary file", + blocknum))); BufFileWrite(lts->pfile, buffer, BLCKSZ); /* Update nBlocksWritten, if we extended the file */ @@ -284,8 +284,8 @@ ltsReadBlock(LogicalTapeSet *lts, int64 blocknum, void *buffer) if (BufFileSeekBlock(lts->pfile, blocknum) != 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not seek to block %lld of temporary file", - (long long) blocknum))); + errmsg("could not seek to block %" PRId64 " of temporary file", + blocknum))); BufFileReadExact(lts->pfile, buffer, BLCKSZ); } @@ -1100,10 +1100,10 @@ LogicalTapeBackspace(LogicalTape *lt, size_t size) ltsReadBlock(lt->tapeSet, prev, lt->buffer); if (TapeBlockGetTrailer(lt->buffer)->next != lt->curBlockNumber) - elog(ERROR, "broken tape, next of block %lld is %lld, expected %lld", - (long long) prev, - (long long) (TapeBlockGetTrailer(lt->buffer)->next), - (long long) lt->curBlockNumber); + elog(ERROR, "broken tape, next of block %" PRId64 " is %" PRId64 ", expected %" PRId64, + prev, + (TapeBlockGetTrailer(lt->buffer)->next), + lt->curBlockNumber); lt->nbytes = TapeBlockPayloadSize; lt->curBlockNumber = prev; diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 2ef32d53a43e..65ab83fff8b2 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -918,13 +918,13 @@ tuplesort_free(Tuplesortstate *state) if (trace_sort) { if (state->tapeset) - elog(LOG, "%s of worker %d ended, %lld disk blocks used: %s", + elog(LOG, "%s of worker %d ended, %" PRId64 " disk blocks used: %s", SERIAL(state) ? "external sort" : "parallel external sort", - state->worker, (long long) spaceUsed, pg_rusage_show(&state->ru_start)); + state->worker, spaceUsed, pg_rusage_show(&state->ru_start)); else - elog(LOG, "%s of worker %d ended, %lld KB used: %s", + elog(LOG, "%s of worker %d ended, %" PRId64 " KB used: %s", SERIAL(state) ? "internal sort" : "unperformed parallel sort", - state->worker, (long long) spaceUsed, pg_rusage_show(&state->ru_start)); + state->worker, spaceUsed, pg_rusage_show(&state->ru_start)); } TRACE_POSTGRESQL_SORT_DONE(state->tapeset != NULL, spaceUsed); diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index dc0c805137aa..c252644b5a89 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -480,17 +480,14 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline, if (r == 1) { char xlogend[64] = {0}; - uint32 hi, - lo; r = read(bgpipe[0], xlogend, sizeof(xlogend) - 1); if (r < 0) pg_fatal("could not read from ready pipe: %m"); - if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2) + if (sscanf(xlogend, "%" SCNx64, &xlogendptr) != 1) pg_fatal("could not parse write-ahead log location \"%s\"", xlogend); - xlogendptr = ((uint64) hi) << 32 | lo; has_xlogendptr = 1; /* @@ -618,8 +615,6 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier, int wal_compress_level) { logstreamer_param *param; - uint32 hi, - lo; char statusdir[MAXPGPATH]; param = pg_malloc0(sizeof(logstreamer_param)); @@ -629,10 +624,9 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier, param->wal_compress_level = wal_compress_level; /* Convert the starting position */ - if (sscanf(startpos, "%X/%X", &hi, &lo) != 2) + if (sscanf(startpos, "%016" SCNx64, ¶m->startptr) != 1) pg_fatal("could not parse write-ahead log location \"%s\"", startpos); - param->startptr = ((uint64) hi) << 32 | lo; /* Round off to even segment position */ param->startptr -= XLogSegmentOffset(param->startptr, WalSegSz); @@ -2227,8 +2221,6 @@ BaseBackup(char *compression_algorithm, char *compression_detail, * casting to a different size on WIN64. */ intptr_t bgchild_handle = bgchild; - uint32 hi, - lo; #endif if (verbose) @@ -2254,10 +2246,9 @@ BaseBackup(char *compression_algorithm, char *compression_detail, * value directly in the variable, and then set the flag that says * it's there. */ - if (sscanf(xlogend, "%X/%X", &hi, &lo) != 2) + if (sscanf(xlogend, "%" SCNx64, &xlogendptr) != 1) pg_fatal("could not parse write-ahead log location \"%s\"", xlogend); - xlogendptr = ((uint64) hi) << 32 | lo; InterlockedIncrement(&has_xlogendptr); /* First wait for the thread to exit */ diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index a5a2d61165d2..d48689d400fc 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -598,8 +598,7 @@ get_primary_sysid(const char *conninfo) sysid = strtou64(PQgetvalue(res, 0, 0), NULL, 10); - pg_log_info("system identifier is %llu on publisher", - (unsigned long long) sysid); + pg_log_info("system identifier is %" PRIu64 " on publisher", sysid); PQclear(res); disconnect_database(conn, false); @@ -627,8 +626,7 @@ get_standby_sysid(const char *datadir) sysid = cf->system_identifier; - pg_log_info("system identifier is %llu on subscriber", - (unsigned long long) sysid); + pg_log_info("system identifier is %" PRIu64 " on subscriber", sysid); pg_free(cf); @@ -668,8 +666,8 @@ modify_subscriber_sysid(const struct CreateSubscriberOptions *opt) if (!dry_run) update_controlfile(subscriber_dir, cf, true); - pg_log_info("system identifier is %llu on subscriber", - (unsigned long long) cf->system_identifier); + pg_log_info("system identifier is %" PRIu64 " on subscriber", + cf->system_identifier); pg_log_info("running pg_resetwal on the subscriber"); @@ -1252,8 +1250,8 @@ setup_recovery(const struct LogicalRepInfo *dbinfo, const char *datadir, const c { appendPQExpBuffer(recoveryconfcontents, "# dry run mode"); appendPQExpBuffer(recoveryconfcontents, - "recovery_target_lsn = '%X/%X'\n", - LSN_FORMAT_ARGS((XLogRecPtr) InvalidXLogRecPtr)); + "recovery_target_lsn = '%016" PRIX64 "'\n", + InvalidXLogRecPtr); } else { @@ -1816,7 +1814,7 @@ set_replication_progress(PGconn *conn, const struct LogicalRepInfo *dbinfo, cons if (dry_run) { suboid = InvalidOid; - lsnstr = psprintf("%X/%X", LSN_FORMAT_ARGS((XLogRecPtr) InvalidXLogRecPtr)); + lsnstr = psprintf("%016" PRIX64, InvalidXLogRecPtr); } else { diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c index de3584018b09..16bbfb7d5072 100644 --- a/src/bin/pg_basebackup/pg_receivewal.c +++ b/src/bin/pg_basebackup/pg_receivewal.c @@ -188,15 +188,15 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished) /* we assume that we get called once at the end of each segment */ if (verbose && segment_finished) - pg_log_info("finished segment at %X/%X (timeline %u)", - LSN_FORMAT_ARGS(xlogpos), + pg_log_info("finished segment at %016" PRIX64 " (timeline %u)", + xlogpos, timeline); if (!XLogRecPtrIsInvalid(endpos) && endpos < xlogpos) { if (verbose) - pg_log_info("stopped log streaming at %X/%X (timeline %u)", - LSN_FORMAT_ARGS(xlogpos), + pg_log_info("stopped log streaming at %016" PRIX64 " (timeline %u)", + xlogpos, timeline); time_to_stop = true; return true; @@ -211,9 +211,9 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished) * timeline, but it's close enough for reporting purposes. */ if (verbose && prevtimeline != 0 && prevtimeline != timeline) - pg_log_info("switched to timeline %u at %X/%X", + pg_log_info("switched to timeline %u at %016" PRIX64, timeline, - LSN_FORMAT_ARGS(prevpos)); + prevpos); prevtimeline = timeline; prevpos = xlogpos; @@ -320,8 +320,8 @@ FindStreamingStart(uint32 *tli) if (statbuf.st_size != WalSegSz) { - pg_log_warning("segment file \"%s\" has incorrect size %lld, skipping", - dirent->d_name, (long long int) statbuf.st_size); + pg_log_warning("segment file \"%s\" has incorrect size %" PRId64 ", skipping", + dirent->d_name, (pgoff_t) statbuf.st_size); continue; } } @@ -575,8 +575,8 @@ StreamLog(void) * Start the replication */ if (verbose) - pg_log_info("starting log streaming at %X/%X (timeline %u)", - LSN_FORMAT_ARGS(stream.startpos), + pg_log_info("starting log streaming at %016" PRIX64 " (timeline %u)", + stream.startpos, stream.timeline); stream.stream_stop = stop_streaming; @@ -651,8 +651,6 @@ main(int argc, char **argv) int c; int option_index; char *db_name; - uint32 hi, - lo; pg_compress_specification compression_spec; char *compression_detail = NULL; char *compression_algorithm_str = "none"; @@ -689,9 +687,8 @@ main(int argc, char **argv) basedir = pg_strdup(optarg); break; case 'E': - if (sscanf(optarg, "%X/%X", &hi, &lo) != 2) + if (sscanf(optarg, "%" SCNx64, &endpos) != 1) pg_fatal("could not parse end position \"%s\"", optarg); - endpos = ((uint64) hi) << 32 | lo; break; case 'h': dbhost = pg_strdup(optarg); diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index b9ea23e14262..0371b393bd88 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -140,9 +140,9 @@ sendFeedback(PGconn *conn, TimestampTz now, bool force, bool replyRequested) return true; if (verbose) - pg_log_info("confirming write up to %X/%X, flush to %X/%X (slot %s)", - LSN_FORMAT_ARGS(output_written_lsn), - LSN_FORMAT_ARGS(output_fsync_lsn), + pg_log_info("confirming write up to %016" PRIX64 ", flush to %016" PRIX64 " (slot %s)", + output_written_lsn, + output_fsync_lsn, replication_slot); replybuf[len] = 'r'; @@ -234,14 +234,14 @@ StreamLogicalLog(void) * Start the replication */ if (verbose) - pg_log_info("starting log streaming at %X/%X (slot %s)", - LSN_FORMAT_ARGS(startpos), + pg_log_info("starting log streaming at %016" PRIX64 " (slot %s)", + startpos, replication_slot); /* Initiate the replication stream at specified location */ query = createPQExpBuffer(); - appendPQExpBuffer(query, "START_REPLICATION SLOT \"%s\" LOGICAL %X/%X", - replication_slot, LSN_FORMAT_ARGS(startpos)); + appendPQExpBuffer(query, "START_REPLICATION SLOT \"%s\" LOGICAL %016" PRIX64, + replication_slot, startpos); /* print options if there are any */ if (noptions) @@ -721,8 +721,6 @@ main(int argc, char **argv) }; int c; int option_index; - uint32 hi, - lo; char *db_name; pg_logging_init(argv[0]); @@ -790,14 +788,12 @@ main(int argc, char **argv) break; /* replication options */ case 'I': - if (sscanf(optarg, "%X/%X", &hi, &lo) != 2) + if (sscanf(optarg, "%" SCNx64, &startpos) != 1) pg_fatal("could not parse start position \"%s\"", optarg); - startpos = ((uint64) hi) << 32 | lo; break; case 'E': - if (sscanf(optarg, "%X/%X", &hi, &lo) != 2) + if (sscanf(optarg, "%" SCNx64, &endpos) != 1) pg_fatal("could not parse end position \"%s\"", optarg); - endpos = ((uint64) hi) << 32 | lo; break; case 'o': { @@ -1051,13 +1047,13 @@ prepareToTerminate(PGconn *conn, XLogRecPtr endpos, StreamStopReason reason, pg_log_info("received interrupt signal, exiting"); break; case STREAM_STOP_KEEPALIVE: - pg_log_info("end position %X/%X reached by keepalive", - LSN_FORMAT_ARGS(endpos)); + pg_log_info("end position %016" PRIX64 " reached by keepalive", + endpos); break; case STREAM_STOP_END_OF_WAL: Assert(!XLogRecPtrIsInvalid(lsn)); - pg_log_info("end position %X/%X reached by WAL record at %X/%X", - LSN_FORMAT_ARGS(endpos), LSN_FORMAT_ARGS(lsn)); + pg_log_info("end position %016" PRIX64 " reached by WAL record at %016" PRIX64, + endpos, lsn); break; case STREAM_STOP_NONE: Assert(false); diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 6b6e32dfbdf5..f9e8cbab05ab 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -571,9 +571,9 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) return true; /* Initiate the replication stream at specified location */ - snprintf(query, sizeof(query), "START_REPLICATION %s%X/%X TIMELINE %u", + snprintf(query, sizeof(query), "START_REPLICATION %s%016" PRIX64 " TIMELINE %u", slotcmd, - LSN_FORMAT_ARGS(stream->startpos), + stream->startpos, stream->timeline); res = PQexec(conn, query); if (PQresultStatus(res) != PGRES_COPY_BOTH) @@ -628,9 +628,9 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) } if (stream->startpos > stoppos) { - pg_log_error("server stopped streaming timeline %u at %X/%X, but reported next timeline %u to begin at %X/%X", - stream->timeline, LSN_FORMAT_ARGS(stoppos), - newtimeline, LSN_FORMAT_ARGS(stream->startpos)); + pg_log_error("server stopped streaming timeline %u at %016" PRIX64 ", but reported next timeline %u to begin at %016" PRIX64, + stream->timeline, stoppos, + newtimeline, stream->startpos); goto error; } @@ -697,15 +697,12 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) static bool ReadEndOfStreamingResult(PGresult *res, XLogRecPtr *startpos, uint32 *timeline) { - uint32 startpos_xlogid, - startpos_xrecoff; - /*---------- * The result set consists of one row and two columns, e.g: * * next_tli | next_tli_startpos * ----------+------------------- - * 4 | 0/9949AE0 + * 4 | 0000000009949AE0 * * next_tli is the timeline ID of the next timeline after the one that * just finished streaming. next_tli_startpos is the WAL location where @@ -720,14 +717,12 @@ ReadEndOfStreamingResult(PGresult *res, XLogRecPtr *startpos, uint32 *timeline) } *timeline = atoi(PQgetvalue(res, 0, 0)); - if (sscanf(PQgetvalue(res, 0, 1), "%X/%X", &startpos_xlogid, - &startpos_xrecoff) != 2) + if (sscanf(PQgetvalue(res, 0, 1), "%" SCNx64, startpos) != 1) { pg_log_error("could not parse next timeline's starting point \"%s\"", PQgetvalue(res, 0, 1)); return false; } - *startpos = ((uint64) startpos_xlogid << 32) | startpos_xrecoff; return true; } diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 021ab61fcb0f..26364f58da27 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -479,8 +479,6 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli, XLogRecPtr *startpos, char **db_name) { PGresult *res; - uint32 hi, - lo; /* Check connection existence */ Assert(conn != NULL); @@ -514,7 +512,7 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli, /* Get LSN start position if necessary */ if (startpos != NULL) { - if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &hi, &lo) != 2) + if (sscanf(PQgetvalue(res, 0, 2), "%" SCNx64, startpos) != 1) { pg_log_error("could not parse write-ahead log location \"%s\"", PQgetvalue(res, 0, 2)); @@ -522,7 +520,6 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli, PQclear(res); return false; } - *startpos = ((uint64) hi) << 32 | lo; } /* Get database name, only available in 9.4 and newer versions */ @@ -617,17 +614,13 @@ GetSlotInformation(PGconn *conn, const char *slot_name, /* restart LSN */ if (!PQgetisnull(res, 0, 1)) { - uint32 hi, - lo; - - if (sscanf(PQgetvalue(res, 0, 1), "%X/%X", &hi, &lo) != 2) + if (sscanf(PQgetvalue(res, 0, 1), "%" SCNx64, &lsn_loc) != 1) { pg_log_error("could not parse restart_lsn \"%s\" for replication slot \"%s\"", PQgetvalue(res, 0, 1), slot_name); PQclear(res); return false; } - lsn_loc = ((uint64) hi) << 32 | lo; } /* current TLI */ diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 89ff26b63143..760497446a63 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -854,7 +854,7 @@ $lsn = $node->safe_psql('postgres', q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot1'} ); -like($lsn, qr!^0/[0-9A-Z]{7,8}$!, 'restart LSN of slot has advanced'); +like($lsn, qr!^[0-9A-Z]{16}$!, 'restart LSN of slot has advanced'); rmtree("$tempdir/backupxs_sl"); $node->command_ok( diff --git a/src/bin/pg_combinebackup/backup_label.c b/src/bin/pg_combinebackup/backup_label.c index e89d4603f09d..3d0fee9d6cdc 100644 --- a/src/bin/pg_combinebackup/backup_label.c +++ b/src/bin/pg_combinebackup/backup_label.c @@ -243,18 +243,13 @@ parse_lsn(char *s, char *e, XLogRecPtr *lsn, char **c) char save = *e; int nchars; bool success; - unsigned hi; - unsigned lo; *e = '\0'; - success = (sscanf(s, "%X/%X%n", &hi, &lo, &nchars) == 2); + success = (sscanf(s, "%" SCNx64 "%n", lsn, &nchars) == 1); *e = save; if (success) - { - *lsn = ((XLogRecPtr) hi) << 32 | (XLogRecPtr) lo; *c = s + nchars; - } return success; } diff --git a/src/bin/pg_combinebackup/load_manifest.c b/src/bin/pg_combinebackup/load_manifest.c index 485fe518e412..c7c0591c703c 100644 --- a/src/bin/pg_combinebackup/load_manifest.c +++ b/src/bin/pg_combinebackup/load_manifest.c @@ -160,8 +160,8 @@ load_backup_manifest(char *backup_directory) if (rc < 0) pg_fatal("could not read file \"%s\": %m", pathname); else - pg_fatal("could not read file \"%s\": read %d of %lld", - pathname, rc, (long long int) statbuf.st_size); + pg_fatal("could not read file \"%s\": read %d of %" PRId64, + pathname, rc, (pgoff_t) statbuf.st_size); } /* Close the manifest file. */ @@ -198,10 +198,10 @@ load_backup_manifest(char *backup_directory) if (rc < 0) pg_fatal("could not read file \"%s\": %m", pathname); else - pg_fatal("could not read file \"%s\": read %lld of %lld", + pg_fatal("could not read file \"%s\": read %" PRId64 " of %" PRId64, pathname, - (long long int) (statbuf.st_size + rc - bytes_left), - (long long int) statbuf.st_size); + (pgoff_t) (statbuf.st_size + rc - bytes_left), + (pgoff_t) statbuf.st_size); } bytes_left -= rc; json_parse_manifest_incremental_chunk(inc_state, buffer, rc, bytes_left == 0); diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c index 5864ec574fb6..9707f29d4030 100644 --- a/src/bin/pg_combinebackup/pg_combinebackup.c +++ b/src/bin/pg_combinebackup/pg_combinebackup.c @@ -298,10 +298,10 @@ main(int argc, char *argv[]) controlpath = psprintf("%s/%s", prior_backup_dirs[i], "global/pg_control"); - pg_fatal("%s: manifest system identifier is %llu, but control file has %llu", + pg_fatal("%s: manifest system identifier is %" PRIu64 ", but control file has %" PRIu64, controlpath, - (unsigned long long) manifests[i]->system_identifier, - (unsigned long long) system_identifier); + manifests[i]->system_identifier, + system_identifier); } } @@ -559,10 +559,10 @@ check_backup_label_files(int n_backups, char **backup_dirs) pg_fatal("backup at \"%s\" starts on timeline %u, but expected %u", backup_dirs[i], start_tli, check_tli); if (i < n_backups - 1 && start_lsn != check_lsn) - pg_fatal("backup at \"%s\" starts at LSN %X/%X, but expected %X/%X", + pg_fatal("backup at \"%s\" starts at LSN %016" PRIX64 ", but expected %016" PRIX64, backup_dirs[i], - LSN_FORMAT_ARGS(start_lsn), - LSN_FORMAT_ARGS(check_lsn)); + start_lsn, + check_lsn); check_tli = previous_tli; check_lsn = previous_lsn; @@ -622,9 +622,9 @@ check_control_files(int n_backups, char **backup_dirs) if (i == n_backups - 1) system_identifier = control_file->system_identifier; else if (system_identifier != control_file->system_identifier) - pg_fatal("%s: expected system identifier %llu, but found %llu", - controlpath, (unsigned long long) system_identifier, - (unsigned long long) control_file->system_identifier); + pg_fatal("%s: expected system identifier %" PRIu64 ", but found %" PRIu64, + controlpath, system_identifier, + control_file->system_identifier); /* * Detect checksum mismatches, but only if the last backup in the @@ -645,8 +645,7 @@ check_control_files(int n_backups, char **backup_dirs) * If debug output is enabled, make a note of the system identifier that * we found in all of the relevant control files. */ - pg_log_debug("system identifier is %llu", - (unsigned long long) system_identifier); + pg_log_debug("system identifier is %" PRIu64, system_identifier); /* * Warn the user if not all backups are in the same state with regards to @@ -1399,8 +1398,8 @@ slurp_file(int fd, char *filename, StringInfo buf, int maxlen) if (rb < 0) pg_fatal("could not read file \"%s\": %m", filename); else - pg_fatal("could not read file \"%s\": read %zd of %lld", - filename, rb, (long long int) st.st_size); + pg_fatal("could not read file \"%s\": read %zd of %" PRId64, + filename, rb, (pgoff_t) st.st_size); } /* Adjust buffer length for new data and restore trailing-\0 invariant */ diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c index 8acaa54ff38b..94e9e9d16204 100644 --- a/src/bin/pg_combinebackup/reconstruct.c +++ b/src/bin/pg_combinebackup/reconstruct.c @@ -420,10 +420,10 @@ debug_reconstruction(int n_source, rfile **sources, bool dry_run) if (fstat(s->fd, &sb) < 0) pg_fatal("could not stat file \"%s\": %m", s->filename); if (sb.st_size < s->highest_offset_read) - pg_fatal("file \"%s\" is too short: expected %llu, found %llu", + pg_fatal("file \"%s\" is too short: expected %" PRIu64 ", found %" PRIu64, s->filename, - (unsigned long long) s->highest_offset_read, - (unsigned long long) sb.st_size); + (pgoff_t) s->highest_offset_read, + (pgoff_t) sb.st_size); } } } @@ -783,7 +783,7 @@ read_block(rfile *s, off_t off, uint8 *buffer) if (rb < 0) pg_fatal("could not read from file \"%s\": %m", s->filename); else - pg_fatal("could not read from file \"%s\", offset %llu: read %d of %d", - s->filename, (unsigned long long) off, rb, BLCKSZ); + pg_fatal("could not read from file \"%s\", offset %" PRIu64 ": read %d of %d", + s->filename, (uint64) off, rb, BLCKSZ); } } diff --git a/src/bin/pg_combinebackup/write_manifest.c b/src/bin/pg_combinebackup/write_manifest.c index 44879b3f3e87..cd3727ec3f59 100644 --- a/src/bin/pg_combinebackup/write_manifest.c +++ b/src/bin/pg_combinebackup/write_manifest.c @@ -104,8 +104,7 @@ add_file_to_manifest(manifest_writer *mwriter, const char *manifest_path, appendStringInfoString(&mwriter->buf, "\", "); } - appendStringInfo(&mwriter->buf, "\"Size\": %llu, ", - (unsigned long long) size); + appendStringInfo(&mwriter->buf, "\"Size\": %" PRIu64 ", ", size); appendStringInfoString(&mwriter->buf, "\"Last-Modified\": \""); enlargeStringInfo(&mwriter->buf, 128); @@ -156,11 +155,11 @@ finalize_manifest(manifest_writer *mwriter, for (wal_range = first_wal_range; wal_range != NULL; wal_range = wal_range->next) appendStringInfo(&mwriter->buf, - "%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }", + "%s{ \"Timeline\": %u, \"Start-LSN\": \"%016" PRIX64 "\", \"End-LSN\": \"%016" PRIX64 "\" }", wal_range == first_wal_range ? "" : ",\n", wal_range->tli, - LSN_FORMAT_ARGS(wal_range->start_lsn), - LSN_FORMAT_ARGS(wal_range->end_lsn)); + wal_range->start_lsn, + wal_range->end_lsn); /* Terminate the list of WAL ranges. */ appendStringInfoString(&mwriter->buf, "\n],\n"); diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index bea779eef940..8ea91e66d8fb 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -239,16 +239,16 @@ main(int argc, char *argv[]) ControlFile->pg_control_version); printf(_("Catalog version number: %u\n"), ControlFile->catalog_version_no); - printf(_("Database system identifier: %llu\n"), - (unsigned long long) ControlFile->system_identifier); + printf(_("Database system identifier: %" PRIu64 "\n"), + ControlFile->system_identifier); printf(_("Database cluster state: %s\n"), dbState(ControlFile->state)); printf(_("pg_control last modified: %s\n"), pgctime_str); - printf(_("Latest checkpoint location: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->checkPoint)); - printf(_("Latest checkpoint's REDO location: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->checkPointCopy.redo)); + printf(_("Latest checkpoint location: %016" PRIX64 "\n"), + ControlFile->checkPoint); + printf(_("Latest checkpoint's REDO location: %016" PRIX64 "\n"), + ControlFile->checkPointCopy.redo); printf(_("Latest checkpoint's REDO WAL file: %s\n"), xlogfilename); printf(_("Latest checkpoint's TimeLineID: %u\n"), @@ -282,16 +282,16 @@ main(int argc, char *argv[]) ControlFile->checkPointCopy.newestCommitTsXid); printf(_("Time of latest checkpoint: %s\n"), ckpttime_str); - printf(_("Fake LSN counter for unlogged rels: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->unloggedLSN)); - printf(_("Minimum recovery ending location: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->minRecoveryPoint)); + printf(_("Fake LSN counter for unlogged rels: %016" PRIX64 "\n"), + ControlFile->unloggedLSN); + printf(_("Minimum recovery ending location: %016" PRIX64 "\n"), + ControlFile->minRecoveryPoint); printf(_("Min recovery ending loc's timeline: %u\n"), ControlFile->minRecoveryPointTLI); - printf(_("Backup start location: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->backupStartPoint)); - printf(_("Backup end location: %X/%X\n"), - LSN_FORMAT_ARGS(ControlFile->backupEndPoint)); + printf(_("Backup start location: %016" PRIX64 "\n"), + ControlFile->backupStartPoint); + printf(_("Backup end location: %016" PRIX64 "\n"), + ControlFile->backupEndPoint); printf(_("End-of-backup record required: %s\n"), ControlFile->backupEndRequired ? _("yes") : _("no")); printf(_("wal_level setting: %s\n"), diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index b5ba3b46dd99..22a991bce6df 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -1048,8 +1048,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) pg_fatal("could not close temporary file: %m"); if (len != th->fileLen) - pg_fatal("actual file length (%lld) does not match expected (%lld)", - (long long) len, (long long) th->fileLen); + pg_fatal("actual file length (%" PRId64 ") does not match expected (%" PRId64 ")", + len, th->fileLen); pad = tarPaddingBytesRequired(len); for (i = 0; i < pad; i++) @@ -1079,14 +1079,14 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) /* Go to end of current file, if any */ if (ctx->tarFHpos != 0) { - pg_log_debug("moving from position %lld to next member at file position %lld", - (long long) ctx->tarFHpos, (long long) ctx->tarNextMember); + pg_log_debug("moving from position %" PRId64 " to next member at file position %" PRId64, + ctx->tarFHpos, ctx->tarNextMember); while (ctx->tarFHpos < ctx->tarNextMember) _tarReadRaw(AH, &c, 1, NULL, ctx->tarFH); } - pg_log_debug("now at file position %lld", (long long) ctx->tarFHpos); + pg_log_debug("now at file position %" PRId64, ctx->tarFHpos); /* We are at the start of the file, or at the next member */ @@ -1194,12 +1194,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) len = read_tar_number(&h[TAR_OFFSET_SIZE], 12); - pg_log_debug("TOC Entry %s at %llu (length %llu, checksum %d)", - tag, (unsigned long long) hPos, (unsigned long long) len, sum); + pg_log_debug("TOC Entry %s at %" PRIu64 " (length %" PRIu64 ", checksum %d)", + tag, hPos, len, sum); if (chk != sum) - pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %llu", - tag, sum, chk, (unsigned long long) ftello(ctx->tarFH)); + pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %" PRIu64, + tag, sum, chk, ftello(ctx->tarFH)); th->targetFile = pg_strdup(tag); th->fileLen = len; diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 31bc0abff16a..2ae3702efba1 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -746,8 +746,8 @@ PrintControlValues(bool guessed) ControlFile.pg_control_version); printf(_("Catalog version number: %u\n"), ControlFile.catalog_version_no); - printf(_("Database system identifier: %llu\n"), - (unsigned long long) ControlFile.system_identifier); + printf(_("Database system identifier: %" PRIu64 "\n"), + ControlFile.system_identifier); printf(_("Latest checkpoint's TimeLineID: %u\n"), ControlFile.checkPointCopy.ThisTimeLineID); printf(_("Latest checkpoint's full_page_writes: %s\n"), diff --git a/src/bin/pg_rewind/libpq_source.c b/src/bin/pg_rewind/libpq_source.c index d171839effe7..b0f14be8f177 100644 --- a/src/bin/pg_rewind/libpq_source.c +++ b/src/bin/pg_rewind/libpq_source.c @@ -209,17 +209,13 @@ libpq_get_current_wal_insert_lsn(rewind_source *source) { PGconn *conn = ((libpq_source *) source)->conn; XLogRecPtr result; - uint32 hi; - uint32 lo; char *val; val = run_simple_query(conn, "SELECT pg_current_wal_insert_lsn()"); - if (sscanf(val, "%X/%X", &hi, &lo) != 2) + if (sscanf(val, "%" SCNx64, &result) != 1) pg_fatal("unrecognized result \"%s\" for current WAL insert location", val); - result = ((uint64) hi) << 32 | lo; - pg_free(val); return result; @@ -567,8 +563,8 @@ process_queued_fetch_requests(libpq_source *src) } else { - pg_log_debug("received chunk for file \"%s\", offset %lld, size %d", - filename, (long long int) chunkoff, chunksize); + pg_log_debug("received chunk for file \"%s\", offset %" PRId64 ", size %d", + filename, chunkoff, chunksize); if (strcmp(filename, rq->path) != 0) { @@ -576,8 +572,8 @@ process_queued_fetch_requests(libpq_source *src) filename, rq->path); } if (chunkoff != rq->offset) - pg_fatal("received data at offset %lld of file \"%s\", when requested for offset %lld", - (long long int) chunkoff, rq->path, (long long int) rq->offset); + pg_fatal("received data at offset %" PRId64 " of file \"%s\", when requested for offset %" PRId64, + chunkoff, rq->path, (pgoff_t) rq->offset); /* * We should not receive more data than we requested, or diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c index 2cd44625ca36..28a536a1107e 100644 --- a/src/bin/pg_rewind/parsexlog.c +++ b/src/bin/pg_rewind/parsexlog.c @@ -89,12 +89,12 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex, XLogRecPtr errptr = xlogreader->EndRecPtr; if (errormsg) - pg_fatal("could not read WAL record at %X/%X: %s", - LSN_FORMAT_ARGS(errptr), + pg_fatal("could not read WAL record at %016" PRIX64 ": %s", + errptr, errormsg); else - pg_fatal("could not read WAL record at %X/%X", - LSN_FORMAT_ARGS(errptr)); + pg_fatal("could not read WAL record at %016" PRIX64, + errptr); } extractPageInfo(xlogreader); @@ -105,8 +105,8 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, int tliIndex, * messed up. */ if (xlogreader->EndRecPtr != endpoint) - pg_fatal("end pointer %X/%X is not a valid end point; expected %X/%X", - LSN_FORMAT_ARGS(endpoint), LSN_FORMAT_ARGS(xlogreader->EndRecPtr)); + pg_fatal("end pointer %016" PRIX64 " is not a valid end point; expected %016" PRIX64, + endpoint, xlogreader->EndRecPtr); XLogReaderFree(xlogreader); if (xlogreadfd != -1) @@ -143,11 +143,11 @@ readOneRecord(const char *datadir, XLogRecPtr ptr, int tliIndex, if (record == NULL) { if (errormsg) - pg_fatal("could not read WAL record at %X/%X: %s", - LSN_FORMAT_ARGS(ptr), errormsg); + pg_fatal("could not read WAL record at %016" PRIX64 ": %s", + ptr, errormsg); else - pg_fatal("could not read WAL record at %X/%X", - LSN_FORMAT_ARGS(ptr)); + pg_fatal("could not read WAL record at %016" PRIX64, + ptr); } endptr = xlogreader->EndRecPtr; @@ -211,12 +211,12 @@ findLastCheckpoint(const char *datadir, XLogRecPtr forkptr, int tliIndex, if (record == NULL) { if (errormsg) - pg_fatal("could not find previous WAL record at %X/%X: %s", - LSN_FORMAT_ARGS(searchptr), + pg_fatal("could not find previous WAL record at %016" PRIX64 ": %s", + searchptr, errormsg); else - pg_fatal("could not find previous WAL record at %X/%X", - LSN_FORMAT_ARGS(searchptr)); + pg_fatal("could not find previous WAL record at %016" PRIX64, + searchptr); } /* Detect if a new WAL file has been opened */ @@ -459,8 +459,8 @@ extractPageInfo(XLogReaderState *record) * track that change. */ pg_fatal("WAL record modifies a relation, but record type is not recognized: " - "lsn: %X/%X, rmid: %d, rmgr: %s, info: %02X", - LSN_FORMAT_ARGS(record->ReadRecPtr), + "lsn: %016" PRIX64 ", rmid: %d, rmgr: %s, info: %02X", + record->ReadRecPtr, rmid, RmgrName(rmid), info); } diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 2ce99d06d1d9..d2822b00f80c 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -393,8 +393,8 @@ main(int argc, char **argv) targetHistory, targetNentries, &divergerec, &lastcommontliIndex); - pg_log_info("servers diverged at WAL location %X/%X on timeline %u", - LSN_FORMAT_ARGS(divergerec), + pg_log_info("servers diverged at WAL location %016" PRIX64 " on timeline %u", + divergerec, targetHistory[lastcommontliIndex].tli); /* @@ -460,8 +460,8 @@ main(int argc, char **argv) findLastCheckpoint(datadir_target, divergerec, lastcommontliIndex, &chkptrec, &chkpttli, &chkptredo, restore_command); - pg_log_info("rewinding from last common checkpoint at %X/%X on timeline %u", - LSN_FORMAT_ARGS(chkptrec), chkpttli); + pg_log_info("rewinding from last common checkpoint at %016" PRIX64 " on timeline %u", + chkptrec, chkpttli); /* Initialize the hash table to track the status of each file */ filehash_init(); @@ -900,9 +900,9 @@ getTimelineHistory(TimeLineID tli, bool is_source, int *nentries) TimeLineHistoryEntry *entry; entry = &history[i]; - pg_log_debug("%u: %X/%X - %X/%X", entry->tli, - LSN_FORMAT_ARGS(entry->begin), - LSN_FORMAT_ARGS(entry->end)); + pg_log_debug("%u: %016" PRIX64 " - %016" PRIX64, entry->tli, + entry->begin, + entry->end); } } @@ -979,14 +979,14 @@ createBackupLabel(XLogRecPtr startpoint, TimeLineID starttli, XLogRecPtr checkpo strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z", tmp); len = snprintf(buf, sizeof(buf), - "START WAL LOCATION: %X/%X (file %s)\n" - "CHECKPOINT LOCATION: %X/%X\n" + "START WAL LOCATION: %016" PRIX64 " (file %s)\n" + "CHECKPOINT LOCATION: %016" PRIX64 "\n" "BACKUP METHOD: pg_rewind\n" "BACKUP FROM: standby\n" "START TIME: %s\n", /* omit LABEL: line */ - LSN_FORMAT_ARGS(startpoint), xlogfilename, - LSN_FORMAT_ARGS(checkpointloc), + startpoint, xlogfilename, + checkpointloc, strfbuf); if (len >= sizeof(buf)) pg_fatal("backup label buffer too small"); /* shouldn't happen */ diff --git a/src/bin/pg_rewind/timeline.c b/src/bin/pg_rewind/timeline.c index 4d9f0d8301bf..b074a48045fe 100644 --- a/src/bin/pg_rewind/timeline.c +++ b/src/bin/pg_rewind/timeline.c @@ -45,8 +45,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries) { char *ptr; TimeLineID tli; - uint32 switchpoint_hi; - uint32 switchpoint_lo; + XLogRecPtr switchpoint; int nfields; fline = bufptr; @@ -66,7 +65,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries) if (*ptr == '\0' || *ptr == '#') continue; - nfields = sscanf(fline, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo); + nfields = sscanf(fline, "%u\t%016" PRIX64, &tli, &switchpoint); if (nfields < 1) { @@ -75,7 +74,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries) pg_log_error_detail("Expected a numeric timeline ID."); exit(1); } - if (nfields != 3) + if (nfields != 2) { pg_log_error("syntax error in history file: %s", fline); pg_log_error_detail("Expected a write-ahead log switchpoint location."); @@ -96,7 +95,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries) entry = &entries[nlines - 1]; entry->tli = tli; entry->begin = prevend; - entry->end = ((uint64) (switchpoint_hi)) << 32 | (uint64) switchpoint_lo; + entry->end = switchpoint; prevend = entry->end; /* we ignore the remainder of each line */ diff --git a/src/bin/pg_verifybackup/astreamer_verify.c b/src/bin/pg_verifybackup/astreamer_verify.c index 6c3a132ea3a6..65c6299bd09e 100644 --- a/src/bin/pg_verifybackup/astreamer_verify.c +++ b/src/bin/pg_verifybackup/astreamer_verify.c @@ -207,11 +207,11 @@ member_verify_header(astreamer *streamer, astreamer_member *member) if (m->size != member->size) { report_backup_error(mystreamer->context, - "\"%s\" has size %llu in \"%s\" but size %llu in the manifest", + "\"%s\" has size %" PRId64 " in \"%s\" but size %" PRId64 " in the manifest", member->pathname, - (unsigned long long) member->size, + member->size, mystreamer->archive_name, - (unsigned long long) m->size); + m->size); m->bad = true; return; } @@ -296,10 +296,10 @@ member_verify_checksum(astreamer *streamer) if (mystreamer->checksum_bytes != m->size) { report_backup_error(mystreamer->context, - "file \"%s\" in \"%s\" should contain %llu bytes, but read %llu bytes", + "file \"%s\" in \"%s\" should contain %" PRId64 " bytes, but read %" PRIu64 " bytes", m->pathname, mystreamer->archive_name, - (unsigned long long) m->size, - (unsigned long long) mystreamer->checksum_bytes); + m->size, + mystreamer->checksum_bytes); return; } @@ -408,11 +408,11 @@ member_verify_control_data(astreamer *streamer) /* System identifiers should match. */ if (manifest->system_identifier != mystreamer->control_file.system_identifier) - report_fatal_error("%s: %s: manifest system identifier is %llu, but control file has %llu", + report_fatal_error("%s: %s: manifest system identifier is %" PRIu64 ", but control file has %" PRIu64, mystreamer->archive_name, mystreamer->mfile->pathname, - (unsigned long long) manifest->system_identifier, - (unsigned long long) mystreamer->control_file.system_identifier); + manifest->system_identifier, + mystreamer->control_file.system_identifier); } /* diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c index 7c720ab98bdc..6e1db1797323 100644 --- a/src/bin/pg_verifybackup/pg_verifybackup.c +++ b/src/bin/pg_verifybackup/pg_verifybackup.c @@ -438,8 +438,8 @@ parse_manifest_file(char *manifest_path) if (rc < 0) pg_fatal("could not read file \"%s\": %m", manifest_path); else - pg_fatal("could not read file \"%s\": read %d of %lld", - manifest_path, rc, (long long int) statbuf.st_size); + pg_fatal("could not read file \"%s\": read %d of %" PRId64, + manifest_path, rc, (pgoff_t) statbuf.st_size); } /* Close the manifest file. */ @@ -476,10 +476,10 @@ parse_manifest_file(char *manifest_path) if (rc < 0) pg_fatal("could not read file \"%s\": %m", manifest_path); else - pg_fatal("could not read file \"%s\": read %lld of %lld", + pg_fatal("could not read file \"%s\": read %" PRId64 " of %" PRId64, manifest_path, - (long long int) (statbuf.st_size + rc - bytes_left), - (long long int) statbuf.st_size); + (pgoff_t) (statbuf.st_size + rc - bytes_left), + (pgoff_t) statbuf.st_size); } bytes_left -= rc; json_parse_manifest_incremental_chunk(inc_state, buffer, rc, @@ -719,9 +719,9 @@ verify_plain_backup_file(verifier_context *context, char *relpath, if (m->size != sb.st_size) { report_backup_error(context, - "\"%s\" has size %llu on disk but size %llu in the manifest", - relpath, (unsigned long long) sb.st_size, - (unsigned long long) m->size); + "\"%s\" has size %" PRId64 " on disk but size %" PRId64 " in the manifest", + relpath, (pgoff_t) sb.st_size, + m->size); m->bad = true; } @@ -770,10 +770,10 @@ verify_control_file(const char *controlpath, uint64 manifest_system_identifier) /* System identifiers should match. */ if (manifest_system_identifier != control_file->system_identifier) - report_fatal_error("%s: manifest system identifier is %llu, but control file has %llu", + report_fatal_error("%s: manifest system identifier is %" PRIu64 ", but control file has %" PRIu64, controlpath, - (unsigned long long) manifest_system_identifier, - (unsigned long long) control_file->system_identifier); + manifest_system_identifier, + control_file->system_identifier); /* Release memory. */ pfree(control_file); @@ -1165,9 +1165,8 @@ verify_file_checksum(verifier_context *context, manifest_file *m, if (bytes_read != m->size) { report_backup_error(context, - "file \"%s\" should contain %llu bytes, but read %llu bytes", - relpath, (unsigned long long) m->size, - (unsigned long long) bytes_read); + "file \"%s\" should contain %" PRIu64 " bytes, but read %" PRIu64, + relpath, m->size, bytes_read); return; } @@ -1207,10 +1206,10 @@ parse_required_wal(verifier_context *context, char *pg_waldump_path, { char *pg_waldump_cmd; - pg_waldump_cmd = psprintf("\"%s\" --quiet --path=\"%s\" --timeline=%u --start=%X/%X --end=%X/%X\n", + pg_waldump_cmd = psprintf("\"%s\" --quiet --path=\"%s\" --timeline=%u --start=%016" PRIX64 " --end=%016" PRIX64, pg_waldump_path, wal_directory, this_wal_range->tli, - LSN_FORMAT_ARGS(this_wal_range->start_lsn), - LSN_FORMAT_ARGS(this_wal_range->end_lsn)); + this_wal_range->start_lsn, + this_wal_range->end_lsn); fflush(NULL); if (system(pg_waldump_cmd) != 0) report_backup_error(context, diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 51fb76efc489..d57a137f7362 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -522,9 +522,9 @@ XLogRecordSaveFPWs(XLogReaderState *record, const char *savepath) else pg_fatal("invalid fork number: %u", fork); - snprintf(filename, MAXPGPATH, "%s/%08X-%08X-%08X.%u.%u.%u.%u%s", savepath, + snprintf(filename, MAXPGPATH, "%s/%08X-%016" PRIX64 ".%u.%u.%u.%u%s", savepath, record->seg.ws_tli, - LSN_FORMAT_ARGS(record->ReadRecPtr), + record->ReadRecPtr, rnode.spcOid, rnode.dbOid, rnode.relNumber, blk, forkname); file = fopen(filename, PG_BINARY_W); @@ -555,12 +555,12 @@ 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: %10u, lsn: %016" PRIX64 ", prev %016" PRIX64 ", ", desc->rm_name, rec_len, XLogRecGetTotalLen(record), XLogRecGetXid(record), - LSN_FORMAT_ARGS(record->ReadRecPtr), - LSN_FORMAT_ARGS(xl_prev)); + record->ReadRecPtr, + xl_prev); id = desc->rm_identify(info); if (id == NULL) @@ -656,8 +656,8 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogStats *stats) } total_len = total_rec_len + total_fpi_len; - printf("WAL statistics between %X/%X and %X/%X:\n", - LSN_FORMAT_ARGS(stats->startptr), LSN_FORMAT_ARGS(stats->endptr)); + printf("WAL statistics between %016" PRIX64 "and %016" PRIX64 ":\n", + stats->startptr, stats->endptr); /* * 27 is strlen("Transaction/COMMIT_PREPARED"), 20 is strlen(2^64), 8 is @@ -791,8 +791,6 @@ usage(void) int main(int argc, char **argv) { - uint32 xlogid; - uint32 xrecoff; XLogReaderState *xlogreader_state; XLogDumpPrivate private; XLogDumpConfig config; @@ -904,13 +902,12 @@ main(int argc, char **argv) config.filter_by_extended = true; break; case 'e': - if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2) + if (sscanf(optarg, "%" SCNx64, &private.endptr) != 1) { pg_log_error("invalid WAL location: \"%s\"", optarg); goto bad_argument; } - private.endptr = (uint64) xlogid << 32 | xrecoff; break; case 'f': config.follow = true; @@ -1002,14 +999,12 @@ main(int argc, char **argv) config.filter_by_extended = true; break; case 's': - if (sscanf(optarg, "%X/%X", &xlogid, &xrecoff) != 2) + if (sscanf(optarg, "%" SCNx64, &private.startptr) != 1) { pg_log_error("invalid WAL location: \"%s\"", optarg); goto bad_argument; } - else - private.startptr = (uint64) xlogid << 32 | xrecoff; break; case 't': @@ -1140,8 +1135,8 @@ main(int argc, char **argv) XLogSegNoOffsetToRecPtr(segno, 0, WalSegSz, private.startptr); else if (!XLByteInSeg(private.startptr, segno, WalSegSz)) { - pg_log_error("start WAL location %X/%X is not inside file \"%s\"", - LSN_FORMAT_ARGS(private.startptr), + pg_log_error("start WAL location %016" PRIX64 " is not inside file \"%s\"", + private.startptr, fname); goto bad_argument; } @@ -1182,8 +1177,8 @@ main(int argc, char **argv) if (!XLByteInSeg(private.endptr, segno, WalSegSz) && private.endptr != (segno + 1) * WalSegSz) { - pg_log_error("end WAL location %X/%X is not inside file \"%s\"", - LSN_FORMAT_ARGS(private.endptr), + pg_log_error("end WAL location %016" PRIX64 " is not inside file \"%s\"", + private.endptr, argv[argc - 1]); goto bad_argument; } @@ -1214,8 +1209,8 @@ main(int argc, char **argv) first_record = XLogFindNextRecord(xlogreader_state, private.startptr); if (first_record == InvalidXLogRecPtr) - pg_fatal("could not find a valid record after %X/%X", - LSN_FORMAT_ARGS(private.startptr)); + pg_fatal("could not find a valid record after %016" PRIX64, + private.startptr); /* * Display a message that we're skipping data if `from` wasn't a pointer @@ -1224,11 +1219,11 @@ main(int argc, char **argv) */ if (first_record != private.startptr && XLogSegmentOffset(private.startptr, WalSegSz) != 0) - pg_log_info(ngettext("first record is after %X/%X, at %X/%X, skipping over %u byte", - "first record is after %X/%X, at %X/%X, skipping over %u bytes", + pg_log_info(ngettext("first record is after %016" PRIX64 ", at %016" PRIX64 ", skipping over %u byte", + "first record is after %016" PRIX64 ", at %016" PRIX64 ", skipping over %u bytes", (first_record - private.startptr)), - LSN_FORMAT_ARGS(private.startptr), - LSN_FORMAT_ARGS(first_record), + private.startptr, + first_record, (uint32) (first_record - private.startptr)); if (config.stats == true && !config.quiet) @@ -1309,8 +1304,8 @@ main(int argc, char **argv) exit(0); if (errormsg) - pg_fatal("error in WAL record at %X/%X: %s", - LSN_FORMAT_ARGS(xlogreader_state->ReadRecPtr), + pg_fatal("error in WAL record at %016" PRIX64 ": %s", + xlogreader_state->ReadRecPtr, errormsg); XLogReaderFree(xlogreader_state); diff --git a/src/bin/pg_waldump/t/001_basic.pl b/src/bin/pg_waldump/t/001_basic.pl index 5c8fea275bb5..0490192f1957 100644 --- a/src/bin/pg_waldump/t/001_basic.pl +++ b/src/bin/pg_waldump/t/001_basic.pl @@ -41,11 +41,11 @@ qr/error: resource manager .* does not exist/, 'invalid rmgr name'); command_fails_like( - [ 'pg_waldump', '--start' => 'bad' ], + [ 'pg_waldump', '--start' => 'hexbad' ], qr/error: invalid WAL location/, 'invalid start LSN'); command_fails_like( - [ 'pg_waldump', '--end' => 'bad' ], + [ 'pg_waldump', '--end' => 'hexbad' ], qr/error: invalid WAL location/, 'invalid end LSN'); @@ -242,10 +242,9 @@ { # Construct a new LSN that is one byte past the original # start_lsn. - my ($part1, $part2) = split qr{/}, $start_lsn; - my $lsn2 = hex $part2; + my $lsn2 = hex $start_lsn; $lsn2++; - my $new_start = sprintf("%s/%X", $part1, $lsn2); + my $new_start = sprintf("%016X", $lsn2); my (@cmd, $stdout, $stderr, $result); diff --git a/src/bin/pg_waldump/t/002_save_fullpage.pl b/src/bin/pg_waldump/t/002_save_fullpage.pl index 17b15e3a649e..ac8ec219b21e 100644 --- a/src/bin/pg_waldump/t/002_save_fullpage.pl +++ b/src/bin/pg_waldump/t/002_save_fullpage.pl @@ -80,7 +80,7 @@ sub get_block_lsn 'pg_waldump with --save-fullpage runs'); # This regexp will match filenames formatted as: -# TLI-LSNh-LSNl.TBLSPCOID.DBOID.NODEOID.dd_fork with the components being: +# TLI-LSN.TBLSPCOID.DBOID.NODEOID.dd_fork with the components being: # - Timeline ID in hex format. # - WAL LSN in hex format, as two 8-character numbers. # - Tablespace OID (0 for global). @@ -89,7 +89,7 @@ sub get_block_lsn # - Block number. # - Fork this block came from (vm, init, fsm, or main). my $file_re = - qr/^[0-9A-F]{8}-([0-9A-F]{8})-([0-9A-F]{8})[.][0-9]+[.][0-9]+[.][0-9]+[.][0-9]+(?:_vm|_init|_fsm|_main)?$/; + qr/^[0-9A-F]{8}-([0-9A-F]{16})[.][0-9]+[.][0-9]+[.][0-9]+[.][0-9]+(?:_vm|_init|_fsm|_main)?$/; my $file_count = 0; @@ -101,11 +101,11 @@ sub get_block_lsn like($file, $file_re, "verify filename format for file $file"); $file_count++; - my ($hi_lsn_fn, $lo_lsn_fn) = ($file =~ $file_re); + my ($lsn_fn) = ($file =~ $file_re); my ($hi_lsn_bk, $lo_lsn_bk) = get_block_lsn($fullpath, $blocksize); # The LSN on the block comes before the file's LSN. - ok( $hi_lsn_fn . $lo_lsn_fn gt $hi_lsn_bk . $lo_lsn_bk, + ok( $lsn_fn gt $hi_lsn_bk . $lo_lsn_bk, 'LSN stored in the file precedes the one stored in the block'); } diff --git a/src/bin/pg_walsummary/t/002_blocks.pl b/src/bin/pg_walsummary/t/002_blocks.pl index 270332780a45..b1fcb0393892 100644 --- a/src/bin/pg_walsummary/t/002_blocks.pl +++ b/src/bin/pg_walsummary/t/002_blocks.pl @@ -86,10 +86,10 @@ note("examining summary for TLI $tli from $start_lsn to $end_lsn"); # Reconstruct the full pathname for the WAL summary file. -my $filename = sprintf "%s/pg_wal/summaries/%08s%08s%08s%08s%08s.summary", +my $filename = sprintf "%s/pg_wal/summaries/%08s%016s%016s.summary", $node1->data_dir, $tli, - split(m@/@, $start_lsn), - split(m@/@, $end_lsn); + $start_lsn, + $end_lsn; ok(-f $filename, "WAL summary file exists"); # Run pg_walsummary on it. We expect exactly two blocks to be modified, diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index bf099aab2787..0a9d3eefc8f2 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -1003,9 +1003,6 @@ is_an_int(const char *str) /* * strtoint64 -- convert a string to 64-bit integer * - * This function is a slightly modified version of pg_strtoint64() from - * src/backend/utils/adt/numutils.c. - * * The function returns whether the conversion worked, and if so * "*result" is set to the result. * @@ -1014,71 +1011,24 @@ is_an_int(const char *str) bool strtoint64(const char *str, bool errorOK, int64 *result) { - const char *ptr = str; - int64 tmp = 0; - bool neg = false; - - /* - * Do our own scan, rather than relying on sscanf which might be broken - * for long long. - * - * As INT64_MIN can't be stored as a positive 64 bit integer, accumulate - * value as a negative number. - */ + char *end; - /* skip leading spaces */ - while (*ptr && isspace((unsigned char) *ptr)) - ptr++; + errno = 0; + *result = strtoi64(str, &end, 10); - /* handle sign */ - if (*ptr == '-') + if (errno == ERANGE) { - ptr++; - neg = true; - } - else if (*ptr == '+') - ptr++; - - /* require at least one digit */ - if (unlikely(!isdigit((unsigned char) *ptr))) - goto invalid_syntax; - - /* process digits */ - while (*ptr && isdigit((unsigned char) *ptr)) - { - int8 digit = (*ptr++ - '0'); - - if (unlikely(pg_mul_s64_overflow(tmp, 10, &tmp)) || - unlikely(pg_sub_s64_overflow(tmp, digit, &tmp))) - goto out_of_range; + if (!errorOK) + pg_log_error("value \"%s\" is out of range for type bigint", str); + return false; } - - /* allow trailing whitespace, but not other trailing chars */ - while (*ptr != '\0' && isspace((unsigned char) *ptr)) - ptr++; - - if (unlikely(*ptr != '\0')) - goto invalid_syntax; - - if (!neg) + if (str == end || *end != '\0') { - if (unlikely(tmp == PG_INT64_MIN)) - goto out_of_range; - tmp = -tmp; + if (!errorOK) + pg_log_error("invalid input syntax for type bigint: \"%s\"", str); + return false; } - - *result = tmp; return true; - -out_of_range: - if (!errorOK) - pg_log_error("value \"%s\" is out of range for type bigint", str); - return false; - -invalid_syntax: - if (!errorOK) - pg_log_error("invalid input syntax for type bigint: \"%s\"", str); - return false; } /* convert string to double, detecting overflows/underflows */ @@ -6201,7 +6151,7 @@ parseScriptWeight(const char *option, char **script) if ((sep = strrchr(option, WSEP))) { int namelen = sep - option; - long wtmp; + int64 wtmp; char *badp; /* generate the script name */ @@ -6211,12 +6161,12 @@ parseScriptWeight(const char *option, char **script) /* process digits of the weight spec */ errno = 0; - wtmp = strtol(sep + 1, &badp, 10); + wtmp = strtoi64(sep + 1, &badp, 10); if (errno != 0 || badp == sep + 1 || *badp != '\0') pg_fatal("invalid weight specification: %s", sep); if (wtmp > INT_MAX || wtmp < 0) - pg_fatal("weight specification out of range (0 .. %d): %lld", - INT_MAX, (long long) wtmp); + pg_fatal("weight specification out of range (0 .. %d): %" PRId64, + INT_MAX, wtmp); weight = wtmp; } else @@ -6639,27 +6589,23 @@ set_random_seed(const char *seed) } else { - /* parse unsigned-int seed value */ - unsigned long ulseed; char garbage; - /* Don't try to use UINT64_FORMAT here; it might not work for sscanf */ - if (sscanf(seed, "%lu%c", &ulseed, &garbage) != 1) + if (sscanf(seed, "%" SCNu64 "%c", &iseed, &garbage) != 1) { pg_log_error("unrecognized random seed option \"%s\"", seed); pg_log_error_detail("Expecting an unsigned integer, \"time\" or \"rand\"."); return false; } - iseed = (uint64) ulseed; } if (seed != NULL) - pg_log_info("setting random seed to %llu", (unsigned long long) iseed); + pg_log_info("setting random seed to %" PRIu64, iseed); random_seed = iseed; /* Initialize base_random_sequence using seed */ - pg_prng_seed(&base_random_sequence, (uint64) iseed); + pg_prng_seed(&base_random_sequence, iseed); return true; } diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 3170bc868560..6d1d1b4f58c7 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -76,7 +76,7 @@ sub psql_fails_like # Test clean handling of unsupported replication command responses psql_fails_like( $node, - 'START_REPLICATION 0/0', + 'START_REPLICATION 0000000000000000', qr/unexpected PQresultStatus: 8$/, 'handling of unexpected PQresultStatus'); diff --git a/src/common/parse_manifest.c b/src/common/parse_manifest.c index 058585782077..baf881bfa6f8 100644 --- a/src/common/parse_manifest.c +++ b/src/common/parse_manifest.c @@ -938,11 +938,5 @@ hexdecode_string(uint8 *result, char *input, int nbytes) static bool parse_xlogrecptr(XLogRecPtr *result, char *input) { - uint32 hi; - uint32 lo; - - if (sscanf(input, "%X/%X", &hi, &lo) != 2) - return false; - *result = ((uint64) hi) << 32 | lo; - return true; + return sscanf(input, "%" SCNx64, result) == 1; } diff --git a/src/fe_utils/archive.c b/src/fe_utils/archive.c index 5de3617cb298..a1c82a085c6f 100644 --- a/src/fe_utils/archive.c +++ b/src/fe_utils/archive.c @@ -66,9 +66,9 @@ RestoreArchivedFile(const char *path, const char *xlogfname, if (stat(xlogpath, &stat_buf) == 0) { if (expectedSize > 0 && stat_buf.st_size != expectedSize) - pg_fatal("unexpected file size for \"%s\": %lld instead of %lld", - xlogfname, (long long int) stat_buf.st_size, - (long long int) expectedSize); + pg_fatal("unexpected file size for \"%s\": %" PRId64 " instead of %" PRId64, + xlogfname, (pgoff_t) stat_buf.st_size, + (pgoff_t) expectedSize); else { int xlogfd = open(xlogpath, O_RDONLY | PG_BINARY, 0); diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c index 5e5e54e1b753..d66630a1b509 100644 --- a/src/fe_utils/print.c +++ b/src/fe_utils/print.c @@ -3185,9 +3185,9 @@ printTableInit(printTableContent *const content, const printTableOpt *opt, /* Catch possible overflow. Using >= here allows adding 1 below */ if (total_cells >= SIZE_MAX / sizeof(*content->cells)) { - fprintf(stderr, _("Cannot print table contents: number of cells %lld is equal to or exceeds maximum %lld.\n"), - (long long int) total_cells, - (long long int) (SIZE_MAX / sizeof(*content->cells))); + fprintf(stderr, _("Cannot print table contents: number of cells %" PRId64 " is equal to or exceeds maximum %zd.\n"), + total_cells, + SIZE_MAX / sizeof(*content->cells)); exit(EXIT_FAILURE); } content->cells = pg_malloc0((total_cells + 1) * sizeof(*content->cells)); @@ -3269,8 +3269,8 @@ printTableAddCell(printTableContent *const content, char *cell, total_cells = (uint64) content->ncolumns * content->nrows; if (content->cellsadded >= total_cells) { - fprintf(stderr, _("Cannot add cell to table content: total cell count of %lld exceeded.\n"), - (long long int) total_cells); + fprintf(stderr, _("Cannot add cell to table content: total cell count of %" PRIu64 " exceeded.\n"), + total_cells); exit(EXIT_FAILURE); } diff --git a/src/include/access/rewriteheap.h b/src/include/access/rewriteheap.h index 99c3f362adc6..b9c9f1a50817 100644 --- a/src/include/access/rewriteheap.h +++ b/src/include/access/rewriteheap.h @@ -45,13 +45,13 @@ typedef struct LogicalRewriteMappingData * components: * 1) database oid or InvalidOid for shared relations * 2) the oid of the relation - * 3) upper 32bit of the LSN at which a rewrite started - * 4) lower 32bit of the LSN at which a rewrite started - * 5) xid we are mapping for - * 6) xid of the xact performing the mapping + * 3) LSN at which a rewrite started + * 4) xid we are mapping for + * 5) xid of the xact performing the mapping * --- */ -#define LOGICAL_REWRITE_FORMAT "map-%x-%x-%X_%X-%x-%x" +#define LOGICAL_REWRITE_FORMAT "map-%x-%x-%016" PRIX64 "-%x-%x" +#define LOGICAL_REWRITE_FORMAT_SCANF "map-%x-%x-%" SCNx64 "-%x-%x" extern void CheckPointLogicalRewriteHeap(void); #endif /* REWRITE_HEAP_H */ diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index 9e41c9f6e844..764c724ecca5 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.h @@ -25,7 +25,7 @@ typedef uint64 XLogRecPtr; * WAL segment, initializing the first WAL page at WAL segment size, so no XLOG * record can begin at zero. */ -#define InvalidXLogRecPtr 0 +#define InvalidXLogRecPtr ((XLogRecPtr) 0) #define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr) /* @@ -35,13 +35,6 @@ typedef uint64 XLogRecPtr; */ #define FirstNormalUnloggedLSN ((XLogRecPtr) 1000) -/* - * Handy macro for printing XLogRecPtr in conventional format, e.g., - * - * printf("%X/%X", LSN_FORMAT_ARGS(lsn)); - */ -#define LSN_FORMAT_ARGS(lsn) (AssertVariableIsOfTypeMacro((lsn), XLogRecPtr), (uint32) ((lsn) >> 32)), ((uint32) (lsn)) - /* * XLogSegNo - physical log file sequence number. */ diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h index f0abb0df389f..a75b77270c4e 100644 --- a/src/include/lib/radixtree.h +++ b/src/include/lib/radixtree.h @@ -2754,7 +2754,7 @@ RT_SCOPE void RT_STATS(RT_RADIX_TREE * tree) { fprintf(stderr, "max_val = " UINT64_FORMAT "\n", tree->ctl->max_val); - fprintf(stderr, "num_keys = %lld\n", (long long) tree->ctl->num_keys); + fprintf(stderr, "num_keys = %" PRId64 "\n", tree->ctl->num_keys); #ifdef RT_SHMEM fprintf(stderr, "handle = " DSA_POINTER_FORMAT "\n", tree->ctl->handle); @@ -2766,10 +2766,10 @@ RT_STATS(RT_RADIX_TREE * tree) { RT_SIZE_CLASS_ELEM size_class = RT_SIZE_CLASS_INFO[i]; - fprintf(stderr, ", n%d = %lld", size_class.fanout, (long long) tree->ctl->num_nodes[i]); + fprintf(stderr, ", n%d = %" PRId64, size_class.fanout, tree->ctl->num_nodes[i]); } - fprintf(stderr, ", leaves = %lld", (long long) tree->ctl->num_leaves); + fprintf(stderr, ", leaves = %" PRId64, tree->ctl->num_leaves); fprintf(stderr, "\n"); } diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c index 7ff18e91e661..177c1e936ad2 100644 --- a/src/test/modules/libpq_pipeline/libpq_pipeline.c +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -1186,7 +1186,7 @@ test_pipelined_insert(PGconn *conn, int n_rows) { snprintf(insert_param_0, MAXINTLEN, "%d", rows_to_send); /* use up some buffer space with a wide value */ - snprintf(insert_param_1, MAXINT8LEN, "%lld", 1LL << 62); + snprintf(insert_param_1, MAXINT8LEN, "%" PRId64, UINT64_C(1) << 62); if (PQsendQueryPrepared(conn, "my_insert", 2, insert_params, NULL, NULL, 0) == 1) diff --git a/src/test/modules/test_copy_callbacks/test_copy_callbacks.c b/src/test/modules/test_copy_callbacks/test_copy_callbacks.c index a83fdbd7cd87..41113a8acdcf 100644 --- a/src/test/modules/test_copy_callbacks/test_copy_callbacks.c +++ b/src/test/modules/test_copy_callbacks/test_copy_callbacks.c @@ -42,8 +42,8 @@ test_copy_to_callback(PG_FUNCTION_ARGS) processed = DoCopyTo(cstate); EndCopyTo(cstate); - ereport(NOTICE, (errmsg("COPY TO callback has processed %lld rows", - (long long) processed))); + ereport(NOTICE, (errmsg("COPY TO callback has processed %" PRId64 " rows", + processed))); table_close(rel, NoLock); diff --git a/src/test/modules/test_slru/test_slru.c b/src/test/modules/test_slru/test_slru.c index 3ea5ceb8552e..2e4492900afb 100644 --- a/src/test/modules/test_slru/test_slru.c +++ b/src/test/modules/test_slru/test_slru.c @@ -151,8 +151,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 %lld on path %s", - (long long) ftag.segno, path); + elog(NOTICE, "Called SlruSyncFileTag() for segment %" PRId64 " on path %s", + ftag.segno, path); PG_RETURN_VOID(); } @@ -166,8 +166,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 %lld", - (long long) ftag.segno); + elog(NOTICE, "Called SlruDeleteSegment() for segment %" PRId64, + ftag.segno); PG_RETURN_VOID(); } diff --git a/src/test/modules/xid_wraparound/xid_wraparound.c b/src/test/modules/xid_wraparound/xid_wraparound.c index af2144d9bebb..e27a5fa57695 100644 --- a/src/test/modules/xid_wraparound/xid_wraparound.c +++ b/src/test/modules/xid_wraparound/xid_wraparound.c @@ -35,7 +35,7 @@ consume_xids(PG_FUNCTION_ARGS) FullTransactionId lastxid; if (nxids < 0) - elog(ERROR, "invalid nxids argument: %lld", (long long) nxids); + elog(ERROR, "invalid nxids argument: %" PRId64, nxids); if (nxids == 0) lastxid = ReadNextFullTransactionId(); @@ -56,8 +56,8 @@ consume_xids_until(PG_FUNCTION_ARGS) FullTransactionId lastxid; if (!FullTransactionIdIsNormal(targetxid)) - elog(ERROR, "targetxid %llu is not normal", - (unsigned long long) U64FromFullTransactionId(targetxid)); + elog(ERROR, "targetxid %" PRIu64 " is not normal", + U64FromFullTransactionId(targetxid)); lastxid = consume_xids_common(targetxid, 0); @@ -136,8 +136,8 @@ consume_xids_common(FullTransactionId untilxid, uint64 nxids) if (consumed - last_reported_at >= REPORT_INTERVAL) { if (nxids > 0) - elog(NOTICE, "consumed %llu / %llu XIDs, latest %u:%u", - (unsigned long long) consumed, (unsigned long long) nxids, + elog(NOTICE, "consumed %" PRIu64 " / %" PRIu64 " XIDs, latest %u:%u", + consumed, nxids, EpochFromFullTransactionId(lastxid), XidFromFullTransactionId(lastxid)); else diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl index 9f469101fd44..9eaa5137ca01 100644 --- a/src/test/recovery/t/006_logical_decoding.pl +++ b/src/test/recovery/t/006_logical_decoding.pl @@ -33,7 +33,7 @@ # Cover walsender error shutdown code my ($result, $stdout, $stderr) = $node_primary->psql( 'template1', - qq[START_REPLICATION SLOT test_slot LOGICAL 0/0], + qq[START_REPLICATION SLOT test_slot LOGICAL 0000000000000000], replication => 'database'); ok( $stderr =~ m/replication slot "test_slot" was not created in this database/, @@ -52,7 +52,7 @@ # decoding should not be allowed. ($result, $stdout, $stderr) = $node_primary->psql( 'template1', - qq[START_REPLICATION SLOT s1 LOGICAL 0/1], + qq[START_REPLICATION SLOT s1 LOGICAL 0000000000000001], replication => 'true'); ok($stderr =~ /ERROR: logical decoding requires a database connection/, "Logical decoding fails on non-database connection"); diff --git a/src/test/recovery/t/016_min_consistency.pl b/src/test/recovery/t/016_min_consistency.pl index 9a3b4866fce4..e4ccdd43c2ae 100644 --- a/src/test/recovery/t/016_min_consistency.pl +++ b/src/test/recovery/t/016_min_consistency.pl @@ -39,7 +39,7 @@ sub find_largest_lsn defined($len) or die "read error on $filename: $!"; close($fh); - return sprintf("%X/%X", $max_hi, $max_lo); + return sprintf("%08X%08X", $max_hi, $max_lo); } # Initialize primary node diff --git a/src/test/recovery/t/038_save_logical_slots_shutdown.pl b/src/test/recovery/t/038_save_logical_slots_shutdown.pl index a47b2d923030..070814b22dad 100644 --- a/src/test/recovery/t/038_save_logical_slots_shutdown.pl +++ b/src/test/recovery/t/038_save_logical_slots_shutdown.pl @@ -96,13 +96,13 @@ sub compare_confirmed_flush # Wait until the walsender creates decoding context $node_publisher->wait_for_log( - qr/Streaming transactions committing after ([A-F0-9]+\/[A-F0-9]+), reading WAL from ([A-F0-9]+\/[A-F0-9]+)./, + qr/Streaming transactions committing after ([A-F0-9]+), reading WAL from ([A-F0-9]+)./, $offset); # Extract confirmed_flush from the logfile my $log_contents = slurp_file($node_publisher->logfile, $offset); $log_contents =~ - qr/Streaming transactions committing after ([A-F0-9]+\/[A-F0-9]+), reading WAL from ([A-F0-9]+\/[A-F0-9]+)./ + qr/Streaming transactions committing after ([A-F0-9]+), reading WAL from ([A-F0-9]+)./ or die "could not get confirmed_flush_lsn"; # Ensure that the slot's confirmed_flush LSN is the same as the diff --git a/src/test/recovery/t/039_end_of_wal.pl b/src/test/recovery/t/039_end_of_wal.pl index 47f9bb15e033..a25e4c875455 100644 --- a/src/test/recovery/t/039_end_of_wal.pl +++ b/src/test/recovery/t/039_end_of_wal.pl @@ -185,7 +185,7 @@ sub build_page_header $log_size = -s $node->logfile; $node->start; ok( $node->log_contains( - "record with incorrect prev-link 0/DEADBEEF at .*", $log_size), + "record with incorrect prev-link 00000000DEADBEEF at .*", $log_size), "xl_prev bad"); # xl_crc check fails. @@ -249,7 +249,7 @@ sub build_page_header $log_size = -s $node->logfile; $node->start; ok( $node->log_contains( - "unexpected pageaddr 0/BAAAAAAD in .*, LSN .*,", $log_size), + "unexpected pageaddr 00000000BAAAAAAD in .*, LSN .*,", $log_size), "xlp_pageaddr bad"); # Good xl_prev, xlp_magic, xlp_pageaddr, but bogus xlp_info. @@ -339,7 +339,7 @@ sub build_page_header $log_size = -s $node->logfile; $node->start; ok( $node->log_contains( - "unexpected pageaddr 0/BAAAAAAD in .*, LSN .*,", $log_size), + "unexpected pageaddr 00000000BAAAAAAD in .*, LSN .*,", $log_size), "xlp_pageaddr bad (split record header)"); # We'll also discover that xlp_rem_len doesn't add up before any diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out index 072d76ce1317..d3942d4eebf2 100644 --- a/src/test/regress/expected/numeric.out +++ b/src/test/regress/expected/numeric.out @@ -3860,21 +3860,21 @@ ERROR: factorial of a negative number is undefined -- Tests for pg_lsn() -- SELECT pg_lsn(23783416::numeric); - pg_lsn ------------ - 0/16AE7F8 + pg_lsn +------------------ + 00000000016AE7F8 (1 row) SELECT pg_lsn(0::numeric); - pg_lsn --------- - 0/0 + pg_lsn +------------------ + 0000000000000000 (1 row) SELECT pg_lsn(18446744073709551615::numeric); - pg_lsn -------------------- - FFFFFFFF/FFFFFFFF + pg_lsn +------------------ + FFFFFFFFFFFFFFFF (1 row) SELECT pg_lsn(-1::numeric); diff --git a/src/test/regress/expected/pg_lsn.out b/src/test/regress/expected/pg_lsn.out index b27eec7c0150..24aa7518ff17 100644 --- a/src/test/regress/expected/pg_lsn.out +++ b/src/test/regress/expected/pg_lsn.out @@ -27,23 +27,23 @@ ERROR: invalid input syntax for type pg_lsn: "/ABCD" LINE 1: INSERT INTO PG_LSN_TBL VALUES ('/ABCD'); ^ -- Also try it with non-error-throwing API -SELECT pg_input_is_valid('16AE7F7', 'pg_lsn'); +SELECT pg_input_is_valid('G', 'pg_lsn'); pg_input_is_valid ------------------- f (1 row) -SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn'); - message | detail | hint | sql_error_code --------------------------------------------------+--------+------+---------------- - invalid input syntax for type pg_lsn: "16AE7F7" | | | 22P02 +SELECT * FROM pg_input_error_info('ZZZ', 'pg_lsn'); + message | detail | hint | sql_error_code +---------------------------------------------+--------+------+---------------- + invalid input syntax for type pg_lsn: "ZZZ" | | | 22P02 (1 row) -- Min/Max aggregation SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL; - min | max ------+------------------- - 0/0 | FFFFFFFF/FFFFFFFF + min | max +------------------+------------------ + 0000000000000000 | FFFFFFFFFFFFFFFF (1 row) DROP TABLE PG_LSN_TBL; @@ -85,49 +85,49 @@ SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn; (1 row) SELECT '0/16AE7F7'::pg_lsn + 16::numeric; - ?column? ------------ - 0/16AE807 + ?column? +------------------ + 00000000016AE807 (1 row) SELECT 16::numeric + '0/16AE7F7'::pg_lsn; - ?column? ------------ - 0/16AE807 + ?column? +------------------ + 00000000016AE807 (1 row) SELECT '0/16AE7F7'::pg_lsn - 16::numeric; - ?column? ------------ - 0/16AE7E7 + ?column? +------------------ + 00000000016AE7E7 (1 row) SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric; - ?column? -------------------- - FFFFFFFF/FFFFFFFF + ?column? +------------------ + FFFFFFFFFFFFFFFF (1 row) SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric; -- out of range error ERROR: pg_lsn out of range SELECT '0/1'::pg_lsn - 1::numeric; - ?column? ----------- - 0/0 + ?column? +------------------ + 0000000000000000 (1 row) SELECT '0/1'::pg_lsn - 2::numeric; -- out of range error ERROR: pg_lsn out of range SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn); - ?column? -------------------- - FFFFFFFF/FFFFFFFF + ?column? +------------------ + FFFFFFFFFFFFFFFF (1 row) SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn); - ?column? ----------- - 0/0 + ?column? +------------------ + 0000000000000000 (1 row) SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric; @@ -164,107 +164,107 @@ SELECT DISTINCT (i || '/' || j)::pg_lsn f generate_series(1, 5) k WHERE i <= 10 AND j > 0 AND j <= 10 ORDER BY f; - f -------- - 1/1 - 1/2 - 1/3 - 1/4 - 1/5 - 1/6 - 1/7 - 1/8 - 1/9 - 1/10 - 2/1 - 2/2 - 2/3 - 2/4 - 2/5 - 2/6 - 2/7 - 2/8 - 2/9 - 2/10 - 3/1 - 3/2 - 3/3 - 3/4 - 3/5 - 3/6 - 3/7 - 3/8 - 3/9 - 3/10 - 4/1 - 4/2 - 4/3 - 4/4 - 4/5 - 4/6 - 4/7 - 4/8 - 4/9 - 4/10 - 5/1 - 5/2 - 5/3 - 5/4 - 5/5 - 5/6 - 5/7 - 5/8 - 5/9 - 5/10 - 6/1 - 6/2 - 6/3 - 6/4 - 6/5 - 6/6 - 6/7 - 6/8 - 6/9 - 6/10 - 7/1 - 7/2 - 7/3 - 7/4 - 7/5 - 7/6 - 7/7 - 7/8 - 7/9 - 7/10 - 8/1 - 8/2 - 8/3 - 8/4 - 8/5 - 8/6 - 8/7 - 8/8 - 8/9 - 8/10 - 9/1 - 9/2 - 9/3 - 9/4 - 9/5 - 9/6 - 9/7 - 9/8 - 9/9 - 9/10 - 10/1 - 10/2 - 10/3 - 10/4 - 10/5 - 10/6 - 10/7 - 10/8 - 10/9 - 10/10 + f +------------------ + 0000000100000001 + 0000000100000002 + 0000000100000003 + 0000000100000004 + 0000000100000005 + 0000000100000006 + 0000000100000007 + 0000000100000008 + 0000000100000009 + 0000000100000010 + 0000000200000001 + 0000000200000002 + 0000000200000003 + 0000000200000004 + 0000000200000005 + 0000000200000006 + 0000000200000007 + 0000000200000008 + 0000000200000009 + 0000000200000010 + 0000000300000001 + 0000000300000002 + 0000000300000003 + 0000000300000004 + 0000000300000005 + 0000000300000006 + 0000000300000007 + 0000000300000008 + 0000000300000009 + 0000000300000010 + 0000000400000001 + 0000000400000002 + 0000000400000003 + 0000000400000004 + 0000000400000005 + 0000000400000006 + 0000000400000007 + 0000000400000008 + 0000000400000009 + 0000000400000010 + 0000000500000001 + 0000000500000002 + 0000000500000003 + 0000000500000004 + 0000000500000005 + 0000000500000006 + 0000000500000007 + 0000000500000008 + 0000000500000009 + 0000000500000010 + 0000000600000001 + 0000000600000002 + 0000000600000003 + 0000000600000004 + 0000000600000005 + 0000000600000006 + 0000000600000007 + 0000000600000008 + 0000000600000009 + 0000000600000010 + 0000000700000001 + 0000000700000002 + 0000000700000003 + 0000000700000004 + 0000000700000005 + 0000000700000006 + 0000000700000007 + 0000000700000008 + 0000000700000009 + 0000000700000010 + 0000000800000001 + 0000000800000002 + 0000000800000003 + 0000000800000004 + 0000000800000005 + 0000000800000006 + 0000000800000007 + 0000000800000008 + 0000000800000009 + 0000000800000010 + 0000000900000001 + 0000000900000002 + 0000000900000003 + 0000000900000004 + 0000000900000005 + 0000000900000006 + 0000000900000007 + 0000000900000008 + 0000000900000009 + 0000000900000010 + 0000001000000001 + 0000001000000002 + 0000001000000003 + 0000001000000004 + 0000001000000005 + 0000001000000006 + 0000001000000007 + 0000001000000008 + 0000001000000009 + 0000001000000010 (100 rows) diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 1443e1d92929..28b82a5386dd 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -116,18 +116,18 @@ CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PU WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | parallel | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub4 | regress_subscription_user | f | {testpub} | f | parallel | d | f | none | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub4 SET (origin = any); \dRs+ regress_testsub4 - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN -------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub4 | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub4 | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) DROP SUBSCRIPTION regress_testsub3; @@ -145,10 +145,10 @@ ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar'; ERROR: invalid connection string syntax: missing "=" after "foobar" in connection info string \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false); @@ -157,10 +157,10 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | f | t | f | off | dbname=regress_doesnotexist2 | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (password_required = true); @@ -176,10 +176,10 @@ ERROR: unrecognized subscription parameter: "create_slot" -- ok ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345'); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/12345 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0000000000012345 (1 row) -- ok - with lsn = NONE @@ -188,10 +188,10 @@ ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE); ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0'); ERROR: invalid WAL location (LSN): 0/0 \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist2 | 0000000000000000 (1 row) BEGIN; @@ -223,10 +223,10 @@ ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar); ERROR: invalid value for parameter "synchronous_commit": "foobar" HINT: Available values: local, remote_write, remote_apply, on, off. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ----------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+---------- - regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +---------------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+------------------------------+------------------ + regress_testsub_foo | regress_subscription_user | f | {testpub2,testpub3} | f | parallel | d | f | any | t | f | f | local | dbname=regress_doesnotexist2 | 0000000000000000 (1 row) -- rename back to keep the rest simple @@ -255,19 +255,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | t | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | t | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (binary = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) DROP SUBSCRIPTION regress_testsub; @@ -279,27 +279,27 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | on | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (streaming = false); ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) -- fail - publication already exists @@ -314,10 +314,10 @@ ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refr ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false); ERROR: publication "testpub1" is already in subscription "regress_testsub" \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-----------------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub,testpub1,testpub2} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) -- fail - publication used more than once @@ -332,10 +332,10 @@ ERROR: publication "testpub3" is not in subscription "regress_testsub" -- ok - delete publications ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | off | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) DROP SUBSCRIPTION regress_testsub; @@ -371,19 +371,19 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) -- we can alter streaming when two_phase enabled ALTER SUBSCRIPTION regress_testsub SET (streaming = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -393,10 +393,10 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | on | p | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); @@ -409,18 +409,18 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB WARNING: subscription was created, but is not connected HINT: To initiate replication, you must manually create the replication slot, enable the subscription, and refresh the subscription. \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | f | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true); \dRs+ - List of subscriptions - Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN ------------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0/0 + List of subscriptions + Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Failover | Synchronous commit | Conninfo | Skip LSN +-----------------+---------------------------+---------+-------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+----------+--------------------+-----------------------------+------------------ + regress_testsub | regress_subscription_user | f | {testpub} | f | parallel | d | t | any | t | f | f | off | dbname=regress_doesnotexist | 0000000000000000 (1 row) ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); diff --git a/src/test/regress/sql/pg_lsn.sql b/src/test/regress/sql/pg_lsn.sql index 98c869df1590..56e838e2764d 100644 --- a/src/test/regress/sql/pg_lsn.sql +++ b/src/test/regress/sql/pg_lsn.sql @@ -16,8 +16,8 @@ INSERT INTO PG_LSN_TBL VALUES ('ABCD/'); INSERT INTO PG_LSN_TBL VALUES ('/ABCD'); -- Also try it with non-error-throwing API -SELECT pg_input_is_valid('16AE7F7', 'pg_lsn'); -SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn'); +SELECT pg_input_is_valid('G', 'pg_lsn'); +SELECT * FROM pg_input_error_info('ZZZ', 'pg_lsn'); -- Min/Max aggregation SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL; diff --git a/src/test/subscription/t/029_on_error.pl b/src/test/subscription/t/029_on_error.pl index 243662e1240c..7225fbbeeff9 100644 --- a/src/test/subscription/t/029_on_error.pl +++ b/src/test/subscription/t/029_on_error.pl @@ -30,7 +30,7 @@ sub test_skip_lsn # ERROR with its CONTEXT when retrieving this information. my $contents = slurp_file($node_subscriber->logfile, $offset); $contents =~ - qr/conflict detected on relation "public.tbl".*\n.*DETAIL:.* Key already exists in unique index "tbl_pkey", modified by .*origin.* transaction \d+ at .*\n.*Key \(i\)=\(\d+\); existing local tuple .*; remote tuple .*\n.*CONTEXT:.* for replication target relation "public.tbl" in transaction \d+, finished at ([[:xdigit:]]+\/[[:xdigit:]]+)/m + qr/conflict detected on relation "public.tbl".*\n.*DETAIL:.* Key already exists in unique index "tbl_pkey", modified by .*origin.* transaction \d+ at .*\n.*Key \(i\)=\(\d+\); existing local tuple .*; remote tuple .*\n.*CONTEXT:.* for replication target relation "public.tbl" in transaction \d+, finished at ([[:xdigit:]]+)/m or die "could not get error-LSN"; my $lsn = $1; @@ -43,7 +43,7 @@ sub test_skip_lsn # Wait for the failed transaction to be skipped $node_subscriber->poll_query_until('postgres', - "SELECT subskiplsn = '0/0' FROM pg_subscription WHERE subname = 'sub'" + "SELECT subskiplsn = '0000000000000000' FROM pg_subscription WHERE subname = 'sub'" ); # Check the log to ensure that the transaction is skipped, and advance the