1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* bootstrap.c
|
1997-09-07 05:04:48 +00:00
|
|
|
* routines to support running postgres in 'bootstrap' mode
|
|
|
|
* bootstrap mode is used to create the initial template database
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2002-06-20 20:29:54 +00:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2002-09-25 20:31:40 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.143 2002/09/25 20:31:40 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2000-11-04 12:43:24 +00:00
|
|
|
#include "postgres.h"
|
|
|
|
|
1999-07-16 03:14:30 +00:00
|
|
|
#include <unistd.h>
|
1996-10-23 07:42:13 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <setjmp.h>
|
1999-07-19 02:27:16 +00:00
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
#include <getopt.h>
|
|
|
|
#endif
|
1998-04-26 04:12:15 +00:00
|
|
|
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
#define BOOTSTRAP_INCLUDE /* mask out stuff in tcop/tcopprot.h */
|
|
|
|
|
1998-04-26 04:12:15 +00:00
|
|
|
#include "access/genam.h"
|
|
|
|
#include "access/heapam.h"
|
2000-11-21 21:16:06 +00:00
|
|
|
#include "access/xlog.h"
|
1998-04-26 04:12:15 +00:00
|
|
|
#include "bootstrap/bootstrap.h"
|
|
|
|
#include "catalog/catname.h"
|
|
|
|
#include "catalog/index.h"
|
|
|
|
#include "catalog/pg_type.h"
|
|
|
|
#include "libpq/pqsignal.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "miscadmin.h"
|
2002-05-05 00:03:29 +00:00
|
|
|
#include "storage/ipc.h"
|
2001-09-29 04:02:27 +00:00
|
|
|
#include "storage/proc.h"
|
1998-04-26 04:12:15 +00:00
|
|
|
#include "tcop/tcopprot.h"
|
|
|
|
#include "utils/builtins.h"
|
2000-05-28 17:56:29 +00:00
|
|
|
#include "utils/fmgroids.h"
|
2000-06-22 22:31:24 +00:00
|
|
|
#include "utils/guc.h"
|
1998-04-26 04:12:15 +00:00
|
|
|
#include "utils/lsyscache.h"
|
2000-11-21 21:16:06 +00:00
|
|
|
#include "utils/relcache.h"
|
2000-06-28 03:33:33 +00:00
|
|
|
|
1996-10-21 08:31:23 +00:00
|
|
|
|
2000-06-05 07:29:25 +00:00
|
|
|
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1999-10-06 21:58:18 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
extern int Int_yyparse(void);
|
1997-08-19 21:40:56 +00:00
|
|
|
static hashnode *AddStr(char *str, int strlength, int mderef);
|
1998-09-01 03:29:17 +00:00
|
|
|
static Form_pg_attribute AllocateAttribute(void);
|
1997-09-08 02:41:22 +00:00
|
|
|
static bool BootstrapAlreadySeen(Oid id);
|
|
|
|
static int CompHash(char *str, int len);
|
1997-09-08 21:56:23 +00:00
|
|
|
static hashnode *FindStr(char *str, int length, hashnode *mderef);
|
1998-08-24 19:04:04 +00:00
|
|
|
static Oid gettype(char *type);
|
1997-09-08 02:41:22 +00:00
|
|
|
static void cleanup(void);
|
1996-10-23 07:42:13 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* global variables
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
2002-04-27 21:24:34 +00:00
|
|
|
|
|
|
|
Relation boot_reldesc; /* current relation descriptor */
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* as our data structure a hash table, where the hashing key taken from
|
|
|
|
* the particular string. The hash table is chained. One of the fields
|
|
|
|
* of the hash table node is an index into the array of character pointers.
|
|
|
|
* The unique index number that every string is assigned is simply the
|
|
|
|
* position of its string pointer in the array of string pointers.
|
|
|
|
*/
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
#define STRTABLESIZE 10000
|
|
|
|
#define HASHTABLESIZE 503
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/* Hash function numbers */
|
1997-09-07 05:04:48 +00:00
|
|
|
#define NUM 23
|
|
|
|
#define NUMSQR 529
|
1996-11-14 10:25:54 +00:00
|
|
|
#define NUMCUBE 12167
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
char *strtable[STRTABLESIZE];
|
|
|
|
hashnode *hashtable[HASHTABLESIZE];
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static int strtable_end = -1; /* Tells us last occupied string space */
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Basic information associated with each type. This is used before
|
|
|
|
* pg_type is created.
|
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* XXX several of these input/output functions do catalog scans
|
|
|
|
* (e.g., F_REGPROCIN scans pg_proc). this obviously creates some
|
|
|
|
* order dependencies in the catalog creation process.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1997-09-07 05:04:48 +00:00
|
|
|
struct typinfo
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
char name[NAMEDATALEN];
|
|
|
|
Oid oid;
|
|
|
|
Oid elem;
|
|
|
|
int16 len;
|
|
|
|
Oid inproc;
|
|
|
|
Oid outproc;
|
1996-07-09 06:22:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct typinfo Procid[] = {
|
2000-01-11 04:00:30 +00:00
|
|
|
{"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},
|
2000-04-12 17:17:23 +00:00
|
|
|
{"int2vector", INT2VECTOROID, 0, INDEX_MAX_KEYS * 2, F_INT2VECTORIN, F_INT2VECTOROUT},
|
2000-01-11 04:00:30 +00:00
|
|
|
{"int4", INT4OID, 0, 4, F_INT4IN, F_INT4OUT},
|
|
|
|
{"regproc", REGPROCOID, 0, 4, F_REGPROCIN, F_REGPROCOUT},
|
2002-04-25 02:56:56 +00:00
|
|
|
{"regclass", REGCLASSOID, 0, 4, F_REGCLASSIN, F_REGCLASSOUT},
|
|
|
|
{"regtype", REGTYPEOID, 0, 4, F_REGTYPEIN, F_REGTYPEOUT},
|
2000-01-11 04:00:30 +00:00
|
|
|
{"text", TEXTOID, 0, -1, F_TEXTIN, F_TEXTOUT},
|
2000-06-05 07:29:25 +00:00
|
|
|
{"oid", OIDOID, 0, 4, F_OIDIN, F_OIDOUT},
|
2000-01-11 04:00:30 +00:00
|
|
|
{"tid", TIDOID, 0, 6, F_TIDIN, F_TIDOUT},
|
|
|
|
{"xid", XIDOID, 0, 4, F_XIDIN, F_XIDOUT},
|
|
|
|
{"cid", CIDOID, 0, 4, F_CIDIN, F_CIDOUT},
|
2002-04-25 02:56:56 +00:00
|
|
|
{"oidvector", OIDVECTOROID, 0, INDEX_MAX_KEYS * 4, F_OIDVECTORIN, F_OIDVECTOROUT},
|
1997-09-07 05:04:48 +00:00
|
|
|
{"smgr", 210, 0, 2, F_SMGRIN, F_SMGROUT},
|
2000-01-11 04:00:30 +00:00
|
|
|
{"_int4", 1007, INT4OID, -1, F_ARRAY_IN, F_ARRAY_OUT},
|
1997-09-07 05:04:48 +00:00
|
|
|
{"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT}
|
1996-07-09 06:22:35 +00:00
|
|
|
};
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static int n_types = sizeof(Procid) / sizeof(struct typinfo);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
struct typmap
|
|
|
|
{ /* a hack */
|
1997-09-08 02:41:22 +00:00
|
|
|
Oid am_oid;
|
1998-09-01 03:29:17 +00:00
|
|
|
FormData_pg_type am_typ;
|
1996-07-09 06:22:35 +00:00
|
|
|
};
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
static struct typmap **Typ = (struct typmap **) NULL;
|
|
|
|
static struct typmap *Ap = (struct typmap *) NULL;
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static int Warnings = 0;
|
|
|
|
static char Blanks[MAXATTR];
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static char *relname; /* current relation name */
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
|
2000-05-30 04:25:00 +00:00
|
|
|
static Datum values[MAXATTR]; /* corresponding attribute values */
|
1997-09-08 02:41:22 +00:00
|
|
|
int numattr; /* number of attributes for cur. rel */
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2001-03-22 06:16:21 +00:00
|
|
|
static MemoryContext nogc = NULL; /* special no-gc mem context */
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
extern int optind;
|
|
|
|
extern char *optarg;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
1997-09-07 05:04:48 +00:00
|
|
|
* At bootstrap time, we first declare all the indices to be built, and
|
|
|
|
* then build them. The IndexList structure stores enough information
|
|
|
|
* to allow us to build the indices after they've been declared.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
typedef struct _IndexList
|
|
|
|
{
|
2002-03-26 19:17:02 +00:00
|
|
|
Oid il_heap;
|
|
|
|
Oid il_ind;
|
2000-07-14 22:18:02 +00:00
|
|
|
IndexInfo *il_info;
|
1997-09-07 05:04:48 +00:00
|
|
|
struct _IndexList *il_next;
|
1997-09-08 21:56:23 +00:00
|
|
|
} IndexList;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
static IndexList *ILHead = (IndexList *) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* misc functions
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* error handling / abort routines
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1996-10-23 07:42:13 +00:00
|
|
|
void
|
|
|
|
err_out(void)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-07 05:04:48 +00:00
|
|
|
Warnings++;
|
|
|
|
cleanup();
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* usage:
|
|
|
|
usage help for the bootstrap backen
|
|
|
|
*/
|
|
|
|
static void
|
1996-10-23 07:42:13 +00:00
|
|
|
usage(void)
|
1996-10-21 08:31:23 +00:00
|
|
|
{
|
2001-06-03 14:53:56 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
gettext("Usage:\n"
|
2002-09-04 20:31:48 +00:00
|
|
|
" postgres -boot [-d level] [-D datadir] [-F] [-o file] [-x num] dbname\n"
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
" -d 1-5 debug mode\n"
|
2001-06-03 14:53:56 +00:00
|
|
|
" -D datadir data directory\n"
|
|
|
|
" -F turn off fsync\n"
|
2001-08-25 00:31:17 +00:00
|
|
|
" -o file send debug output to file\n"
|
2001-06-03 14:53:56 +00:00
|
|
|
" -x num internal use\n"));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-06-27 04:53:49 +00:00
|
|
|
proc_exit(1);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1996-11-14 10:25:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
BootstrapMain(int argc, char *argv[])
|
1996-07-09 06:22:35 +00:00
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* 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
|
|
|
|
* commands in a special bootstrap language.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* 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
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int i;
|
|
|
|
char *dbName;
|
|
|
|
int flag;
|
2000-11-09 11:26:00 +00:00
|
|
|
int xlogop = BS_XLOG_NOP;
|
2001-03-22 06:16:21 +00:00
|
|
|
char *potential_DataDir = NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2001-03-22 06:16:21 +00:00
|
|
|
/*
|
|
|
|
* initialize globals
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
|
|
|
|
1998-01-25 05:15:15 +00:00
|
|
|
MyProcPid = getpid();
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-06-28 03:33:33 +00:00
|
|
|
/*
|
|
|
|
* Fire up essential subsystems: error and memory management
|
|
|
|
*
|
|
|
|
* If we are running under the postmaster, this is done already.
|
|
|
|
*/
|
|
|
|
if (!IsUnderPostmaster)
|
|
|
|
MemoryContextInit();
|
|
|
|
|
2001-03-22 06:16:21 +00:00
|
|
|
/*
|
|
|
|
* process command arguments
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Set defaults, to be overriden by explicit options below */
|
|
|
|
dbName = NULL;
|
2000-06-22 22:31:24 +00:00
|
|
|
if (!IsUnderPostmaster)
|
|
|
|
{
|
2002-05-17 01:19:19 +00:00
|
|
|
InitializeGUCOptions();
|
2002-08-17 15:12:07 +00:00
|
|
|
potential_DataDir = getenv("PGDATA"); /* Null if no PGDATA
|
|
|
|
* variable */
|
2000-06-22 22:31:24 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2002-08-17 15:12:07 +00:00
|
|
|
while ((flag = getopt(argc, argv, "B:d:D:Fo:px:")) != -1)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
|
|
|
switch (flag)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
case 'D':
|
2000-11-04 12:43:24 +00:00
|
|
|
potential_DataDir = optarg;
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2002-09-04 20:31:48 +00:00
|
|
|
{
|
|
|
|
/* Turn on debugging for the bootstrap process. */
|
|
|
|
char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
|
|
|
|
|
|
|
|
sprintf(debugstr, "debug%s", optarg);
|
|
|
|
SetConfigOption("server_min_messages", debugstr,
|
|
|
|
PGC_POSTMASTER, PGC_S_ARGV);
|
|
|
|
SetConfigOption("client_min_messages", debugstr,
|
|
|
|
PGC_POSTMASTER, PGC_S_ARGV);
|
|
|
|
pfree(debugstr);
|
|
|
|
break;
|
|
|
|
}
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
|
|
|
case 'F':
|
2002-02-23 01:31:37 +00:00
|
|
|
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
2001-08-25 00:31:17 +00:00
|
|
|
case 'o':
|
|
|
|
StrNCpy(OutputFileName, optarg, MAXPGPATH);
|
|
|
|
break;
|
1999-10-06 21:58:18 +00:00
|
|
|
case 'x':
|
2000-11-09 11:26:00 +00:00
|
|
|
xlogop = atoi(optarg);
|
1999-10-06 21:58:18 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
2000-06-22 22:31:24 +00:00
|
|
|
/* indicates fork from postmaster */
|
1999-10-06 21:58:18 +00:00
|
|
|
break;
|
|
|
|
case 'B':
|
2002-02-23 01:31:37 +00:00
|
|
|
SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
break;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
} /* while */
|
|
|
|
|
2001-05-12 01:48:49 +00:00
|
|
|
if (argc - optind != 1)
|
1997-09-07 05:04:48 +00:00
|
|
|
usage();
|
|
|
|
|
2001-05-12 01:48:49 +00:00
|
|
|
dbName = argv[optind];
|
|
|
|
|
|
|
|
Assert(dbName);
|
1999-10-06 21:58:18 +00:00
|
|
|
|
2000-11-04 12:43:24 +00:00
|
|
|
if (!IsUnderPostmaster)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2000-11-04 12:43:24 +00:00
|
|
|
if (!potential_DataDir)
|
|
|
|
{
|
2001-10-25 05:50:21 +00:00
|
|
|
fprintf(stderr,
|
2001-06-03 14:53:56 +00:00
|
|
|
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"),
|
2000-11-04 12:43:24 +00:00
|
|
|
argv[0]);
|
|
|
|
proc_exit(1);
|
|
|
|
}
|
|
|
|
SetDataDir(potential_DataDir);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2001-10-19 17:03:08 +00:00
|
|
|
|
|
|
|
/* Validate we have been given a reasonable-looking DataDir */
|
2000-11-04 12:43:24 +00:00
|
|
|
Assert(DataDir);
|
2001-10-19 17:03:08 +00:00
|
|
|
ValidatePgVersion(DataDir);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
if (IsUnderPostmaster)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
/*
|
|
|
|
* Properly accept or ignore signals the postmaster might send us
|
|
|
|
*/
|
|
|
|
pqsignal(SIGHUP, SIG_IGN);
|
2001-03-22 06:16:21 +00:00
|
|
|
pqsignal(SIGINT, SIG_IGN); /* ignore query-cancel */
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
pqsignal(SIGTERM, die);
|
|
|
|
pqsignal(SIGQUIT, quickdie);
|
2001-08-04 00:14:43 +00:00
|
|
|
pqsignal(SIGALRM, SIG_IGN);
|
|
|
|
pqsignal(SIGPIPE, SIG_IGN);
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
pqsignal(SIGUSR1, SIG_IGN);
|
|
|
|
pqsignal(SIGUSR2, SIG_IGN);
|
2001-03-22 06:16:21 +00:00
|
|
|
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
/*
|
|
|
|
* Reset some signals that are accepted by postmaster but not here
|
|
|
|
*/
|
2001-08-04 00:14:43 +00:00
|
|
|
pqsignal(SIGCHLD, SIG_DFL);
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
pqsignal(SIGTTIN, SIG_DFL);
|
|
|
|
pqsignal(SIGTTOU, SIG_DFL);
|
|
|
|
pqsignal(SIGCONT, SIG_DFL);
|
|
|
|
pqsignal(SIGWINCH, SIG_DFL);
|
2001-03-22 06:16:21 +00:00
|
|
|
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
/*
|
2001-03-22 06:16:21 +00:00
|
|
|
* Unblock signals (they were blocked when the postmaster forked
|
|
|
|
* us)
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
*/
|
|
|
|
PG_SETMASK(&UnBlockSig);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
else
|
1999-10-06 21:58:18 +00:00
|
|
|
{
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
/* Set up appropriately for interactive use */
|
2001-01-14 05:08:17 +00:00
|
|
|
pqsignal(SIGHUP, die);
|
|
|
|
pqsignal(SIGINT, die);
|
|
|
|
pqsignal(SIGTERM, die);
|
|
|
|
pqsignal(SIGQUIT, die);
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create lockfile for data directory.
|
|
|
|
*/
|
2001-03-22 06:16:21 +00:00
|
|
|
if (!CreateDataDirLockFile(DataDir, false))
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
proc_exit(1);
|
1999-10-06 21:58:18 +00:00
|
|
|
}
|
|
|
|
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
2001-03-13 01:17:06 +00:00
|
|
|
SetProcessingMode(BootstrapProcessing);
|
|
|
|
IgnoreSystemIndexes(true);
|
|
|
|
|
|
|
|
XLOGPathInit();
|
|
|
|
|
|
|
|
BaseInit();
|
|
|
|
|
2002-09-25 20:31:40 +00:00
|
|
|
if (IsUnderPostmaster)
|
|
|
|
InitDummyProcess(); /* needed to get LWLocks */
|
|
|
|
|
1999-10-06 21:58:18 +00:00
|
|
|
/*
|
2000-11-09 11:26:00 +00:00
|
|
|
* XLOG operations
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-11-21 09:39:57 +00:00
|
|
|
SetProcessingMode(NormalProcessing);
|
2001-09-29 04:02:27 +00:00
|
|
|
|
|
|
|
switch (xlogop)
|
2000-11-21 09:39:57 +00:00
|
|
|
{
|
2001-09-29 04:02:27 +00:00
|
|
|
case BS_XLOG_NOP:
|
|
|
|
StartupXLOG();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_XLOG_BOOTSTRAP:
|
|
|
|
BootStrapXLOG();
|
|
|
|
StartupXLOG();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BS_XLOG_CHECKPOINT:
|
2000-11-21 09:39:57 +00:00
|
|
|
CreateDummyCaches();
|
|
|
|
CreateCheckPoint(false);
|
2002-09-04 20:31:48 +00:00
|
|
|
SetSavedRedoRecPtr(); /* pass redo ptr back to
|
|
|
|
* postmaster */
|
2001-09-29 04:02:27 +00:00
|
|
|
proc_exit(0); /* done */
|
|
|
|
|
|
|
|
case BS_XLOG_STARTUP:
|
2000-11-21 09:39:57 +00:00
|
|
|
StartupXLOG();
|
2001-09-29 04:02:27 +00:00
|
|
|
proc_exit(0); /* done */
|
|
|
|
|
|
|
|
case BS_XLOG_SHUTDOWN:
|
2000-11-21 09:39:57 +00:00
|
|
|
ShutdownXLOG();
|
2001-09-29 04:02:27 +00:00
|
|
|
proc_exit(0); /* done */
|
|
|
|
|
|
|
|
default:
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(PANIC, "Unsupported XLOG op %d", xlogop);
|
2001-09-29 04:02:27 +00:00
|
|
|
proc_exit(0);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2001-09-29 04:02:27 +00:00
|
|
|
|
2000-11-21 09:39:57 +00:00
|
|
|
SetProcessingMode(BootstrapProcessing);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-10-06 21:58:18 +00:00
|
|
|
/*
|
|
|
|
* backend initialization
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-09-06 14:15:31 +00:00
|
|
|
InitPostgres(dbName, NULL);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAXATTR; i++)
|
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
attrtypes[i] = (Form_pg_attribute) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
Blanks[i] = ' ';
|
|
|
|
}
|
|
|
|
for (i = 0; i < STRTABLESIZE; ++i)
|
|
|
|
strtable[i] = NULL;
|
|
|
|
for (i = 0; i < HASHTABLESIZE; ++i)
|
|
|
|
hashtable[i] = NULL;
|
|
|
|
|
2001-03-22 06:16:21 +00:00
|
|
|
/*
|
|
|
|
* abort processing resumes here
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
|
|
|
if (sigsetjmp(Warn_restart, 1) != 0)
|
|
|
|
{
|
|
|
|
Warnings++;
|
|
|
|
AbortCurrentTransaction();
|
|
|
|
}
|
|
|
|
|
2001-03-22 06:16:21 +00:00
|
|
|
/*
|
|
|
|
* process input.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the sed script boot.sed renamed yyparse to Int_yyparse for the
|
|
|
|
* bootstrap parser to avoid conflicts with the normal SQL parser
|
|
|
|
*/
|
|
|
|
Int_yyparse();
|
|
|
|
|
2000-11-21 09:39:57 +00:00
|
|
|
SetProcessingMode(NormalProcessing);
|
|
|
|
CreateCheckPoint(true);
|
|
|
|
SetProcessingMode(BootstrapProcessing);
|
2000-10-24 09:56:23 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/* clean up processing */
|
2002-08-30 22:18:07 +00:00
|
|
|
StartTransactionCommand(true);
|
1997-09-07 05:04:48 +00:00
|
|
|
cleanup();
|
|
|
|
|
|
|
|
/* not reached, here to make compiler happy */
|
|
|
|
return 0;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* boot_openrel
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
boot_openrel(char *relname)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int i;
|
1997-09-07 05:04:48 +00:00
|
|
|
struct typmap **app;
|
1998-08-19 02:04:17 +00:00
|
|
|
Relation rel;
|
|
|
|
HeapScanDesc scan;
|
1997-09-08 02:41:22 +00:00
|
|
|
HeapTuple tup;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
if (strlen(relname) >= NAMEDATALEN - 1)
|
|
|
|
relname[NAMEDATALEN - 1] = '\0';
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (Typ == (struct typmap **) NULL)
|
|
|
|
{
|
1999-09-18 19:08:25 +00:00
|
|
|
rel = heap_openr(TypeRelationName, NoLock);
|
2002-05-20 23:51:44 +00:00
|
|
|
scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
|
1998-08-19 02:04:17 +00:00
|
|
|
i = 0;
|
2002-05-20 23:51:44 +00:00
|
|
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
1998-08-19 02:04:17 +00:00
|
|
|
++i;
|
|
|
|
heap_endscan(scan);
|
1997-09-07 05:04:48 +00:00
|
|
|
app = Typ = ALLOC(struct typmap *, i + 1);
|
|
|
|
while (i-- > 0)
|
|
|
|
*app++ = ALLOC(struct typmap, 1);
|
|
|
|
*app = (struct typmap *) NULL;
|
2002-05-20 23:51:44 +00:00
|
|
|
scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
|
1997-09-07 05:04:48 +00:00
|
|
|
app = Typ;
|
2002-05-20 23:51:44 +00:00
|
|
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2002-07-20 05:16:59 +00:00
|
|
|
(*app)->am_oid = HeapTupleGetOid(tup);
|
2000-06-28 03:33:33 +00:00
|
|
|
memcpy((char *) &(*app)->am_typ,
|
|
|
|
(char *) GETSTRUCT(tup),
|
|
|
|
sizeof((*app)->am_typ));
|
|
|
|
app++;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1998-08-19 02:04:17 +00:00
|
|
|
heap_endscan(scan);
|
1999-09-18 19:08:25 +00:00
|
|
|
heap_close(rel, NoLock);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
|
2002-04-27 21:24:34 +00:00
|
|
|
if (boot_reldesc != NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
closerel(NULL);
|
|
|
|
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "open relation %s, attrsize %d", relname ? relname : "(null)",
|
|
|
|
(int) ATTRIBUTE_TUPLE_SIZE);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2002-04-27 21:24:34 +00:00
|
|
|
boot_reldesc = heap_openr(relname, NoLock);
|
|
|
|
numattr = boot_reldesc->rd_rel->relnatts;
|
1997-09-07 05:04:48 +00:00
|
|
|
for (i = 0; i < numattr; i++)
|
|
|
|
{
|
|
|
|
if (attrtypes[i] == NULL)
|
|
|
|
attrtypes[i] = AllocateAttribute();
|
|
|
|
memmove((char *) attrtypes[i],
|
2002-04-27 21:24:34 +00:00
|
|
|
(char *) boot_reldesc->rd_att->attrs[i],
|
1997-09-07 05:04:48 +00:00
|
|
|
ATTRIBUTE_TUPLE_SIZE);
|
|
|
|
|
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
Form_pg_attribute at = attrtypes[i];
|
1997-09-07 05:04:48 +00:00
|
|
|
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "create attribute %d name %s len %d num %d type %u",
|
2001-05-12 01:48:49 +00:00
|
|
|
i, NameStr(at->attname), at->attlen, at->attnum,
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
at->atttypid);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* closerel
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
closerel(char *name)
|
|
|
|
{
|
1997-09-07 05:04:48 +00:00
|
|
|
if (name)
|
|
|
|
{
|
2002-04-27 21:24:34 +00:00
|
|
|
if (boot_reldesc)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2002-04-27 21:24:34 +00:00
|
|
|
if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
|
1998-01-07 21:07:04 +00:00
|
|
|
elog(ERROR, "closerel: close of '%s' when '%s' was expected",
|
1997-09-07 05:04:48 +00:00
|
|
|
name, relname ? relname : "(null)");
|
|
|
|
}
|
|
|
|
else
|
1998-01-07 21:07:04 +00:00
|
|
|
elog(ERROR, "closerel: close of '%s' before any relation was opened",
|
1997-09-07 05:04:48 +00:00
|
|
|
name);
|
|
|
|
}
|
|
|
|
|
2002-04-27 21:24:34 +00:00
|
|
|
if (boot_reldesc == NULL)
|
2001-05-12 01:48:49 +00:00
|
|
|
elog(ERROR, "no open relation to close");
|
1997-09-07 05:04:48 +00:00
|
|
|
else
|
|
|
|
{
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "close relation %s", relname ? relname : "(null)");
|
2002-04-27 21:24:34 +00:00
|
|
|
heap_close(boot_reldesc, NoLock);
|
|
|
|
boot_reldesc = (Relation) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/* ----------------
|
|
|
|
* DEFINEATTR()
|
|
|
|
*
|
|
|
|
* define a <field,type> pair
|
|
|
|
* if there are n fields in a relation to be created, this routine
|
|
|
|
* will be called n times
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
DefineAttr(char *name, char *type, int attnum)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int attlen;
|
1998-08-24 19:04:04 +00:00
|
|
|
Oid typeoid;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2002-04-27 21:24:34 +00:00
|
|
|
if (boot_reldesc != NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(LOG, "warning: no open relations allowed with 'create' command");
|
1997-09-07 05:04:48 +00:00
|
|
|
closerel(relname);
|
|
|
|
}
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
if (attrtypes[attnum] == (Form_pg_attribute) NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
attrtypes[attnum] = AllocateAttribute();
|
2002-08-02 18:15:10 +00:00
|
|
|
MemSet(attrtypes[attnum], 0, ATTRIBUTE_TUPLE_SIZE);
|
|
|
|
|
|
|
|
namestrcpy(&attrtypes[attnum]->attname, name);
|
|
|
|
elog(DEBUG3, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
|
2002-09-22 19:42:52 +00:00
|
|
|
attrtypes[attnum]->attnum = attnum + 1; /* fillatt */
|
2002-08-02 18:15:10 +00:00
|
|
|
|
|
|
|
typeoid = gettype(type);
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
if (Typ != (struct typmap **) NULL)
|
|
|
|
{
|
|
|
|
attrtypes[attnum]->atttypid = Ap->am_oid;
|
|
|
|
attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen;
|
|
|
|
attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
|
2002-04-25 02:56:56 +00:00
|
|
|
attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;
|
1998-08-24 19:04:04 +00:00
|
|
|
attrtypes[attnum]->attalign = Ap->am_typ.typalign;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-08-24 19:04:04 +00:00
|
|
|
attrtypes[attnum]->atttypid = Procid[typeoid].oid;
|
|
|
|
attlen = attrtypes[attnum]->attlen = Procid[typeoid].len;
|
1999-05-25 16:15:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cheat like mad to fill in these items from the length only.
|
2002-04-25 02:56:56 +00:00
|
|
|
* This only has to work for types that appear in Procid[].
|
1999-03-25 03:49:34 +00:00
|
|
|
*/
|
|
|
|
switch (attlen)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
attrtypes[attnum]->attbyval = true;
|
2002-04-25 02:56:56 +00:00
|
|
|
attrtypes[attnum]->attstorage = 'p';
|
1999-03-25 03:49:34 +00:00
|
|
|
attrtypes[attnum]->attalign = 'c';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
attrtypes[attnum]->attbyval = true;
|
2002-04-25 02:56:56 +00:00
|
|
|
attrtypes[attnum]->attstorage = 'p';
|
1999-03-25 03:49:34 +00:00
|
|
|
attrtypes[attnum]->attalign = 's';
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
attrtypes[attnum]->attbyval = true;
|
2002-04-25 02:56:56 +00:00
|
|
|
attrtypes[attnum]->attstorage = 'p';
|
|
|
|
attrtypes[attnum]->attalign = 'i';
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
attrtypes[attnum]->attbyval = false;
|
|
|
|
attrtypes[attnum]->attstorage = 'x';
|
1999-03-25 03:49:34 +00:00
|
|
|
attrtypes[attnum]->attalign = 'i';
|
|
|
|
break;
|
|
|
|
default:
|
2002-04-25 02:56:56 +00:00
|
|
|
/* TID and fixed-length arrays, such as oidvector */
|
1999-03-25 03:49:34 +00:00
|
|
|
attrtypes[attnum]->attbyval = false;
|
2002-04-25 02:56:56 +00:00
|
|
|
attrtypes[attnum]->attstorage = 'p';
|
1999-03-25 03:49:34 +00:00
|
|
|
attrtypes[attnum]->attalign = 'i';
|
|
|
|
break;
|
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1998-02-06 19:18:06 +00:00
|
|
|
attrtypes[attnum]->attcacheoff = -1;
|
1998-02-07 06:11:56 +00:00
|
|
|
attrtypes[attnum]->atttypmod = -1;
|
2002-09-22 19:42:52 +00:00
|
|
|
attrtypes[attnum]->attislocal = true;
|
2002-09-04 20:31:48 +00:00
|
|
|
|
2002-08-02 18:15:10 +00:00
|
|
|
/*
|
2002-09-04 20:31:48 +00:00
|
|
|
* 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.
|
2002-08-02 18:15:10 +00:00
|
|
|
*/
|
|
|
|
if (attlen > 0)
|
|
|
|
{
|
2002-09-04 20:31:48 +00:00
|
|
|
int i;
|
2002-08-02 18:15:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < attnum; i++)
|
|
|
|
{
|
|
|
|
if (attrtypes[i]->attlen <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == attnum)
|
|
|
|
attrtypes[attnum]->attnotnull = true;
|
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* InsertOneTuple
|
2001-08-10 18:57:42 +00:00
|
|
|
*
|
|
|
|
* If objectid is not zero, it is a specific OID to assign to the tuple.
|
|
|
|
* Otherwise, an OID will be assigned (if necessary) by heap_insert.
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
InsertOneTuple(Oid objectid)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
HeapTuple tuple;
|
|
|
|
TupleDesc tupDesc;
|
|
|
|
int i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "inserting row oid %u, %d columns", objectid, numattr);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2002-09-02 01:05:06 +00:00
|
|
|
tupDesc = CreateTupleDesc(numattr,
|
|
|
|
RelationGetForm(boot_reldesc)->relhasoids,
|
|
|
|
attrtypes);
|
2000-05-30 04:25:00 +00:00
|
|
|
tuple = heap_formtuple(tupDesc, values, Blanks);
|
1997-09-07 05:04:48 +00:00
|
|
|
if (objectid != (Oid) 0)
|
2002-07-20 05:16:59 +00:00
|
|
|
HeapTupleSetOid(tuple, objectid);
|
|
|
|
pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
|
2002-09-02 01:05:06 +00:00
|
|
|
|
2002-05-21 22:05:55 +00:00
|
|
|
simple_heap_insert(boot_reldesc, tuple);
|
1999-12-16 22:20:03 +00:00
|
|
|
heap_freetuple(tuple);
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "row inserted");
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset blanks for next tuple
|
|
|
|
*/
|
|
|
|
for (i = 0; i < numattr; i++)
|
|
|
|
Blanks[i] = ' ';
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* InsertOneValue
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
2001-08-10 18:57:42 +00:00
|
|
|
InsertOneValue(char *value, int i)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int typeindex;
|
|
|
|
char *prt;
|
1997-09-07 05:04:48 +00:00
|
|
|
struct typmap **app;
|
|
|
|
|
2001-05-12 01:48:49 +00:00
|
|
|
AssertArg(i >= 0 || i < MAXATTR);
|
|
|
|
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "inserting column %d value '%s'", i, value);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (Typ != (struct typmap **) NULL)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
struct typmap *ap;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "Typ != NULL");
|
1997-09-07 05:04:48 +00:00
|
|
|
app = Typ;
|
2002-04-27 21:24:34 +00:00
|
|
|
while (*app && (*app)->am_oid != boot_reldesc->rd_att->attrs[i]->atttypid)
|
1997-09-07 05:04:48 +00:00
|
|
|
++app;
|
|
|
|
ap = *app;
|
|
|
|
if (ap == NULL)
|
|
|
|
{
|
2001-05-12 01:48:49 +00:00
|
|
|
elog(FATAL, "unable to find atttypid %u in Typ list",
|
2002-04-27 21:24:34 +00:00
|
|
|
boot_reldesc->rd_att->attrs[i]->atttypid);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2000-05-30 04:25:00 +00:00
|
|
|
values[i] = OidFunctionCall3(ap->am_typ.typinput,
|
|
|
|
CStringGetDatum(value),
|
|
|
|
ObjectIdGetDatum(ap->am_typ.typelem),
|
|
|
|
Int32GetDatum(-1));
|
|
|
|
prt = DatumGetCString(OidFunctionCall3(ap->am_typ.typoutput,
|
2001-03-22 06:16:21 +00:00
|
|
|
values[i],
|
|
|
|
ObjectIdGetDatum(ap->am_typ.typelem),
|
|
|
|
Int32GetDatum(-1)));
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, " -> %s", prt);
|
1997-09-07 05:04:48 +00:00
|
|
|
pfree(prt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-01-11 04:00:30 +00:00
|
|
|
for (typeindex = 0; typeindex < n_types; typeindex++)
|
|
|
|
{
|
|
|
|
if (Procid[typeindex].oid == attrtypes[i]->atttypid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (typeindex >= n_types)
|
2001-05-12 01:48:49 +00:00
|
|
|
elog(ERROR, "type oid %u not found", attrtypes[i]->atttypid);
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "Typ == NULL, typeindex = %u", typeindex);
|
2000-05-30 04:25:00 +00:00
|
|
|
values[i] = OidFunctionCall3(Procid[typeindex].inproc,
|
|
|
|
CStringGetDatum(value),
|
2001-03-22 06:16:21 +00:00
|
|
|
ObjectIdGetDatum(Procid[typeindex].elem),
|
2000-05-30 04:25:00 +00:00
|
|
|
Int32GetDatum(-1));
|
|
|
|
prt = DatumGetCString(OidFunctionCall3(Procid[typeindex].outproc,
|
2001-03-22 06:16:21 +00:00
|
|
|
values[i],
|
|
|
|
ObjectIdGetDatum(Procid[typeindex].elem),
|
|
|
|
Int32GetDatum(-1)));
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, " -> %s", prt);
|
1997-09-07 05:04:48 +00:00
|
|
|
pfree(prt);
|
|
|
|
}
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "inserted");
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* InsertOneNull
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
InsertOneNull(int i)
|
|
|
|
{
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "inserting column %d NULL", i);
|
2001-05-12 01:48:49 +00:00
|
|
|
Assert(i >= 0 || i < MAXATTR);
|
2000-05-30 04:25:00 +00:00
|
|
|
values[i] = PointerGetDatum(NULL);
|
1997-09-07 05:04:48 +00:00
|
|
|
Blanks[i] = 'n';
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MORE_THAN_THE_NUMBER_OF_CATALOGS 256
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static bool
|
1996-07-09 06:22:35 +00:00
|
|
|
BootstrapAlreadySeen(Oid id)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS];
|
|
|
|
static int nseen = 0;
|
|
|
|
bool seenthis;
|
|
|
|
int i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
seenthis = false;
|
|
|
|
|
|
|
|
for (i = 0; i < nseen; i++)
|
|
|
|
{
|
|
|
|
if (seenArray[i] == id)
|
|
|
|
{
|
|
|
|
seenthis = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!seenthis)
|
|
|
|
{
|
|
|
|
seenArray[nseen] = id;
|
|
|
|
nseen++;
|
|
|
|
}
|
1998-09-01 03:29:17 +00:00
|
|
|
return seenthis;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* cleanup
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-08-19 21:40:56 +00:00
|
|
|
static void
|
1996-07-09 06:22:35 +00:00
|
|
|
cleanup()
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
static int beenhere = 0;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (!beenhere)
|
|
|
|
beenhere = 1;
|
|
|
|
else
|
|
|
|
{
|
2000-01-15 02:59:43 +00:00
|
|
|
elog(FATAL, "Memory manager fault: cleanup called twice.\n");
|
1998-06-27 04:53:49 +00:00
|
|
|
proc_exit(1);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2002-08-02 22:36:05 +00:00
|
|
|
if (boot_reldesc != NULL)
|
|
|
|
closerel(NULL);
|
2002-08-30 22:18:07 +00:00
|
|
|
CommitTransactionCommand(true);
|
1998-06-27 04:53:49 +00:00
|
|
|
proc_exit(Warnings);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* gettype
|
2002-04-25 02:56:56 +00:00
|
|
|
*
|
|
|
|
* NB: this is really ugly; it will return an integer index into Procid[],
|
|
|
|
* and not an OID at all, until the first reference to a type not known in
|
|
|
|
* Procid[]. 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
|
2002-09-04 20:31:48 +00:00
|
|
|
* point at the found row in Typ). So caller must check whether Typ is
|
2002-04-25 02:56:56 +00:00
|
|
|
* still NULL to determine what the return value is!
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-08-24 19:04:04 +00:00
|
|
|
static Oid
|
1996-07-09 06:22:35 +00:00
|
|
|
gettype(char *type)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int i;
|
1998-08-19 02:04:17 +00:00
|
|
|
Relation rel;
|
|
|
|
HeapScanDesc scan;
|
1997-09-08 02:41:22 +00:00
|
|
|
HeapTuple tup;
|
1997-09-07 05:04:48 +00:00
|
|
|
struct typmap **app;
|
|
|
|
|
|
|
|
if (Typ != (struct typmap **) NULL)
|
|
|
|
{
|
|
|
|
for (app = Typ; *app != (struct typmap *) NULL; app++)
|
|
|
|
{
|
1999-11-07 23:08:36 +00:00
|
|
|
if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
|
|
|
Ap = *app;
|
1998-09-01 03:29:17 +00:00
|
|
|
return (*app)->am_oid;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-25 02:56:56 +00:00
|
|
|
for (i = 0; i < n_types; i++)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
|
|
|
if (strncmp(type, Procid[i].name, NAMEDATALEN) == 0)
|
1998-09-01 03:29:17 +00:00
|
|
|
return i;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 21:39:36 +00:00
|
|
|
elog(DEBUG3, "external type: %s", type);
|
1999-09-18 19:08:25 +00:00
|
|
|
rel = heap_openr(TypeRelationName, NoLock);
|
2002-05-20 23:51:44 +00:00
|
|
|
scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
|
1997-09-07 05:04:48 +00:00
|
|
|
i = 0;
|
2002-05-20 23:51:44 +00:00
|
|
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
++i;
|
1998-08-19 02:04:17 +00:00
|
|
|
heap_endscan(scan);
|
1997-09-07 05:04:48 +00:00
|
|
|
app = Typ = ALLOC(struct typmap *, i + 1);
|
|
|
|
while (i-- > 0)
|
|
|
|
*app++ = ALLOC(struct typmap, 1);
|
|
|
|
*app = (struct typmap *) NULL;
|
2002-05-20 23:51:44 +00:00
|
|
|
scan = heap_beginscan(rel, SnapshotNow, 0, (ScanKey) NULL);
|
1997-09-07 05:04:48 +00:00
|
|
|
app = Typ;
|
2002-05-20 23:51:44 +00:00
|
|
|
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2002-07-20 05:16:59 +00:00
|
|
|
(*app)->am_oid = HeapTupleGetOid(tup);
|
1997-09-07 05:04:48 +00:00
|
|
|
memmove((char *) &(*app++)->am_typ,
|
|
|
|
(char *) GETSTRUCT(tup),
|
|
|
|
sizeof((*app)->am_typ));
|
|
|
|
}
|
1998-08-19 02:04:17 +00:00
|
|
|
heap_endscan(scan);
|
1999-09-18 19:08:25 +00:00
|
|
|
heap_close(rel, NoLock);
|
1998-09-01 03:29:17 +00:00
|
|
|
return gettype(type);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1998-01-07 21:07:04 +00:00
|
|
|
elog(ERROR, "Error: unknown type '%s'.\n", type);
|
1997-09-07 05:04:48 +00:00
|
|
|
err_out();
|
|
|
|
/* not reached, here to make compiler happy */
|
|
|
|
return 0;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* AllocateAttribute
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
2002-08-02 18:15:10 +00:00
|
|
|
static Form_pg_attribute
|
|
|
|
AllocateAttribute(void)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1999-02-03 21:18:02 +00:00
|
|
|
Form_pg_attribute attribute = (Form_pg_attribute) malloc(ATTRIBUTE_TUPLE_SIZE);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (!PointerIsValid(attribute))
|
|
|
|
elog(FATAL, "AllocateAttribute: malloc failed");
|
1997-09-18 20:22:58 +00:00
|
|
|
MemSet(attribute, 0, ATTRIBUTE_TUPLE_SIZE);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return attribute;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* MapArrayTypeName
|
1996-07-09 06:22:35 +00:00
|
|
|
* XXX arrays of "basetype" are always "_basetype".
|
1997-09-07 05:04:48 +00:00
|
|
|
* this is an evil hack inherited from rel. 3.1.
|
1996-07-09 06:22:35 +00:00
|
|
|
* XXX array dimension is thrown away because we
|
1997-09-07 05:04:48 +00:00
|
|
|
* don't support fixed-dimension arrays. again,
|
|
|
|
* sickness from 3.1.
|
|
|
|
*
|
|
|
|
* the string passed in must have a '[' character in it
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
* the string returned is a pointer to static storage and should NOT
|
|
|
|
* be freed by the CALLER.
|
|
|
|
* ----------------
|
|
|
|
*/
|
1998-02-26 04:46:47 +00:00
|
|
|
char *
|
1996-07-09 06:22:35 +00:00
|
|
|
MapArrayTypeName(char *s)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
int i,
|
|
|
|
j;
|
|
|
|
static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN
|
|
|
|
* long */
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
if (s == NULL || s[0] == '\0')
|
|
|
|
return s;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
j = 1;
|
|
|
|
newStr[0] = '_';
|
|
|
|
for (i = 0; i < NAMEDATALEN - 1 && s[i] != '['; i++, j++)
|
|
|
|
newStr[j] = s[i];
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
newStr[j] = '\0';
|
|
|
|
|
|
|
|
return newStr;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* EnterString
|
|
|
|
* returns the string table position of the identifier
|
|
|
|
* passed to it. We add it to the table if we can't find it.
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
int
|
1997-09-07 05:04:48 +00:00
|
|
|
EnterString(char *str)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
hashnode *node;
|
|
|
|
int len;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
len = strlen(str);
|
|
|
|
|
|
|
|
node = FindStr(str, len, 0);
|
|
|
|
if (node)
|
1998-09-01 03:29:17 +00:00
|
|
|
return node->strnum;
|
1997-09-07 05:04:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
node = AddStr(str, len, 0);
|
1998-09-01 03:29:17 +00:00
|
|
|
return node->strnum;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* LexIDStr
|
|
|
|
* when given an idnum into the 'string-table' return the string
|
|
|
|
* associated with the idnum
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-02-26 04:46:47 +00:00
|
|
|
char *
|
1997-09-07 05:04:48 +00:00
|
|
|
LexIDStr(int ident_num)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
return strtable[ident_num];
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* CompHash
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* Compute a hash function for a given string. We look at the first,
|
|
|
|
* the last, and the middle character of a string to try to get spread
|
|
|
|
* the strings out. The function is rather arbitrary, except that we
|
|
|
|
* are mod'ing by a prime number.
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-08-19 21:40:56 +00:00
|
|
|
static int
|
1996-07-09 06:22:35 +00:00
|
|
|
CompHash(char *str, int len)
|
|
|
|
{
|
1998-02-26 04:46:47 +00:00
|
|
|
int result;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
result = (NUM * str[0] + NUMSQR * str[len - 1] + NUMCUBE * str[(len - 1) / 2]);
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return result % HASHTABLESIZE;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* FindStr
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* This routine looks for the specified string in the hash
|
|
|
|
* table. It returns a pointer to the hash node found,
|
|
|
|
* or NULL if the string is not in the table.
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-08-19 21:40:56 +00:00
|
|
|
static hashnode *
|
1997-09-08 21:56:23 +00:00
|
|
|
FindStr(char *str, int length, hashnode *mderef)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
hashnode *node;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
if (!strcmp(str, strtable[node->strnum]))
|
|
|
|
{
|
1998-09-01 03:29:17 +00:00
|
|
|
return node; /* no need to check */
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
node = node->next;
|
|
|
|
}
|
|
|
|
/* Couldn't find it in the list */
|
1998-09-01 03:29:17 +00:00
|
|
|
return NULL;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* AddStr
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* This function adds the specified string, along with its associated
|
|
|
|
* data, to the hash table and the string table. We return the node
|
|
|
|
* so that the calling routine can find out the unique id that AddStr
|
|
|
|
* has assigned to this string.
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-08-19 21:40:56 +00:00
|
|
|
static hashnode *
|
1996-07-09 06:22:35 +00:00
|
|
|
AddStr(char *str, int strlength, int mderef)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
hashnode *temp,
|
|
|
|
*trail,
|
|
|
|
*newnode;
|
|
|
|
int hashresult;
|
|
|
|
int len;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
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.");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some of the utilites (eg, define type, create relation) assume that
|
|
|
|
* the string they're passed is a NAMEDATALEN. We get array bound
|
|
|
|
* read violations from purify if we don't allocate at least
|
|
|
|
* NAMEDATALEN bytes for strings of this sort. Because we're lazy, we
|
|
|
|
* allocate at least NAMEDATALEN bytes all the time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((len = strlength + 1) < NAMEDATALEN)
|
|
|
|
len = NAMEDATALEN;
|
|
|
|
|
|
|
|
strtable[strtable_end] = malloc((unsigned) len);
|
|
|
|
strcpy(strtable[strtable_end], str);
|
|
|
|
|
|
|
|
/* Now put a node in the hash table */
|
|
|
|
|
|
|
|
newnode = (hashnode *) malloc(sizeof(hashnode) * 1);
|
|
|
|
newnode->strnum = strtable_end;
|
|
|
|
newnode->next = NULL;
|
|
|
|
|
|
|
|
/* Find out where it goes */
|
|
|
|
|
|
|
|
hashresult = CompHash(str, strlength);
|
|
|
|
if (hashtable[hashresult] == NULL)
|
|
|
|
hashtable[hashresult] = newnode;
|
|
|
|
else
|
|
|
|
{ /* There is something in the list */
|
|
|
|
trail = hashtable[hashresult];
|
|
|
|
temp = trail->next;
|
|
|
|
while (temp != NULL)
|
|
|
|
{
|
|
|
|
trail = temp;
|
|
|
|
temp = temp->next;
|
|
|
|
}
|
|
|
|
trail->next = newnode;
|
|
|
|
}
|
1998-09-01 03:29:17 +00:00
|
|
|
return newnode;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1997-09-07 05:04:48 +00:00
|
|
|
* index_register() -- record an index that has been set up for building
|
|
|
|
* later.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* At bootstrap time, we define a bunch of indices on system catalogs.
|
|
|
|
* We postpone actually building the indices until just before we're
|
|
|
|
* finished with initialization, however. This is because more classes
|
|
|
|
* and indices may be defined, and we want to be sure that all of them
|
|
|
|
* are present in the index.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
void
|
2002-03-26 19:17:02 +00:00
|
|
|
index_register(Oid heap,
|
|
|
|
Oid ind,
|
2000-07-14 22:18:02 +00:00
|
|
|
IndexInfo *indexInfo)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
IndexList *newind;
|
|
|
|
MemoryContext oldcxt;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX mao 10/31/92 -- don't gc index reldescs, associated info at
|
|
|
|
* bootstrap time. we'll declare the indices now, but want to create
|
|
|
|
* them later.
|
|
|
|
*/
|
|
|
|
|
2000-06-28 03:33:33 +00:00
|
|
|
if (nogc == NULL)
|
|
|
|
nogc = AllocSetContextCreate((MemoryContext) NULL,
|
|
|
|
"BootstrapNoGC",
|
|
|
|
ALLOCSET_DEFAULT_MINSIZE,
|
|
|
|
ALLOCSET_DEFAULT_INITSIZE,
|
|
|
|
ALLOCSET_DEFAULT_MAXSIZE);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-06-28 03:33:33 +00:00
|
|
|
oldcxt = MemoryContextSwitchTo(nogc);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
newind = (IndexList *) palloc(sizeof(IndexList));
|
2002-03-26 19:17:02 +00:00
|
|
|
newind->il_heap = heap;
|
|
|
|
newind->il_ind = ind;
|
2000-07-14 22:18:02 +00:00
|
|
|
newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-07-14 22:18:02 +00:00
|
|
|
memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
|
2001-07-16 05:07:00 +00:00
|
|
|
/* predicate will likely be null, but may as well copy it */
|
|
|
|
newind->il_info->ii_Predicate = (List *)
|
|
|
|
copyObject(indexInfo->ii_Predicate);
|
2000-06-17 23:41:51 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
newind->il_next = ILHead;
|
|
|
|
ILHead = newind;
|
|
|
|
|
|
|
|
MemoryContextSwitchTo(oldcxt);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
build_indices()
|
|
|
|
{
|
1997-09-07 05:04:48 +00:00
|
|
|
for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
|
|
|
|
{
|
2000-07-14 22:18:02 +00:00
|
|
|
Relation heap;
|
|
|
|
Relation ind;
|
|
|
|
|
2002-03-26 19:17:02 +00:00
|
|
|
heap = heap_open(ILHead->il_heap, NoLock);
|
|
|
|
ind = index_open(ILHead->il_ind);
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-15 22:48:19 +00:00
|
|
|
index_build(heap, ind, ILHead->il_info);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In normal processing mode, index_build would close the heap and
|
|
|
|
* index, but in bootstrap mode it will not.
|
1999-09-18 19:08:25 +00:00
|
|
|
*/
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
1999-11-24 00:58:48 +00:00
|
|
|
* ghost tuple problem (see heap_update). To get around this we
|
1997-09-07 05:04:48 +00:00
|
|
|
* 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
|
|
|
|
*/
|
1998-08-19 02:04:17 +00:00
|
|
|
if (!BootstrapAlreadySeen(RelationGetRelid(heap)))
|
2000-11-08 22:10:03 +00:00
|
|
|
UpdateStats(RelationGetRelid(heap), 0);
|
1999-09-18 19:08:25 +00:00
|
|
|
|
|
|
|
/* XXX Probably we ought to close the heap and index here? */
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|