]> granicus.if.org Git - postgresql/blobdiff - src/backend/bootstrap/bootstrap.c
lease find enclosed a patch that matches the PL/Perl documentation
[postgresql] / src / backend / bootstrap / bootstrap.c
index 41b932a653b47dffdc6527c2f16a932dfef045ae..43f694886313d09238fec6a4ce16c4c80c604e0a 100644 (file)
@@ -4,18 +4,17 @@
  *       routines to support running postgres in 'bootstrap' mode
  *     bootstrap mode is used to create the initial template database
  *
- * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.115 2001/08/25 00:31:17 petere Exp $
+ *       $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.188 2004/07/21 20:22:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 
 #include <unistd.h>
-#include <time.h>
 #include <signal.h>
 #include <setjmp.h>
 #ifdef HAVE_GETOPT_H
 #include "catalog/catname.h"
 #include "catalog/index.h"
 #include "catalog/pg_type.h"
+#include "executor/executor.h"
 #include "libpq/pqsignal.h"
 #include "miscadmin.h"
+#include "postmaster/bgwriter.h"
+#include "postmaster/pg_autovacuum.h"
+#include "storage/freespace.h"
+#include "storage/ipc.h"
+#include "storage/pg_shmem.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/builtins.h"
-#include "utils/exc.h"
 #include "utils/fmgroids.h"
 #include "utils/guc.h"
 #include "utils/lsyscache.h"
+#include "utils/ps_status.h"
 #include "utils/relcache.h"
 
 
 #define ALLOC(t, c)            ((t *) calloc((unsigned)(c), sizeof(t)))
 
-
 extern int     Int_yyparse(void);
+static void usage(void);
+static void bootstrap_signals(void);
 static hashnode *AddStr(char *str, int strlength, int mderef);
 static Form_pg_attribute AllocateAttribute(void);
-static bool BootstrapAlreadySeen(Oid id);
 static int     CompHash(char *str, int len);
 static hashnode *FindStr(char *str, int length, hashnode *mderef);
 static Oid     gettype(char *type);
@@ -58,6 +64,9 @@ static void cleanup(void);
  *             global variables
  * ----------------
  */
+
+Relation       boot_reldesc;           /* current relation descriptor */
+
 /*
  * In the lexical analyzer, we need to get the reference number quickly from
  * the string, and the string from the reference number.  Thus we have
@@ -95,31 +104,55 @@ struct typinfo
        Oid                     oid;
        Oid                     elem;
        int16           len;
+       bool            byval;
+       char            align;
+       char            storage;
        Oid                     inproc;
        Oid                     outproc;
 };
 
-static struct typinfo Procid[] = {
-       {"bool", BOOLOID, 0, 1, F_BOOLIN, F_BOOLOUT},
-       {"bytea", BYTEAOID, 0, -1, F_BYTEAIN, F_BYTEAOUT},
-       {"char", CHAROID, 0, 1, F_CHARIN, F_CHAROUT},
-       {"name", NAMEOID, 0, NAMEDATALEN, F_NAMEIN, F_NAMEOUT},
-       {"int2", INT2OID, 0, 2, F_INT2IN, F_INT2OUT},
-       {"int2vector", INT2VECTOROID, 0, INDEX_MAX_KEYS * 2, F_INT2VECTORIN, F_INT2VECTOROUT},
-       {"int4", INT4OID, 0, 4, F_INT4IN, F_INT4OUT},
-       {"regproc", REGPROCOID, 0, 4, F_REGPROCIN, F_REGPROCOUT},
-       {"text", TEXTOID, 0, -1, F_TEXTIN, F_TEXTOUT},
-       {"oid", OIDOID, 0, 4, F_OIDIN, F_OIDOUT},
-       {"tid", TIDOID, 0, 6, F_TIDIN, F_TIDOUT},
-       {"xid", XIDOID, 0, 4, F_XIDIN, F_XIDOUT},
-       {"cid", CIDOID, 0, 4, F_CIDIN, F_CIDOUT},
-       {"oidvector", 30, 0, INDEX_MAX_KEYS * 4, F_OIDVECTORIN, F_OIDVECTOROUT},
-       {"smgr", 210, 0, 2, F_SMGRIN, F_SMGROUT},
-       {"_int4", 1007, INT4OID, -1, F_ARRAY_IN, F_ARRAY_OUT},
-       {"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT}
+static const struct typinfo TypInfo[] = {
+       {"bool", BOOLOID, 0, 1, true, 'c', 'p',
+        F_BOOLIN, F_BOOLOUT},
+       {"bytea", BYTEAOID, 0, -1, false, 'i', 'x',
+        F_BYTEAIN, F_BYTEAOUT},
+       {"char", CHAROID, 0, 1, true, 'c', 'p',
+        F_CHARIN, F_CHAROUT},
+       {"name", NAMEOID, CHAROID, NAMEDATALEN, false, 'i', 'p',
+        F_NAMEIN, F_NAMEOUT},
+       {"int2", INT2OID, 0, 2, true, 's', 'p',
+        F_INT2IN, F_INT2OUT},
+       {"int4", INT4OID, 0, 4, true, 'i', 'p',
+        F_INT4IN, F_INT4OUT},
+       {"regproc", REGPROCOID, 0, 4, true, 'i', 'p',
+        F_REGPROCIN, F_REGPROCOUT},
+       {"regclass", REGCLASSOID, 0, 4, true, 'i', 'p',
+        F_REGCLASSIN, F_REGCLASSOUT},
+       {"regtype", REGTYPEOID, 0, 4, true, 'i', 'p',
+        F_REGTYPEIN, F_REGTYPEOUT},
+       {"text", TEXTOID, 0, -1, false, 'i', 'x',
+        F_TEXTIN, F_TEXTOUT},
+       {"oid", OIDOID, 0, 4, true, 'i', 'p',
+        F_OIDIN, F_OIDOUT},
+       {"tid", TIDOID, 0, 6, false, 's', 'p',
+        F_TIDIN, F_TIDOUT},
+       {"xid", XIDOID, 0, 4, true, 'i', 'p',
+        F_XIDIN, F_XIDOUT},
+       {"cid", CIDOID, 0, 4, true, 'i', 'p',
+        F_CIDIN, F_CIDOUT},
+       {"int2vector", INT2VECTOROID, INT2OID, INDEX_MAX_KEYS * 2, false, 's', 'p',
+        F_INT2VECTORIN, F_INT2VECTOROUT},
+       {"oidvector", OIDVECTOROID, OIDOID, INDEX_MAX_KEYS * 4, false, 'i', 'p',
+        F_OIDVECTORIN, F_OIDVECTOROUT},
+       {"_int4", INT4ARRAYOID, INT4OID, -1, false, 'i', 'x',
+        F_ARRAY_IN, F_ARRAY_OUT},
+       {"_text", 1009, TEXTOID, -1, false, 'i', 'x',
+        F_ARRAY_IN, F_ARRAY_OUT},
+       {"_aclitem", 1034, ACLITEMOID, -1, false, 'i', 'x',
+        F_ARRAY_IN, F_ARRAY_OUT}
 };
 
-static int     n_types = sizeof(Procid) / sizeof(struct typinfo);
+static const int       n_types = sizeof(TypInfo) / sizeof(struct typinfo);
 
 struct typmap
 {                                                              /* a hack */
@@ -127,8 +160,8 @@ struct typmap
        FormData_pg_type am_typ;
 };
 
-static struct typmap **Typ = (struct typmap **) NULL;
-static struct typmap *Ap = (struct typmap *) NULL;
+static struct typmap **Typ = NULL;
+static struct typmap *Ap = NULL;
 
 static int     Warnings = 0;
 static char Blanks[MAXATTR];
@@ -139,8 +172,6 @@ Form_pg_attribute attrtypes[MAXATTR];       /* points to attribute info */
 static Datum values[MAXATTR];  /* corresponding attribute values */
 int                    numattr;                        /* number of attributes for cur. rel */
 
-int                    DebugMode;
-
 static MemoryContext nogc = NULL;              /* special no-gc mem context */
 
 extern int     optind;
@@ -154,75 +185,38 @@ extern char *optarg;
 
 typedef struct _IndexList
 {
-       char       *il_heap;
-       char       *il_ind;
+       Oid                     il_heap;
+       Oid                     il_ind;
        IndexInfo  *il_info;
        struct _IndexList *il_next;
 } IndexList;
 
-static IndexList *ILHead = (IndexList *) NULL;
-
+static IndexList *ILHead = NULL;
 
-/* ----------------------------------------------------------------
- *                                             misc functions
- * ----------------------------------------------------------------
- */
 
-/* ----------------
- *             error handling / abort routines
- * ----------------
- */
-void
-err_out(void)
-{
-       Warnings++;
-       cleanup();
-}
-
-/* usage:
-   usage help for the bootstrap backen
-*/
-static void
-usage(void)
-{
-       fprintf(stderr,
-                       gettext("Usage:\n"
-                                       "  postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n"
-                                       "  -d               debug mode\n"
-                                       "  -D datadir       data directory\n"
-                                       "  -F               turn off fsync\n"
-                                       "  -o file          send debug output to file\n"
-                                       "  -x num           internal use\n"));
-
-       proc_exit(1);
-}
-
-
-
-int
-BootstrapMain(int argc, char *argv[])
-/* ----------------------------------------------------------------
- *      The main loop for handling the backend in bootstrap mode
- *      the bootstrap mode is used to initialize the template database
- *      the bootstrap backend doesn't speak SQL, but instead expects
+/*
+ *      The main entry point for running the backend in bootstrap mode
+ *
+ *      The bootstrap mode is used to initialize the template database.
+ *      The bootstrap backend doesn't speak SQL, but instead expects
  *      commands in a special bootstrap language.
  *
- *      The arguments passed in to BootstrapMain are the run-time arguments
- *      without the argument '-boot', the caller is required to have
- *      removed -boot from the run-time args
- * ----------------------------------------------------------------
+ *      For historical reasons, BootstrapMain is also used as the control
+ *      routine for non-backend subprocesses launched by the postmaster,
+ *      such as startup and shutdown.
  */
+int
+BootstrapMain(int argc, char *argv[])
 {
        int                     i;
-       char       *dbName;
+       char       *dbname;
        int                     flag;
        int                     xlogop = BS_XLOG_NOP;
-       char       *potential_DataDir = NULL;
+       char       *userPGDATA = NULL;
 
        /*
         * initialize globals
         */
-
        MyProcPid = getpid();
 
        /*
@@ -231,37 +225,50 @@ BootstrapMain(int argc, char *argv[])
         * If we are running under the postmaster, this is done already.
         */
        if (!IsUnderPostmaster)
-       {
-               EnableExceptionHandling(true);
                MemoryContextInit();
-       }
 
        /*
         * process command arguments
         */
 
        /* Set defaults, to be overriden by explicit options below */
-       dbName = NULL;
+       dbname = NULL;
        if (!IsUnderPostmaster)
        {
-               ResetAllOptions(true);
-               potential_DataDir = getenv("PGDATA");   /* Null if no PGDATA
-                                                                                                * variable */
+               InitializeGUCOptions();
+               userPGDATA = getenv("PGDATA");  /* Null if no PGDATA variable */
        }
 
-       while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != EOF)
+       /* Ignore the initial -boot argument, if present */
+       if (argc > 1 && strcmp(argv[1], "-boot") == 0)
+       {
+               argv++;
+               argc--;
+       }
+
+       while ((flag = getopt(argc, argv, "B:c:d:D:Fo:p:x:-:")) != -1)
        {
                switch (flag)
                {
                        case 'D':
-                               potential_DataDir = optarg;
+                               userPGDATA = optarg;
                                break;
                        case 'd':
-                               DebugMode = true;               /* print out debugging info while
-                                                                                * parsing */
+                               {
+                                       /* Turn on debugging for the bootstrap process. */
+                                       char       *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
+
+                                       sprintf(debugstr, "debug%s", optarg);
+                                       SetConfigOption("log_min_messages", debugstr,
+                                                                       PGC_POSTMASTER, PGC_S_ARGV);
+                                       SetConfigOption("client_min_messages", debugstr,
+                                                                       PGC_POSTMASTER, PGC_S_ARGV);
+                                       pfree(debugstr);
+                                       break;
+                               }
                                break;
                        case 'F':
-                               SetConfigOption("fsync", "false", PGC_POSTMASTER, true);
+                               SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
                                break;
                        case 'o':
                                StrNCpy(OutputFileName, optarg, MAXPGPATH);
@@ -270,85 +277,109 @@ BootstrapMain(int argc, char *argv[])
                                xlogop = atoi(optarg);
                                break;
                        case 'p':
-                               /* indicates fork from postmaster */
+                               dbname = strdup(optarg);
                                break;
                        case 'B':
-                               SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
+                               SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
                                break;
+                       case 'c':
+                       case '-':
+                               {
+                                       char       *name,
+                                                          *value;
+
+                                       ParseLongOption(optarg, &name, &value);
+                                       if (!value)
+                                       {
+                                               if (flag == '-')
+                                                       ereport(ERROR,
+                                                                       (errcode(ERRCODE_SYNTAX_ERROR),
+                                                                        errmsg("--%s requires a value",
+                                                                                       optarg)));
+                                               else
+                                                       ereport(ERROR,
+                                                                       (errcode(ERRCODE_SYNTAX_ERROR),
+                                                                        errmsg("-c %s requires a value",
+                                                                                       optarg)));
+                                       }
+
+                                       SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV);
+                                       free(name);
+                                       if (value)
+                                               free(value);
+                                       break;
+                               }
                        default:
                                usage();
                                break;
                }
-       }                                                       /* while */
+       }
 
-       if (argc - optind != 1)
+       if (!dbname && argc - optind == 1)
+       {
+               dbname = argv[optind];
+               optind++;
+       }
+       if (!dbname || argc != optind)
                usage();
 
-       dbName = argv[optind];
-
-       Assert(dbName);
-
        if (!IsUnderPostmaster)
        {
-               if (!potential_DataDir)
+               if (!userPGDATA)
                {
-                       fprintf(stderr, 
-                                       gettext("%s does not know where to find the database system data.\n"
-                                                       "You must specify the directory that contains the database system\n"
-                                                       "either by specifying the -D invocation option or by setting the\n"
-                                                       "PGDATA environment variable.\n\n"),
-                                       argv[0]);
+                       write_stderr("%s does not know where to find the database system data.\n"
+                                                "You must specify the directory that contains the database system\n"
+                                                "either by specifying the -D invocation option or by setting the\n"
+                                                "PGDATA environment variable.\n",
+                                                argv[0]);
                        proc_exit(1);
                }
-               SetDataDir(potential_DataDir);
+               SetDataDir(userPGDATA);
        }
+
+       /* Validate we have been given a reasonable-looking DataDir */
        Assert(DataDir);
+       ValidatePgVersion(DataDir);
 
+       /*
+        * Identify myself via ps
+        */
        if (IsUnderPostmaster)
        {
+               const char *statmsg;
 
-               /*
-                * Properly accept or ignore signals the postmaster might send us
-                */
-               pqsignal(SIGHUP, SIG_IGN);
-               pqsignal(SIGINT, SIG_IGN);              /* ignore query-cancel */
-               pqsignal(SIGTERM, die);
-               pqsignal(SIGQUIT, quickdie);
-               pqsignal(SIGALRM, SIG_IGN);
-               pqsignal(SIGPIPE, SIG_IGN);
-               pqsignal(SIGUSR1, SIG_IGN);
-               pqsignal(SIGUSR2, SIG_IGN);
-
-               /*
-                * Reset some signals that are accepted by postmaster but not here
-                */
-               pqsignal(SIGCHLD, SIG_DFL);
-               pqsignal(SIGTTIN, SIG_DFL);
-               pqsignal(SIGTTOU, SIG_DFL);
-               pqsignal(SIGCONT, SIG_DFL);
-               pqsignal(SIGWINCH, SIG_DFL);
-
-               /*
-                * Unblock signals (they were blocked when the postmaster forked
-                * us)
-                */
-               PG_SETMASK(&UnBlockSig);
+               switch (xlogop)
+               {
+                       case BS_XLOG_STARTUP:
+                               statmsg = "startup process";
+                               break;
+                       case BS_XLOG_BGWRITER:
+                               statmsg = "writer process";
+                               break;
+                       case BS_XLOG_AUTOVAC:
+                               statmsg = "auto vacuum process";
+                               break;
+                       default:
+                               statmsg = "??? process";
+                               break;
+               }
+               init_ps_display(statmsg, "", "");
+               set_ps_display("");
        }
-       else
+
+       /* Acquire configuration parameters, unless inherited from postmaster */
+       if (!IsUnderPostmaster)
        {
-               /* Set up appropriately for interactive use */
-               pqsignal(SIGHUP, die);
-               pqsignal(SIGINT, die);
-               pqsignal(SIGTERM, die);
-               pqsignal(SIGQUIT, die);
+               ProcessConfigFile(PGC_POSTMASTER);
 
-               /*
-                * Create lockfile for data directory.
-                */
-               if (!CreateDataDirLockFile(DataDir, false))
-                       proc_exit(1);
+               /* If timezone is not set, determine what the OS uses */
+               pg_timezone_initialize();
        }
 
+       /* If standalone, create lockfile for data directory */
+       if (!IsUnderPostmaster)
+               CreateDataDirLockFile(DataDir, false);
+
        SetProcessingMode(BootstrapProcessing);
        IgnoreSystemIndexes(true);
 
@@ -356,44 +387,83 @@ BootstrapMain(int argc, char *argv[])
 
        BaseInit();
 
+       /* needed to get LWLocks */
+       if (IsUnderPostmaster)
+       {
+               switch (xlogop)
+               {
+                       case BS_XLOG_BGWRITER:
+                               InitDummyProcess(DUMMY_PROC_BGWRITER);
+                               break;
+                       case BS_XLOG_AUTOVAC:
+                               InitDummyProcess(DUMMY_PROC_AUTOVAC);
+                               break;
+
+                       default:
+                               InitDummyProcess(DUMMY_PROC_DEFAULT);
+                               break;
+               }
+       }
+
        /*
         * XLOG operations
         */
        SetProcessingMode(NormalProcessing);
-       if (xlogop == BS_XLOG_NOP)
-               StartupXLOG();
-       else if (xlogop == BS_XLOG_BOOTSTRAP)
-       {
-               BootStrapXLOG();
-               StartupXLOG();
-       }
-       else
+
+       switch (xlogop)
        {
-               if (xlogop == BS_XLOG_CHECKPOINT)
-               {
-                       CreateDummyCaches();
-                       CreateCheckPoint(false);
-                       SetRedoRecPtr();
-               }
-               else if (xlogop == BS_XLOG_STARTUP)
+               case BS_XLOG_NOP:
+                       bootstrap_signals();
+                       break;
+
+               case BS_XLOG_BOOTSTRAP:
+                       bootstrap_signals();
+                       BootStrapXLOG();
                        StartupXLOG();
-               else if (xlogop == BS_XLOG_SHUTDOWN)
-                       ShutdownXLOG();
-               else
-                       elog(STOP, "Unsupported XLOG op %d", xlogop);
-               proc_exit(0);
+                       break;
+
+               case BS_XLOG_STARTUP:
+                       bootstrap_signals();
+                       StartupXLOG();
+                       LoadFreeSpaceMap();
+                       proc_exit(0);           /* startup done */
+
+               case BS_XLOG_BGWRITER:
+                       /* don't set signals, bgwriter has its own agenda */
+                       InitXLOGAccess();
+                       BackgroundWriterMain();
+                       proc_exit(1);           /* should never return */
+
+               case BS_XLOG_AUTOVAC:
+                       /* don't set signals, autovac has its own agenda */
+                       InitXLOGAccess();
+                       AutoVacMain();
+                       proc_exit(1);           /* should never return */
+               
+               default:
+                       elog(PANIC, "unrecognized XLOG op: %d", xlogop);
+                       proc_exit(1);
        }
+
        SetProcessingMode(BootstrapProcessing);
 
        /*
         * backend initialization
         */
-       InitPostgres(dbName, NULL);
-       LockDisable(true);
+       InitPostgres(dbname, NULL);
 
+       /*
+        * In NOP mode, all we really want to do is create shared memory and
+        * semaphores (just to prove we can do it with the current GUC
+        * settings). So, quit now.
+        */
+       if (xlogop == BS_XLOG_NOP)
+               proc_exit(0);
+
+       /* Initialize stuff for bootstrap-file processing */
        for (i = 0; i < MAXATTR; i++)
        {
-               attrtypes[i] = (Form_pg_attribute) NULL;
+               attrtypes[i] = NULL;
                Blanks[i] = ' ';
        }
        for (i = 0; i < STRTABLESIZE; ++i)
@@ -402,7 +472,7 @@ BootstrapMain(int argc, char *argv[])
                hashtable[i] = NULL;
 
        /*
-        * abort processing resumes here
+        * abort processing resumes here (this is probably dead code?)
         */
        if (sigsetjmp(Warn_restart, 1) != 0)
        {
@@ -411,28 +481,107 @@ BootstrapMain(int argc, char *argv[])
        }
 
        /*
-        * process input.
-        */
-
-       /*
+        * Process bootstrap input.
+        *
         * the sed script boot.sed renamed yyparse to Int_yyparse for the
         * bootstrap parser to avoid conflicts with the normal SQL parser
         */
        Int_yyparse();
 
+       /* Perform a checkpoint to ensure everything's down to disk */
        SetProcessingMode(NormalProcessing);
-       CreateCheckPoint(true);
+       CreateCheckPoint(true, true);
        SetProcessingMode(BootstrapProcessing);
 
-       /* clean up processing */
+       /* Clean up and exit */
        StartTransactionCommand();
        cleanup();
 
        /* not reached, here to make compiler happy */
        return 0;
+}
+
+
+/* ----------------------------------------------------------------
+ *                                             misc functions
+ * ----------------------------------------------------------------
+ */
+
+/* usage:
+ *             usage help for the bootstrap backend
+ */
+static void
+usage(void)
+{
+       write_stderr("Usage:\n"
+                                       "  postgres -boot [OPTION]... DBNAME\n"
+                                       "  -c NAME=VALUE    set run-time parameter\n"
+                                       "  -d 1-5           debug level\n"
+                                       "  -D datadir       data directory\n"
+                                       "  -F               turn off fsync\n"
+                                       "  -o file          send debug output to file\n"
+                                       "  -x num           internal use\n");
 
+       proc_exit(1);
 }
 
