Turn the -i/--ignore-version options of pg_dump and pg_dumpall into no-ops:
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Apr 2008 03:49:22 +0000 (03:49 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Apr 2008 03:49:22 +0000 (03:49 +0000)
the server version check is now always enforced.  Relax the version check to
allow a server that is of pg_dump's own major version but a later minor
version; this is the only case that -i was at all safe to use in.

pg_restore already enforced only a very weak version check, so this is
really just a documentation change for it.

Per discussion.

doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_dumpall.sgml
doc/src/sgml/ref/pg_restore.sgml
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_restore.c

index 1e0712002602732de5616edbff722b3d28cdd55f..abe24bd43241897413de3957fe60c1de1c20c381 100644 (file)
@@ -296,20 +296,7 @@ PostgreSQL documentation
       <term><option>--ignore-version</></term>
       <listitem>
        <para>
-        Ignore version mismatch between
-        <application>pg_dump</application> and the database server.
-       </para>
-
-       <para>
-        By default, <application>pg_dump</> will refuse to attempt
-        to dump from a server that is of a newer <productname>PostgreSQL</>
-        version than <application>pg_dump</application> is.  It will also
-        refuse to attempt to dump from a server that is older than the oldest
-        supported version (currently, 7.0).  The <option>-i</> option
-        overrides this check and forces a dump to be attempted anyway.
-        This option is <emphasis>deprecated</> because the dump is very
-        likely to fail &mdash; or worse, seem to succeed but be wrong or
-        incomplete.
+        A deprecated option that is now ignored.
        </para>
       </listitem>
      </varlistentry>
index ce5b8232c85c31f071727eb58e69a18e5b667a03..d00da825663addd8afd60f91551eb2a075c62b0c 100644 (file)
@@ -156,20 +156,7 @@ PostgreSQL documentation
       <term><option>--ignore-version</></term>
       <listitem>
        <para>
-        Ignore version mismatch between
-        <application>pg_dumpall</application> and the database server.
-       </para>
-
-       <para>
-        By default, <application>pg_dumpall</> will refuse to attempt
-        to dump from a server that is of a newer <productname>PostgreSQL</>
-        version than <application>pg_dumpall</application> is.  It will also
-        refuse to attempt to dump from a server that is older than the oldest
-        supported version (currently, 7.0).  The <option>-i</> option
-        overrides this check and forces a dump to be attempted anyway.
-        This option is <emphasis>deprecated</> because the dump is very
-        likely to fail &mdash; or worse, seem to succeed but be wrong or
-        incomplete.
+        A deprecated option that is now ignored.
        </para>
       </listitem>
      </varlistentry>
index 073aeca01c5bf3b804e8a52a8d1eb8a842fc0ace..fd3f7c906911057b21dd32ff7f34f8335364e7f9 100644 (file)
       <term><option>--ignore-version</option></term>
       <listitem>
        <para>
-        Ignore version mismatch between
-        <application>pg_restore</application> and the database server.
+        A deprecated option that is now ignored.
        </para>
       </listitem>
      </varlistentry>
index 6cff8e9ecdec4b21bfafc89c1e71f4abaaccf3ed..c57bb22d9aaa8e31c571b2b43bece37a6e01bf0f 100644 (file)
@@ -116,7 +116,6 @@ typedef struct _restoreOptions
        char       *pgport;
        char       *pghost;
        char       *username;
-       int                     ignoreVersion;
        int                     noDataForFailedTables;
        int                     requirePassword;
        int                     exit_on_error;
@@ -144,9 +143,7 @@ PGconn *ConnectDatabase(Archive *AH,
                                const char *pghost,
                                const char *pgport,
                                const char *username,
-                               const int reqPwd,
-                               const int ignoreVersion);
-
+                               int reqPwd);
 
 /* Called to add a TOC entry */
 extern void ArchiveEntry(Archive *AHX,
index 07f8f64998397bda5d42e319631edc5c8a6d5c9d..e6c343ced586bdf8fb8ef60f054e2e3c24e93f49 100644 (file)
@@ -162,7 +162,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 
                ConnectDatabase(AHX, ropt->dbname,
                                                ropt->pghost, ropt->pgport, ropt->username,
-                                               ropt->requirePassword, ropt->ignoreVersion);
+                                               ropt->requirePassword);
 
                /*
                 * If we're talking to the DB directly, don't send comments since they
index 8f2de9739c184eb82cf75021825b95ca08743205..947fa6ae60c20c9d8184f41b70317098731c5e3a 100644 (file)
@@ -24,7 +24,7 @@
 
 static const char *modulename = gettext_noop("archiver (db)");
 
-static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
+static void _check_database_version(ArchiveHandle *AH);
 static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser);
 static void notice_processor(void *arg, const char *message);
 static char *_sendSQLLine(ArchiveHandle *AH, char *qry, char *eos);
@@ -48,7 +48,7 @@ _parse_version(ArchiveHandle *AH, const char *versionString)
 }
 
 static void
-_check_database_version(ArchiveHandle *AH, bool ignoreVersion)
+_check_database_version(ArchiveHandle *AH)
 {
        int                     myversion;
        const char *remoteversion_str;
@@ -71,11 +71,7 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
        {
                write_msg(NULL, "server version: %s; %s version: %s\n",
                                  remoteversion_str, progname, PG_VERSION);
-               if (ignoreVersion)
-                       write_msg(NULL, "ignoring server version mismatch\n");
-               else
-                       die_horribly(AH, NULL, "aborting because of server version mismatch\n"
-                       "Use the -i option to bypass server version check, but be prepared for failure.\n");
+               die_horribly(AH, NULL, "aborting because of server version mismatch\n");
        }
 }
 
@@ -182,7 +178,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
                free(password);
 
        /* check for version mismatch */
