Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6980497

Browse files
committed
Add a server version check to pg_basebackup and pg_receivexlog.
These programs don't work against 9.0 or earlier servers, so check that whenthe connection is made. That's better than a cryptic error message you gotbefore.Also, these programs won't work with a 9.3 server, because the WAL streamingprotocol was changed in a non-backwards-compatible way. As a general rule,we don't make any guarantee that an old client will work with a new server,so check that. However, allow a 9.1 client to connect to a 9.2 server, toavoid breaking environments that currently work; a 9.1 client happens towork with a 9.2 server, even though we didn't make any great effort toensure that.This patch is for the 9.1 and 9.2 branches, I'll commit a similar patch tomaster later. Although this isn't a critical bug fix, it seems safe enoughto back-patch. The error message you got when connecting to a 9.3develserver without this patch was cryptic enough to warrant backpatching.
1 parent3a003c5 commit6980497

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,9 @@ BaseBackup(void)
947947
inti;
948948
charxlogstart[64];
949949
charxlogend[64];
950+
intminServerMajor,
951+
maxServerMajor;
952+
intserverMajor;
950953

951954
/*
952955
* Connect in replication mode to the server
@@ -956,6 +959,21 @@ BaseBackup(void)
956959
/* Error message already written in GetConnection() */
957960
exit(1);
958961

962+
/*
963+
* Check server version. BASE_BACKUP command was introduced in 9.1, so
964+
* we can't work with servers older than 9.1. And we don't support servers
965+
* newer than the client.
966+
*/
967+
minServerMajor=901;
968+
maxServerMajor=PG_VERSION_NUM /100;
969+
serverMajor=PQserverVersion(conn) /100;
970+
if (serverMajor<minServerMajor||serverMajor>maxServerMajor)
971+
{
972+
fprintf(stderr,_("%s: unsupported server version %s\n"),
973+
progname,PQparameterStatus(conn,"server_version"));
974+
disconnect_and_exit(1);
975+
}
976+
959977
/*
960978
* Run IDENTIFY_SYSTEM so we can get the timeline
961979
*/

‎src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ StreamLog(void)
220220
PGresult*res;
221221
uint32timeline;
222222
XLogRecPtrstartpos;
223+
intminServerMajor,
224+
maxServerMajor;
225+
intserverMajor;
223226

224227
/*
225228
* Connect in replication mode to the server
@@ -229,6 +232,21 @@ StreamLog(void)
229232
/* Error message already written in GetConnection() */
230233
return;
231234

235+
/*
236+
* Check server version. IDENTIFY_SYSTEM didn't return the current xlog
237+
* position before 9.1, so we can't work with servers older than 9.1. And
238+
* we don't support servers newer than the client.
239+
*/
240+
minServerMajor=901;
241+
maxServerMajor=PG_VERSION_NUM /100;
242+
serverMajor=PQserverVersion(conn) /100;
243+
if (serverMajor<minServerMajor||serverMajor>maxServerMajor)
244+
{
245+
fprintf(stderr,_("%s: unsupported server version %s\n"),
246+
progname,PQparameterStatus(conn,"server_version"));
247+
disconnect_and_exit(1);
248+
}
249+
232250
/*
233251
* Run IDENTIFY_SYSTEM so we can get the timeline and current xlog
234252
* position.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp