2014-03-18 17:19:57 +01:00
|
|
|
#include "libpq-fe.h"
|
|
|
|
|
2011-10-26 20:13:33 +02:00
|
|
|
#include "access/xlogdefs.h"
|
|
|
|
|
|
|
|
/*
|
2012-05-25 11:36:22 +02:00
|
|
|
* Called before trying to read more data or when a segment is
|
|
|
|
* finished. Return true to stop streaming.
|
2011-10-26 20:13:33 +02:00
|
|
|
*/
|
2012-06-10 21:20:04 +02:00
|
|
|
typedef bool (*stream_stop_callback) (XLogRecPtr segendpos, uint32 timeline, bool segment_finished);
|
2011-10-26 20:13:33 +02:00
|
|
|
|
Make pg_basebackup work with pre-9.3 servers, and add server version check.
A new 'starttli' field was added to the response of BASE_BACKUP command.
Make pg_basebackup tolerate the case that it's missing, so that it still
works with older servers.
Add an explicit check for the server version, so that you get a nicer error
message if you try to use it with a pre-9.1 server.
The streaming protocol message format changed in 9.3, so -X stream still won't
work with pre-9.3 servers. I added a version check to ReceiveXLogStream()
earlier, but write that slightly differently, so that in 9.4, it will still
work with a 9.3 server. (In 9.4, the error message needs to be adjusted to
"9.3 or above", though). Also, if the version check fails, don't retry.
2013-03-22 12:02:59 +01:00
|
|
|
extern bool CheckServerVersionForStreaming(PGconn *conn);
|
2011-10-26 20:13:33 +02:00
|
|
|
extern bool ReceiveXlogStream(PGconn *conn,
|
2012-06-10 21:20:04 +02:00
|
|
|
XLogRecPtr startpos,
|
|
|
|
uint32 timeline,
|
|
|
|
char *sysidentifier,
|
|
|
|
char *basedir,
|
|
|
|
stream_stop_callback stream_stop,
|
|
|
|
int standby_message_timeout,
|
Make pg_receivexlog and pg_basebackup -X stream work across timeline switches.
This mirrors the changes done earlier to the server in standby mode. When
receivelog reaches the end of a timeline, as reported by the server, it
fetches the timeline history file of the next timeline, and restarts
streaming from the new timeline by issuing a new START_STREAMING command.
When pg_receivexlog crosses a timeline, it leaves the .partial suffix on the
last segment on the old timeline. This helps you to tell apart a partial
segment left in the directory because of a timeline switch, and a completed
segment. If you just follow a single server, it won't make a difference, but
it can be significant in more complicated scenarios where new WAL is still
generated on the old timeline.
This includes two small changes to the streaming replication protocol:
First, when you reach the end of timeline while streaming, the server now
sends the TLI of the next timeline in the server's history to the client.
pg_receivexlog uses that as the next timeline, so that it doesn't need to
parse the timeline history file like a standby server does. Second, when
BASE_BACKUP command sends the begin and end WAL positions, it now also sends
the timeline IDs corresponding the positions.
2013-01-17 19:23:00 +01:00
|
|
|
char *partial_suffix);
|