diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-12 05:55:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-12 05:55:50 +0000 |
commit | 1d584f97b9bfe1501f9d2bc5528e7818fa73c235 (patch) | |
tree | 59a1a520e2a31718257ca9fa58f7819c8b321ac8 /src/backend/utils/cache/relcache.c | |
parent | d2c8358188cc6710e80800827cbb555600fd4b4d (diff) | |
download | postgresql-1d584f97b9bfe1501f9d2bc5528e7818fa73c235.tar.gz postgresql-1d584f97b9bfe1501f9d2bc5528e7818fa73c235.zip |
Clean up various to-do items associated with system indexes:
pg_database now has unique indexes on oid and on datname.
pg_shadow now has unique indexes on usename and on usesysid.
pg_am now has unique index on oid.
pg_opclass now has unique index on oid.
pg_amproc now has unique index on amid+amopclaid+amprocnum.
Remove pg_rewrite's unnecessary index on oid, delete unused RULEOID syscache.
Remove index on pg_listener and associated syscache for performance reasons
(caching rows that are certain to change before you need 'em again is
rather pointless).
Change pg_attrdef's nonunique index on adrelid into a unique index on
adrelid+adnum.
Fix various incorrect settings of pg_class.relisshared, make that the
primary reference point for whether a relation is shared or not.
IsSharedSystemRelationName() is now only consulted to initialize relisshared
during initial creation of tables and indexes. In theory we might now
support shared user relations, though it's not clear how one would get
entries for them into pg_class &etc of multiple databases.
Fix recently reported bug that pg_attribute rows created for an index all have
the same OID. (Proof that non-unique OID doesn't matter unless it's
actually used to do lookups ;-))
There's no need to treat pg_trigger, pg_attrdef, pg_relcheck as bootstrap
relations. Convert them into plain system catalogs without hardwired
entries in pg_class and friends.
Unify global.bki and template1.bki into a single init script postgres.bki,
since the alleged distinction between them was misleading and pointless.
Not to mention that it didn't work for setting up indexes on shared
system relations.
Rationalize locking of pg_shadow, pg_group, pg_attrdef (no need to use
AccessExclusiveLock where ExclusiveLock or even RowExclusiveLock will do).
Also, hold locks until transaction commit where necessary.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 6431bd9382e..4c8c3c4398c 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.136 2001/06/01 02:41:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.137 2001/06/12 05:55:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1116,7 +1116,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo, */ RelationInitLockInfo(relation); /* see lmgr.c */ - if (IsSharedSystemRelationName(NameStr(relation->rd_rel->relname))) + if (relation->rd_rel->relisshared) relation->rd_node.tblNode = InvalidOid; else relation->rd_node.tblNode = MyDatabaseId; @@ -1201,7 +1201,6 @@ IndexedAccessMethodInitialize(Relation relation) * catalogs... * * NOTE: we assume we are already switched into CacheMemoryContext. - * */ static void formrdesc(char *relationName, @@ -1245,15 +1244,10 @@ formrdesc(char *relationName, strcpy(RelationGetPhysicalRelationName(relation), relationName); /* - * For debugging purposes, it's important to distinguish between - * shared and non-shared relations, even at bootstrap time. There's - * code in the buffer manager that traces allocations that has to know - * about this. + * It's important to distinguish between shared and non-shared relations, + * even at bootstrap time, to make sure we know where they are stored. */ - if (IsSystemRelationName(relationName)) - relation->rd_rel->relisshared = IsSharedSystemRelationName(relationName); - else - relation->rd_rel->relisshared = false; + relation->rd_rel->relisshared = IsSharedSystemRelationName(relationName); relation->rd_rel->relpages = 1; relation->rd_rel->reltuples = 1; @@ -1286,7 +1280,7 @@ formrdesc(char *relationName, */ RelationInitLockInfo(relation); /* see lmgr.c */ - if (IsSharedSystemRelationName(relationName)) + if (relation->rd_rel->relisshared) relation->rd_node.tblNode = InvalidOid; else relation->rd_node.tblNode = MyDatabaseId; @@ -1301,14 +1295,15 @@ formrdesc(char *relationName, /* In bootstrap mode, we have no indexes */ if (!IsBootstrapProcessingMode()) { - for (i = 0; IndexedCatalogNames[i] != NULL; i++) - { - if (strcmp(IndexedCatalogNames[i], relationName) == 0) - { - relation->rd_rel->relhasindex = true; - break; - } - } + /* + * This list is incomplete, but it only has to work for the + * set of rels that formrdesc is used for ... + */ + if (strcmp(relationName, RelationRelationName) == 0 || + strcmp(relationName, AttributeRelationName) == 0 || + strcmp(relationName, ProcedureRelationName) == 0 || + strcmp(relationName, TypeRelationName) == 0) + relation->rd_rel->relhasindex = true; } /* @@ -1323,7 +1318,6 @@ formrdesc(char *relationName, * * Update the phony data inserted by formrdesc() with real info * from pg_class. - * */ static void fixrdesc(char *relationName) |