+/*
+ * Set up signal handling for a bootstrap process
+ */
+static void
+bootstrap_signals(void)
+{
+       if (IsUnderPostmaster)
+       {
+               /*
+                * Properly accept or ignore signals the postmaster might send us
+                */
+               pqsignal(SIGHUP, SIG_IGN);
+               pqsignal(SIGINT, SIG_IGN);              /* ignore query-cancel */
+               pqsignal(SIGTERM, die);
+               pqsignal(SIGQUIT, quickdie);
+               pqsignal(SIGALRM, SIG_IGN);
+               pqsignal(SIGPIPE, SIG_IGN);
+               pqsignal(SIGUSR1, SIG_IGN);
+               pqsignal(SIGUSR2, SIG_IGN);
+
+               /*
+                * Reset some signals that are accepted by postmaster but not here
+                */
+               pqsignal(SIGCHLD, SIG_DFL);
+               pqsignal(SIGTTIN, SIG_DFL);
+               pqsignal(SIGTTOU, SIG_DFL);
+               pqsignal(SIGCONT, SIG_DFL);
+               pqsignal(SIGWINCH, SIG_DFL);
+
+               /*
+                * Unblock signals (they were blocked when the postmaster forked
+                * us)
+                */
+               PG_SETMASK(&UnBlockSig);
+       }
+       else
+       {
+               /* Set up appropriately for interactive use */
+               pqsignal(SIGHUP, die);
+               pqsignal(SIGINT, die);
+               pqsignal(SIGTERM, die);
+               pqsignal(SIGQUIT, die);
+       }
+}
+
+/* ----------------
+ *             error handling / abort routines
+ * ----------------
+ */
+void
+err_out(void)
+{
+       Warnings++;
+       cleanup();
+}
+
+
 /* ----------------------------------------------------------------
  *                             MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
  * ----------------------------------------------------------------
@@ -454,23 +603,23 @@ boot_openrel(char *relname)
        if (strlen(relname) >= NAMEDATALEN - 1)
                relname[NAMEDATALEN - 1] = '\0';
 
-       if (Typ == (struct typmap **) NULL)
+       if (Typ == NULL)
        {
                rel = heap_openr(TypeRelationName, NoLock);
-               scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
+               scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
                i = 0;
-               while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+               while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
                        ++i;
                heap_endscan(scan);
                app = Typ = ALLOC(struct typmap *, i + 1);
                while (i-- > 0)
                        *app++ = ALLOC(struct typmap, 1);
-               *app = (struct typmap *) NULL;
-               scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
+               *app = NULL;
+               scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
                app = Typ;
-               while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+               while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
                {
-                       (*app)->am_oid = tup->t_data->t_oid;
+                       (*app)->am_oid = HeapTupleGetOid(tup);
                        memcpy((char *) &(*app)->am_typ,
                                   (char *) GETSTRUCT(tup),
                                   sizeof((*app)->am_typ));
@@ -480,43 +629,29 @@ boot_openrel(char *relname)
                heap_close(rel, NoLock);
        }
 
-       if (reldesc != NULL)
+       if (boot_reldesc != NULL)
                closerel(NULL);
 
-       if (DebugMode)
-               elog(DEBUG, "open relation %s, attrsize %d", relname ? relname : "(null)",
-                        (int) ATTRIBUTE_TUPLE_SIZE);
+       elog(DEBUG4, "open relation %s, attrsize %d",
+                relname ? relname : "(null)",
+                (int) ATTRIBUTE_TUPLE_SIZE);
 
-       reldesc = heap_openr(relname, NoLock);
-       numattr = reldesc->rd_rel->relnatts;
+       boot_reldesc = heap_openr(relname, NoLock);
+       numattr = boot_reldesc->rd_rel->relnatts;
        for (i = 0; i < numattr; i++)
        {
                if (attrtypes[i] == NULL)
                        attrtypes[i] = AllocateAttribute();
                memmove((char *) attrtypes[i],
-                               (char *) reldesc->rd_att->attrs[i],
+                               (char *) boot_reldesc->rd_att->attrs[i],
                                ATTRIBUTE_TUPLE_SIZE);
 
-               /* Some old pg_attribute tuples might not have attisset. */
-
-               /*
-                * If the attname is attisset, don't look for it - it may not be
-                * defined yet.
-                */
-               if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0)
-                       attrtypes[i]->attisset = get_attisset(RelationGetRelid(reldesc),
-                                                                                NameStr(attrtypes[i]->attname));
-               else
-                       attrtypes[i]->attisset = false;
-
-               if (DebugMode)
                {
                        Form_pg_attribute at = attrtypes[i];
 
-                       elog(DEBUG, "create attribute %d name %s len %d num %d type %u",
+                       elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
                                 i, NameStr(at->attname), at->attlen, at->attnum,
-                                at->atttypid
-                               );
+                                at->atttypid);
                }
        }
 }
