Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4aecd22

Browse files
committed
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.
1 parent 9211919 commit 4aecd22

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/bin/pg_basebackup/streamutil.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ GetConnection(void)
233233
/*
234234
* Run IDENTIFY_SYSTEM through a given connection and give back to caller
235235
* some result information if requested:
236-
* - Start LSN position
237-
* - Current timeline ID
238236
* - System identifier
239-
* - Plugin name
237+
* - Current timeline ID
238+
* - Start LSN position
239+
* - Database name (NULL in servers prior to 9.4)
240240
*/
241241
bool
242242
RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
@@ -294,15 +294,21 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
294294
/* Get database name, only available in 9.4 and newer versions */
295295
if (db_name != NULL)
296296
{
297-
if (PQnfields(res) < 4)
298-
fprintf(stderr,
299-
_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
300-
progname, PQntuples(res), PQnfields(res), 1, 4);
297+
*db_name = NULL;
298+
if (PQserverVersion(conn) >= 90400)
299+
{
300+
if (PQnfields(res) < 4)
301+
{
302+
fprintf(stderr,
303+
_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
304+
progname, PQntuples(res), PQnfields(res), 1, 4);
301305

302-
if (PQgetisnull(res, 0, 3))
303-
*db_name = NULL;
304-
else
305-
*db_name = pg_strdup(PQgetvalue(res, 0, 3));
306+
PQclear(res);
307+
return false;
308+
}
309+
if (!PQgetisnull(res, 0, 3))
310+
*db_name = pg_strdup(PQgetvalue(res, 0, 3));
311+
}
306312
}
307313

308314
PQclear(res);

0 commit comments

Comments
 (0)