aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2016-01-05 17:25:12 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2016-01-05 17:25:12 -0300
commit7ef311eb426b2ab01831cc5f1502a5b838c8cdd3 (patch)
treeefd9f5b7efb55e39c9ad04486d4d4774fc5d8afb
parent41abf185024c2a7d36c09e30654efe3d939362b7 (diff)
downloadpostgresql-7ef311eb426b2ab01831cc5f1502a5b838c8cdd3.tar.gz
postgresql-7ef311eb426b2ab01831cc5f1502a5b838c8cdd3.zip
Make pg_receivexlog silent with 9.3 and older servers
A pointless and confusing error message is shown to the user when attempting to identify a 9.3 or older remote server with a 9.5/9.6 pg_receivexlog, because the return signature of IDENTIFY_SYSTEM was changed in 9.4. There's no good reason for the warning message, so shuffle code around to keep it quiet. (pg_recvlogical is also affected by this commit, but since it obviously cannot work with 9.3 that doesn't actually matter much.) Backpatch to 9.5. Reported by Marco Nenciarini, who also wrote the initial patch. Further tweaked by Robert Haas and Fujii Masao; reviewed by Michael Paquier and Craig Ringer.
-rw-r--r--src/bin/pg_basebackup/streamutil.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index 2c963b67a32..99828e5879d 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -233,10 +233,10 @@ GetConnection(void)
/*
* Run IDENTIFY_SYSTEM through a given connection and give back to caller
* some result information if requested:
- * - Start LSN position
- * - Current timeline ID
* - System identifier
- * - Plugin name
+ * - Current timeline ID
+ * - Start LSN position
+ * - Database name (NULL in servers prior to 9.4)
*/
bool
RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
@@ -294,15 +294,21 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
/* Get database name, only available in 9.4 and newer versions */
if (db_name != NULL)
{
- if (PQnfields(res) < 4)
- fprintf(stderr,
- _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
- progname, PQntuples(res), PQnfields(res), 1, 4);
+ *db_name = NULL;
+ if (PQserverVersion(conn) >= 90400)
+ {
+ if (PQnfields(res) < 4)
+ {
+ fprintf(stderr,
+ _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
+ progname, PQntuples(res), PQnfields(res), 1, 4);
- if (PQgetisnull(res, 0, 3))
- *db_name = NULL;
- else
- *db_name = pg_strdup(PQgetvalue(res, 0, 3));
+ PQclear(res);
+ return false;
+ }
+ if (!PQgetisnull(res, 0, 3))
+ *db_name = pg_strdup(PQgetvalue(res, 0, 3));
+ }
}
PQclear(res);