diff options
| author | Tom Lane | 2003-09-24 18:54:02 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-09-24 18:54:02 +0000 |
| commit | a56a016ceb612cdee1ddc5990682f36d541e5b07 (patch) | |
| tree | c496319424e0445562dd42ee7229e6d87567996f /src/backend/access | |
| parent | 5f78c6a886a22209dee62de0c13edd6a68453011 (diff) | |
Repair some REINDEX problems per recent discussions. The relcache is
now able to cope with assigning new relfilenode values to nailed-in-cache
indexes, so they can be reindexed using the fully crash-safe method. This
leaves only shared system indexes as special cases. Remove the 'index
deactivation' code, since it provides no useful protection in the shared-
index case. Require reindexing of shared indexes to be done in standalone
mode, but remove other restrictions on REINDEX. -P (IgnoreSystemIndexes)
now prevents using indexes for lookups, but does not disable index updates.
It is therefore safe to allow from PGOPTIONS. Upshot: reindexing system catalogs
can be done without a standalone backend for all cases except
shared catalogs.
Diffstat (limited to 'src/backend/access')
| -rw-r--r-- | src/backend/access/index/genam.c | 29 | ||||
| -rw-r--r-- | src/backend/access/transam/xact.c | 5 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index eaa0d172e54..a362cd8cfaf 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.40 2003/08/04 02:39:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.41 2003/09/24 18:54:01 tgl Exp $ * * NOTES * many of the old access method routines have been turned into @@ -184,21 +184,32 @@ systable_beginscan(Relation heapRelation, int nkeys, ScanKey key) { SysScanDesc sysscan; + Relation irel; + + if (indexOK && !IsIgnoringSystemIndexes()) + { + /* We assume it's a system index, so index_openr is OK */ + irel = index_openr(indexRelname); + + if (ReindexIsProcessingIndex(RelationGetRelid(irel))) + { + /* oops, can't use index that's being rebuilt */ + index_close(irel); + irel = NULL; + } + } + else + irel = NULL; sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData)); sysscan->heap_rel = heapRelation; + sysscan->irel = irel; - if (indexOK && - heapRelation->rd_rel->relhasindex && - !IsIgnoringSystemIndexes()) + if (irel) { - Relation irel; int i; - /* We assume it's a system index, so index_openr is OK */ - sysscan->irel = irel = index_openr(indexRelname); - /* * Change attribute numbers to be index column numbers. * @@ -210,13 +221,13 @@ systable_beginscan(Relation heapRelation, Assert(key[i].sk_attno == irel->rd_index->indkey[i]); key[i].sk_attno = i + 1; } + sysscan->iscan = index_beginscan(heapRelation, irel, snapshot, nkeys, key); sysscan->scan = NULL; } else { - sysscan->irel = NULL; sysscan->scan = heap_beginscan(heapRelation, snapshot, nkeys, key); sysscan->iscan = NULL; } diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index e632ae9e1f4..e17a3f3c372 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.152 2003/08/08 21:41:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.153 2003/09/24 18:54:01 tgl Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -834,8 +834,6 @@ StartTransaction(void) */ s->state = TRANS_START; - SetReindexProcessing(false); - /* * generate a new transaction id */ @@ -1085,6 +1083,7 @@ AbortTransaction(void) AtEOXact_Namespace(false); AtEOXact_CatCache(false); AtEOXact_Files(); + SetReindexProcessing(InvalidOid, InvalidOid); pgstat_count_xact_rollback(); /* |
