/*
* 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,
/* 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);