Commit c822fe05 authored by Tom Lane's avatar Tom Lane

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.
parent 8023b7fa
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * 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; ...@@ -63,6 +63,7 @@ PQExpBuffer pgdumpopts;
bool output_clean = false; bool output_clean = false;
bool skip_acls = false; bool skip_acls = false;
bool verbose = false; bool verbose = false;
static bool ignoreVersion = false;
int server_version; int server_version;
/* flags for -X long options */ /* flags for -X long options */
...@@ -193,11 +194,13 @@ main(int argc, char *argv[]) ...@@ -193,11 +194,13 @@ main(int argc, char *argv[])
break; break;
case 'i': case 'i':
ignoreVersion = true;
appendPQExpBuffer(pgdumpopts, " -i");
break;
case 'o': case 'o':
appendPQExpBuffer(pgdumpopts, " -%c", c); appendPQExpBuffer(pgdumpopts, " -o");
break; break;
case 'O': case 'O':
...@@ -935,6 +938,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, ...@@ -935,6 +938,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
char *password = NULL; char *password = NULL;
bool need_pass = false; bool need_pass = false;
const char *remoteversion_str; const char *remoteversion_str;
int my_version;
if (require_password) if (require_password)
password = simple_prompt("Password: ", 100, false); password = simple_prompt("Password: ", 100, false);
...@@ -992,6 +996,29 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, ...@@ -992,6 +996,29 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
exit(1); 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; return conn;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment