From ffda05977a93f9b3f8a6b05657ba2f16decb6b23 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 15 Jan 2013 15:45:52 +0200 Subject: [PATCH] Give a proper error message if connecting to incompatible server. The WAL streaming message format changed in 9.3, so 9.3 pg_basebackup or pg_receivelog won't work against older servers. --- src/bin/pg_basebackup/receivelog.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index cf9cea1e2d..88d0c136b0 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -342,6 +342,21 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, int64 last_status = -1; XLogRecPtr blockpos = InvalidXLogRecPtr; + /* + * The message format used in streaming replication changed in 9.3, so we + * cannot stream from older servers. Don't know if we would work with + * newer versions, but let's not take the risk. + */ + if (PQserverVersion(conn) / 100 != PG_VERSION_NUM / 100) + { + const char *serverver = PQparameterStatus(conn, "server_version"); + fprintf(stderr, _("%s: incompatible server version %s; streaming is only supported with server version %s\n"), + progname, + serverver ? serverver : "'unknown'", + PG_MAJORVERSION); + return false; + } + if (sysidentifier != NULL) { /* Validate system identifier and timeline hasn't changed */ -- 2.40.0