From: Tom Lane Date: Mon, 18 Apr 2005 23:47:52 +0000 (+0000) Subject: pg_dumpall should enforce the server version check for itself, rather X-Git-Tag: REL9_0_0~10388 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c822fe05ae877ae6007ac91cce4111076e74b1f0;p=pg-rex%2Fsyncrep.git pg_dumpall should enforce the server version check for itself, rather than simply passing it down to pg_dump. Else, version-related failures in pg_dumpall itself generate unhelpful error messages. --- diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index c1c3ac6661..07a08c41d8 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.58 2005/02/22 04:39:38 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.59 2005/04/18 23:47:52 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,6 +63,7 @@ PQExpBuffer pgdumpopts; bool output_clean = false; bool skip_acls = false; bool verbose = false; +static bool ignoreVersion = false; int server_version; /* flags for -X long options */ @@ -193,11 +194,13 @@ main(int argc, char *argv[]) break; - - case 'i': + ignoreVersion = true; + appendPQExpBuffer(pgdumpopts, " -i"); + break; + case 'o': - appendPQExpBuffer(pgdumpopts, " -%c", c); + appendPQExpBuffer(pgdumpopts, " -o"); break; case 'O': @@ -935,6 +938,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, char *password = NULL; bool need_pass = false; const char *remoteversion_str; + int my_version; if (require_password) password = simple_prompt("Password: ", 100, false); @@ -992,6 +996,29 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, exit(1); } + my_version = parse_version(PG_VERSION); + if (my_version < 0) + { + fprintf(stderr, _("%s: could not parse version \"%s\"\n"), + progname, PG_VERSION); + exit(1); + } + + if (my_version != server_version + && (server_version < 70000 /* we can handle back to 7.0 */ + || server_version > my_version)) + { + fprintf(stderr, _("server version: %s; %s version: %s\n"), + remoteversion_str, progname, PG_VERSION); + if (ignoreVersion) + fprintf(stderr, _("proceeding despite version mismatch\n")); + else + { + fprintf(stderr, _("aborting because of version mismatch (Use the -i option to proceed anyway.)\n")); + exit(1); + } + } + return conn; }