mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
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.
This commit is contained in:
parent
1186365c3c
commit
92645c42c8
@ -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.57 2004/12/31 22:03:09 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.57.4.1 2005/04/18 23:48:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,6 +64,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 */
|
||||
@ -194,11 +195,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':
|
||||
@ -936,6 +939,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);
|
||||
@ -993,6 +997,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user