diff options
author | Hiroshi Inoue <inoue@tpf.co.jp> | 2000-12-08 06:17:58 +0000 |
---|---|---|
committer | Hiroshi Inoue <inoue@tpf.co.jp> | 2000-12-08 06:17:58 +0000 |
commit | d7892e026396cffb19ebb760fcd12f966054294b (patch) | |
tree | 4d8b41da2e587c1ce7895efbf023ca59527f9f35 /src/backend/utils/cache/relcache.c | |
parent | 8d7c0851a3d6a69030a29cadea74b5eeeaf3b8a6 (diff) | |
download | postgresql-d7892e026396cffb19ebb760fcd12f966054294b.tar.gz postgresql-d7892e026396cffb19ebb760fcd12f966054294b.zip |
REINDEX under WAL.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index e4551d4c604..deb8cc67df3 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.118 2000/11/30 18:38:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.119 2000/12/08 06:17:56 inoue Exp $ * *------------------------------------------------------------------------- */ @@ -250,6 +250,10 @@ do { \ /* non-export function prototypes */ static void RelationClearRelation(Relation relation, bool rebuildIt); +#ifdef ENABLE_REINDEX_NAILED_RELATIONS +static void RelationReloadClassinfo(Relation relation); +#endif /* ENABLE_REINDEX_NAILED_RELATIONS */ +static void RelationResetRelation(Relation relation, bool rebuildIt); static void RelationFlushRelation(Relation *relationPtr, int skipLocalRelations); static Relation RelationNameCacheGetRelation(const char *relationName); @@ -387,6 +391,15 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) HeapTuple return_tuple; pg_class_desc = heap_openr(RelationRelationName, AccessShareLock); + /* + * If the indexes of pg_class are deactivated + * we have to call scan_pg_rel_seq() instead. + */ + if (!pg_class_desc->rd_rel->relhasindex) + { + heap_close(pg_class_desc, AccessShareLock); + return scan_pg_rel_seq(buildinfo); + } switch (buildinfo.infotype) { @@ -1555,6 +1568,45 @@ RelationClose(Relation relation) RelationDecrementReferenceCount(relation); } +#ifdef ENABLE_REINDEX_NAILED_RELATIONS +/* -------------------------------- + * RelationReloadClassinfo + * + * This function is especially for nailed relations. + * relhasindex/relfilenode could be changed even for + * nailed relations. + * -------------------------------- + */ +static void +RelationReloadClassinfo(Relation relation) +{ + RelationBuildDescInfo buildinfo; + HeapTuple pg_class_tuple; + Form_pg_class relp; + + if (!relation->rd_rel) + return; + buildinfo.infotype = INFO_RELID; + buildinfo.i.info_id = relation->rd_id; + pg_class_tuple = ScanPgRelation(buildinfo); + if (!HeapTupleIsValid(pg_class_tuple)) + { + elog(ERROR, "RelationReloadClassinfo system relation id=%d doesn't exist", relation->rd_id); + return; + } + RelationCacheDelete(relation); + relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); + memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE); + relation->rd_node.relNode = relp->relfilenode; + RelationCacheInsert(relation); + heap_freetuple(pg_class_tuple); +fprintf(stderr, "RelationClearRelation nailed %s hasindex=%d relfilenode=%d,%d\n", +RelationGetRelationName(relation), relation->rd_rel->relhasindex, +relation->rd_rel->relfilenode, relation->rd_node.relNode); + + return; +} +#endif /* ENABLE_REINDEX_NAILED_RELATIONS */ /* -------------------------------- * RelationClearRelation * @@ -1588,7 +1640,14 @@ RelationClearRelation(Relation relation, bool rebuildIt) * we'd be unable to recover. */ if (relation->rd_isnailed) +#ifdef ENABLE_REINDEX_NAILED_RELATIONS + { + RelationReloadClassinfo(relation); +#endif /* ENABLE_REINDEX_NAILED_RELATIONS */ return; +#ifdef ENABLE_REINDEX_NAILED_RELATIONS + } +#endif /* ENABLE_REINDEX_NAILED_RELATIONS */ /* * Remove relation from hash tables |