-       _check_database_version(AH, true);
+       _check_database_version(AH);
 
        PQsetNoticeProcessor(newConn, notice_processor, NULL);
 
@@ -201,8 +197,7 @@ ConnectDatabase(Archive *AHX,
                                const char *pghost,
                                const char *pgport,
                                const char *username,
-                               const int reqPwd,
-                               const int ignoreVersion)
+                               int reqPwd)
 {
        ArchiveHandle *AH = (ArchiveHandle *) AHX;
        char       *password = NULL;
@@ -254,7 +249,7 @@ ConnectDatabase(Archive *AHX,
                                         PQdb(AH->connection), PQerrorMessage(AH->connection));
 
        /* check for version mismatch */
-       _check_database_version(AH, ignoreVersion);
+       _check_database_version(AH);
 
        PQsetNoticeProcessor(AH->connection, notice_processor, NULL);
 
index 8e1bc90fb4d075e1b2817208b35b455e5c3cb9c9..f1142b74c33ce2a8924a759e0df1bf36cb959cf8 100644 (file)
@@ -211,19 +211,20 @@ main(int argc, char **argv)
        int                     i;
        bool            force_password = false;
        int                     compressLevel = -1;
-       bool            ignore_version = false;
        int                     plainText = 0;
        int                     outputClean = 0;
        int                     outputCreate = 0;
        bool            outputBlobs = false;
        int                     outputNoOwner = 0;
        char       *outputSuperuser = NULL;
+       int                     my_version;
+       int                     optindex;
+       RestoreOptions *ropt;
+
        static int      disable_triggers = 0;
        static int  outputNoTablespaces = 0;
        static int      use_setsessauth = 0;
 
-       RestoreOptions *ropt;
-
        static struct option long_options[] = {
                {"data-only", no_argument, NULL, 'a'},
                {"blobs", no_argument, NULL, 'b'},
@@ -266,7 +267,6 @@ main(int argc, char **argv)
 
                {NULL, 0, NULL, 0}
        };
-       int                     optindex;
 
        set_pglocale_pgservice(argv[0], "pg_dump");
 
@@ -345,8 +345,8 @@ main(int argc, char **argv)
                                pghost = optarg;
                                break;
 
-                       case 'i':                       /* ignore database version mismatch */
-                               ignore_version = true;
+                       case 'i':
+                               /* ignored, deprecated option */
                                break;
 
                        case 'n':                       /* include schema(s) */
@@ -512,20 +512,26 @@ main(int argc, char **argv)
        /* 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)
+       my_version = parse_version(PG_VERSION);
+       if (my_version < 0)
        {
                write_msg(NULL, "could not parse version string \"%s\"\n", PG_VERSION);
                exit(1);
        }
 
+       /*
+        * We allow the server to be back to 7.0, and up to any minor release
+        * of our own major version.  (See also version check in pg_dumpall.c.)
+        */
+       g_fout->minRemoteVersion = 70000;
+       g_fout->maxRemoteVersion = (my_version / 100) * 100 + 99;
+
        /*
         * Open the database using the Archiver, so it knows about it. Errors mean
         * death.
         */
        g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport,
-                                                        username, force_password, ignore_version);
+                                                        username, force_password);
 
        /* Set the client encoding if requested */
        if (dumpencoding)
