summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/pg_receivexlog.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 18:51:37 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-06-24 19:19:45 +0300
commit0ab9d1c4b31622e9176472b4276f3e9831e3d6ba (patch)
treeb8e9e5337338ba3010e00af50e1a33adb906a212 /src/bin/pg_basebackup/pg_receivexlog.c
parent061e7efb1b4c5b8a5d02122b7780531b8d5bf23d (diff)
Replace XLogRecPtr struct with a 64-bit integer.
This simplifies code that needs to do arithmetic on XLogRecPtrs. To avoid changing on-disk format of data pages, the LSN on data pages is still stored in the old format. That should keep pg_upgrade happy. However, we have XLogRecPtrs embedded in the control file, and in the structs that are sent over the replication protocol, so this changes breaks compatibility of pg_basebackup and server. I didn't do anything about this in this patch, per discussion on -hackers, the right thing to do would to be to change the replication protocol to be architecture-independent, so that you could use a newer version of pg_receivexlog, for example, against an older server version.
Diffstat (limited to 'src/bin/pg_basebackup/pg_receivexlog.c')
-rw-r--r--src/bin/pg_basebackup/pg_receivexlog.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index 4b109f4b96f..dbc6ecf431d 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -77,7 +77,9 @@ stop_streaming(XLogRecPtr segendpos, uint32 timeline, bool segment_finished)
{
if (verbose && segment_finished)
fprintf(stderr, _("%s: finished segment at %X/%X (timeline %u)\n"),
- progname, segendpos.xlogid, segendpos.xrecoff, timeline);
+ progname,
+ (uint32) (segendpos >> 32), (uint32) segendpos,
+ timeline);
if (time_to_abort)
{
@@ -212,6 +214,8 @@ StreamLog(void)
PGresult *res;
uint32 timeline;
XLogRecPtr startpos;
+ uint32 hi,
+ lo;
/*
* Connect in replication mode to the server
@@ -239,12 +243,13 @@ StreamLog(void)
disconnect_and_exit(1);
}
timeline = atoi(PQgetvalue(res, 0, 1));
- if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &startpos.xlogid, &startpos.xrecoff) != 2)
+ if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &hi, &lo) != 2)
{
fprintf(stderr, _("%s: could not parse log start position from value \"%s\"\n"),
progname, PQgetvalue(res, 0, 2));
disconnect_and_exit(1);
}
+ startpos = ((uint64) hi) << 32 | lo;
PQclear(res);
/*
@@ -255,14 +260,16 @@ StreamLog(void)
/*
* Always start streaming at the beginning of a segment
*/
- startpos.xrecoff -= startpos.xrecoff % XLOG_SEG_SIZE;
+ startpos -= startpos % XLOG_SEG_SIZE;
/*
* Start the replication
*/
if (verbose)
fprintf(stderr, _("%s: starting log streaming at %X/%X (timeline %u)\n"),
- progname, startpos.xlogid, startpos.xrecoff, timeline);
+ progname,
+ (uint32) (startpos >> 32), (uint32) startpos,
+ timeline);
ReceiveXlogStream(conn, startpos, timeline, NULL, basedir,
stop_streaming,