aboutsummaryrefslogtreecommitdiff
path: root/src/backend/catalog/indexing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/catalog/indexing.c')
-rw-r--r--src/backend/catalog/indexing.c685
1 files changed, 4 insertions, 681 deletions
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 1a96c3f5ea5..6003ab6bc53 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.72 2000/10/24 01:38:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.73 2000/11/10 00:33:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -176,50 +176,6 @@ CatalogIndexInsert(Relation *idescs,
}
}
-/*
- * This is needed at initialization when reldescs for some of the crucial
- * system catalogs are created and nailed into the cache.
- */
-bool
-CatalogHasIndex(char *catName, Oid catId)
-{
- Relation pg_class;
- HeapTuple htup;
- Form_pg_class pgRelP;
- int i;
-
- Assert(IsSystemRelationName(catName));
-
- /*
- * If we're bootstraping we don't have pg_class (or any indices).
- */
- if (IsBootstrapProcessingMode())
- return false;
-
- if (IsInitProcessingMode())
- {
- for (i = 0; IndexedCatalogNames[i] != NULL; i++)
- {
- if (strcmp(IndexedCatalogNames[i], catName) == 0)
- return true;
- }
- return false;
- }
-
- pg_class = heap_openr(RelationRelationName, AccessShareLock);
- htup = ClassOidIndexScan(pg_class, catId);
- heap_close(pg_class, AccessShareLock);
-
- if (!HeapTupleIsValid(htup))
- {
- elog(NOTICE, "CatalogHasIndex: no relation with oid %u", catId);
- return false;
- }
-
- pgRelP = (Form_pg_class) GETSTRUCT(htup);
- return pgRelP->relhasindex;
-}
-
/*
* CatalogIndexFetchTuple() -- Get a tuple that satisfies a scan key
@@ -271,163 +227,13 @@ CatalogIndexFetchTuple(Relation heapRelation,
*/
/*
- * The remainder of the file is for individual index scan routines. Each
- * index should be scanned according to how it was defined during bootstrap
- * (that is, functional or normal) and what arguments the cache lookup
- * requires. Each routine returns the heap tuple that qualifies.
+ * The remainder of the file is for individual index scan routines.
+ * These routines provide canned scanning code for certain widely-used
+ * indexes. Most indexes don't need one of these.
*/
HeapTuple
-AggregateNameTypeIndexScan(Relation heapRelation,
- Datum aggName, Datum aggType)
-{
- Relation idesc;
- ScanKeyData skey[2];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- aggName);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_OIDEQ,
- aggType);
-
- idesc = index_openr(AggregateNameTypeIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-AmNameIndexScan(Relation heapRelation, Datum amName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- amName);
-
- idesc = index_openr(AmNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-AccessMethodOpidIndexScan(Relation heapRelation,
- Datum claid,
- Datum opopr,
- Datum opid)
-{
- Relation idesc;
- ScanKeyData skey[3];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- claid);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_OIDEQ,
- opopr);
-
- ScanKeyEntryInitialize(&skey[2],
- (bits16) 0x0,
- (AttrNumber) 3,
- (RegProcedure) F_OIDEQ,
- opid);
-
- idesc = index_openr(AccessMethodOpidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
-
- index_close(idesc);
- return tuple;
-}
-
-HeapTuple
-AccessMethodStrategyIndexScan(Relation heapRelation,
- Datum opid,
- Datum claid,
- Datum opstrategy)
-{
- Relation idesc;
- ScanKeyData skey[3];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- opid);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_OIDEQ,
- claid);
-
- ScanKeyEntryInitialize(&skey[2],
- (bits16) 0x0,
- (AttrNumber) 3,
- (RegProcedure) F_INT2EQ,
- opstrategy);
-
- idesc = index_openr(AccessMethodStrategyIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-AttributeRelidNameIndexScan(Relation heapRelation,
- Datum relid,
- Datum attname)
-{
- Relation idesc;
- ScanKeyData skey[2];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- relid);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_NAMEEQ,
- attname);
-
- idesc = index_openr(AttributeRelidNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
AttributeRelidNumIndexScan(Relation heapRelation,
Datum relid,
Datum attnum)
@@ -450,332 +256,6 @@ AttributeRelidNumIndexScan(Relation heapRelation,
idesc = index_openr(AttributeRelidNumIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-OpclassDeftypeIndexScan(Relation heapRelation, Datum defType)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- defType);
-
- idesc = index_openr(OpclassDeftypeIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-OpclassNameIndexScan(Relation heapRelation, Datum opcName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- opcName);
-
- idesc = index_openr(OpclassNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-GroupNameIndexScan(Relation heapRelation, Datum groName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- groName);
-
- idesc = index_openr(GroupNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-GroupSysidIndexScan(Relation heapRelation, Datum sysId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_INT4EQ,
- sysId);
-
- idesc = index_openr(GroupSysidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-IndexRelidIndexScan(Relation heapRelation, Datum relid)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- relid);
-
- idesc = index_openr(IndexRelidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-InheritsRelidSeqnoIndexScan(Relation heapRelation,
- Datum relid,
- Datum seqno)
-{
- Relation idesc;
- ScanKeyData skey[2];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- relid);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_INT4EQ,
- seqno);
-
- idesc = index_openr(InheritsRelidSeqnoIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-LanguageNameIndexScan(Relation heapRelation, Datum lanName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- lanName);
-
- idesc = index_openr(LanguageNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-LanguageOidIndexScan(Relation heapRelation, Datum lanId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- lanId);
-
- idesc = index_openr(LanguageOidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-ListenerPidRelnameIndexScan(Relation heapRelation,
- Datum pid, Datum relName)
-{
- Relation idesc;
- ScanKeyData skey[2];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_INT4EQ,
- pid);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_NAMEEQ,
- relName);
-
- idesc = index_openr(ListenerPidRelnameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-OperatorNameIndexScan(Relation heapRelation,
- Datum oprName,
- Datum oprLeft,
- Datum oprRight,
- Datum oprKind)
-{
- Relation idesc;
- ScanKeyData skey[4];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- oprName);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_OIDEQ,
- oprLeft);
-
- ScanKeyEntryInitialize(&skey[2],
- (bits16) 0x0,
- (AttrNumber) 3,
- (RegProcedure) F_OIDEQ,
- oprRight);
-
- ScanKeyEntryInitialize(&skey[3],
- (bits16) 0x0,
- (AttrNumber) 4,
- (RegProcedure) F_CHAREQ,
- oprKind);
-
- idesc = index_openr(OperatorNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 4);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-OperatorOidIndexScan(Relation heapRelation, Datum oprId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- oprId);
-
- idesc = index_openr(OperatorOidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-ProcedureNameIndexScan(Relation heapRelation,
- Datum procName,
- Datum nargs,
- Datum argTypes)
-{
- Relation idesc;
- ScanKeyData skey[3];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- procName);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_INT2EQ,
- nargs);
-
- ScanKeyEntryInitialize(&skey[2],
- (bits16) 0x0,
- (AttrNumber) 3,
- (RegProcedure) F_OIDVECTOREQ,
- argTypes);
-
- idesc = index_openr(ProcedureNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-ProcedureOidIndexScan(Relation heapRelation, Datum procId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- procId);
-
- idesc = index_openr(ProcedureOidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
index_close(idesc);
return tuple;
}
@@ -796,7 +276,6 @@ ClassNameIndexScan(Relation heapRelation, Datum relName)
idesc = index_openr(ClassNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
index_close(idesc);
return tuple;
}
@@ -817,162 +296,6 @@ ClassOidIndexScan(Relation heapRelation, Datum relId)
idesc = index_openr(ClassOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-RewriteRulenameIndexScan(Relation heapRelation, Datum ruleName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- ruleName);
-
- idesc = index_openr(RewriteRulenameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-RewriteOidIndexScan(Relation heapRelation, Datum rewriteId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- rewriteId);
-
- idesc = index_openr(RewriteOidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-ShadowNameIndexScan(Relation heapRelation, Datum useName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- useName);
-
- idesc = index_openr(ShadowNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-ShadowSysidIndexScan(Relation heapRelation, Datum sysId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_INT4EQ,
- sysId);
-
- idesc = index_openr(ShadowSysidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-StatisticRelidAttnumIndexScan(Relation heapRelation,
- Datum relId,
- Datum attNum)
-{
- Relation idesc;
- ScanKeyData skey[2];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- relId);
-
- ScanKeyEntryInitialize(&skey[1],
- (bits16) 0x0,
- (AttrNumber) 2,
- (RegProcedure) F_INT2EQ,
- attNum);
-
- idesc = index_openr(StatisticRelidAttnumIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-TypeNameIndexScan(Relation heapRelation, Datum typeName)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_NAMEEQ,
- typeName);
-
- idesc = index_openr(TypeNameIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
- index_close(idesc);
- return tuple;
-}
-
-
-HeapTuple
-TypeOidIndexScan(Relation heapRelation, Datum typeId)
-{
- Relation idesc;
- ScanKeyData skey[1];
- HeapTuple tuple;
-
- ScanKeyEntryInitialize(&skey[0],
- (bits16) 0x0,
- (AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- typeId);
-
- idesc = index_openr(TypeOidIndex);
- tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
-
index_close(idesc);
return tuple;
}