Skip to content

Commit c822fe0

Browse files
committed
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.
1 parent 8023b7f commit c822fe0

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/bin/pg_dump/pg_dumpall.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.58 2005/02/22 04:39:38 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.59 2005/04/18 23:47:52 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -63,6 +63,7 @@ PQExpBuffer pgdumpopts;
6363
bool output_clean = false;
6464
bool skip_acls = false;
6565
bool verbose = false;
66+
static bool ignoreVersion = false;
6667
int server_version;
6768

6869
/* flags for -X long options */
@@ -193,11 +194,13 @@ main(int argc, char *argv[])
193194

194195
break;
195196

196-
197-
198197
case 'i':
198+
ignoreVersion = true;
199+
appendPQExpBuffer(pgdumpopts, " -i");
200+
break;
201+
199202
case 'o':
200-
appendPQExpBuffer(pgdumpopts, " -%c", c);
203+
appendPQExpBuffer(pgdumpopts, " -o");
201204
break;
202205

203206
case 'O':
@@ -935,6 +938,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
935938
char *password = NULL;
936939
bool need_pass = false;
937940
const char *remoteversion_str;
941+
int my_version;
938942

939943
if (require_password)
940944
password = simple_prompt("Password: ", 100, false);
@@ -992,6 +996,29 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
992996
exit(1);
993997
}
994998

999+
my_version = parse_version(PG_VERSION);
1000+
if (my_version < 0)
1001+
{
1002+
fprintf(stderr, _("%s: could not parse version \"%s\"\n"),
1003+
progname, PG_VERSION);
1004+
exit(1);
1005+
}
1006+
1007+
if (my_version != server_version
1008+
&& (server_version < 70000 /* we can handle back to 7.0 */
1009+
|| server_version > my_version))
1010+
{
1011+
fprintf(stderr, _("server version: %s; %s version: %s\n"),
1012+
remoteversion_str, progname, PG_VERSION);
1013+
if (ignoreVersion)
1014+
fprintf(stderr, _("proceeding despite version mismatch\n"));
1015+
else
1016+
{
1017+
fprintf(stderr, _("aborting because of version mismatch (Use the -i option to proceed anyway.)\n"));
1018+
exit(1);
1019+
}
1020+
}
1021+
9951022
return conn;
9961023
}
9971024

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy