summaryrefslogtreecommitdiff
path: root/src/backend/catalog
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1999-11-22 17:56:41 +0000
committerBruce Momjian <bruce@momjian.us>1999-11-22 17:56:41 +0000
commitfc955b14ea667e04475e2b7339c8445611470771 (patch)
tree5f5a3760e1e5cdfe910125817d9217b837eab23b /src/backend/catalog
parente30c2d67ef1c58d148bdc1b3a7faeed7b17d8b28 (diff)
downloadpostgresql-fc955b14ea667e04475e2b7339c8445611470771.tar.gz
Add system indexes to match all caches.
Make all system indexes unique. Make all cache loads use system indexes. Rename *rel to *relid in inheritance tables. Rename cache names to be clearer.
Diffstat (limited to 'src/backend/catalog')
-rw-r--r--src/backend/catalog/Makefile5
-rw-r--r--src/backend/catalog/aclchk.c18
-rw-r--r--src/backend/catalog/catalog.c4
-rw-r--r--src/backend/catalog/heap.c10
-rw-r--r--src/backend/catalog/index.c10
-rw-r--r--src/backend/catalog/indexing.c498
-rw-r--r--src/backend/catalog/pg_aggregate.c27
-rw-r--r--src/backend/catalog/pg_operator.c58
-rw-r--r--src/backend/catalog/pg_proc.c6
-rw-r--r--src/backend/catalog/pg_type.c10
10 files changed, 554 insertions, 92 deletions
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 0d63ad7330..cf6e586927 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -4,7 +4,7 @@
# Makefile for catalog
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.17 1999/03/27 17:25:09 tgl Exp $
+# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.18 1999/11/22 17:55:56 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -38,7 +38,8 @@ LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
pg_rewrite.h pg_listener.h pg_description.h indexing.h \
)
-global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS)
+global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS) \
+ $(addprefix ../../include/catalog/, indexing.h)
ifneq ($(PORTNAME), win)
sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
else
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 262312eb67..0744f47b63 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.29 1999/11/07 23:08:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.30 1999/11/22 17:55:56 momjian Exp $
*
* NOTES
* See acl.h.
@@ -350,7 +350,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
int32 result;
Relation relation;
- tuple = SearchSysCacheTuple(USENAME,
+ tuple = SearchSysCacheTuple(USERNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -469,7 +469,7 @@ pg_ownercheck(char *usename,
AclId user_id,
owner_id = 0;
- tuple = SearchSysCacheTuple(USENAME,
+ tuple = SearchSysCacheTuple(USERNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -493,13 +493,13 @@ pg_ownercheck(char *usename,
0, 0, 0);
switch (cacheid)
{
- case OPROID:
+ case OPEROID:
if (!HeapTupleIsValid(tuple))
elog(ERROR, "pg_ownercheck: operator %ld not found",
PointerGetDatum(value));
owner_id = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner;
break;
- case PRONAME:
+ case PROCNAME:
if (!HeapTupleIsValid(tuple))
elog(ERROR, "pg_ownercheck: function \"%s\" not found",
value);
@@ -511,7 +511,7 @@ pg_ownercheck(char *usename,
value);
owner_id = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
break;
- case TYPNAME:
+ case TYPENAME:
if (!HeapTupleIsValid(tuple))
elog(ERROR, "pg_ownercheck: type \"%s\" not found",
value);
@@ -535,7 +535,7 @@ pg_func_ownercheck(char *usename,
AclId user_id,
owner_id;
- tuple = SearchSysCacheTuple(USENAME,
+ tuple = SearchSysCacheTuple(USERNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -555,7 +555,7 @@ pg_func_ownercheck(char *usename,
return 1;
}
- tuple = SearchSysCacheTuple(PRONAME,
+ tuple = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(funcname),
Int32GetDatum(nargs),
PointerGetDatum(arglist),
@@ -577,7 +577,7 @@ pg_aggr_ownercheck(char *usename,
AclId user_id,
owner_id;
- tuple = SearchSysCacheTuple(USENAME,
+ tuple = SearchSysCacheTuple(USERNAME,
PointerGetDatum(usename),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 1ad931e8b2..fc2536f543 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.25 1999/07/17 20:16:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.26 1999/11/22 17:55:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,7 +151,7 @@ fillatt(TupleDesc tupleDesc)
for (i = 0; i < natts;)
{
- tuple = SearchSysCacheTuple(TYPOID,
+ tuple = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum((*attributeP)->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index cc0ce0293b..873873dff4 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.108 1999/11/16 04:13:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.109 1999/11/22 17:55:57 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -964,7 +964,7 @@ RelationRemoveInheritance(Relation relation)
tuple = heap_getnext(scan, 0);
if (HeapTupleIsValid(tuple))
{
- Oid subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrel;
+ Oid subclass = ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
heap_endscan(scan);
heap_close(catalogRelation, RowExclusiveLock);
@@ -979,7 +979,7 @@ RelationRemoveInheritance(Relation relation)
* so we can trash it. First we remove dead INHERITS tuples.
* ----------------
*/
- entry.sk_attno = Anum_pg_inherits_inhrel;
+ entry.sk_attno = Anum_pg_inherits_inhrelid;
scan = heap_beginscan(catalogRelation,
false,
@@ -1003,7 +1003,7 @@ RelationRemoveInheritance(Relation relation)
catalogRelation = heap_openr(InheritancePrecidenceListRelationName,
RowExclusiveLock);
- entry.sk_attno = Anum_pg_ipl_iplrel;
+ entry.sk_attno = Anum_pg_ipl_iplrelid;
scan = heap_beginscan(catalogRelation,
false,
@@ -1157,7 +1157,7 @@ RelationTruncateIndexes(Relation heapRelation)
{
funcInfo = &fInfo;
FIsetnArgs(funcInfo, numberOfAttributes);
- procTuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(procId),
+ procTuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(procId),
0, 0, 0);
if (!HeapTupleIsValid(procTuple))
elog(ERROR, "RelationTruncateIndexes: index procedure not found");
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 65ec5ad42c..d33d97c2ba 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.96 1999/11/21 20:01:10 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.97 1999/11/22 17:55:57 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -157,7 +157,7 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
funcname = FIgetname(funcInfo);
nargs = FIgetnArgs(funcInfo);
argtypes = FIgetArglist(funcInfo);
- tuple = SearchSysCacheTuple(PRONAME,
+ tuple = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(funcname),
Int32GetDatum(nargs),
PointerGetDatum(argtypes),
@@ -171,7 +171,7 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
/*
* Look up the return type in pg_type for the type length.
*/
- tuple = SearchSysCacheTuple(TYPOID,
+ tuple = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(retType),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
@@ -317,7 +317,7 @@ ConstructTupleDescriptor(Oid heapoid,
{
HeapTuple tup;
- tup = SearchSysCacheTuple(TYPNAME,
+ tup = SearchSysCacheTuple(TYPENAME,
PointerGetDatum(IndexKeyType->name),
0, 0, 0);
if (!HeapTupleIsValid(tup))
@@ -1028,7 +1028,7 @@ index_create(char *heapRelationName,
{
HeapTuple proc_tup;
- proc_tup = SearchSysCacheTuple(PRONAME,
+ proc_tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(FIgetname(funcInfo)),
Int32GetDatum(FIgetnArgs(funcInfo)),
PointerGetDatum(FIgetArglist(funcInfo)),
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index c91230267b..1dfd531d34 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.50 1999/11/01 04:00:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.51 1999/11/22 17:55:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,34 +26,49 @@
#include "utils/syscache.h"
/*
- * Names of indices on the following system catalogs:
- *
- * pg_attribute
- * pg_proc
- * pg_type
- * pg_naming
- * pg_class
- * pg_attrdef
- * pg_relcheck
- * pg_trigger
+ * Names of indices - they match all system caches
*/
-char *Name_pg_amop_indices[Num_pg_amop_indices] = {AccessMethodOpidIndex,
- AccessMethodStrategyIndex};
-char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
- AttributeNumIndex, AttributeRelidIndex};
-char *Name_pg_index_indices[Num_pg_index_indices] = {IndexRelidIndex};
-char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
- ProcedureOidIndex};
-char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
- TypeOidIndex};
-char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
- ClassOidIndex};
-char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
-char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
-char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex,
- TriggerConstrNameIndex, TriggerConstrRelidIndex};
-char *Name_pg_description_indices[Num_pg_description_indices] = {DescriptionObjIndex};
+char *Name_pg_aggregate_indices[Num_pg_aggregate_indices] =
+ {AggregateNameTypeIndex};
+char *Name_pg_am_indices[Num_pg_am_indices] =
+ {AmNameIndex};
+char *Name_pg_amop_indices[Num_pg_amop_indices] =
+ {AccessMethodOpidIndex, AccessMethodStrategyIndex};
+char *Name_pg_attr_indices[Num_pg_attr_indices] =
+ {AttributeRelidNameIndex, AttributeRelidNumIndex};
+char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] =
+ {AttrDefaultIndex};
+char *Name_pg_class_indices[Num_pg_class_indices] =
+ {ClassNameIndex, ClassOidIndex};
+char *Name_pg_group_indices[Num_pg_group_indices] =
+ {GroupNameIndex, GroupSysidIndex};
+char *Name_pg_index_indices[Num_pg_index_indices] =
+ {IndexRelidIndex};
+char *Name_pg_inherits_indices[Num_pg_inherits_indices] =
+ {InheritsRelidSeqnoIndex};
+char *Name_pg_language_indices[Num_pg_language_indices] =
+ {LanguageOidIndex, LanguageNameIndex};
+char *Name_pg_listener_indices[Num_pg_listener_indices] =
+ {ListenerRelnamePidIndex};
+char *Name_pg_opclass_indices[Num_pg_opclass_indices] =
+ {OpclassNameIndex, OpclassDeftypeIndex};
+char *Name_pg_operator_indices[Num_pg_operator_indices] =
+ {OperatorOidIndex, OperatorNameIndex};
+char *Name_pg_proc_indices[Num_pg_proc_indices] =
+ {ProcedureOidIndex, ProcedureNameIndex};
+char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] =
+ {RelCheckIndex};
+char *Name_pg_rewrite_indices[Num_pg_rewrite_indices] =
+ {RewriteOidIndex, RewriteRulenameIndex};
+char *Name_pg_shadow_indices[Num_pg_shadow_indices] =
+ {ShadowNameIndex, ShadowSysidIndex};
+char *Name_pg_trigger_indices[Num_pg_trigger_indices] =
+ {TriggerRelidIndex, TriggerConstrNameIndex, TriggerConstrRelidIndex};
+char *Name_pg_type_indices[Num_pg_type_indices] =
+ {TypeNameIndex, TypeOidIndex};
+char *Name_pg_description_indices[Num_pg_description_indices] =
+ {DescriptionObjIndex};
@@ -264,6 +279,56 @@ CatalogIndexFetchTuple(Relation heapRelation,
* (that is, functional or normal) and what arguments the cache lookup
* requires. Each routine returns the heap tuple that qualifies.
*/
+
+
+HeapTuple
+AggregateNameTypeIndexScan(Relation heapRelation, char *aggName, Oid aggType)
+{
+ Relation idesc;
+ ScanKeyData skey[2];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(aggName));
+
+ ScanKeyEntryInitialize(&skey[1],
+ (bits16) 0x0,
+ (AttrNumber) 2,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(aggType));
+
+ idesc = index_openr(AggregateNameTypeIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+AmNameIndexScan(Relation heapRelation, char *amName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(amName));
+
+ idesc = index_openr(AmNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
HeapTuple
AccessMethodOpidIndexScan(Relation heapRelation,
Oid claid,
@@ -335,9 +400,10 @@ AccessMethodStrategyIndexScan(Relation heapRelation,
return tuple;
}
-
+
+
HeapTuple
-AttributeNameIndexScan(Relation heapRelation,
+AttributeRelidNameIndexScan(Relation heapRelation,
Oid relid,
char *attname)
{
@@ -357,7 +423,7 @@ AttributeNameIndexScan(Relation heapRelation,
(RegProcedure) F_NAMEEQ,
NameGetDatum(attname));
- idesc = index_openr(AttributeNameIndex);
+ idesc = index_openr(AttributeRelidNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
@@ -367,7 +433,7 @@ AttributeNameIndexScan(Relation heapRelation,
HeapTuple
-AttributeNumIndexScan(Relation heapRelation,
+AttributeRelidNumIndexScan(Relation heapRelation,
Oid relid,
AttrNumber attnum)
{
@@ -387,7 +453,7 @@ AttributeNumIndexScan(Relation heapRelation,
(RegProcedure) F_INT2EQ,
Int16GetDatum(attnum));
- idesc = index_openr(AttributeNumIndex);
+ idesc = index_openr(AttributeRelidNumIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
index_close(idesc);
@@ -395,6 +461,92 @@ AttributeNumIndexScan(Relation heapRelation,
return tuple;
}
+
+HeapTuple
+OpclassDeftypeIndexScan(Relation heapRelation, Oid defType)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(defType));
+
+ idesc = index_openr(OpclassDeftypeIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+OpclassNameIndexScan(Relation heapRelation, char *opcName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(opcName));
+
+ idesc = index_openr(OpclassNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+GroupNameIndexScan(Relation heapRelation, char *groName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(groName));
+
+ idesc = index_openr(GroupNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+GroupSysidIndexScan(Relation heapRelation, int4 sysId)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_INT4EQ,
+ Int32GetDatum(sysId));
+
+ idesc = index_openr(GroupSysidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
HeapTuple
IndexRelidIndexScan(Relation heapRelation, Oid relid)
{
@@ -417,9 +569,59 @@ IndexRelidIndexScan(Relation heapRelation, Oid relid)
}
+HeapTuple
+InheritsRelidSeqnoIndexScan(Relation heapRelation,
+ Oid relid,
+ int4 seqno)
+{
+ Relation idesc;
+ ScanKeyData skey[2];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(relid));
+
+ ScanKeyEntryInitialize(&skey[1],
+ (bits16) 0x0,
+ (AttrNumber) 2,
+ (RegProcedure) F_INT4EQ,
+ Int32GetDatum(seqno));
+
+ idesc = index_openr(InheritsRelidSeqnoIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+LanguageNameIndexScan(Relation heapRelation, char *lanName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(lanName));
+
+ idesc = index_openr(LanguageNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
HeapTuple
-ProcedureOidIndexScan(Relation heapRelation, Oid procId)
+LanguageOidIndexScan(Relation heapRelation, Oid lanId)
{
Relation idesc;
ScanKeyData skey[1];
@@ -429,9 +631,102 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
- ObjectIdGetDatum(procId));
+ ObjectIdGetDatum(lanId));
- idesc = index_openr(ProcedureOidIndex);
+ idesc = index_openr(LanguageOidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid)
+{
+ Relation idesc;
+ ScanKeyData skey[2];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(relName));
+
+ ScanKeyEntryInitialize(&skey[1],
+ (bits16) 0x0,
+ (AttrNumber) 2,
+ (RegProcedure) F_INT4EQ,
+ Int32GetDatum(pid));
+
+ idesc = index_openr(ListenerRelnamePidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+OperatorNameIndexScan(Relation heapRelation,
+ char *oprName,
+ Oid oprLeft,
+ Oid oprRight,
+ char oprKind)
+{
+ Relation idesc;
+ ScanKeyData skey[4];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(oprName));
+
+ ScanKeyEntryInitialize(&skey[1],
+ (bits16) 0x0,
+ (AttrNumber) 2,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(oprLeft));
+
+ ScanKeyEntryInitialize(&skey[2],
+ (bits16) 0x0,
+ (AttrNumber) 3,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(oprRight));
+
+ ScanKeyEntryInitialize(&skey[3],
+ (bits16) 0x0,
+ (AttrNumber) 4,
+ (RegProcedure) F_CHAREQ,
+ CharGetDatum(oprKind));
+
+ idesc = index_openr(OperatorNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 4);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+OperatorOidIndexScan(Relation heapRelation, Oid oprId)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(oprId));
+
+ idesc = index_openr(OperatorOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
@@ -478,7 +773,7 @@ ProcedureNameIndexScan(Relation heapRelation,
HeapTuple
-TypeOidIndexScan(Relation heapRelation, Oid typeId)
+ProcedureOidIndexScan(Relation heapRelation, Oid procId)
{
Relation idesc;
ScanKeyData skey[1];
@@ -488,9 +783,95 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_OIDEQ,
- ObjectIdGetDatum(typeId));
+ ObjectIdGetDatum(procId));
- idesc = index_openr(TypeOidIndex);
+ idesc = index_openr(ProcedureOidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+ClassNameIndexScan(Relation heapRelation, char *relName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(relName));
+
+ idesc = index_openr(ClassNameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+ClassOidIndexScan(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(ClassOidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+RewriteRulenameIndexScan(Relation heapRelation, char *ruleName)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_NAMEEQ,
+ PointerGetDatum(ruleName));
+
+ idesc = index_openr(RewriteRulenameIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+ return tuple;
+}
+
+
+HeapTuple
+RewriteOidIndexScan(Relation heapRelation, Oid rewriteId)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(rewriteId));
+
+ idesc = index_openr(RewriteOidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
@@ -522,7 +903,29 @@ TypeNameIndexScan(Relation heapRelation, char *typeName)
HeapTuple
-ClassNameIndexScan(Relation heapRelation, char *relName)
+TypeOidIndexScan(Relation heapRelation, Oid typeId)
+{
+ Relation idesc;
+ ScanKeyData skey[1];
+ HeapTuple tuple;
+
+ ScanKeyEntryInitialize(&skey[0],
+ (bits16) 0x0,
+ (AttrNumber) 1,
+ (RegProcedure) F_OIDEQ,
+ ObjectIdGetDatum(typeId));
+
+ idesc = index_openr(TypeOidIndex);
+ tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
+
+ index_close(idesc);
+
+ return tuple;
+}
+
+
+HeapTuple
+ShadowNameIndexScan(Relation heapRelation, char *useName)
{
Relation idesc;
ScanKeyData skey[1];
@@ -532,9 +935,9 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
(bits16) 0x0,
(AttrNumber) 1,
(RegProcedure) F_NAMEEQ,
- PointerGetDatum(relName));
+ PointerGetDatum(useName));
- idesc = index_openr(ClassNameIndex);
+ idesc = index_openr(ShadowNameIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
@@ -543,22 +946,23 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
HeapTuple
-ClassOidIndexScan(Relation heapRelation, Oid relId)
+ShadowSysidIndexScan(Relation heapRelation, int4 sysId)
{
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
-
+
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
(AttrNumber) 1,
- (RegProcedure) F_OIDEQ,
- ObjectIdGetDatum(relId));
+ (RegProcedure) F_INT4EQ,
+ Int32GetDatum(sysId));
- idesc = index_openr(ClassOidIndex);
+ idesc = index_openr(ShadowSysidIndex);
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
index_close(idesc);
-
return tuple;
}
+
+
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 0f2b98da90..e7e61178c2 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.25 1999/09/18 19:06:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.26 1999/11/22 17:55:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,6 +15,7 @@
#include "access/heapam.h"
#include "catalog/catname.h"
+#include "catalog/indexing.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
@@ -83,7 +84,7 @@ AggregateCreate(char *aggName,
if (!aggtransfn1Name && !aggtransfn2Name)
elog(ERROR, "AggregateCreate: aggregate must have at least one transition function");
- tup = SearchSysCacheTuple(TYPNAME,
+ tup = SearchSysCacheTuple(TYPENAME,
PointerGetDatum(aggbasetypeName),
0, 0, 0);
if (!HeapTupleIsValid(tup))
@@ -92,7 +93,7 @@ AggregateCreate(char *aggName,
if (aggtransfn1Name)
{
- tup = SearchSysCacheTuple(TYPNAME,
+ tup = SearchSysCacheTuple(TYPENAME,
PointerGetDatum(aggtransfn1typeName),
0, 0, 0);
if (!HeapTupleIsValid(tup))
@@ -102,7 +103,7 @@ AggregateCreate(char *aggName,
fnArgs[0] = xret1;
fnArgs[1] = xbase;
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(aggtransfn1Name),
Int32GetDatum(2),
PointerGetDatum(fnArgs),
@@ -122,7 +123,7 @@ AggregateCreate(char *aggName,
if (aggtransfn2Name)
{
- tup = SearchSysCacheTuple(TYPNAME,
+ tup = SearchSysCacheTuple(TYPENAME,
PointerGetDatum(aggtransfn2typeName),
0, 0, 0);
if (!HeapTupleIsValid(tup))
@@ -132,7 +133,7 @@ AggregateCreate(char *aggName,
fnArgs[0] = xret2;
fnArgs[1] = 0;
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(aggtransfn2Name),
Int32GetDatum(1),
PointerGetDatum(fnArgs),
@@ -168,7 +169,7 @@ AggregateCreate(char *aggName,
{
fnArgs[0] = xret1;
fnArgs[1] = xret2;
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(aggfinalfnName),
Int32GetDatum(2),
PointerGetDatum(fnArgs),
@@ -242,6 +243,16 @@ AggregateCreate(char *aggName,
elog(ERROR, "AggregateCreate: heap_formtuple failed");
if (!OidIsValid(heap_insert(aggdesc, tup)))
elog(ERROR, "AggregateCreate: heap_insert failed");
+
+ if (RelationGetForm(aggdesc)->relhasindex)
+ {
+ Relation idescs[Num_pg_aggregate_indices];
+
+ CatalogOpenIndices(Num_pg_aggregate_indices, Name_pg_aggregate_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_aggregate_indices, aggdesc, tup);
+ CatalogCloseIndices(Num_pg_aggregate_indices, idescs);
+ }
+
heap_close(aggdesc, RowExclusiveLock);
}
@@ -301,7 +312,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
heap_close(aggRel, AccessShareLock);
- tup = SearchSysCacheTuple(TYPOID,
+ tup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(transtype),
0, 0, 0);
if (!HeapTupleIsValid(tup))
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 53b250fe3f..ad035ae801 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.42 1999/09/18 19:06:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.43 1999/11/22 17:55:58 momjian Exp $
*
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
@@ -18,6 +18,7 @@
#include "access/heapam.h"
#include "catalog/catname.h"
+#include "catalog/indexing.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
@@ -292,6 +293,15 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
heap_insert(pg_operator_desc, tup);
operatorObjectId = tup->t_data->t_oid;
+ if (RelationGetForm(pg_operator_desc)->relhasindex)
+ {
+ Relation idescs[Num_pg_operator_indices];
+
+ CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
+ CatalogCloseIndices(Num_pg_operator_indices, idescs);
+ }
+
/* ----------------
* free the tuple and return the operator oid
* ----------------
@@ -563,7 +573,7 @@ OperatorDef(char *operatorName,
typeId[1] = rightTypeId;
nargs = 2;
}
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(procedureName),
Int32GetDatum(nargs),
PointerGetDatum(typeId),
@@ -588,7 +598,7 @@ OperatorDef(char *operatorName,
typeId[2] = INT2OID; /* attribute number */
typeId[3] = 0; /* value - can be any type */
typeId[4] = INT4OID; /* flags - left or right selectivity */
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(restrictionName),
Int32GetDatum(5),
PointerGetDatum(typeId),
@@ -614,7 +624,7 @@ OperatorDef(char *operatorName,
typeId[3] = OIDOID; /* relation OID 2 */
typeId[4] = INT2OID; /* attribute number 2 */
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(joinName),
Int32GetDatum(5),
PointerGetDatum(typeId),
@@ -759,7 +769,6 @@ OperatorDef(char *operatorName,
/*
* If we are adding to an operator shell, get its t_self
*/
-
if (operatorObjectId)
{
opKey[0].sk_argument = PointerGetDatum(operatorName);
@@ -797,6 +806,16 @@ OperatorDef(char *operatorName,
heap_insert(pg_operator_desc, tup);
operatorObjectId = tup->t_data->t_oid;
+
+ }
+
+ if (RelationGetForm(pg_operator_desc)->relhasindex)
+ {
+ Relation idescs[Num_pg_operator_indices];
+
+ CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
+ CatalogCloseIndices(Num_pg_operator_indices, idescs);
}
heap_close(pg_operator_desc, RowExclusiveLock);
@@ -904,7 +923,15 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
setheapoverride(true);
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
setheapoverride(false);
-
+
+ if (RelationGetForm(pg_operator_desc)->relhasindex)
+ {
+ Relation idescs[Num_pg_operator_indices];
+
+ CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
+ CatalogCloseIndices(Num_pg_operator_indices, idescs);
+ }
}
}
heap_endscan(pg_operator_scan);
@@ -931,6 +958,15 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
setheapoverride(false);
+ if (RelationGetForm(pg_operator_desc)->relhasindex)
+ {
+ Relation idescs[Num_pg_operator_indices];
+
+ CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
+ CatalogCloseIndices(Num_pg_operator_indices, idescs);
+ }
+
values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
replaces[Anum_pg_operator_oprcom - 1] = ' ';
}
@@ -961,10 +997,20 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
setheapoverride(true);
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
setheapoverride(false);
+
+ if (RelationGetForm(pg_operator_desc)->relhasindex)
+ {
+ Relation idescs[Num_pg_operator_indices];
+
+ CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
+ CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
+ CatalogCloseIndices(Num_pg_operator_indices, idescs);
+ }
}
heap_endscan(pg_operator_scan);
+
heap_close(pg_operator_desc, RowExclusiveLock);
}
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index a87c7fa3db..3c0ca76890 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.35 1999/09/30 10:31:42 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.36 1999/11/22 17:55:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -109,7 +109,7 @@ ProcedureCreate(char *procedureName,
typev[parameterCount++] = toid;
}
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(procedureName),
UInt16GetDatum(parameterCount),
PointerGetDatum(typev),
@@ -157,7 +157,7 @@ ProcedureCreate(char *procedureName,
}
}
- tup = SearchSysCacheTuple(LANNAME,
+ tup = SearchSysCacheTuple(LANGNAME,
PointerGetDatum(languageName),
0, 0, 0);
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 91c7cd995b..f252933d6f 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.41 1999/09/18 19:06:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.42 1999/11/22 17:55:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -395,7 +395,7 @@ TypeCreate(char *typeName,
*/
MemSet(argList, 0, 8 * sizeof(Oid));
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(procname),
Int32GetDatum(1),
PointerGetDatum(argList),
@@ -425,7 +425,7 @@ TypeCreate(char *typeName,
nargs = 3;
argList[2] = INT4OID;
}
- tup = SearchSysCacheTuple(PRONAME,
+ tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(procname),
Int32GetDatum(nargs),
PointerGetDatum(argList),
@@ -536,7 +536,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
pg_type_desc = heap_openr(TypeRelationName, RowExclusiveLock);
- oldtup = SearchSysCacheTupleCopy(TYPNAME,
+ oldtup = SearchSysCacheTupleCopy(TYPENAME,
PointerGetDatum(oldTypeName),
0, 0, 0);
@@ -546,7 +546,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
elog(ERROR, "TypeRename: type %s not defined", oldTypeName);
}
- newtup = SearchSysCacheTuple(TYPNAME,
+ newtup = SearchSysCacheTuple(TYPENAME,
PointerGetDatum(newTypeName),
0, 0, 0);
if (HeapTupleIsValid(newtup))