@@ -530,26 +665,24 @@ closerel(char *name)
 {
        if (name)
        {
-               if (reldesc)
+               if (boot_reldesc)
                {
-                       if (strcmp(RelationGetRelationName(reldesc), name) != 0)
-                               elog(ERROR, "closerel: close of '%s' when '%s' was expected",
+                       if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
+                               elog(ERROR, "close of %s when %s was expected",
                                         name, relname ? relname : "(null)");
                }
                else
-                       elog(ERROR, "closerel: close of '%s' before any relation was opened",
+                       elog(ERROR, "close of %s before any relation was opened",
                                 name);
-
        }
 
-       if (reldesc == NULL)
+       if (boot_reldesc == NULL)
                elog(ERROR, "no open relation to close");
        else
        {
-               if (DebugMode)
-                       elog(DEBUG, "close relation %s", relname ? relname : "(null)");
-               heap_close(reldesc, NoLock);
-               reldesc = (Relation) NULL;
+               elog(DEBUG4, "close relation %s", relname ? relname : "(null)");
+               heap_close(boot_reldesc, NoLock);
+               boot_reldesc = NULL;
        }
 }
 
@@ -569,63 +702,71 @@ DefineAttr(char *name, char *type, int attnum)
        int                     attlen;
        Oid                     typeoid;
 
-       if (reldesc != NULL)
+       if (boot_reldesc != NULL)
        {
-               elog(DEBUG, "warning: no open relations allowed with 'create' command");
+               elog(WARNING, "no open relations allowed with CREATE command");
                closerel(relname);
        }
 
-       typeoid = gettype(type);
-       if (attrtypes[attnum] == (Form_pg_attribute) NULL)
+       if (attrtypes[attnum] == NULL)
                attrtypes[attnum] = AllocateAttribute();
-       if (Typ != (struct typmap **) NULL)
+       MemSet(attrtypes[attnum], 0, ATTRIBUTE_TUPLE_SIZE);
+
+       namestrcpy(&attrtypes[attnum]->attname, name);
+       elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
+       attrtypes[attnum]->attnum = attnum + 1;         /* fillatt */
+
+       typeoid = gettype(type);
+
+       if (Typ != NULL)
        {
                attrtypes[attnum]->atttypid = Ap->am_oid;
-               namestrcpy(&attrtypes[attnum]->attname, name);
-               if (DebugMode)
-                       elog(DEBUG, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
-               attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
                attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen;
                attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
-               attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;;
+               attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;
                attrtypes[attnum]->attalign = Ap->am_typ.typalign;
+               /* if an array type, assume 1-dimensional attribute */
+               if (Ap->am_typ.typelem != InvalidOid && Ap->am_typ.typlen < 0)
+                       attrtypes[attnum]->attndims = 1;
+               else
+                       attrtypes[attnum]->attndims = 0;
        }
        else
        {
-               attrtypes[attnum]->atttypid = Procid[typeoid].oid;
-               namestrcpy(&attrtypes[attnum]->attname, name);
-               if (DebugMode)
-                       elog(DEBUG, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
-               attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */
-               attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
-               attrtypes[attnum]->attstorage = 'p';
+               attrtypes[attnum]->atttypid = TypInfo[typeoid].oid;
+               attlen = attrtypes[attnum]->attlen = TypInfo[typeoid].len;
+               attrtypes[attnum]->attbyval = TypInfo[typeoid].byval;
+               attrtypes[attnum]->attstorage = TypInfo[typeoid].storage;
+               attrtypes[attnum]->attalign = TypInfo[typeoid].align;
+               /* if an array type, assume 1-dimensional attribute */
+               if (TypInfo[typeoid].elem != InvalidOid && attlen < 0)
+                       attrtypes[attnum]->attndims = 1;
+               else
+                       attrtypes[attnum]->attndims = 0;
+       }
+
+       attrtypes[attnum]->attstattarget = -1;
+       attrtypes[attnum]->attcacheoff = -1;
+       attrtypes[attnum]->atttypmod = -1;
+       attrtypes[attnum]->attislocal = true;
+
+       /*
+        * Mark as "not null" if type is fixed-width and prior columns are
+        * too. This corresponds to case where column can be accessed directly
+        * via C struct declaration.
+        */
+       if (attlen > 0)
+       {
+               int                     i;
 
-               /*
-                * Cheat like mad to fill in these items from the length only.
-                * This only has to work for types used in the system catalogs...
-                */
-               switch (attlen)
+               for (i = 0; i < attnum; i++)
                {
-                       case 1:
-                               attrtypes[attnum]->attbyval = true;
-                               attrtypes[attnum]->attalign = 'c';
-                               break;
-                       case 2:
-                               attrtypes[attnum]->attbyval = true;
-                               attrtypes[attnum]->attalign = 's';
-                               break;
-                       case 4:
-                               attrtypes[attnum]->attbyval = true;
-                               attrtypes[attnum]->attalign = 'i';
-                               break;
-                       default:
-                               attrtypes[attnum]->attbyval = false;
-                               attrtypes[attnum]->attalign = 'i';
+                       if (attrtypes[i]->attlen <= 0)
                                break;
                }
+               if (i == attnum)
+                       attrtypes[attnum]->attnotnull = true;
        }
-       attrtypes[attnum]->attcacheoff = -1;
-       attrtypes[attnum]->atttypmod = -1;
 }
 
 
@@ -643,19 +784,19 @@ InsertOneTuple(Oid objectid)
        TupleDesc       tupDesc;
        int                     i;
 
-       if (DebugMode)
-               elog(DEBUG, "inserting row oid %u, %d columns", objectid, numattr);
+       elog(DEBUG4, "inserting row oid %u, %d columns", objectid, numattr);
 
-       tupDesc = CreateTupleDesc(numattr, attrtypes);
+       tupDesc = CreateTupleDesc(numattr,
+                                                         RelationGetForm(boot_reldesc)->relhasoids,
+                                                         attrtypes);
        tuple = heap_formtuple(tupDesc, values, Blanks);
+       if (objectid != (Oid) 0)
+               HeapTupleSetOid(tuple, objectid);
        pfree(tupDesc);                         /* just free's tupDesc, not the attrtypes */
 
-       if (objectid != (Oid) 0)
-               tuple->t_data->t_oid = objectid;
-       heap_insert(reldesc, tuple);
+       simple_heap_insert(boot_reldesc, tuple);
        heap_freetuple(tuple);
-       if (DebugMode)
-               elog(DEBUG, "row inserted");
+       elog(DEBUG4, "row inserted");
 
        /*
         * Reset blanks for next tuple
@@ -671,67 +812,71 @@ InsertOneTuple(Oid objectid)
 void
 InsertOneValue(char *value, int i)
 {
-       int                     typeindex;
+       Oid                     typoid;
+       Oid                     typioparam;
+       Oid                     typinput;
+       Oid                     typoutput;
        char       *prt;
-       struct typmap **app;
 
        AssertArg(i >= 0 || i < MAXATTR);
 
-       if (DebugMode)
-               elog(DEBUG, "inserting column %d value '%s'", i, value);
+       elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
 
-       if (Typ != (struct typmap **) NULL)
+       if (Typ != NULL)
        {
+               struct typmap **app;
                struct typmap *ap;
 
-               if (DebugMode)
-                       elog(DEBUG, "Typ != NULL");
+               elog(DEBUG5, "Typ != NULL");
+               typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
                app = Typ;
-               while (*app && (*app)->am_oid != reldesc->rd_att->attrs[i]->atttypid)
+               while (*app && (*app)->am_oid != typoid)
                        ++app;
                ap = *app;
                if (ap == NULL)
-               {
-                       elog(FATAL, "unable to find atttypid %u in Typ list",
-                                reldesc->rd_att->attrs[i]->atttypid);
-               }
-               values[i] = OidFunctionCall3(ap->am_typ.typinput,
-                                                                        CStringGetDatum(value),
-                                                                        ObjectIdGetDatum(ap->am_typ.typelem),
-                                                                        Int32GetDatum(-1));
-               prt = DatumGetCString(OidFunctionCall3(ap->am_typ.typoutput,
-                                                                                          values[i],
-                                                                       ObjectIdGetDatum(ap->am_typ.typelem),
-                                                                                          Int32GetDatum(-1)));
-               if (DebugMode)
-                       elog(DEBUG, " -> %s", prt);
-               pfree(prt);
+                       elog(ERROR, "could not find atttypid %u in Typ list", typoid);
+
+               /* XXX this should match getTypeIOParam() */
+               if (ap->am_typ.typtype == 'c')
+                       typioparam = typoid;
+               else
+                       typioparam = ap->am_typ.typelem;
+
+               typinput = ap->am_typ.typinput;
+               typoutput = ap->am_typ.typoutput;
        }
        else
        {
+               int                     typeindex;
+
+               /* XXX why is typoid determined differently in this path? */
+               typoid = attrtypes[i]->atttypid;
                for (typeindex = 0; typeindex < n_types; typeindex++)
                {
-                       if (Procid[typeindex].oid == attrtypes[i]->atttypid)
+                       if (TypInfo[typeindex].oid == typoid)
                                break;
                }
                if (typeindex >= n_types)
-                       elog(ERROR, "type oid %u not found", attrtypes[i]->atttypid);
-               if (DebugMode)
-                       elog(DEBUG, "Typ == NULL, typeindex = %u", typeindex);
-               values[i] = OidFunctionCall3(Procid[typeindex].inproc,
-                                                                        CStringGetDatum(value),
-                                                               ObjectIdGetDatum(Procid[typeindex].elem),
-                                                                        Int32GetDatum(-1));
-               prt = DatumGetCString(OidFunctionCall3(Procid[typeindex].outproc,
-                                                                                          values[i],
-                                                               ObjectIdGetDatum(Procid[typeindex].elem),
-                                                                                          Int32GetDatum(-1)));
-               if (DebugMode)
-                       elog(DEBUG, " -> %s", prt);
-               pfree(prt);
+                       elog(ERROR, "type oid %u not found", typoid);
+               elog(DEBUG5, "Typ == NULL, typeindex = %u", typeindex);
+
+               /* XXX there are no composite types in TypInfo */
+               typioparam = TypInfo[typeindex].elem;
+
+               typinput = TypInfo[typeindex].inproc;
+               typoutput = TypInfo[typeindex].outproc;
        }
-       if (DebugMode)
-               elog(DEBUG, "inserted");
+
+       values[i] = OidFunctionCall3(typinput,
+                                                                CStringGetDatum(value),
+                                                                ObjectIdGetDatum(typioparam),
+                                                                Int32GetDatum(-1));
+       prt = DatumGetCString(OidFunctionCall3(typoutput,
+                                                                                  values[i],
+                                                                                  ObjectIdGetDatum(typioparam),
+                                                                                  Int32GetDatum(-1)));
+       elog(DEBUG4, "inserted -> %s", prt);
+       pfree(prt);
 }
 
 /* ----------------
@@ -741,47 +886,18 @@ InsertOneValue(char *value, int i)
 void
 InsertOneNull(int i)
 {
-       if (DebugMode)
-               elog(DEBUG, "inserting column %d NULL", i);
+       elog(DEBUG4, "inserting column %d NULL", i);
        Assert(i >= 0 || i < MAXATTR);
        values[i] = PointerGetDatum(NULL);
        Blanks[i] = 'n';
 }
 
-#define MORE_THAN_THE_NUMBER_OF_CATALOGS 256
-
-static bool
-BootstrapAlreadySeen(Oid id)
-{
-       static Oid      seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS];
-       static int      nseen = 0;
-       bool            seenthis;
-       int                     i;
-
-       seenthis = false;
-
-       for (i = 0; i < nseen; i++)
-       {
-               if (seenArray[i] == id)
-               {
-                       seenthis = true;
-                       break;
-               }
-       }
-       if (!seenthis)
-       {
-               seenArray[nseen] = id;
-               nseen++;
-       }
-       return seenthis;
-}
-
 /* ----------------
  *             cleanup
  * ----------------
  */
 static void
-cleanup()
+cleanup(void)
 {
        static int      beenhere = 0;
 
@@ -789,17 +905,24 @@ cleanup()
                beenhere = 1;
        else
        {
-               elog(FATAL, "Memory manager fault: cleanup called twice.\n");
+               elog(FATAL, "cleanup called twice");
                proc_exit(1);
        }
-       if (reldesc != (Relation) NULL)
-               heap_close(reldesc, NoLock);
+       if (boot_reldesc != NULL)
+               closerel(NULL);
        CommitTransactionCommand();
-       proc_exit(Warnings);
+       proc_exit(Warnings ? 1 : 0);
 }
 
 /* ----------------
  *             gettype
+ *
+ * NB: this is really ugly; it will return an integer index into TypInfo[],
+ * and not an OID at all, until the first reference to a type not known in
+ * TypInfo[].  At that point it will read and cache pg_type in the Typ array,
+ * and subsequently return a real OID (and set the global pointer Ap to
+ * point at the found row in Typ).     So caller must check whether Typ is
+ * still NULL to determine what the return value is!
  * ----------------
  */
 static Oid
@@ -811,9 +934,9 @@ gettype(char *type)
        HeapTuple       tup;
        struct typmap **app;
 
-       if (Typ != (struct typmap **) NULL)
+       if (Typ != NULL)
        {
-               for (app = Typ; *app != (struct typmap *) NULL; app++)
+               for (app = Typ; *app != NULL; app++)
                {
                        if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
                        {
@@ -824,28 +947,27 @@ gettype(char *type)
        }
        else
        {
-               for (i = 0; i <= n_types; i++)
+               for (i = 0; i < n_types; i++)
                {
-                       if (strncmp(type, Procid[i].name, NAMEDATALEN) == 0)
+                       if (strncmp(type, TypInfo[i].name, NAMEDATALEN) == 0)
                                return i;
                }
-               if (DebugMode)
-                       elog(DEBUG, "external type: %s", type);
+               elog(DEBUG4, "external type: %s", type);
                rel = heap_openr(TypeRelationName, NoLock);
-               scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
+               scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
                i = 0;
-               while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+               while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
                        ++i;
                heap_endscan(scan);
                app = Typ = ALLOC(struct typmap *, i + 1);
                while (i-- > 0)
                        *app++ = ALLOC(struct typmap, 1);
-               *app = (struct typmap *) NULL;
-               scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
+               *app = NULL;
+               scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
                app = Typ;
-               while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+               while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
                {
-                       (*app)->am_oid = tup->t_data->t_oid;
+                       (*app)->am_oid = HeapTupleGetOid(tup);
                        memmove((char *) &(*app++)->am_typ,
                                        (char *) GETSTRUCT(tup),
                                        sizeof((*app)->am_typ));
@@ -854,7 +976,7 @@ gettype(char *type)
                heap_close(rel, NoLock);
                return gettype(type);
        }
-       elog(ERROR, "Error: unknown type '%s'.\n", type);
+       elog(ERROR, "unrecognized type \"%s\"", type);
        err_out();
        /* not reached, here to make compiler happy */
        return 0;
@@ -864,13 +986,13 @@ gettype(char *type)
  *             AllocateAttribute
  * ----------------
  */
-static Form_pg_attribute               /* XXX */
-AllocateAttribute()
+static Form_pg_attribute
+AllocateAttribute(void)
 {
        Form_pg_attribute attribute = (Form_pg_attribute) malloc(ATTRIBUTE_TUPLE_SIZE);
 
        if (!PointerIsValid(attribute))
-               elog(FATAL, "AllocateAttribute: malloc failed");
+               elog(FATAL, "out of memory");
        MemSet(attribute, 0, ATTRIBUTE_TUPLE_SIZE);
 
        return attribute;
@@ -984,7 +1106,6 @@ FindStr(char *str, int length, hashnode *mderef)
        node = hashtable[CompHash(str, length)];
        while (node != NULL)
        {
-
                /*
                 * We must differentiate between string constants that might have
                 * the same value as a identifier and the identifier itself.
@@ -1018,14 +1139,8 @@ AddStr(char *str, int strlength, int mderef)
        int                     hashresult;
        int                     len;
 
-       if (++strtable_end == STRTABLESIZE)
-       {
-               /* Error, string table overflow, so we Punt */
-               elog(FATAL,
-                        "There are too many string constants and identifiers for the compiler to handle.");
-
-
-       }
+       if (++strtable_end >= STRTABLESIZE)
+               elog(FATAL, "bootstrap string table overflow");
 
        /*
         * Some of the utilites (eg, define type, create relation) assume that
@@ -1079,8 +1194,8 @@ AddStr(char *str, int strlength, int mderef)
  *             are present in the index.
  */
 void
-index_register(char *heap,
-                          char *ind,
+index_register(Oid heap,
+                          Oid ind,
                           IndexInfo *indexInfo)
 {
        IndexList  *newind;
@@ -1093,7 +1208,7 @@ index_register(char *heap,
         */
 
        if (nogc == NULL)
-               nogc = AllocSetContextCreate((MemoryContext) NULL,
+               nogc = AllocSetContextCreate(NULL,
                                                                         "BootstrapNoGC",
                                                                         ALLOCSET_DEFAULT_MINSIZE,
                                                                         ALLOCSET_DEFAULT_INITSIZE,
@@ -1102,14 +1217,19 @@ index_register(char *heap,
        oldcxt = MemoryContextSwitchTo(nogc);
 
        newind = (IndexList *) palloc(sizeof(IndexList));
-       newind->il_heap = pstrdup(heap);
-       newind->il_ind = pstrdup(ind);
+       newind->il_heap = heap;
+       newind->il_ind = ind;
        newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
 
        memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
+       /* expressions will likely be null, but may as well copy it */
+       newind->il_info->ii_Expressions = (List *)
+               copyObject(indexInfo->ii_Expressions);
+       newind->il_info->ii_ExpressionsState = NIL;
        /* predicate will likely be null, but may as well copy it */
        newind->il_info->ii_Predicate = (List *)
                copyObject(indexInfo->ii_Predicate);
+       newind->il_info->ii_PredicateState = NIL;
 
        newind->il_next = ILHead;
        ILHead = newind;
@@ -1118,15 +1238,15 @@ index_register(char *heap,
 }
 
 void
-build_indices()
+build_indices(void)
 {
-       for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
+       for (; ILHead != NULL; ILHead = ILHead->il_next)
        {
                Relation        heap;
                Relation        ind;
 
-               heap = heap_openr(ILHead->il_heap, NoLock);
-               ind = index_openr(ILHead->il_ind);
+               heap = heap_open(ILHead->il_heap, NoLock);
+               ind = index_open(ILHead->il_ind);
                index_build(heap, ind, ILHead->il_info);
 
                /*
@@ -1134,25 +1254,6 @@ build_indices()
                 * index, but in bootstrap mode it will not.
                 */
 
-               /*
-                * All of the rest of this routine is needed only because in
-                * bootstrap processing we don't increment xact id's.  The normal
-                * DefineIndex code replaces a pg_class tuple with updated info
-                * including the relhasindex flag (which we need to have updated).
-                * Unfortunately, there are always two indices defined on each
-                * catalog causing us to update the same pg_class tuple twice for
-                * each catalog getting an index during bootstrap resulting in the
-                * ghost tuple problem (see heap_update).       To get around this we
-                * change the relhasindex field ourselves in this routine keeping
-                * track of what catalogs we already changed so that we don't
-                * modify those tuples twice.  The normal mechanism for updating
-                * pg_class is disabled during bootstrap.
-                *
-                * -mer
-                */
-               if (!BootstrapAlreadySeen(RelationGetRelid(heap)))
-                       UpdateStats(RelationGetRelid(heap), 0);
-
                /* XXX Probably we ought to close the heap and index here? */
        }
 }