mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Allow indexes on system catalogs for use in cache code.
Thanks to Hiroshi
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.92 1999/10/26 03:12:33 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.93 1999/11/01 02:29:24 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -54,26 +54,23 @@
|
||||
|
||||
/* non-export function prototypes */
|
||||
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
|
||||
bool istemp);
|
||||
bool istemp);
|
||||
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
|
||||
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
|
||||
List *attributeList,
|
||||
int numatts, AttrNumber *attNums);
|
||||
List *attributeList, int numatts, AttrNumber *attNums);
|
||||
|
||||
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
|
||||
static Oid UpdateRelationRelation(Relation indexRelation, char *temp_relname);
|
||||
static void InitializeAttributeOids(Relation indexRelation,
|
||||
int numatts,
|
||||
Oid indexoid);
|
||||
static void
|
||||
AppendAttributeTuples(Relation indexRelation, int numatts);
|
||||
int numatts, Oid indexoid);
|
||||
static void AppendAttributeTuples(Relation indexRelation, int numatts);
|
||||
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber *attNums, Oid *classOids, Node *predicate,
|
||||
List *attributeList, bool islossy, bool unique, bool primary);
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber *attNums, Oid *classOids, Node *predicate,
|
||||
List *attributeList, bool islossy, bool unique, bool primary);
|
||||
static void DefaultBuild(Relation heapRelation, Relation indexRelation,
|
||||
int numberOfAttributes, AttrNumber *attributeNumber,
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
int numberOfAttributes, AttrNumber *attributeNumber,
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
Datum *parameter, FuncIndexInfoPtr funcInfo, PredInfo *predInfo);
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
@@ -661,6 +658,7 @@ UpdateIndexRelation(Oid indexoid,
|
||||
Relation pg_index;
|
||||
HeapTuple tuple;
|
||||
int i;
|
||||
Relation idescs[Num_pg_index_indices];
|
||||
|
||||
/* ----------------
|
||||
* allocate an Form_pg_index big enough to hold the
|
||||
@@ -752,6 +750,16 @@ UpdateIndexRelation(Oid indexoid,
|
||||
*/
|
||||
heap_insert(pg_index, tuple);
|
||||
|
||||
/* ----------------
|
||||
* insert the index tuple into the pg_index
|
||||
* ----------------
|
||||
*/
|
||||
if (!IsBootstrapProcessingMode())
|
||||
{
|
||||
CatalogOpenIndices(Num_pg_index_indices, Name_pg_index_indices, idescs);
|
||||
CatalogIndexInsert(idescs, Num_pg_index_indices, pg_index, tuple);
|
||||
CatalogCloseIndices(Num_pg_index_indices, idescs);
|
||||
}
|
||||
/* ----------------
|
||||
* close the relation and free the tuple
|
||||
* ----------------
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.48 1999/10/15 01:49:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.49 1999/11/01 02:29:25 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,15 +38,17 @@
|
||||
* pg_trigger
|
||||
*/
|
||||
|
||||
char *Name_pg_amop_indices[Num_pg_amop_indices] = {AccessMethodOpidIndex,
|
||||
AccessMethodStrategyIndex};
|
||||
char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
|
||||
AttributeNumIndex,
|
||||
AttributeRelidIndex};
|
||||
AttributeNumIndex, AttributeRelidIndex};
|
||||
char *Name_pg_index_indices[Num_pg_index_indices] = {IndexRelidIndex};
|
||||
char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
|
||||
ProcedureOidIndex};
|
||||
ProcedureOidIndex};
|
||||
char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
|
||||
TypeOidIndex};
|
||||
TypeOidIndex};
|
||||
char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
|
||||
ClassOidIndex};
|
||||
ClassOidIndex};
|
||||
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
|
||||
|
||||
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
|
||||
@@ -255,12 +257,89 @@ CatalogIndexFetchTuple(Relation heapRelation,
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* Class-specific index lookups
|
||||
*---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
HeapTuple
|
||||
AccessMethodOpidIndexScan(Relation heapRelation,
|
||||
Oid claid,
|
||||
Oid opopr,
|
||||
Oid opid)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[3];
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(claid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 2,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(opopr));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[2],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 3,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(opid));
|
||||
|
||||
idesc = index_openr(AccessMethodOpidIndex);
|
||||
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
|
||||
|
||||
index_close(idesc);
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
HeapTuple
|
||||
AccessMethodStrategyIndexScan(Relation heapRelation,
|
||||
Oid opid,
|
||||
Oid claid,
|
||||
int2 opstrategy)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[3];
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(opid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[1],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 2,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(claid));
|
||||
|
||||
ScanKeyEntryInitialize(&skey[2],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 3,
|
||||
(RegProcedure) F_INT2EQ,
|
||||
Int16GetDatum(opstrategy));
|
||||
|
||||
idesc = index_openr(AccessMethodStrategyIndex);
|
||||
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
|
||||
|
||||
index_close(idesc);
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
HeapTuple
|
||||
AttributeNameIndexScan(Relation heapRelation,
|
||||
Oid relid,
|
||||
@@ -320,6 +399,28 @@ AttributeNumIndexScan(Relation heapRelation,
|
||||
return tuple;
|
||||
}
|
||||
|
||||
HeapTuple
|
||||
IndexRelidIndexScan(Relation heapRelation, Oid relid)
|
||||
{
|
||||
Relation idesc;
|
||||
ScanKeyData skey[1];
|
||||
HeapTuple tuple;
|
||||
|
||||
ScanKeyEntryInitialize(&skey[0],
|
||||
(bits16) 0x0,
|
||||
(AttrNumber) 1,
|
||||
(RegProcedure) F_OIDEQ,
|
||||
ObjectIdGetDatum(relid));
|
||||
|
||||
idesc = index_openr(IndexRelidIndex);
|
||||
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
||||
|
||||
index_close(idesc);
|
||||
|
||||
return tuple;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HeapTuple
|
||||
ProcedureOidIndexScan(Relation heapRelation, Oid procId)
|
||||
|
||||
Reference in New Issue
Block a user