aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/index/genam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/index/genam.c')
-rw-r--r--src/backend/access/index/genam.c29
1 files changed, 20 insertions, 9 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;
}