Add postmaster/postgres undocumented -b option for binary upgrades.
authorBruce Momjian <bruce@momjian.us>
Mon, 25 Apr 2011 16:00:21 +0000 (12:00 -0400)
committerBruce Momjian <bruce@momjian.us>
Mon, 25 Apr 2011 16:00:21 +0000 (12:00 -0400)
This option turns off autovacuum, prevents non-super-user connections,
and enables oid setting hooks in the backend.  The code continues to use
the old autoavacuum disable settings for servers with earlier catalog
versions.

This includes a catalog version bump to identify servers that support
the -b option.

16 files changed:
contrib/pg_upgrade/check.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/server.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/pg_enum.c
src/backend/catalog/pg_type.c
src/backend/catalog/toasting.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/backend/utils/init/globals.c
src/backend/utils/init/postinit.c
src/include/catalog/catversion.h
src/include/miscadmin.h

index d1dc5dbeaacc0f61812814536cc6c78299fcdc5a..415f95b616d19099bb4a6a301a5aad9d5e82cd79 100644 (file)
@@ -264,7 +264,7 @@ check_cluster_compatibility(bool live_check)
 
        /* Is it 9.0 but without tablespace directories? */
        if (GET_MAJOR_VERSION(new_cluster.major_version) == 900 &&
-               new_cluster.controldata.cat_ver < TABLE_SPACE_SUBDIRS)
+               new_cluster.controldata.cat_ver < TABLE_SPACE_SUBDIRS_CAT_VER)
                pg_log(PG_FATAL, "This utility can only upgrade to PostgreSQL version 9.0 after 2010-01-11\n"
                           "because of backend API changes made during development.\n");
 }
index 5ca570eb157c7e7287464025d7d526a59c568b89..5865315d9e4f44afa36d52502f9ab93fda082931 100644 (file)
@@ -58,7 +58,9 @@
 #define atooid(x)  ((Oid) strtoul((x), NULL, 10))
 
 /* OID system catalog preservation added during PG 9.0 development */
-#define TABLE_SPACE_SUBDIRS 201001111
+#define TABLE_SPACE_SUBDIRS_CAT_VER 201001111
+/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
+#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
 
 /*
  * Each relation is represented by a relinfo structure.
index 2a0f50eb2a22b4907e8d462db169530e1f251ea0..ab8d8c73342c634ecc2f30c0780bc696aefc2fa8 100644 (file)
@@ -173,6 +173,11 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
        const char *datadir;
        unsigned short port;
        bool            exit_hook_registered = false;
+#ifndef WIN32
+       char            *output_filename = log_opts.filename;
+#else
+       char            *output_filename = DEVNULL;
+#endif
 
        bindir = cluster->bindir;
        datadir = cluster->pgdata;
@@ -193,7 +198,6 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
         * same file because we get the error: "The process cannot access the file
         * because it is being used by another process." so we have to send all
         * other output to 'nul'.
-        *
         * Using autovacuum=off disables cleanup vacuum and analyze, but freeze
         * vacuums can still happen, so we set autovacuum_freeze_max_age to its
         * maximum.  We assume all datfrozenxid and relfrozen values are less than
@@ -202,15 +206,13 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
         */
        snprintf(cmd, sizeof(cmd),
                         SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
-                        "-o \"-p %d -c autovacuum=off "
-                        "-c autovacuum_freeze_max_age=2000000000\" "
-                        "start >> \"%s\" 2>&1" SYSTEMQUOTE,
-                        bindir,
-#ifndef WIN32
-                        log_opts.filename, datadir, port, log_opts.filename);
-#else
-                        DEVNULL, datadir, port, DEVNULL);
-#endif
+                        "-o \"-p %d %s\" start >> \"%s\" 2>&1" SYSTEMQUOTE,
+                        bindir, output_filename, datadir, port,
+                        (cluster->controldata.cat_ver >=
+                               BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
+                               "-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
+                        log_opts.filename);
+
        exec_prog(true, "%s", cmd);
 
        /* wait for the server to start properly */
index 28d5c549a32d3eff46dd39ca391a90e1437c93f5..4c089677030d391f5a0e8e8ede24566e558359de 100644 (file)
@@ -1053,7 +1053,8 @@ heap_create_with_catalog(const char *relname,
                 * Use binary-upgrade override for pg_class.oid/relfilenode, if
                 * supplied.
                 */
-               if (OidIsValid(binary_upgrade_next_heap_pg_class_oid) &&
+               if (IsBinaryUpgrade &&
+                       OidIsValid(binary_upgrade_next_heap_pg_class_oid) &&
                        (relkind == RELKIND_RELATION || relkind == RELKIND_SEQUENCE ||
                         relkind == RELKIND_VIEW || relkind == RELKIND_COMPOSITE_TYPE ||
                         relkind == RELKIND_FOREIGN_TABLE))
@@ -1061,7 +1062,8 @@ heap_create_with_catalog(const char *relname,
                        relid = binary_upgrade_next_heap_pg_class_oid;
                        binary_upgrade_next_heap_pg_class_oid = InvalidOid;
                }
-               else if (OidIsValid(binary_upgrade_next_toast_pg_class_oid) &&
+               else if (IsBinaryUpgrade &&
+                                OidIsValid(binary_upgrade_next_toast_pg_class_oid) &&
                                 relkind == RELKIND_TOASTVALUE)
                {
                        relid = binary_upgrade_next_toast_pg_class_oid;
index bc630a6f3ac9e9a3f3bc45e08e70563b9ae2960e..a0898e00488a84d963239fbf847d07a5d1b65145 100644 (file)
@@ -789,7 +789,8 @@ index_create(Relation heapRelation,
                 * Use binary-upgrade override for pg_class.oid/relfilenode, if
                 * supplied.
                 */
-               if (OidIsValid(binary_upgrade_next_index_pg_class_oid))
+               if (IsBinaryUpgrade &&
+                       OidIsValid(binary_upgrade_next_index_pg_class_oid))
                {
                        indexRelationId = binary_upgrade_next_index_pg_class_oid;
                        binary_upgrade_next_index_pg_class_oid = InvalidOid;
index 08d8aa13f332d6058572a51b4eff1d9871afed68..61a9322d901bda96fe55e799658c527d34057a18 100644 (file)
@@ -21,6 +21,7 @@
 #include "catalog/pg_enum.h"
 #include "catalog/pg_type.h"
 #include "storage/lmgr.h"
+#include "miscadmin.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/rel.h"
@@ -311,7 +312,7 @@ restart:
        }
 
        /* Get a new OID for the new label */
-       if (OidIsValid(binary_upgrade_next_pg_enum_oid))
+       if (IsBinaryUpgrade && OidIsValid(binary_upgrade_next_pg_enum_oid))
        {
                /*
                 * Use binary-upgrade override for pg_enum.oid, if supplied. During
index b6912578786060b4da2bc94eb682b54b64db8215..de5c63defe5f292d08145fdb543e93ee4acced4b 100644 (file)
@@ -125,7 +125,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
        tup = heap_form_tuple(tupDesc, values, nulls);