diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-14 01:38:22 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-14 01:38:22 +0000 |
commit | 7c13781ee7a617235f24617e3bd7628cda95df15 (patch) | |
tree | 5815af97251619f856d480997c71ec9aab3b9262 /src/backend/utils/cache | |
parent | 2193a856a229026673cbc56310cd0bddf7b5ea25 (diff) | |
download | postgresql-7c13781ee7a617235f24617e3bd7628cda95df15.tar.gz postgresql-7c13781ee7a617235f24617e3bd7628cda95df15.zip |
First phase of project to use fixed OIDs for all system catalogs and
indexes. Extend the macros in include/catalog/*.h to carry the info
about hand-assigned OIDs, and adjust the genbki script and bootstrap
code to make the relations actually get those OIDs. Remove the small
number of RelOid_pg_foo macros that we had in favor of a complete
set named like the catname.h and indexing.h macros. Next phase will
get rid of internal use of names for looking up catalogs and indexes;
but this completes the changes forcing an initdb, so it looks like a
good place to commit.
Along the way, I made the shared relations (pg_database etc) not be
'bootstrap' relations any more, so as to reduce the number of hardwired
entries and simplify changing those relations in future. I'm not
sure whether they ever really needed to be handled as bootstrap
relations, but it seems to work fine to not do so now.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/inval.c | 6 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 35 |
2 files changed, 27 insertions, 14 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 21954589829..61b7522f8c9 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -80,7 +80,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.70 2005/01/10 21:57:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.71 2005/04/14 01:38:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -541,7 +541,7 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) */ tupleRelId = RelationGetRelid(relation); - if (tupleRelId == RelOid_pg_class) + if (tupleRelId == RelationRelationId) { Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple); RelFileNode rnode; @@ -575,7 +575,7 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) rnode.relNode = classtup->relfilenode; RegisterSmgrInvalidation(rnode); } - else if (tupleRelId == RelOid_pg_attribute) + else if (tupleRelId == AttributeRelationId) { Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 109a6e811aa..e6c59b1815b 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.218 2005/03/29 00:17:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.219 2005/04/14 01:38:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2150,18 +2150,36 @@ RelationBuildLocalRelation(const char *relname, TupleDesc tupDesc, Oid relid, Oid reltablespace, - bool shared_relation, - bool nailit) + bool shared_relation) { Relation rel; MemoryContext oldcxt; int natts = tupDesc->natts; int i; bool has_not_null; + bool nailit; AssertArg(natts >= 0); /* + * check for creation of a rel that must be nailed in cache. + * + * XXX this list had better match RelationCacheInitialize's list. + */ + switch (relid) + { + case RelationRelationId: + case AttributeRelationId: + case ProcedureRelationId: + case TypeRelationId: + nailit = true; + break; + default: + nailit = false; + break; + } + + /* * switch to the cache context to create the relcache entry. */ if (!CacheMemoryContext) @@ -2179,6 +2197,9 @@ RelationBuildLocalRelation(const char *relname, /* make sure relation is marked as having no open file yet */ rel->rd_smgr = NULL; + /* mark it nailed if appropriate */ + rel->rd_isnailed = nailit; + rel->rd_refcnt = nailit ? 1 : 0; /* it's being created in this transaction */ @@ -2191,14 +2212,6 @@ RelationBuildLocalRelation(const char *relname, rel->rd_istemp = isTempNamespace(relnamespace); /* - * nail the reldesc if this is a bootstrap create reln and we may need - * it in the cache later on in the bootstrap process so we don't ever - * want it kicked out. e.g. pg_attribute!!! - */ - if (nailit) - rel->rd_isnailed = true; - - /* * create a new tuple descriptor from the one passed in. We do this * partly to copy it into the cache context, and partly because the * new relation can't have any defaults or constraints yet; they have |