@@ -739,7 +745,6 @@ help(const char *progname)
        printf(_("\nGeneral options:\n"));
        printf(_("  -f, --file=FILENAME      output file name\n"));
        printf(_("  -F, --format=c|t|p       output file format (custom, tar, plain text)\n"));
-       printf(_("  -i, --ignore-version     ignore server version mismatch\n"));
        printf(_("  -v, --verbose            verbose mode\n"));
        printf(_("  -Z, --compress=0-9       compression level for compressed formats\n"));
        printf(_("  --help                   show this help, then exit\n"));
index 90cd0f08e04d04ae0731836cd6e8b9663b5f6ae6..beacebd077c10958a155add348e824d6f0bb3107 100644 (file)
@@ -60,7 +60,6 @@ static PQExpBuffer pgdumpopts;
 static bool output_clean = false;
 static bool skip_acls = false;
 static bool verbose = false;
-static bool ignoreVersion = false;
 
 static int     disable_dollar_quoting = 0;
 static int     disable_triggers = 0;
@@ -214,8 +213,7 @@ main(int argc, char *argv[])
                                break;
 
                        case 'i':
-                               ignoreVersion = true;
-                               appendPQExpBuffer(pgdumpopts, " -i");
+                               /* ignored, deprecated option */
                                break;
 
                        case 'l':
@@ -488,7 +486,6 @@ help(void)
 
        printf(_("\nGeneral options:\n"));
        printf(_("  -f, --file=FILENAME      output file name\n"));
-       printf(_("  -i, --ignore-version     ignore server version mismatch\n"));
        printf(_("  --help                   show this help, then exit\n"));
        printf(_("  --version                output version information, then exit\n"));
        printf(_("\nOptions controlling the output content:\n"));
@@ -1391,20 +1388,18 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
                exit(1);
        }
 
+       /*
+        * We allow the server to be back to 7.0, and up to any minor release
+        * of our own major version.  (See also version check in pg_dump.c.)
+        */
        if (my_version != server_version
-               && (server_version < 70000              /* we can handle back to 7.0 */
-                       || server_version > my_version))
+               && (server_version < 70000 ||
+                       (server_version / 100) > (my_version / 100)))
        {
                fprintf(stderr, _("server version: %s; %s version: %s\n"),
                                remoteversion_str, progname, PG_VERSION);
-               if (ignoreVersion)
-                       fprintf(stderr, _("ignoring server version mismatch\n"));
-               else
-               {
-                       fprintf(stderr, _("aborting because of server version mismatch\n"
-                               "Use the -i option to bypass server version check, but be prepared for failure.\n"));
-                       exit(1);
-               }
+               fprintf(stderr, _("aborting because of server version mismatch\n"));
+               exit(1);
        }
 
        /*
index 6ab32bd18e74032e8bfcfeff49df4badb1c52bd4..899a8a4e4fa4506f7ec74faa44043146e81d8fe3 100644 (file)
@@ -171,7 +171,7 @@ main(int argc, char **argv)
                                        opts->pghost = strdup(optarg);
                                break;
                        case 'i':
-                               opts->ignoreVersion = 1;
+                               /* ignored, deprecated option */
                                break;
 
                        case 'l':                       /* Dump the TOC summary */
@@ -378,7 +378,6 @@ usage(const char *progname)
        printf(_("  -d, --dbname=NAME        connect to database name\n"));
        printf(_("  -f, --file=FILENAME      output file name\n"));
        printf(_("  -F, --format=c|t         specify backup file format\n"));
-       printf(_("  -i, --ignore-version     ignore server version mismatch\n"));
        printf(_("  -l, --list               print summarized TOC of the archive\n"));
        printf(_("  -v, --verbose            verbose mode\n"));
        printf(_("  --help                   show this help, then exit\n"));