aboutsummaryrefslogtreecommitdiff
path: root/src/backend/bootstrap/bootstrap.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-04-14 20:03:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-04-14 20:03:27 +0000
commit162bd08b3f2e6783d1d75ae79f86fc444d34a28d (patch)
tree0220cd8a906557db64763a1a57dd339de313d221 /src/backend/bootstrap/bootstrap.c
parent9dc2e6deaf66f97ff9157478a517d0f48a1e5060 (diff)
downloadpostgresql-162bd08b3f2e6783d1d75ae79f86fc444d34a28d.tar.gz
postgresql-162bd08b3f2e6783d1d75ae79f86fc444d34a28d.zip
Completion of project to use fixed OIDs for all system catalogs and
indexes. Replace all heap_openr and index_openr calls by heap_open and index_open. Remove runtime lookups of catalog OID numbers in various places. Remove relcache's support for looking up system catalogs by name. Bulky but mostly very boring patch ...
Diffstat (limited to 'src/backend/bootstrap/bootstrap.c')
-rw-r--r--src/backend/bootstrap/bootstrap.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index fcff278ebb5..82c29b128b4 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.201 2005/03/29 19:44:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.202 2005/04/14 20:03:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,12 +26,12 @@
#include "access/heapam.h"
#include "access/xlog.h"
#include "bootstrap/bootstrap.h"
-#include "catalog/catname.h"
#include "catalog/index.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
+#include "nodes/makefuncs.h"
#include "postmaster/bgwriter.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
@@ -46,10 +46,14 @@
#include "utils/ps_status.h"
#include "utils/relcache.h"
+extern int optind;
+extern char *optarg;
+
#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
extern int Int_yyparse(void);
+
static void usage(void);
static void bootstrap_signals(void);
static hashnode *AddStr(char *str, int strlength, int mderef);
@@ -169,17 +173,12 @@ static struct typmap *Ap = NULL;
static int Warnings = 0;
static char Blanks[MAXATTR];
-static char *relname; /* current relation name */
-
Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */
static Datum values[MAXATTR]; /* corresponding attribute values */
int numattr; /* number of attributes for cur. rel */
static MemoryContext nogc = NULL; /* special no-gc mem context */
-extern int optind;
-extern char *optarg;
-
/*
* At bootstrap time, we first declare all the indices to be built, and
* then build them. The IndexList structure stores enough information
@@ -572,12 +571,12 @@ boot_openrel(char *relname)
HeapScanDesc scan;
HeapTuple tup;
- if (strlen(relname) >= NAMEDATALEN - 1)
+ if (strlen(relname) >= NAMEDATALEN)
relname[NAMEDATALEN - 1] = '\0';
if (Typ == NULL)
{
- rel = heap_openr(TypeRelationName, NoLock);
+ rel = heap_open(TypeRelationId, NoLock);
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
i = 0;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -605,10 +604,9 @@ boot_openrel(char *relname)
closerel(NULL);
elog(DEBUG4, "open relation %s, attrsize %d",
- relname ? relname : "(null)",
- (int) ATTRIBUTE_TUPLE_SIZE);
+ relname, (int) ATTRIBUTE_TUPLE_SIZE);
- boot_reldesc = heap_openr(relname, NoLock);
+ boot_reldesc = heap_openrv(makeRangeVar(NULL, relname), NoLock);
numattr = boot_reldesc->rd_rel->relnatts;
for (i = 0; i < numattr; i++)
{
@@ -641,7 +639,7 @@ closerel(char *name)
{
if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
elog(ERROR, "close of %s when %s was expected",
- name, relname ? relname : "(null)");
+ name, RelationGetRelationName(boot_reldesc));
}
else
elog(ERROR, "close of %s before any relation was opened",
@@ -652,7 +650,8 @@ closerel(char *name)
elog(ERROR, "no open relation to close");
else
{
- elog(DEBUG4, "close relation %s", relname ? relname : "(null)");
+ elog(DEBUG4, "close relation %s",
+ RelationGetRelationName(boot_reldesc));
heap_close(boot_reldesc, NoLock);
boot_reldesc = NULL;
}
@@ -676,7 +675,7 @@ DefineAttr(char *name, char *type, int attnum)
if (boot_reldesc != NULL)
{
elog(WARNING, "no open relations allowed with CREATE command");
- closerel(relname);
+ closerel(NULL);
}
if (attrtypes[attnum] == NULL)
@@ -933,7 +932,7 @@ gettype(char *type)
return i;
}
elog(DEBUG4, "external type: %s", type);
- rel = heap_openr(TypeRelationName, NoLock);
+ rel = heap_open(TypeRelationId, NoLock);
scan = heap_beginscan(rel, SnapshotNow, 0, NULL);
i = 0;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)