* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.47 2003/05/14 03:26:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.48 2003/06/22 00:56:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static void
_check_database_version(ArchiveHandle *AH, bool ignoreVersion)
{
- PGresult *res;
int myversion;
const char *remoteversion_str;
int remoteversion;
- PGconn *conn = AH->connection;
myversion = _parse_version(AH, PG_VERSION);
- res = PQexec(conn, "SELECT version();");
- if (!res ||
- PQresultStatus(res) != PGRES_TUPLES_OK ||
- PQntuples(res) != 1)
- die_horribly(AH, modulename, "could not get version from server: %s", PQerrorMessage(conn));
-
- remoteversion_str = PQgetvalue(res, 0, 0);
- remoteversion = _parse_version(AH, remoteversion_str + 11);
+ remoteversion_str = PQparameterStatus(AH->connection, "server_version");
+ if (!remoteversion_str)
+ die_horribly(AH, modulename, "could not get server_version from libpq\n");
- PQclear(res);
+ remoteversion = _parse_version(AH, remoteversion_str);
AH->public.remoteVersion = remoteversion;
if (myversion != remoteversion
- && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion))
+ && (remoteversion < AH->public.minRemoteVersion ||
+ remoteversion > AH->public.maxRemoteVersion))
{
write_msg(NULL, "server version: %s; %s version: %s\n",
remoteversion_str, progname, PG_VERSION);
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.21 2003/06/11 05:13:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.22 2003/06/22 00:56:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
PGconn *conn;
char *password = NULL;
bool need_pass = false;
- PGresult *res;
+ const char *remoteversion_str;
if (require_password)
password = simple_prompt("Password: ", 100, false);
exit(1);
}
- res = executeQuery(conn, "SELECT version();");
- if (PQntuples(res) != 1)
+ remoteversion_str = PQparameterStatus(conn, "server_version");
+ if (!remoteversion_str)
{
fprintf(stderr, _("%s: could not get server version\n"), progname);
exit(1);
}
- else
+ server_version = parse_version(remoteversion_str);
+ if (server_version < 0)
{
- char *val = PQgetvalue(res, 0, 0);
- server_version = parse_version(val + strcspn(val, "0123456789"));
- if (server_version < 0)
- {
- fprintf(stderr, _("%s: could not parse server version \"%s\"\n"), progname, val);
- exit(1);
- }
+ fprintf(stderr, _("%s: could not parse server version \"%s\"\n"),
+ progname, remoteversion_str);
+ exit(1);
}
- PQclear(res);
return conn;
}