<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.50 2002/09/06 21:58:36 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.51 2002/09/07 16:14:33 petere Exp $
PostgreSQL documentation
-->
<term><option>--ignore-version</></term>
<listitem>
<para>
- Ignore version mismatch between <command>pg_dump</command>
- and the database server. Since <command>pg_dump</command>
- knows a great deal about system catalogs, any given version of
- <command>pg_dump</command> is only intended to work with
- the corresponding release of the database server. Use this option
- if you need to override the version check (and if
- <command>pg_dump</command> then fails, don't
- say you weren't warned).
+ Ignore version mismatch between
+ <application>pg_dump</application> and the database server.
+ </para>
+
+ <para>
+ <application>pg_dump</application> can handle databases from
+ previous releases of PostgreSQL, but very old versions are not
+ supported anymore (currently prior to 7.0). Use this option
+ if you need to override the version check (and if
+ <application>pg_dump</application> then fails, don't say you
+ weren't warned).
</para>
</listitem>
</varlistentry>
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.33 2002/09/05 22:05:50 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.34 2002/09/07 16:14:33 petere Exp $
PostgreSQL documentation
-->
<variablelist>
<varlistentry>
- <term>-c, --clean</term>
+ <term><option>-c</option></term>
+ <term><option>--clean</option></term>
<listitem>
<para>
- Include SQL commands to clean (drop) database objects before
- recreating them. (This option is fairly useless, since the
- output script expects to create the databases themselves;
- they would always be empty upon creation.)
+ Include SQL commands to clean (drop) the databases before
+ recreating them.
</para>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
- <term>-g, --globals-only</term>
+ <term><option>-g</option></term>
+ <term><option>--globals-only</option></term>
<listitem>
<para>
- Only dump global objects (users and groups), no databases.
+ Dump only global objects (users and groups), no databases.
</para>
</listitem>
</varlistentry>
<para>
Ignore version mismatch between
<application>pg_dumpall</application> and the database server.
- Since <application>pg_dumpall</application> knows a great deal
- about system catalogs, any given version of
- <application>pg_dumpall</application> is only intended to work
- with the corresponding release of the database server. Use
- this option if you need to override the version check (and if
+ </para>
+
+ <para>
+ <application>pg_dumpall</application> can handle databases
+ from previous releases of PostgreSQL, but very old versions
+ are not supported anymore (currently prior to 7.0). Use this
+ option if you need to override the version check (and if
<application>pg_dumpall</application> then fails, don't say
you weren't warned).
</para>
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.2 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.3 2002/09/07 16:14:33 petere Exp $
*
*-------------------------------------------------------------------------
*/
}
appendPQExpBufferChar(buf, '\'');
}
+
+
+
+int
+parse_version(const char *versionString)
+{
+ int cnt;
+ int vmaj,
+ vmin,
+ vrev;
+
+ cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
+
+ if (cnt < 2)
+ return -1;
+
+ if (cnt == 2)
+ vrev = 0;
+
+ return (100 * vmaj + vmin) * 100 + vrev;
+}
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.h,v 1.3 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.h,v 1.4 2002/09/07 16:14:33 petere Exp $
*
*-------------------------------------------------------------------------
*/
extern const char *fmtId(const char *identifier);
extern void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll);
+extern int parse_version(const char *versionString);
#endif /* DUMPUTILS_H */
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.40 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.41 2002/09/07 16:14:33 petere Exp $
*
*-------------------------------------------------------------------------
*/
static int
_parse_version(ArchiveHandle *AH, const char *versionString)
{
- int cnt;
- int vmaj,
- vmin,
- vrev;
+ int v;
- cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
-
- if (cnt < 2)
+ v = parse_version(versionString);
+ if (v < 0)
die_horribly(AH, modulename, "unable to parse version string \"%s\"\n", versionString);
- if (cnt == 2)
- vrev = 0;
-
- return (100 * vmaj + vmin) * 100 + vrev;
+ return v;
}
static void
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.297 2002/09/04 20:31:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.298 2002/09/07 16:14:33 petere Exp $
*
*-------------------------------------------------------------------------
*/
} DumpContext;
static void help(const char *progname);
-static int parse_version(const char *versionString);
static NamespaceInfo *findNamespace(const char *nsoid, const char *objoid);
static void dumpClasses(const TableInfo *tblinfo, const int numTables,
Archive *fout, const bool oids);
/* Let the archiver know how noisy to be */
g_fout->verbose = g_verbose;
+ g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
+ g_fout->maxRemoteVersion = parse_version(PG_VERSION);
+ if (g_fout->maxRemoteVersion < 0)
+ {
+ write_msg(NULL, "unable to parse version string \"%s\"\n", PG_VERSION);
+ exit(1);
+ }
+
/*
* Open the database using the Archiver, so it knows about it. Errors
* mean death.
*/
- g_fout->minRemoteVersion = 70000; /* we can handle back to 7.0 */
- g_fout->maxRemoteVersion = parse_version(PG_VERSION);
g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, username, force_password, ignore_version);
/*
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
}
-static int
-parse_version(const char *versionString)
-{
- int cnt;
- int vmaj,
- vmin,
- vrev;
-
- cnt = sscanf(versionString, "%d.%d.%d", &vmaj, &vmin, &vrev);
-
- if (cnt < 2)
- {
- write_msg(NULL, "unable to parse version string \"%s\"\n", versionString);
- exit(1);
- }
-
- if (cnt == 2)
- vrev = 0;
-
- return (100 * vmaj + vmin) * 100 + vrev;
-}
-
void
exit_nicely(void)
{
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.6 2002/09/04 20:31:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.7 2002/09/07 16:14:33 petere Exp $
*
*-------------------------------------------------------------------------
*/
PQExpBuffer pgdumpopts;
bool output_clean = false;
bool verbose = false;
+int server_version;
{
case 'c':
output_clean = true;
- appendPQExpBuffer(pgdumpopts, " -c");
break;
case 'd':
printf(_("Options:\n"));
#ifdef HAVE_GETOPT_LONG
- printf(_(" -c, --clean clean (drop) schema prior to create\n"));
+ printf(_(" -c, --clean clean (drop) databases prior to create\n"));
printf(_(" -d, --inserts dump data as INSERT, rather than COPY, commands\n"));
printf(_(" -D, --column-inserts dump data as INSERT commands with column names\n"));
- printf(_(" -g, --globals-only only dump global objects, no databases\n"));
+ printf(_(" -g, --globals-only dump only global objects, no databases\n"));
printf(_(" -h, --host=HOSTNAME database server host name\n"));
printf(_(" -i, --ignore-version proceed even when server version mismatches\n"
" pg_dumpall version\n"));
printf(_(" -v, --verbose verbose mode\n"));
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
#else /* not HAVE_GETOPT_LONG */
- printf(_(" -c clean (drop) schema prior to create\n"));
+ printf(_(" -c clean (drop) databases prior to create\n"));
printf(_(" -d dump data as INSERT, rather than COPY, commands\n"));
printf(_(" -D dump data as INSERT commands with column names\n"));
- printf(_(" -g only dump global objects, no databases\n"));
+ printf(_(" -g dump only global objects, no databases\n"));
printf(_(" -h HOSTNAME database server host name\n"));
printf(_(" -i proceed even when server version mismatches\n"
" pg_dumpall version\n"));
printf("%s", buf->data);
destroyPQExpBuffer(buf);
- dumpUserConfig(conn, username);
+ if (server_version >= 70300)
+ dumpUserConfig(conn, username);
}
PQclear(res);
printf("%s", buf->data);
destroyPQExpBuffer(buf);
- dumpDatabaseConfig(conn, dbname);
+ if (server_version >= 70300)
+ dumpDatabaseConfig(conn, dbname);
}
PQclear(res);
PGconn *conn;
char *password = NULL;
bool need_pass = false;
+ PGresult *res;
if (require_password)
password = simple_prompt("Password: ", 100, false);
{
fprintf(stderr, _("%s: could not connect to database %s\n"),
progname, dbname);
- exit(0);
+ exit(1);
}
if (PQstatus(conn) == CONNECTION_BAD &&
{
fprintf(stderr, _("%s: could not connect to database %s: %s\n"),
progname, dbname, PQerrorMessage(conn));
- exit(0);
+ exit(1);
+ }
+
+ res = executeQuery(conn, "SELECT version();");
+ if (PQntuples(res) != 1)
+ {
+ fprintf(stderr, _("%s: could not get server version\n"), progname);
+ exit(1);
+ }
+ else
+ {
+ 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);
+ }
}
return conn;