diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-11-04 10:51:37 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-11-04 10:57:58 +0200 |
commit | 2103430179c6be37d68364c84d68d5211472f528 (patch) | |
tree | 7b7de3a5106707adfe53e6f0114f3f9044951769 | |
parent | e36ce0c7f7b329b25f92cf440fd88fcc695de101 (diff) | |
download | postgresql-2103430179c6be37d68364c84d68d5211472f528.tar.gz postgresql-2103430179c6be37d68364c84d68d5211472f528.zip |
Fix parsing of xlog file name in pg_receivexlog.
The parsing of WAL filenames of segments larger than > 255 was broken,
making pg_receivexlog unable to restart streaming after stopping it.
The bug was introduced by the changes in 9.3 to represent WAL segment number
as a 64-bit integer instead of two ints, log and seg. To fix, replace the
plain sscanf call with XLogFromFileName macro, which does the conversion
from log+seg to a 64-bit integer correcly.
Reported by Mika Eloranta.
-rw-r--r-- | src/bin/pg_basebackup/pg_receivexlog.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c index 031ec1aa97c..252a7e08d67 100644 --- a/src/bin/pg_basebackup/pg_receivexlog.c +++ b/src/bin/pg_basebackup/pg_receivexlog.c @@ -134,8 +134,6 @@ FindStreamingStart(uint32 *tli) while ((dirent = readdir(dir)) != NULL) { uint32 tli; - unsigned int log, - seg; XLogSegNo segno; bool ispartial; @@ -164,14 +162,7 @@ FindStreamingStart(uint32 *tli) /* * Looks like an xlog file. Parse its position. */ - if (sscanf(dirent->d_name, "%08X%08X%08X", &tli, &log, &seg) != 3) - { - fprintf(stderr, - _("%s: could not parse transaction log file name \"%s\"\n"), - progname, dirent->d_name); - disconnect_and_exit(1); - } - segno = ((uint64) log) << 32 | seg; + XLogFromFileName(dirent->d_name, &tli, &segno); /* * Check that the segment has the right size, if it's supposed to be |