From fc955b14ea667e04475e2b7339c8445611470771 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 22 Nov 1999 17:56:41 +0000 Subject: [PATCH] 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. --- doc/src/sgml/libpq++.sgml | 2 +- src/backend/access/common/printtup.c | 4 +- src/backend/access/common/tupdesc.c | 4 +- src/backend/access/index/istrat.c | 4 +- src/backend/access/nbtree/nbtinsert.c | 4 +- src/backend/catalog/Makefile | 5 +- src/backend/catalog/aclchk.c | 18 +- src/backend/catalog/catalog.c | 4 +- src/backend/catalog/heap.c | 10 +- src/backend/catalog/index.c | 10 +- src/backend/catalog/indexing.c | 524 ++++++++++++++++--- src/backend/catalog/pg_aggregate.c | 27 +- src/backend/catalog/pg_operator.c | 58 +- src/backend/catalog/pg_proc.c | 6 +- src/backend/catalog/pg_type.c | 10 +- src/backend/commands/async.c | 21 +- src/backend/commands/cluster.c | 4 +- src/backend/commands/command.c | 4 +- src/backend/commands/comment.c | 16 +- src/backend/commands/copy.c | 10 +- src/backend/commands/creatinh.c | 14 +- src/backend/commands/dbcommands.c | 4 +- src/backend/commands/define.c | 4 +- src/backend/commands/indexcmds.c | 6 +- src/backend/commands/proclang.c | 16 +- src/backend/commands/remove.c | 16 +- src/backend/commands/trigger.c | 4 +- src/backend/commands/user.c | 6 +- src/backend/commands/vacuum.c | 8 +- src/backend/executor/nodeMergejoin.c | 4 +- src/backend/executor/spi.c | 4 +- src/backend/optimizer/path/_deadcode/xfunc.c | 12 +- src/backend/optimizer/path/indxpath.c | 8 +- src/backend/optimizer/util/clauses.c | 4 +- src/backend/optimizer/util/plancat.c | 4 +- src/backend/parser/parse_coerce.c | 4 +- src/backend/parser/parse_func.c | 12 +- src/backend/parser/parse_node.c | 6 +- src/backend/parser/parse_oper.c | 20 +- src/backend/parser/parse_target.c | 4 +- src/backend/parser/parse_type.c | 16 +- src/backend/rewrite/locks.c | 4 +- src/backend/rewrite/rewriteRemove.c | 6 +- src/backend/rewrite/rewriteSupport.c | 6 +- src/backend/tcop/fastpath.c | 8 +- src/backend/utils/adt/acl.c | 6 +- src/backend/utils/adt/arrayfuncs.c | 4 +- src/backend/utils/adt/regproc.c | 8 +- src/backend/utils/adt/ri_triggers.c | 6 +- src/backend/utils/adt/ruleutils.c | 16 +- src/backend/utils/adt/selfuncs.c | 6 +- src/backend/utils/adt/sets.c | 6 +- src/backend/utils/cache/catcache.c | 125 +++-- src/backend/utils/cache/fcache.c | 10 +- src/backend/utils/cache/lsyscache.c | 34 +- src/backend/utils/cache/relcache.c | 6 +- src/backend/utils/cache/syscache.c | 341 ++++++------ src/backend/utils/fmgr/dfmgr.c | 4 +- src/backend/utils/fmgr/fmgr.c | 6 +- src/backend/utils/init/miscinit.c | 4 +- src/backend/utils/misc/superuser.c | 4 +- src/bin/pg_dump/common.c | 6 +- src/bin/pg_dump/pg_dump.c | 18 +- src/bin/pg_dump/pg_dump.h | 4 +- src/include/catalog/catversion.h | 4 +- src/include/catalog/indexing.h | 177 +++++-- src/include/catalog/pg_inheritproc.h | 10 +- src/include/catalog/pg_inherits.h | 6 +- src/include/catalog/pg_ipl.h | 6 +- src/include/catalog/pg_opclass.h | 19 +- src/include/catalog/pg_operator.h | 13 +- src/include/utils/syscache.h | 61 +-- src/pl/plpgsql/src/pl_comp.c | 18 +- src/pl/plpgsql/src/pl_exec.c | 8 +- src/pl/tcl/pltcl.c | 18 +- 75 files changed, 1265 insertions(+), 634 deletions(-) diff --git a/doc/src/sgml/libpq++.sgml b/doc/src/sgml/libpq++.sgml index 4e253d31f4..acbf823f81 100644 --- a/doc/src/sgml/libpq++.sgml +++ b/doc/src/sgml/libpq++.sgml @@ -351,7 +351,7 @@ int PgConnection::ExecTuplesOk(const char *query) - Returns TRUE if the command query succeeds and there are tuples to be retrieved. + Returns TRUE if the command query succeeds. diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 70d700f5a7..42a55767dc 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.50 1999/11/07 23:07:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.51 1999/11/22 17:55:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,7 @@ getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem) { HeapTuple typeTuple; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type), 0, 0, 0); diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index b4d1c0c0cc..9d39d14ff9 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.56 1999/11/07 23:07:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.57 1999/11/22 17:55:52 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -309,7 +309,7 @@ TupleDescInitEntry(TupleDesc desc, * -cim 6/14/90 * ---------------- */ - tuple = SearchSysCacheTuple(TYPOID, + tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typeid), 0, 0, 0); if (!HeapTupleIsValid(tuple)) diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c index 77918725e1..ee3477bedc 100644 --- a/src/backend/access/index/istrat.c +++ b/src/backend/access/index/istrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.37 1999/10/23 03:13:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.38 1999/11/22 17:55:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -479,7 +479,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, if (!IsBootstrapProcessingMode()) { - tuple = SearchSysCacheTuple(OPROID, + tuple = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(operatorObjectId), 0, 0, 0); } diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 94e1d0ccbb..ed8e3ac324 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.50 1999/08/09 01:39:19 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.51 1999/11/22 17:55:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ l1: buf = _bt_getbuf(rel, blkno, BT_WRITE); goto l1;/* continue from the begin */ } - elog(ERROR, "Cannot insert a duplicate key into a unique index"); + elog(ERROR, "Cannot insert a duplicate key into unique index %s", RelationGetRelationName(rel)); } /* htup null so no buffer to release */ /* get next offnum */ 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 -ProcedureOidIndexScan(Relation heapRelation, Oid procId) +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 +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,31 +783,9 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId) (bits16) 0x0, (AttrNumber) 1, (RegProcedure) F_OIDEQ, - ObjectIdGetDatum(typeId)); + ObjectIdGetDatum(procId)); - idesc = index_openr(TypeOidIndex); - tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); - - index_close(idesc); - - return tuple; -} - - -HeapTuple -TypeNameIndexScan(Relation heapRelation, char *typeName) -{ - Relation idesc; - ScanKeyData skey[1]; - HeapTuple tuple; - - ScanKeyEntryInitialize(&skey[0], - (bits16) 0x0, - (AttrNumber) 1, - (RegProcedure) F_NAMEEQ, - PointerGetDatum(typeName)); - - idesc = index_openr(TypeNameIndex); + idesc = index_openr(ProcedureOidIndex); tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); index_close(idesc); @@ -562,3 +835,134 @@ ClassOidIndexScan(Relation heapRelation, Oid relId) 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); + + return tuple; +} + + +HeapTuple +TypeNameIndexScan(Relation heapRelation, char *typeName) +{ + Relation idesc; + ScanKeyData skey[1]; + HeapTuple tuple; + + ScanKeyEntryInitialize(&skey[0], + (bits16) 0x0, + (AttrNumber) 1, + (RegProcedure) F_NAMEEQ, + PointerGetDatum(typeName)); + + idesc = index_openr(TypeNameIndex); + tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); + + index_close(idesc); + + return tuple; +} + + +HeapTuple +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]; + HeapTuple tuple; + + ScanKeyEntryInitialize(&skey[0], + (bits16) 0x0, + (AttrNumber) 1, + (RegProcedure) F_NAMEEQ, + PointerGetDatum(useName)); + + idesc = index_openr(ShadowNameIndex); + tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1); + + index_close(idesc); + return tuple; +} + + +HeapTuple +ShadowSysidIndexScan(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(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)) diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index f8196f86ab..cc1b9517b6 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.54 1999/09/18 19:06:39 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.55 1999/11/22 17:55:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,6 +79,7 @@ #include "access/heapam.h" #include "catalog/catname.h" +#include "catalog/indexing.h" #include "catalog/pg_listener.h" #include "commands/async.h" #include "lib/dllist.h" @@ -464,7 +465,6 @@ AtCommit_Notify() if (listenerPID == MyProcPid) { - /* * Self-notify: no need to bother with table update. * Indeed, we *must not* clear the notification field in @@ -490,7 +490,6 @@ AtCommit_Notify() */ if (kill(listenerPID, SIGUSR2) < 0) { - /* * Get rid of pg_listener entry if it refers to a PID * that no longer exists. Presumably, that backend @@ -511,6 +510,14 @@ AtCommit_Notify() rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl); heap_replace(lRel, &lTuple->t_self, rTuple, NULL); + if (RelationGetForm(lRel)->relhasindex) + { + Relation idescs[Num_pg_listener_indices]; + + CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs); + CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple); + CatalogCloseIndices(Num_pg_listener_indices, idescs); + } } } } @@ -769,6 +776,14 @@ ProcessIncomingNotify(void) /* Rewrite the tuple with 0 in notification column */ rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl); heap_replace(lRel, &lTuple->t_self, rTuple, NULL); + if (RelationGetForm(lRel)->relhasindex) + { + Relation idescs[Num_pg_listener_indices]; + + CatalogOpenIndices(Num_pg_listener_indices, Name_pg_listener_indices, idescs); + CatalogIndexInsert(idescs, Num_pg_listener_indices, lRel, rTuple); + CatalogCloseIndices(Num_pg_listener_indices, idescs); + } } } heap_endscan(sRel); diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 9f87d27b47..d2cdfb332e 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.46 1999/11/07 23:08:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.47 1999/11/22 17:56:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -270,7 +270,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) FIgetnArgs(finfo) = natts; FIgetProcOid(finfo) = Old_pg_index_Form->indproc; - pg_proc_Tuple = SearchSysCacheTuple(PROOID, + pg_proc_Tuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(Old_pg_index_Form->indproc), 0, 0, 0); diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 5fab0e79d1..1746eefbe3 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.56 1999/11/07 23:08:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.57 1999/11/22 17:56:00 momjian Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -438,7 +438,7 @@ PerformAddAttribute(char *relationName, else attnelems = 0; - typeTuple = SearchSysCacheTuple(TYPNAME, + typeTuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(typename), 0, 0, 0); tform = (Form_pg_type) GETSTRUCT(typeTuple); diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 048dfc8d88..e7419252b7 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -395,7 +395,7 @@ void CommentDatabase(char *database, char *comment) { /*** Now, fetch user information ***/ username = GetPgUserName(); - usertuple = SearchSysCacheTuple(USENAME, PointerGetDatum(username), + usertuple = SearchSysCacheTuple(USERNAME, PointerGetDatum(username), 0, 0, 0); if (!HeapTupleIsValid(usertuple)) { elog(ERROR, "current user '%s' does not exist", username); @@ -454,7 +454,7 @@ void CommentRewrite(char *rule, char *comment) { /*** Next, find the rule's oid ***/ - rewritetuple = SearchSysCacheTuple(REWRITENAME, PointerGetDatum(rule), + rewritetuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(rule), 0, 0, 0); if (!HeapTupleIsValid(rewritetuple)) { elog(ERROR, "rule '%s' does not exist", rule); @@ -489,7 +489,7 @@ void CommentType(char *type, char *comment) { #ifndef NO_SECURITY user = GetPgUserName(); - if (!pg_ownercheck(user, type, TYPNAME)) { + if (!pg_ownercheck(user, type, TYPENAME)) { elog(ERROR, "you are not permitted to comment on type '%s'", type); } @@ -497,7 +497,7 @@ void CommentType(char *type, char *comment) { /*** Next, find the type's oid ***/ - typetuple = SearchSysCacheTuple(TYPNAME, PointerGetDatum(type), + typetuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(type), 0, 0, 0); if (!HeapTupleIsValid(typetuple)) { elog(ERROR, "type '%s' does not exist", type); @@ -604,7 +604,7 @@ void CommentProc(char *function, List *arguments, char *comment) { if (strcmp(argument, "opaque") == 0) { argoids[i] = 0; } else { - argtuple = SearchSysCacheTuple(TYPNAME, PointerGetDatum(argument), + argtuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(argument), 0, 0, 0); if (!HeapTupleIsValid(argtuple)) { elog(ERROR, "function argument type '%s' does not exist", @@ -627,7 +627,7 @@ void CommentProc(char *function, List *arguments, char *comment) { /*** Now, find the corresponding oid for this procedure ***/ - functuple = SearchSysCacheTuple(PRONAME, PointerGetDatum(function), + functuple = SearchSysCacheTuple(PROCNAME, PointerGetDatum(function), Int32GetDatum(argcount), PointerGetDatum(argoids), 0); @@ -702,7 +702,7 @@ void CommentOperator(char *opername, List *arguments, char *comment) { /*** Attempt to fetch the operator oid ***/ - optuple = SearchSysCacheTupleCopy(OPRNAME, PointerGetDatum(opername), + optuple = SearchSysCacheTupleCopy(OPERNAME, PointerGetDatum(opername), ObjectIdGetDatum(leftoid), ObjectIdGetDatum(rightoid), CharGetDatum(oprtype)); @@ -716,7 +716,7 @@ void CommentOperator(char *opername, List *arguments, char *comment) { #ifndef NO_SECURITY user = GetPgUserName(); - if (!pg_ownercheck(user, (char *) ObjectIdGetDatum(oid), OPROID)) { + if (!pg_ownercheck(user, (char *) ObjectIdGetDatum(oid), OPEROID)) { elog(ERROR, "you are not permitted to comment on operator '%s'", opername); } diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index cac94cebad..9a33a08779 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.90 1999/11/21 04:16:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.91 1999/11/22 17:56:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -938,7 +938,7 @@ GetOutputFunction(Oid type) { HeapTuple typeTuple; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type), 0, 0, 0); @@ -954,7 +954,7 @@ GetTypeElement(Oid type) { HeapTuple typeTuple; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type), 0, 0, 0); @@ -970,7 +970,7 @@ GetInputFunction(Oid type) { HeapTuple typeTuple; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type), 0, 0, 0); @@ -986,7 +986,7 @@ IsTypeByVal(Oid type) { HeapTuple typeTuple; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type), 0, 0, 0); diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 491f3f642f..6d7ceab1a1 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.51 1999/11/07 23:08:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.52 1999/11/22 17:56:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -342,7 +342,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) * form name, type and constraints */ attributeName = NameStr(attribute->attname); - tuple = SearchSysCacheTuple(TYPOID, + tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(attribute->atttypid), 0, 0, 0); Assert(HeapTupleIsValid(tuple)); @@ -495,6 +495,16 @@ StoreCatalogInheritance(Oid relationId, List *supers) tuple = heap_formtuple(desc, datum, nullarr); heap_insert(relation, tuple); + + if (RelationGetForm(relation)->relhasindex) + { + Relation idescs[Num_pg_inherits_indices]; + + CatalogOpenIndices(Num_pg_inherits_indices, Name_pg_inherits_indices, idescs); + CatalogIndexInsert(idescs, Num_pg_inherits_indices, relation, tuple); + CatalogCloseIndices(Num_pg_inherits_indices, idescs); + } + pfree(tuple); seqNumber += 1; diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index fc3bff2e4f..0fd64a10ca 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.43 1999/10/26 03:12:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.44 1999/11/22 17:56:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ check_permissions(char *command, char path[MAXPGPATH]; userName = GetPgUserName(); - utup = SearchSysCacheTuple(USENAME, + utup = SearchSysCacheTuple(USERNAME, PointerGetDatum(userName), 0, 0, 0); Assert(utup); diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index 2aa197654c..85c7094abc 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.36 1999/10/02 21:33:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.37 1999/11/22 17:56:01 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -269,7 +269,7 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest) Form_pg_language languageStruct; /* Lookup the language in the system cache */ - languageTuple = SearchSysCacheTuple(LANNAME, + languageTuple = SearchSysCacheTuple(LANGNAME, PointerGetDatum(languageName), 0, 0, 0); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 1e110bcdb9..62eed98665 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.13 1999/11/07 23:08:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.14 1999/11/22 17:56:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -310,7 +310,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) /* FIgetnArgs(funcInfo) = numberOfAttributes; */ FIsetnArgs(funcInfo, numberOfAttributes); - tuple = SearchSysCacheTuple(PROOID, + tuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(indproc), 0, 0, 0); if (!HeapTupleIsValid(tuple)) @@ -482,7 +482,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */ /* we want the type so we can set the proper alignment, etc. */ if (attribute->typename == NULL) { - tuple = SearchSysCacheTuple(TYPOID, + tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(attform->atttypid), 0, 0, 0); if (!HeapTupleIsValid(tuple)) diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index b2fc76f090..aad945bd6b 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -11,6 +11,7 @@ #include "access/heapam.h" #include "catalog/catname.h" +#include "catalog/indexing.h" #include "catalog/pg_language.h" #include "catalog/pg_proc.h" #include "catalog/pg_shadow.h" @@ -75,7 +76,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) */ case_translate_language_name(stmt->plname, languageName); - langTup = SearchSysCacheTuple(LANNAME, + langTup = SearchSysCacheTuple(LANGNAME, PointerGetDatum(languageName), 0, 0, 0); if (HeapTupleIsValid(langTup)) @@ -87,7 +88,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) * ---------------- */ memset(typev, 0, sizeof(typev)); - procTup = SearchSysCacheTuple(PRONAME, + procTup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(stmt->plhandler), Int32GetDatum(0), PointerGetDatum(typev), @@ -127,6 +128,15 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) heap_insert(rel, tup); + if (RelationGetForm(rel)->relhasindex) + { + Relation idescs[Num_pg_language_indices]; + + CatalogOpenIndices(Num_pg_language_indices, Name_pg_language_indices, idescs); + CatalogIndexInsert(idescs, Num_pg_language_indices, rel, tup); + CatalogCloseIndices(Num_pg_language_indices, idescs); + } + heap_close(rel, RowExclusiveLock); } @@ -161,7 +171,7 @@ DropProceduralLanguage(DropPLangStmt *stmt) rel = heap_openr(LanguageRelationName, RowExclusiveLock); - langTup = SearchSysCacheTupleCopy(LANNAME, + langTup = SearchSysCacheTupleCopy(LANGNAME, PointerGetDatum(languageName), 0, 0, 0); if (!HeapTupleIsValid(langTup)) diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index ffc1d56960..65366a8ad7 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.39 1999/11/07 23:08:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.40 1999/11/22 17:56:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,7 +78,7 @@ RemoveOperator(char *operatorName, /* operator name */ relation = heap_openr(OperatorRelationName, RowExclusiveLock); - tup = SearchSysCacheTupleCopy(OPRNAME, + tup = SearchSysCacheTupleCopy(OPERNAME, PointerGetDatum(operatorName), ObjectIdGetDatum(typeId1), ObjectIdGetDatum(typeId2), @@ -90,7 +90,7 @@ RemoveOperator(char *operatorName, /* operator name */ userName = GetPgUserName(); if (!pg_ownercheck(userName, (char *) ObjectIdGetDatum(tup->t_data->t_oid), - OPROID)) + OPEROID)) elog(ERROR, "RemoveOperator: operator '%s': permission denied", operatorName); #endif @@ -259,14 +259,14 @@ RemoveType(char *typeName) /* type name to be removed */ #ifndef NO_SECURITY userName = GetPgUserName(); - if (!pg_ownercheck(userName, typeName, TYPNAME)) + if (!pg_ownercheck(userName, typeName, TYPENAME)) elog(ERROR, "RemoveType: type '%s': permission denied", typeName); #endif relation = heap_openr(TypeRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(TYPNAME, + tup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(typeName), 0, 0, 0); if (!HeapTupleIsValid(tup)) @@ -285,7 +285,7 @@ RemoveType(char *typeName) /* type name to be removed */ /* Now, Delete the "array of" that type */ shadow_type = makeArrayTypeName(typeName); - tup = SearchSysCacheTuple(TYPNAME, + tup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(shadow_type), 0, 0, 0); if (!HeapTupleIsValid(tup)) @@ -331,7 +331,7 @@ RemoveFunction(char *functionName, /* function name to be removed */ argList[i] = 0; else { - tup = SearchSysCacheTuple(TYPNAME, + tup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(typename), 0, 0, 0); @@ -351,7 +351,7 @@ RemoveFunction(char *functionName, /* function name to be removed */ #endif relation = heap_openr(ProcedureRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(PRONAME, + tup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(functionName), Int32GetDatum(nargs), PointerGetDatum(argList), diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index cf68bbb8a7..93ae9ba36a 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -144,7 +144,7 @@ CreateTrigger(CreateTrigStmt *stmt) heap_endscan(tgscan); MemSet(fargtypes, 0, 8 * sizeof(Oid)); - tuple = SearchSysCacheTuple(PRONAME, + tuple = SearchSysCacheTuple(PROCNAME, PointerGetDatum(stmt->funcname), Int32GetDatum(0), PointerGetDatum(fargtypes), @@ -161,7 +161,7 @@ CreateTrigger(CreateTrigStmt *stmt) { HeapTuple langTup; - langTup = SearchSysCacheTuple(LANOID, + langTup = SearchSysCacheTuple(LANGOID, ObjectIdGetDatum(((Form_pg_proc) GETSTRUCT(tuple))->prolang), 0, 0, 0); if (!HeapTupleIsValid(langTup)) diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 8b5956bad1..b7bfff8710 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: user.c,v 1.36 1999/11/21 04:16:16 tgl Exp $ + * $Id: user.c,v 1.37 1999/11/22 17:56:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -261,7 +261,7 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest) pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock); pg_shadow_dsc = RelationGetDescr(pg_shadow_rel); - tuple = SearchSysCacheTuple(USENAME, + tuple = SearchSysCacheTuple(USERNAME, PointerGetDatum(stmt->user), 0, 0, 0); if (!HeapTupleIsValid(tuple)) @@ -374,7 +374,7 @@ RemoveUser(char *user, CommandDest dest) pg_shadow_rel = heap_openr(ShadowRelationName, AccessExclusiveLock); pg_dsc = RelationGetDescr(pg_shadow_rel); - tuple = SearchSysCacheTuple(USENAME, + tuple = SearchSysCacheTuple(USERNAME, PointerGetDatum(user), 0, 0, 0); if (!HeapTupleIsValid(tuple)) diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index b7955e5553..f80a07f388 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.124 1999/11/14 17:27:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.125 1999/11/22 17:56:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -490,7 +490,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols) else stats->f_cmpgt.fn_addr = NULL; - typetuple = SearchSysCacheTuple(TYPOID, + typetuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(stats->attr->atttypid), 0, 0, 0); if (HeapTupleIsValid(typetuple)) @@ -1976,7 +1976,7 @@ vc_scanoneind(Relation indrel, int num_tuples) ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec); if (nitups != num_tuples) - elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u).\nTry recreating the index.", + elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u).\n\tTry recreating the index.", RelationGetRelationName(indrel), nitups, num_tuples); } /* vc_scanoneind */ @@ -2057,7 +2057,7 @@ vc_vaconeind(VPageList vpl, Relation indrel, int num_tuples, int keep_tuples) ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec); if (num_index_tuples != num_tuples + keep_tuples) - elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u).\nTry recreating the index.", + elog(NOTICE, "Index %s: NUMBER OF INDEX' TUPLES (%u) IS NOT THE SAME AS HEAP' (%u).\n\tTry recreating the index.", RelationGetRelationName(indrel), num_index_tuples, num_tuples); } /* vc_vaconeind */ diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 288fbfe8a1..b15e135465 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.31 1999/10/17 18:00:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.32 1999/11/22 17:56:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -159,7 +159,7 @@ MJFormSkipQual(List *qualList, char *replaceopname) * whoever marked the "=" operator mergejoinable was a loser. * ---------------- */ - optup = SearchSysCacheTuple(OPRNAME, + optup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(replaceopname), ObjectIdGetDatum(oprleft), ObjectIdGetDatum(oprright), diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index e8aa326b6c..e99475942b 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface * - * $Id: spi.c,v 1.41 1999/11/07 23:08:06 momjian Exp $ + * $Id: spi.c,v 1.42 1999/11/22 17:56:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -449,7 +449,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid), 0, 0, 0); diff --git a/src/backend/optimizer/path/_deadcode/xfunc.c b/src/backend/optimizer/path/_deadcode/xfunc.c index d063a73199..771cec3ecd 100644 --- a/src/backend/optimizer/path/_deadcode/xfunc.c +++ b/src/backend/optimizer/path/_deadcode/xfunc.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.10 1999/09/21 20:58:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.11 1999/11/22 17:56:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -494,7 +494,7 @@ xfunc_func_expense(LispValue node, LispValue args) funcid = get_funcid((Func) node); /* look up tuple in cache */ - tupl = SearchSysCacheTuple(PROOID, + tupl = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); if (!HeapTupleIsValid(tupl)) @@ -609,7 +609,7 @@ xfunc_width(LispValue clause) else if (IsA(clause, Var)) { /* base case: width is width of this attribute */ - tupl = SearchSysCacheTuple(TYPOID, + tupl = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(get_vartype((Var) clause)), 0, 0, 0); if (!HeapTupleIsValid(tupl)) @@ -672,7 +672,7 @@ xfunc_width(LispValue clause) * * get function associated with this Oper, and treat this as * a * Func */ - tupl = SearchSysCacheTuple(OPROID, + tupl = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(get_opno((Oper) get_op(clause))), 0, 0, 0); if (!HeapTupleIsValid(tupl)) @@ -1303,7 +1303,7 @@ xfunc_func_width(RegProcedure funcid, LispValue args) /* lookup function and find its return type */ Assert(RegProcedureIsValid(funcid)); - tupl = SearchSysCacheTuple(PROOID, + tupl = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); if (!HeapTupleIsValid(tupl)) @@ -1321,7 +1321,7 @@ xfunc_func_width(RegProcedure funcid, LispValue args) else /* function returns a base type */ { - tupl = SearchSysCacheTuple(TYPOID, + tupl = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(proc->prorettype), 0, 0, 0); if (!HeapTupleIsValid(tupl)) diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 3964d5d5bb..4f52f9377d 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.72 1999/09/18 19:06:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.73 1999/11/22 17:56:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1893,7 +1893,7 @@ prefix_quals(Var *leftop, Oid expr_op, */ if (pstatus == Prefix_Exact) { - optup = SearchSysCacheTuple(OPRNAME, + optup = SearchSysCacheTuple(OPERNAME, PointerGetDatum("="), ObjectIdGetDatum(datatype), ObjectIdGetDatum(datatype), @@ -1919,7 +1919,7 @@ prefix_quals(Var *leftop, Oid expr_op, * * We can always say "x >= prefix". */ - optup = SearchSysCacheTuple(OPRNAME, + optup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(">="), ObjectIdGetDatum(datatype), ObjectIdGetDatum(datatype), @@ -1947,7 +1947,7 @@ prefix_quals(Var *leftop, Oid expr_op, prefix[prefixlen] = '\377'; prefix[prefixlen+1] = '\0'; - optup = SearchSysCacheTuple(OPRNAME, + optup = SearchSysCacheTuple(OPERNAME, PointerGetDatum("<="), ObjectIdGetDatum(datatype), ObjectIdGetDatum(datatype), diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 066b391826..07ccca7bf0 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.54 1999/10/07 04:23:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.55 1999/11/22 17:56:17 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -902,7 +902,7 @@ eval_const_expressions_mutator (Node *node, void *context) result_typeid = func->functype; } /* Someday lsyscache.c might provide a function for this */ - func_tuple = SearchSysCacheTuple(PROOID, + func_tuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); if (!HeapTupleIsValid(func_tuple)) diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index b023c5451d..03d29be4dc 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.39 1999/11/21 23:25:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.40 1999/11/22 17:56:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -372,7 +372,7 @@ find_inheritance_children(Oid inhparent) scan = heap_beginscan(relation, 0, SnapshotNow, 1, key); while (HeapTupleIsValid(inheritsTuple = heap_getnext(scan, 0))) { - inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrel; + inhrelid = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhrelid; list = lappendi(list, inhrelid); } heap_endscan(scan); diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 127e493db1..0d51f2ae05 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.24 1999/10/02 23:29:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.25 1999/11/22 17:56:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,7 +175,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids) * look for a single-argument function named with the * target type name */ - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(typeidTypeName(func_typeids[i])), Int32GetDatum(1), PointerGetDatum(oid_array), diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 04030330d5..8949ae3140 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.61 1999/11/07 23:08:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.62 1999/11/22 17:56:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -403,7 +403,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, * just pass through the argument itself. (make this clearer * with some extra brackets - thomas 1998-12-05) */ - if ((HeapTupleIsValid(tp = SearchSysCacheTuple(TYPNAME, + if ((HeapTupleIsValid(tp = SearchSysCacheTuple(TYPENAME, PointerGetDatum(funcname), 0, 0, 0))) && IS_BINARY_COMPATIBLE(typeTypeId(tp), basetype)) @@ -923,7 +923,7 @@ func_get_detail(char *funcname, Form_pg_proc pform; /* attempt to find with arguments exactly as specified... */ - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(funcname), Int32GetDatum(nargs), PointerGetDatum(oid_array), @@ -953,7 +953,7 @@ func_get_detail(char *funcname, if (ncandidates == 1) { *true_typeids = current_function_typeids->args; - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(funcname), Int32GetDatum(nargs), PointerGetDatum(*true_typeids), @@ -982,7 +982,7 @@ func_get_detail(char *funcname, /* found something, so use the first one... */ else { - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(funcname), Int32GetDatum(nargs), PointerGetDatum(*true_typeids), @@ -1111,7 +1111,7 @@ find_inheritors(Oid relid, Oid **supervec) */ do { - ScanKeyEntryInitialize(&skey, 0x0, Anum_pg_inherits_inhrel, + ScanKeyEntryInitialize(&skey, 0x0, Anum_pg_inherits_inhrelid, F_OIDEQ, ObjectIdGetDatum(relid)); diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index d4593a1357..2cab730412 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.32 1999/11/01 05:06:21 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.33 1999/11/22 17:56:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -251,7 +251,7 @@ transformArraySubscripts(ParseState *pstate, /* Get the type tuple for the array */ typearray = exprType(arrayBase); - type_tuple = SearchSysCacheTuple(TYPOID, + type_tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typearray), 0, 0, 0); if (!HeapTupleIsValid(type_tuple)) @@ -265,7 +265,7 @@ transformArraySubscripts(ParseState *pstate, type_struct_array->typname); /* Get the type tuple for the array element type */ - type_tuple = SearchSysCacheTuple(TYPOID, + type_tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typeelement), 0, 0, 0); if (!HeapTupleIsValid(type_tuple)) diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 5a5c870996..fd5231e61a 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.32 1999/09/18 19:07:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.33 1999/11/22 17:56:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -395,7 +395,7 @@ oper_exact(char *op, Oid arg1, Oid arg2) else if ((arg2 == UNKNOWNOID) && (arg1 != InvalidOid)) arg2 = arg1; - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(arg1), ObjectIdGetDatum(arg2), @@ -434,7 +434,7 @@ oper_inexact(char *op, Oid arg1, Oid arg2) /* Or found exactly one? Then proceed... */ else if (ncandidates == 1) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(candidates->args[0]), ObjectIdGetDatum(candidates->args[1]), @@ -450,7 +450,7 @@ oper_inexact(char *op, Oid arg1, Oid arg2) targetOids = oper_select_candidate(2, inputOids, candidates); if (targetOids != NULL) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(targetOids[0]), ObjectIdGetDatum(targetOids[1]), @@ -558,7 +558,7 @@ right_oper(char *op, Oid arg) int ncandidates; Oid *targetOid; - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(arg), ObjectIdGetDatum(InvalidOid), @@ -574,7 +574,7 @@ right_oper(char *op, Oid arg) } else if (ncandidates == 1) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(candidates->args[0]), ObjectIdGetDatum(InvalidOid), @@ -587,7 +587,7 @@ right_oper(char *op, Oid arg) if (targetOid != NULL) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(*targetOid), @@ -618,7 +618,7 @@ left_oper(char *op, Oid arg) int ncandidates; Oid *targetOid; - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(arg), @@ -634,7 +634,7 @@ left_oper(char *op, Oid arg) } else if (ncandidates == 1) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(candidates->args[0]), @@ -646,7 +646,7 @@ left_oper(char *op, Oid arg) targetOid = oper_select_candidate(1, &arg, candidates); if (targetOid != NULL) { - tup = SearchSysCacheTuple(OPRNAME, + tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum(op), ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(*targetOid), diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index f87c0aca25..8cac8b417c 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.48 1999/11/07 23:08:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.49 1999/11/22 17:56:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -329,7 +329,7 @@ SizeTargetExpr(ParseState *pstate, oid_array[i] = InvalidOid; /* attempt to find with arguments exactly as specified... */ - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum(funcname), Int32GetDatum(2), PointerGetDatum(oid_array), diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index ac551e9e22..d76d573de1 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.26 1999/11/07 23:08:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.27 1999/11/22 17:56:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ bool typeidIsValid(Oid id) { - return (SearchSysCacheTuple(TYPOID, + return (SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(id), 0, 0, 0) != NULL); } @@ -39,7 +39,7 @@ typeidTypeName(Oid id) HeapTuple tup; Form_pg_type typetuple; - if (!(tup = SearchSysCacheTuple(TYPOID, + if (!(tup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(id), 0, 0, 0))) { @@ -56,7 +56,7 @@ typeidType(Oid id) { HeapTuple tup; - if (!(tup = SearchSysCacheTuple(TYPOID, + if (!(tup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(id), 0, 0, 0))) { @@ -75,7 +75,7 @@ typenameType(char *s) if (s == NULL) elog(ERROR, "type(): Null type"); - if (!(tup = SearchSysCacheTuple(TYPNAME, + if (!(tup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(s), 0, 0, 0))) elog(ERROR, "Unable to locate type name '%s' in catalog", s); @@ -154,7 +154,7 @@ typeidOutfunc(Oid type_id) Form_pg_type type; Oid outfunc; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type_id), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) @@ -173,7 +173,7 @@ typeidTypeRelid(Oid type_id) HeapTuple typeTuple; Form_pg_type type; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(type_id), 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) @@ -212,7 +212,7 @@ GetArrayElementType(Oid typearray) HeapTuple type_tuple; Form_pg_type type_struct_array; - type_tuple = SearchSysCacheTuple(TYPOID, + type_tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typearray), 0, 0, 0); diff --git a/src/backend/rewrite/locks.c b/src/backend/rewrite/locks.c index 4a148ac2d5..aea4ee5820 100644 --- a/src/backend/rewrite/locks.c +++ b/src/backend/rewrite/locks.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.24 1999/11/07 23:08:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.25 1999/11/22 17:56:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ checkLockPerms(List *locks, Query *parsetree, int rt_index) */ rte = (RangeTblEntry *) nth(rt_index - 1, parsetree->rtable); ev_rel = heap_openr(rte->relname, AccessShareLock); - usertup = SearchSysCacheTuple(USESYSID, + usertup = SearchSysCacheTuple(USERSYSID, ObjectIdGetDatum(ev_rel->rd_rel->relowner), 0, 0, 0); if (!HeapTupleIsValid(usertup)) diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index d8645e1d12..ec473fb471 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.32 1999/11/18 13:56:27 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.33 1999/11/22 17:56:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ RewriteGetRuleEventRel(char *rulename) HeapTuple htup; Oid eventrel; - htup = SearchSysCacheTuple(REWRITENAME, + htup = SearchSysCacheTuple(RULENAME, PointerGetDatum(rulename), 0, 0, 0); if (!HeapTupleIsValid(htup)) @@ -83,7 +83,7 @@ RemoveRewriteRule(char *ruleName) /* * Scan the RuleRelation ('pg_rewrite') until we find a tuple */ - tuple = SearchSysCacheTupleCopy(REWRITENAME, + tuple = SearchSysCacheTupleCopy(RULENAME, PointerGetDatum(ruleName), 0, 0, 0); diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index c089be56d3..47d8fc88de 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.37 1999/09/18 19:07:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.38 1999/11/22 17:56:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ RuleIdGetActionInfo(Oid ruleoid, bool *instead_flag, Query **parseTrees) ruleRelation = heap_openr(RewriteRelationName, AccessShareLock); ruleTupdesc = RelationGetDescr(ruleRelation); - ruletuple = SearchSysCacheTuple(RULOID, + ruletuple = SearchSysCacheTuple(RULEOID, ObjectIdGetDatum(ruleoid), 0, 0, 0); if (ruletuple == NULL) @@ -81,7 +81,7 @@ IsDefinedRewriteRule(char *ruleName) { HeapTuple tuple; - tuple = SearchSysCacheTuple(REWRITENAME, + tuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(ruleName), 0, 0, 0); return HeapTupleIsValid(tuple); diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index aed201e36d..d8f3009afb 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.30 1999/07/22 02:40:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.31 1999/11/22 17:56:26 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -202,7 +202,7 @@ update_fp_info(Oid func_id, struct fp_info * fip) MemSet((char *) fip, 0, (int) sizeof(struct fp_info)); fip->funcid = InvalidOid; - func_htp = SearchSysCacheTuple(PROOID, + func_htp = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(func_id), 0, 0, 0); if (!HeapTupleIsValid(func_htp)) @@ -219,7 +219,7 @@ update_fp_info(Oid func_id, struct fp_info * fip) { if (OidIsValid(argtypes[i])) { - type_htp = SearchSysCacheTuple(TYPOID, + type_htp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(argtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(type_htp)) @@ -235,7 +235,7 @@ update_fp_info(Oid func_id, struct fp_info * fip) if (OidIsValid(rettype)) { - type_htp = SearchSysCacheTuple(TYPOID, + type_htp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(rettype), 0, 0, 0); if (!HeapTupleIsValid(type_htp)) diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 3793c749b9..15db9b3041 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.41 1999/10/18 03:32:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.42 1999/11/22 17:56:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ aclparse(char *s, AclItem *aip, unsigned *modechg) switch (aip->ai_idtype) { case ACL_IDTYPE_UID: - htup = SearchSysCacheTuple(USENAME, + htup = SearchSysCacheTuple(USERNAME, PointerGetDatum(name), 0, 0, 0); if (!HeapTupleIsValid(htup)) @@ -281,7 +281,7 @@ aclitemout(AclItem *aip) switch (aip->ai_idtype) { case ACL_IDTYPE_UID: - htup = SearchSysCacheTuple(USESYSID, + htup = SearchSysCacheTuple(USERSYSID, ObjectIdGetDatum(aip->ai_id), 0, 0, 0); if (!HeapTupleIsValid(htup)) diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 57d7a08a9e..b8b023575d 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.48 1999/07/19 07:07:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.49 1999/11/22 17:56:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1470,7 +1470,7 @@ system_cache_lookup(Oid element_type, HeapTuple typeTuple; Form_pg_type typeStruct; - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(element_type), 0, 0, 0); diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 74dd671e96..f5ebcdf0eb 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.44 1999/11/07 23:08:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.45 1999/11/22 17:56:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ regprocin(char *pro_name_or_oid) if (pro_name_or_oid[0] >= '0' && pro_name_or_oid[0] <= '9') { - proctup = SearchSysCacheTuple(PROOID, + proctup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(oidin(pro_name_or_oid)), 0, 0, 0); if (HeapTupleIsValid(proctup)) @@ -165,7 +165,7 @@ regprocout(RegProcedure proid) if (!IsBootstrapProcessingMode()) { - proctup = SearchSysCacheTuple(PROOID, + proctup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(proid), 0, 0, 0); @@ -254,7 +254,7 @@ oid8types(Oid *oidArray) { if (*sp != InvalidOid) { - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(*sp), 0, 0, 0); if (HeapTupleIsValid(typetup)) diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 6f69479ba3..e3b6030541 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -6,7 +6,7 @@ * * 1999 Jan Wieck * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.2 1999/10/08 12:00:08 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.3 1999/11/22 17:56:29 momjian Exp $ * * ---------- */ @@ -1073,7 +1073,7 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) elog(FATAL, "error in RI operator cache"); /* ---------- - * If not found, lookup the OPRNAME system cache for it + * If not found, lookup the OPERNAME system cache for it * and remember that info. * ---------- */ @@ -1082,7 +1082,7 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) HeapTuple opr_tup; Form_pg_operator opr_struct; - opr_tup = SearchSysCacheTuple(OPRNAME, + opr_tup = SearchSysCacheTuple(OPERNAME, PointerGetDatum("="), ObjectIdGetDatum(typeid), ObjectIdGetDatum(typeid), diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 89febb159b..a342daba8b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * out of it's tuple * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.31 1999/11/15 02:00:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.32 1999/11/22 17:56:30 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -484,7 +484,7 @@ pg_get_indexdef(Oid indexrelid) HeapTuple proctup; Form_pg_proc procStruct; - proctup = SearchSysCacheTuple(PROOID, + proctup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(idxrec->indproc), 0, 0, 0); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup for proc %u failed", idxrec->indproc); @@ -567,7 +567,7 @@ pg_get_userbyid(int32 uid) * Get the pg_shadow entry and print the result * ---------- */ - usertup = SearchSysCacheTuple(USESYSID, + usertup = SearchSysCacheTuple(USERSYSID, ObjectIdGetDatum(uid), 0, 0, 0); if (HeapTupleIsValid(usertup)) { @@ -1282,7 +1282,7 @@ get_rule_expr(Node *node, deparse_context *context) HeapTuple tp; Form_pg_operator optup; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); Assert(HeapTupleIsValid(tp)); @@ -1439,7 +1439,7 @@ get_func_expr(Expr *expr, deparse_context *context) * Get the functions pg_proc tuple * ---------- */ - proctup = SearchSysCacheTuple(PROOID, + proctup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(func->funcid), 0, 0, 0); if (!HeapTupleIsValid(proctup)) @@ -1524,7 +1524,7 @@ get_tle_expr(TargetEntry *tle, deparse_context *context) * Get the functions pg_proc tuple * ---------- */ - tup = SearchSysCacheTuple(PROOID, + tup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(func->funcid), 0, 0, 0); if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup for proc %u failed", func->funcid); @@ -1548,7 +1548,7 @@ get_tle_expr(TargetEntry *tle, deparse_context *context) * Furthermore, the name of the function must be the same * as the argument/result type name. */ - tup = SearchSysCacheTuple(TYPOID, + tup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(tup)) @@ -1607,7 +1607,7 @@ get_const_expr(Const *constval, deparse_context *context) return; } - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(constval->consttype), 0, 0, 0); if (!HeapTupleIsValid(typetup)) diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index e14e537555..3e2d123df1 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.41 1999/09/18 19:07:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.42 1999/11/22 17:56:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -510,7 +510,7 @@ convert_to_scale(Datum value, Oid typid, MemSet(oid_array, 0, MAXFARGS * sizeof(Oid)); oid_array[0] = typid; - ftup = SearchSysCacheTuple(PRONAME, + ftup = SearchSysCacheTuple(PROCNAME, PointerGetDatum("float8"), Int32GetDatum(1), PointerGetDatum(oid_array), @@ -622,7 +622,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid typid, int32 typmod, *commonfrac = ((Form_pg_statistic) GETSTRUCT(tuple))->stacommonfrac; /* Get the type input proc for the column datatype */ - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (! HeapTupleIsValid(typeTuple)) diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 46dbca9d69..964012a31e 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.26 1999/09/18 19:07:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.27 1999/11/22 17:56:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ SetDefine(char *querystr, char *typename) * until you start the next command.) */ CommandCounterIncrement(); - tup = SearchSysCacheTuple(PROOID, + tup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(setoid), 0, 0, 0); if (!HeapTupleIsValid(tup)) @@ -102,7 +102,7 @@ SetDefine(char *querystr, char *typename) /* change the pg_proc tuple */ procrel = heap_openr(ProcedureRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(PROOID, + tup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(setoid), 0, 0, 0); if (HeapTupleIsValid(tup)) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index e5a1684041..96e8288916 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.53 1999/11/21 01:58:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.54 1999/11/22 17:56:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,6 +15,7 @@ #include "access/genam.h" #include "access/heapam.h" #include "access/valid.h" +#include "catalog/pg_operator.h" #include "catalog/pg_type.h" #include "catalog/catname.h" #include "catalog/indexing.h" @@ -711,7 +712,6 @@ InitSysCache(char *relname, * ---------------- */ { - /* * We can only do this optimization because the number of hash * buckets never changes. Without it, we call malloc() too much. @@ -811,9 +811,10 @@ InitSysCache(char *relname, /* -------------------------------- * SearchSelfReferences * - * This call searches a self referencing information, - * - * which causes a cycle in system catalog cache + * This call searches for self-referencing information, + * which causes infinite recursion in the system catalog cache. + * This code short-circuits the normal index lookup for cache loads + * in those cases and replaces it with a heap scan. * * cache should already be initailized * -------------------------------- @@ -823,45 +824,81 @@ SearchSelfReferences(struct catcache * cache) { HeapTuple ntp; Relation rel; - static Oid indexSelfOid = 0; - static HeapTuple indexSelfTuple = 0; - if (cache->id != INDEXRELID) + if (cache->id == INDEXRELID) + { + static Oid indexSelfOid = InvalidOid; + static HeapTuple indexSelfTuple = NULL; + + if (!OidIsValid(indexSelfOid)) + { + /* Find oid of pg_index_indexrelid_index */ + rel = heap_openr(RelationRelationName, AccessShareLock); + ntp = ClassNameIndexScan(rel, IndexRelidIndex); + if (!HeapTupleIsValid(ntp)) + elog(ERROR, "SearchSelfReferences: %s not found in %s", + IndexRelidIndex, RelationRelationName); + indexSelfOid = ntp->t_data->t_oid; + pfree(ntp); + heap_close(rel, AccessShareLock); + } + /* Looking for something other than pg_index_indexrelid_index? */ + if ((Oid)cache->cc_skey[0].sk_argument != indexSelfOid) + return (HeapTuple)0; + + /* Do we need to load our private copy of the tuple? */ + if (!HeapTupleIsValid(indexSelfTuple)) + { + HeapScanDesc sd; + MemoryContext oldcxt; + + if (!CacheCxt) + CacheCxt = CreateGlobalMemory("Cache"); + rel = heap_open(cache->relationId, AccessShareLock); + sd = heap_beginscan(rel, false, SnapshotNow, 1, cache->cc_skey); + ntp = heap_getnext(sd, 0); + if (!HeapTupleIsValid(ntp)) + elog(ERROR, "SearchSelfReferences: tuple not found"); + oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); + indexSelfTuple = heap_copytuple(ntp); + MemoryContextSwitchTo(oldcxt); + heap_endscan(sd); + heap_close(rel, AccessShareLock); + } + return indexSelfTuple; + } + else if (cache->id == OPEROID) + { + /* bootstrapping this requires preloading a range of rows. bjm */ + static HeapTuple operatorSelfTuple[MAX_OIDCMP-MIN_OIDCMP+1]; + Oid lookup_oid = (Oid)cache->cc_skey[0].sk_argument; + + if (lookup_oid < MIN_OIDCMP || lookup_oid > MAX_OIDCMP) + return (HeapTuple)0; + + if (!HeapTupleIsValid(operatorSelfTuple[lookup_oid-MIN_OIDCMP])) + { + HeapScanDesc sd; + MemoryContext oldcxt; + + if (!CacheCxt) + CacheCxt = CreateGlobalMemory("Cache"); + rel = heap_open(cache->relationId, AccessShareLock); + sd = heap_beginscan(rel, false, SnapshotNow, 1, cache->cc_skey); + ntp = heap_getnext(sd, 0); + if (!HeapTupleIsValid(ntp)) + elog(ERROR, "SearchSelfReferences: tuple not found"); + oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); + operatorSelfTuple[lookup_oid-MIN_OIDCMP] = heap_copytuple(ntp); + MemoryContextSwitchTo(oldcxt); + heap_endscan(sd); + heap_close(rel, AccessShareLock); + } + return operatorSelfTuple[lookup_oid-MIN_OIDCMP]; + } + else return (HeapTuple)0; - if (!indexSelfOid) - { - rel = heap_openr(RelationRelationName, AccessShareLock); - ntp = ClassNameIndexScan(rel, IndexRelidIndex); - if (!HeapTupleIsValid(ntp)) - elog(ERROR, "SearchSelfRefernces: %s not found in %s", - IndexRelidIndex, RelationRelationName); - indexSelfOid = ntp->t_data->t_oid; - pfree(ntp); - heap_close(rel, AccessShareLock); - } - if ((Oid)cache->cc_skey[0].sk_argument != indexSelfOid) - return (HeapTuple)0; - if (!indexSelfTuple) - { - HeapScanDesc sd; - MemoryContext oldcxt; - - if (!CacheCxt) - CacheCxt = CreateGlobalMemory("Cache"); - rel = heap_open(cache->relationId, AccessShareLock); - sd = heap_beginscan(rel, false, SnapshotNow, 1, cache->cc_skey); - ntp = heap_getnext(sd, 0); - if (!HeapTupleIsValid(ntp)) - elog(ERROR, "SearchSelfRefernces: tuple not found"); - oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); - indexSelfTuple = heap_copytuple(ntp); - MemoryContextSwitchTo(oldcxt); - heap_endscan(sd); - heap_close(rel, AccessShareLock); - } - - return indexSelfTuple; } /* -------------------------------- @@ -907,10 +944,8 @@ SearchSysCache(struct catcache * cache, /* * resolve self referencing informtion */ - if (ntp = SearchSelfReferences(cache), ntp) - { - return heap_copytuple(ntp); - } + if ((ntp = SearchSelfReferences(cache))) + return heap_copytuple(ntp); /* ---------------- * find the hash bucket in which to look for the tuple diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c index 33ba637b13..69ef78af09 100644 --- a/src/backend/utils/cache/fcache.c +++ b/src/backend/utils/cache/fcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.26 1999/07/17 20:18:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.27 1999/11/22 17:56:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext) relname = (char *) getrelname(rtid, econtext->ecxt_range_table); - tup = SearchSysCacheTuple(TYPNAME, + tup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(relname), 0, 0, 0); if (!tup) @@ -89,7 +89,7 @@ init_fcache(Oid foid, if (!use_syscache) elog(ERROR, "what the ????, init the fcache without the catalogs?"); - procedureTuple = SearchSysCacheTuple(PROOID, + procedureTuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(foid), 0, 0, 0); @@ -110,7 +110,7 @@ init_fcache(Oid foid, * to "null" so we just return it. * ---------------- */ - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procedureStruct->prorettype), 0, 0, 0); @@ -255,7 +255,7 @@ init_fcache(Oid foid, else { tmp = (text *) - SearchSysCacheGetAttribute(PROOID, + SearchSysCacheGetAttribute(PROCOID, Anum_pg_proc_probin, ObjectIdGetDatum(foid), 0, 0, 0); diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index d2b097ed2f..ab9f74c0ae 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.35 1999/11/07 23:08:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.36 1999/11/22 17:56:32 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -263,7 +263,7 @@ get_opcode(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -286,7 +286,7 @@ get_opname(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -310,7 +310,7 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -342,7 +342,7 @@ op_hashjoinable(Oid opno, Oid ltype, Oid rtype) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -362,7 +362,7 @@ get_operator_tuple(Oid opno) { HeapTuple optup; - if ((optup = SearchSysCacheTuple(OPROID, + if ((optup = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0))) return optup; @@ -381,7 +381,7 @@ get_commutator(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -404,7 +404,7 @@ get_negator(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -427,7 +427,7 @@ get_oprrest(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -450,7 +450,7 @@ get_oprjoin(Oid opno) { HeapTuple tp; - tp = SearchSysCacheTuple(OPROID, + tp = SearchSysCacheTuple(OPEROID, ObjectIdGetDatum(opno), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -474,7 +474,7 @@ get_func_rettype(Oid funcid) HeapTuple func_tuple; Oid funcrettype; - func_tuple = SearchSysCacheTuple(PROOID, + func_tuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); @@ -548,7 +548,7 @@ get_typlen(Oid typid) { HeapTuple tp; - tp = SearchSysCacheTuple(TYPOID, + tp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -572,7 +572,7 @@ get_typbyval(Oid typid) { HeapTuple tp; - tp = SearchSysCacheTuple(TYPOID, + tp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -590,7 +590,7 @@ get_typalign(Oid typid) { HeapTuple tp; - tp = SearchSysCacheTuple(TYPOID, + tp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (HeapTupleIsValid(tp)) @@ -628,7 +628,7 @@ get_typdefault(Oid typid) * First, see if there is a non-null typdefault field (usually there isn't) */ typDefault = (struct varlena *) - SearchSysCacheGetAttribute(TYPOID, + SearchSysCacheGetAttribute(TYPEOID, Anum_pg_type_typdefault, ObjectIdGetDatum(typid), 0, 0, 0); @@ -645,7 +645,7 @@ get_typdefault(Oid typid) * just did --- but at present this path isn't taken often enough to * make it worth fixing. */ - typeTuple = SearchSysCacheTuple(TYPOID, + typeTuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); @@ -727,7 +727,7 @@ get_typtype(Oid typid) { HeapTuple tp; - tp = SearchSysCacheTuple(TYPOID, + tp = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(typid), 0, 0, 0); if (HeapTupleIsValid(tp)) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index b668474411..c2f5a7d655 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.80 1999/11/21 01:58:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.81 1999/11/22 17:56:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -524,7 +524,7 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo, for (i = 1; i <= relation->rd_rel->relnatts; i++) { - atttup = (HeapTuple) AttributeNumIndexScan(attrel, + atttup = (HeapTuple) AttributeRelidNumIndexScan(attrel, RelationGetRelid(relation), i); if (!HeapTupleIsValid(atttup)) @@ -2085,7 +2085,7 @@ write_irels(void) SetProcessingMode(BootstrapProcessing); bi.infotype = INFO_RELNAME; - bi.i.info_name = AttributeNumIndex; + bi.i.info_name = AttributeRelidNumIndex; irel[0] = RelationBuildDesc(bi, NULL); irel[0]->rd_isnailed = true; diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index aa532d99bd..e851c40d28 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.40 1999/11/18 13:56:29 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.41 1999/11/22 17:56:32 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -45,12 +45,63 @@ extern bool AMI_OVERRIDE; /* XXX style */ typedef HeapTuple (*ScanFunc) (); -/* ---------------- - * Warning: cacheinfo[] below is changed, then be sure and - * update the magic constants in syscache.h! - * ---------------- - */ + +/*--------------------------------------------------------------------------- + + Adding system caches: + + Add your new cache to the list in include/utils/syscache.h. Keep + the list sorted alphabetically and adjust the cache numbers + accordingly. + + Add your entry to the cacheinfo[] array below. All cache lists are + alphabetical, so add it in the proper place. Specify the relation + name, number of arguments, argument names, size of tuple, index lookup + function, and index name. + + In include/catalog/indexing.h, add a define for the number of indexes + in the relation, add a define for the index name, add an extern + array to hold the index names, define the index lookup function + prototype, and use DECLARE_UNIQUE_INDEX to define the index. Cache + lookups return only one row, so the index should be unique. + + In backend/catalog/indexing.c, initialize the relation array with + the index names for the relation, and create the index lookup function. + Pick one that takes similar arguments and use that one, but keep the + function names in the same order as the cache list for clarity. + + Finally, any place your relation gets heap_insert() or + heap_replace calls, include code to do a CatalogIndexInsert() to update + the system indexes. The heap_* calls do not update indexes. + + bjm 1999/11/22 + + --------------------------------------------------------------------------- +*/ + static struct cachedesc cacheinfo[] = { + {AggregateRelationName, /* AGGNAME */ + 2, + { + Anum_pg_aggregate_aggname, + Anum_pg_aggregate_aggbasetype, + 0, + 0 + }, + offsetof(FormData_pg_aggregate, agginitval1), + AggregateNameTypeIndex, + AggregateNameTypeIndexScan}, + {AccessMethodRelationName, /* AMNAME */ + 1, + { + Anum_pg_am_amname, + 0, + 0, + 0 + }, + sizeof(FormData_pg_am), + AmNameIndex, + AmNameIndexScan}, {AccessMethodOperatorRelationName, /* AMOPOPID */ 3, { @@ -61,7 +112,7 @@ static struct cachedesc cacheinfo[] = { }, sizeof(FormData_pg_amop), AccessMethodOpidIndex, - (ScanFunc) AccessMethodOpidIndexScan}, + AccessMethodOpidIndexScan}, {AccessMethodOperatorRelationName, /* AMOPSTRATEGY */ 3, { @@ -82,8 +133,8 @@ static struct cachedesc cacheinfo[] = { 0 }, ATTRIBUTE_TUPLE_SIZE, - AttributeNameIndex, - (ScanFunc) AttributeNameIndexScan}, + AttributeRelidNameIndex, + AttributeRelidNameIndexScan}, {AttributeRelationName, /* ATTNUM */ 2, { @@ -93,8 +144,52 @@ static struct cachedesc cacheinfo[] = { 0 }, ATTRIBUTE_TUPLE_SIZE, - AttributeNumIndex, - (ScanFunc) AttributeNumIndexScan}, + AttributeRelidNumIndex, + (ScanFunc) AttributeRelidNumIndexScan}, + {OperatorClassRelationName, /* CLADEFTYPE */ + 1, + { + Anum_pg_opclass_opcdeftype, + 0, + 0, + 0 + }, + sizeof(FormData_pg_opclass), + OpclassDeftypeIndex, + OpclassDeftypeIndexScan}, + {OperatorClassRelationName, /* CLANAME */ + 1, + { + Anum_pg_opclass_opcname, + 0, + 0, + 0 + }, + sizeof(FormData_pg_opclass), + OpclassNameIndex, + OpclassNameIndexScan}, + {GroupRelationName, /* GRONAME */ + 1, + { + Anum_pg_group_groname, + 0, + 0, + 0 + }, + offsetof(FormData_pg_group, grolist[0]), + GroupNameIndex, + GroupNameIndexScan}, + {GroupRelationName, /* GROSYSID */ + 1, + { + Anum_pg_group_grosysid, + 0, + 0, + 0 + }, + offsetof(FormData_pg_group, grolist[0]), + GroupSysidIndex, + GroupSysidIndexScan}, {IndexRelationName, /* INDEXRELID */ 1, { @@ -105,8 +200,19 @@ static struct cachedesc cacheinfo[] = { }, offsetof(FormData_pg_index, indpred), IndexRelidIndex, - (ScanFunc) IndexRelidIndexScan}, - {LanguageRelationName, /* LANNAME */ + IndexRelidIndexScan}, + {InheritsRelationName, /* INHRELID */ + 2, + { + Anum_pg_inherits_inhrelid, + Anum_pg_inherits_inhseqno, + 0, + 0 + }, + sizeof(FormData_pg_inherits), + InheritsRelidSeqnoIndex, + InheritsRelidSeqnoIndexScan}, + {LanguageRelationName, /* LANGNAME */ 1, { Anum_pg_language_lanname, @@ -115,9 +221,31 @@ static struct cachedesc cacheinfo[] = { 0 }, offsetof(FormData_pg_language, lancompiler), - NULL, - NULL}, - {OperatorRelationName, /* OPRNAME */ + LanguageNameIndex, + LanguageNameIndexScan}, + {LanguageRelationName, /* LANGOID */ + 1, + { + ObjectIdAttributeNumber, + 0, + 0, + 0 + }, + offsetof(FormData_pg_language, lancompiler), + LanguageOidIndex, + LanguageOidIndexScan}, + {ListenerRelationName, /* LISTENREL */ + 2, + { + Anum_pg_listener_relname, + Anum_pg_listener_pid, + 0, + 0 + }, + sizeof(FormData_pg_listener), + ListenerRelnamePidIndex, + ListenerRelnamePidIndexScan}, + {OperatorRelationName, /* OPERNAME */ 4, { Anum_pg_operator_oprname, @@ -126,9 +254,9 @@ static struct cachedesc cacheinfo[] = { Anum_pg_operator_oprkind }, sizeof(FormData_pg_operator), - NULL, - NULL}, - {OperatorRelationName, /* OPROID */ + OperatorNameIndex, + (ScanFunc) OperatorNameIndexScan}, + {OperatorRelationName, /* OPEROID */ 1, { ObjectIdAttributeNumber, @@ -137,9 +265,9 @@ static struct cachedesc cacheinfo[] = { 0 }, sizeof(FormData_pg_operator), - NULL, - (ScanFunc) NULL}, - {ProcedureRelationName, /* PRONAME */ + OperatorOidIndex, + OperatorOidIndexScan}, + {ProcedureRelationName, /* PROCNAME */ 3, { Anum_pg_proc_proname, @@ -150,7 +278,7 @@ static struct cachedesc cacheinfo[] = { offsetof(FormData_pg_proc, prosrc), ProcedureNameIndex, (ScanFunc) ProcedureNameIndexScan}, - {ProcedureRelationName, /* PROOID */ + {ProcedureRelationName, /* PROCOID */ 1, { ObjectIdAttributeNumber, @@ -160,7 +288,7 @@ static struct cachedesc cacheinfo[] = { }, offsetof(FormData_pg_proc, prosrc), ProcedureOidIndex, - (ScanFunc) ProcedureOidIndexScan}, + ProcedureOidIndexScan}, {RelationRelationName, /* RELNAME */ 1, { @@ -171,7 +299,7 @@ static struct cachedesc cacheinfo[] = { }, CLASS_TUPLE_SIZE, ClassNameIndex, - (ScanFunc) ClassNameIndexScan}, + ClassNameIndexScan}, {RelationRelationName, /* RELOID */ 1, { @@ -182,8 +310,30 @@ static struct cachedesc cacheinfo[] = { }, CLASS_TUPLE_SIZE, ClassOidIndex, - (ScanFunc) ClassOidIndexScan}, - {TypeRelationName, /* TYPNAME */ + ClassOidIndexScan}, + {RewriteRelationName, /* REWRITENAME */ + 1, + { + Anum_pg_rewrite_rulename, + 0, + 0, + 0 + }, + offsetof(FormData_pg_rewrite, ev_qual), + RewriteRulenameIndex, + RewriteRulenameIndexScan}, + {RewriteRelationName, /* RULEOID */ + 1, + { + ObjectIdAttributeNumber, + 0, + 0, + 0 + }, + offsetof(FormData_pg_rewrite, ev_qual), + RewriteOidIndex, + RewriteOidIndexScan}, + {TypeRelationName, /* TYPENAME */ 1, { Anum_pg_type_typname, @@ -194,7 +344,7 @@ static struct cachedesc cacheinfo[] = { offsetof(FormData_pg_type, typalign) +sizeof(char), TypeNameIndex, TypeNameIndexScan}, - {TypeRelationName, /* TYPOID */ + {TypeRelationName, /* TYPEOID */ 1, { ObjectIdAttributeNumber, @@ -205,73 +355,7 @@ static struct cachedesc cacheinfo[] = { offsetof(FormData_pg_type, typalign) +sizeof(char), TypeOidIndex, TypeOidIndexScan}, - {AccessMethodRelationName, /* AMNAME */ - 1, - { - Anum_pg_am_amname, - 0, - 0, - 0 - }, - sizeof(FormData_pg_am), - NULL, - NULL}, - {OperatorClassRelationName, /* CLANAME */ - 1, - { - Anum_pg_opclass_opcname, - 0, - 0, - 0 - }, - sizeof(FormData_pg_opclass), - NULL, - NULL}, - {InheritsRelationName, /* INHRELID */ - 2, - { - Anum_pg_inherits_inhrel, - Anum_pg_inherits_inhseqno, - 0, - 0 - }, - sizeof(FormData_pg_inherits), - NULL, - (ScanFunc) NULL}, - {RewriteRelationName, /* RULOID */ - 1, - { - ObjectIdAttributeNumber, - 0, - 0, - 0 - }, - offsetof(FormData_pg_rewrite, ev_qual), - NULL, - (ScanFunc) NULL}, - {AggregateRelationName, /* AGGNAME */ - 2, - { - Anum_pg_aggregate_aggname, - Anum_pg_aggregate_aggbasetype, - 0, - 0 - }, - offsetof(FormData_pg_aggregate, agginitval1), - NULL, - (ScanFunc) NULL}, - {ListenerRelationName, /* LISTENREL */ - 2, - { - Anum_pg_listener_relname, - Anum_pg_listener_pid, - 0, - 0 - }, - sizeof(FormData_pg_listener), - NULL, - (ScanFunc) NULL}, - {ShadowRelationName, /* USENAME */ + {ShadowRelationName, /* USERNAME */ 1, { Anum_pg_shadow_usename, @@ -280,9 +364,10 @@ static struct cachedesc cacheinfo[] = { 0 }, sizeof(FormData_pg_shadow), - NULL, - (ScanFunc) NULL}, - {ShadowRelationName, /* USESYSID */ +NULL,NULL +/* ShadowNameIndex, + ShadowNameIndexScan*/}, + {ShadowRelationName, /* USERSYSID */ 1, { Anum_pg_shadow_usesysid, @@ -291,63 +376,9 @@ static struct cachedesc cacheinfo[] = { 0 }, sizeof(FormData_pg_shadow), - NULL, - (ScanFunc) NULL}, - {GroupRelationName, /* GRONAME */ - 1, - { - Anum_pg_group_groname, - 0, - 0, - 0 - }, - offsetof(FormData_pg_group, grolist[0]), - NULL, - (ScanFunc) NULL}, - {GroupRelationName, /* GROSYSID */ - 1, - { - Anum_pg_group_grosysid, - 0, - 0, - 0 - }, - offsetof(FormData_pg_group, grolist[0]), - NULL, - (ScanFunc) NULL}, - {RewriteRelationName, /* REWRITENAME */ - 1, - { - Anum_pg_rewrite_rulename, - 0, - 0, - 0 - }, - offsetof(FormData_pg_rewrite, ev_qual), - NULL, - (ScanFunc) NULL}, - {OperatorClassRelationName, /* CLADEFTYPE */ - 1, - { - Anum_pg_opclass_opcdeftype, - 0, - 0, - 0 - }, - sizeof(FormData_pg_opclass), - NULL, - (ScanFunc) NULL}, - {LanguageRelationName, /* LANOID */ - 1, - { - ObjectIdAttributeNumber, - 0, - 0, - 0 - }, - offsetof(FormData_pg_language, lancompiler), - NULL, - NULL} +NULL,NULL +/* ShadowSysidIndex, + ShadowSysidIndexScan*/} }; static struct catcache *SysCache[lengthof(cacheinfo)]; diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 18f573d6d1..8182e9edd5 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.36 1999/11/07 23:08:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.37 1999/11/22 17:56:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ fmgr_dynamic(Oid procedureId, int *pronargs) */ rel = heap_openr(ProcedureRelationName, AccessShareLock); - procedureTuple = SearchSysCacheTuple(PROOID, + procedureTuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(procedureId), 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 6b95c4c11e..6506f4a519 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.32 1999/07/17 20:18:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.33 1999/11/22 17:56:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -217,7 +217,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) } else { - procedureTuple = SearchSysCacheTuple(PROOID, + procedureTuple = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(procedureId), 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) @@ -270,7 +270,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) * this is the case, we return a NULL function pointer and * the number of arguments from the procedure. */ - languageTuple = SearchSysCacheTuple(LANOID, + languageTuple = SearchSysCacheTuple(LANGOID, ObjectIdGetDatum(procedureStruct->prolang), 0, 0, 0); if (!HeapTupleIsValid(languageTuple)) diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 11ac358026..0f6c376e8a 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.35 1999/10/06 21:58:10 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.36 1999/11/22 17:56:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -453,7 +453,7 @@ SetUserId() } userName = GetPgUserName(); - userTup = SearchSysCacheTuple(USENAME, + userTup = SearchSysCacheTuple(USERNAME, PointerGetDatum(userName), 0, 0, 0); if (!HeapTupleIsValid(userTup)) diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index 22263a3ab4..cffaacdd7f 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.10 1999/07/16 05:23:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.11 1999/11/22 17:56:35 momjian Exp $ * * DESCRIPTION * See superuser(). @@ -30,7 +30,7 @@ superuser(void) HeapTuple utup; - utup = SearchSysCacheTuple(USENAME, + utup = SearchSysCacheTuple(USERNAME, PointerGetDatum(UserName), 0, 0, 0); Assert(utup != NULL); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index d600ba5821..f4d1008236 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.34 1999/10/23 03:13:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.35 1999/11/22 17:56:36 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -118,7 +118,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables, numParents = 0; for (i = 0; i < numInherits; i++) { - if (strcmp(inhinfo[i].inhrel, oid) == 0) + if (strcmp(inhinfo[i].inhrelid, oid) == 0) numParents++; } @@ -130,7 +130,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables, j = 0; for (i = 0; i < numInherits; i++) { - if (strcmp(inhinfo[i].inhrel, oid) == 0) + if (strcmp(inhinfo[i].inhrelid, oid) == 0) { parentInd = findTableByOid(tblinfo, numTables, inhinfo[i].inhparent); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 6a8602dfa6..149c838537 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.123 1999/10/23 03:13:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.124 1999/11/22 17:56:36 momjian Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -1096,8 +1096,8 @@ clearInhInfo(InhInfo *inh, int numInherits) return; for (i = 0; i < numInherits; ++i) { - if (inh[i].inhrel) - free(inh[i].inhrel); + if (inh[i].inhrelid) + free(inh[i].inhrelid); if (inh[i].inhparent) free(inh[i].inhparent); } @@ -1478,7 +1478,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) sprintf(query, "SELECT rcname from pg_relcheck, pg_inherits as i " "where rcrelid = '%s'::oid " - " and rcrelid = i.inhrel" + " and rcrelid = i.inhrelid" " and exists " " (select * from pg_relcheck as c " " where c.rcname = pg_relcheck.rcname " @@ -1523,7 +1523,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) "where rcrelid = '%s'::oid " " and not exists " " (select * from pg_relcheck as c, pg_inherits as i " - " where i.inhrel = pg_relcheck.rcrelid " + " where i.inhrelid = pg_relcheck.rcrelid " " and c.rcname = pg_relcheck.rcname " " and c.rcsrc = pg_relcheck.rcsrc " " and c.rcrelid = i.inhparent) ", @@ -1738,12 +1738,12 @@ getInherits(int *numInherits) char query[MAX_QUERY_SIZE]; InhInfo *inhinfo; - int i_inhrel; + int i_inhrelid; int i_inhparent; /* find all the inheritance information */ - sprintf(query, "SELECT inhrel, inhparent from pg_inherits"); + sprintf(query, "SELECT inhrelid, inhparent from pg_inherits"); res = PQexec(g_conn, query); if (!res || @@ -1759,12 +1759,12 @@ getInherits(int *numInherits) inhinfo = (InhInfo *) malloc(ntups * sizeof(InhInfo)); - i_inhrel = PQfnumber(res, "inhrel"); + i_inhrelid = PQfnumber(res, "inhrelid"); i_inhparent = PQfnumber(res, "inhparent"); for (i = 0; i < ntups; i++) { - inhinfo[i].inhrel = strdup(PQgetvalue(res, i, i_inhrel)); + inhinfo[i].inhrelid = strdup(PQgetvalue(res, i, i_inhrelid)); inhinfo[i].inhparent = strdup(PQgetvalue(res, i, i_inhparent)); } diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 9ef43b3713..fc0b055b19 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_dump.h,v 1.40 1999/10/23 03:13:26 tgl Exp $ + * $Id: pg_dump.h,v 1.41 1999/11/22 17:56:36 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -105,7 +105,7 @@ typedef struct _tableInfo typedef struct _inhInfo { - char *inhrel; + char *inhrelid; char *inhparent; } InhInfo; diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 7ac22873d1..6ffe6f79a4 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -36,7 +36,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.2 1999/11/04 08:01:06 inoue Exp $ + * $Id: catversion.h,v 1.3 1999/11/22 17:56:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,6 +51,6 @@ * catalog changes on the same day...) */ -#define CATALOG_VERSION_NO 199911041 +#define CATALOG_VERSION_NO 199911221 #endif diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 5d3d34e876..8c61143a56 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: indexing.h,v 1.28 1999/11/04 08:01:06 inoue Exp $ + * $Id: indexing.h,v 1.29 1999/11/22 17:56:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,16 +19,26 @@ /* * Some definitions for indices on pg_attribute */ +#define Num_pg_aggregate_indices 1 +#define Num_pg_am_indices 1 #define Num_pg_amop_indices 2 -#define Num_pg_attr_indices 3 -#define Num_pg_index_indices 1 -#define Num_pg_proc_indices 2 -#define Num_pg_type_indices 2 -#define Num_pg_class_indices 2 +#define Num_pg_attr_indices 2 #define Num_pg_attrdef_indices 1 -#define Num_pg_relcheck_indices 1 -#define Num_pg_trigger_indices 3 +#define Num_pg_class_indices 2 #define Num_pg_description_indices 1 +#define Num_pg_group_indices 2 +#define Num_pg_index_indices 1 +#define Num_pg_inherits_indices 1 +#define Num_pg_language_indices 2 +#define Num_pg_listener_indices 1 +#define Num_pg_opclass_indices 2 +#define Num_pg_operator_indices 2 +#define Num_pg_proc_indices 2 +#define Num_pg_relcheck_indices 1 +#define Num_pg_rewrite_indices 2 +#define Num_pg_shadow_indices 2 +#define Num_pg_trigger_indices 3 +#define Num_pg_type_indices 2 /* @@ -36,33 +46,58 @@ */ #define AccessMethodOpidIndex "pg_amop_opid_index" #define AccessMethodStrategyIndex "pg_amop_strategy_index" -#define AttributeNameIndex "pg_attribute_relid_attnam_index" -#define AttributeNumIndex "pg_attribute_relid_attnum_index" -#define IndexRelidIndex "pg_index_indexrelid_index" -#define AttributeRelidIndex "pg_attribute_attrelid_index" -#define ProcedureOidIndex "pg_proc_oid_index" -#define ProcedureNameIndex "pg_proc_proname_narg_type_index" -#define TypeOidIndex "pg_type_oid_index" -#define TypeNameIndex "pg_type_typname_index" -#define ClassOidIndex "pg_class_oid_index" -#define ClassNameIndex "pg_class_relname_index" +#define AggregateNameTypeIndex "pg_aggregate_name_type_index" +#define AmNameIndex "pg_am_name_index" #define AttrDefaultIndex "pg_attrdef_adrelid_index" +#define AttributeRelidNameIndex "pg_attribute_relid_attnam_index" +#define AttributeRelidNumIndex "pg_attribute_relid_attnum_index" +#define ClassNameIndex "pg_class_relname_index" +#define ClassOidIndex "pg_class_oid_index" +#define DescriptionObjIndex "pg_description_objoid_index" +#define GroupNameIndex "pg_group_name_index" +#define GroupSysidIndex "pg_group_sysid_index" +#define IndexRelidIndex "pg_index_indexrelid_index" +#define InheritsRelidSeqnoIndex "pg_inherits_relid_seqno_index" +#define LanguageNameIndex "pg_language_name_index" +#define LanguageOidIndex "pg_language_oid_index" +#define ListenerRelnamePidIndex "pg_listener_relname_pid_index" +#define OpclassDeftypeIndex "pg_opclass_deftype_index" +#define OpclassNameIndex "pg_opclass_name_index" +#define OperatorNameIndex "pg_operator_oprname_l_r_k_index" +#define OperatorOidIndex "pg_operator_oid_index" +#define ProcedureNameIndex "pg_proc_proname_narg_type_index" +#define ProcedureOidIndex "pg_proc_oid_index" #define RelCheckIndex "pg_relcheck_rcrelid_index" -#define TriggerRelidIndex "pg_trigger_tgrelid_index" +#define RewriteOidIndex "pg_rewrite_oid_index" +#define RewriteRulenameIndex "pg_rewrite_rulename_index" +#define ShadowNameIndex "pg_shadow_name_index" +#define ShadowSysidIndex "pg_shadow_sysid_index" #define TriggerConstrNameIndex "pg_trigger_tgconstrname_index" #define TriggerConstrRelidIndex "pg_trigger_tgconstrrelid_index" -#define DescriptionObjIndex "pg_description_objoid_index" +#define TriggerRelidIndex "pg_trigger_tgrelid_index" +#define TypeNameIndex "pg_type_typname_index" +#define TypeOidIndex "pg_type_oid_index" +extern char *Name_pg_aggregate_indices[]; +extern char *Name_pg_am_indices[]; extern char *Name_pg_amop_indices[]; extern char *Name_pg_attr_indices[]; -extern char *Name_pg_index_indices[]; -extern char *Name_pg_proc_indices[]; -extern char *Name_pg_type_indices[]; -extern char *Name_pg_class_indices[]; extern char *Name_pg_attrdef_indices[]; -extern char *Name_pg_relcheck_indices[]; -extern char *Name_pg_trigger_indices[]; +extern char *Name_pg_class_indices[]; extern char *Name_pg_description_indices[]; +extern char *Name_pg_group_indices[]; +extern char *Name_pg_index_indices[]; +extern char *Name_pg_inherits_indices[]; +extern char *Name_pg_language_indices[]; +extern char *Name_pg_listener_indices[]; +extern char *Name_pg_opclass_indices[]; +extern char *Name_pg_operator_indices[]; +extern char *Name_pg_proc_indices[]; +extern char *Name_pg_relcheck_indices[]; +extern char *Name_pg_rewrite_indices[]; +extern char *Name_pg_shadow_indices[]; +extern char *Name_pg_trigger_indices[]; +extern char *Name_pg_type_indices[]; extern char *IndexedCatalogNames[]; @@ -84,18 +119,39 @@ extern HeapTuple AccessMethodOpidIndexScan(Relation heapRelation, Oid claid, Oid opopr, Oid opid); extern HeapTuple AccessMethodStrategyIndexScan(Relation heapRelation, Oid opid, Oid claid, int2 opstrategy); -extern HeapTuple AttributeNameIndexScan(Relation heapRelation, +extern HeapTuple AggregateNameTypeIndexScan(Relation heapRelation, + char *aggName, Oid aggType); +extern HeapTuple AmNameIndexScan(Relation heapRelation, char *amName); +extern HeapTuple AttributeRelidNameIndexScan(Relation heapRelation, Oid relid, char *attname); -extern HeapTuple AttributeNumIndexScan(Relation heapRelation, +extern HeapTuple AttributeRelidNumIndexScan(Relation heapRelation, Oid relid, AttrNumber attnum); -extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid); -extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId); -extern HeapTuple ProcedureNameIndexScan(Relation heapRelation, - char *procName, int2 nargs, Oid *argTypes); -extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId); -extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName); +extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName); extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName); extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId); +extern HeapTuple GroupNameIndexScan(Relation heapRelation, char *groName); +extern HeapTuple GroupSysidIndexScan(Relation heapRelation, int4 sysId); +extern HeapTuple IndexRelidIndexScan(Relation heapRelation, Oid relid); +extern HeapTuple InheritsRelidSeqnoIndexScan(Relation heapRelation, Oid relid, + int4 seqno); +extern HeapTuple LanguageNameIndexScan(Relation heapRelation, char *lanName); +extern HeapTuple LanguageOidIndexScan(Relation heapRelation, Oid lanId); +extern HeapTuple ListenerRelnamePidIndexScan(Relation heapRelation, char *relName, int4 pid); +extern HeapTuple OpclassDeftypeIndexScan(Relation heapRelation, Oid defType); +extern HeapTuple OpclassNameIndexScan(Relation heapRelation, char *opcName); +extern HeapTuple OperatorNameIndexScan(Relation heapRelation, + char *oprName, Oid oprLeft, Oid oprRight, char oprKind); +extern HeapTuple OperatorOidIndexScan(Relation heapRelation, Oid oprId); +extern HeapTuple ProcedureNameIndexScan(Relation heapRelation, + char *procName, int2 nargs, Oid *argTypes); +extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId); +extern HeapTuple RewriteOidIndexScan(Relation heapRelation, Oid rewriteId); +extern HeapTuple RewriteRulenameIndexScan(Relation heapRelation, + char *ruleName); +extern HeapTuple ShadowNameIndexScan(Relation heapRelation, char *useName); +extern HeapTuple ShadowSysidIndexScan(Relation heapRelation, int4 sysId); +extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName); +extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId); @@ -107,33 +163,44 @@ extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId); * The keyword is DECLARE_INDEX every thing after that is just like in a * normal specification of the 'define index' POSTQUEL command. */ -DECLARE_INDEX(pg_amop_opid_index on pg_amop using btree(amopclaid oid_ops, amopopr oid_ops, amopid oid_ops)); -DECLARE_INDEX(pg_amop_strategy_index on pg_amop using btree(amopid oid_ops, amopclaid oid_ops, amopstrategy int2_ops)); - -DECLARE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops)); -DECLARE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops)); -DECLARE_INDEX(pg_attribute_attrelid_index on pg_attribute using btree(attrelid oid_ops)); - -DECLARE_INDEX(pg_index_indexrelid_index on pg_index using btree(indexrelid oid_ops)); - -DECLARE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops)); -DECLARE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oid8_ops)); - -DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops)); -DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_ops)); +DECLARE_UNIQUE_INDEX(pg_aggregate_name_type_index on pg_aggregate using btree(aggname name_ops, aggbasetype oid_ops)); +DECLARE_UNIQUE_INDEX(pg_am_name_index on pg_am using btree(amname name_ops)); +DECLARE_UNIQUE_INDEX(pg_amop_opid_index on pg_amop using btree(amopclaid oid_ops, amopopr oid_ops, amopid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_amop_strategy_index on pg_amop using btree(amopid oid_ops, amopclaid oid_ops, amopstrategy int2_ops)); +/* This following index is not used for a cache and is not unique */ +DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops)); +DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops)); DECLARE_UNIQUE_INDEX(pg_class_oid_index on pg_class using btree(oid oid_ops)); DECLARE_UNIQUE_INDEX(pg_class_relname_index on pg_class using btree(relname name_ops)); - -DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid oid_ops)); - +DECLARE_UNIQUE_INDEX(pg_description_objoid_index on pg_description using btree(objoid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_group_name_index on pg_group using btree(groname name_ops)); +DECLARE_UNIQUE_INDEX(pg_group_sysid_index on pg_group using btree(grosysid int4_ops)); +DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index on pg_index using btree(indexrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops)); +DECLARE_UNIQUE_INDEX(pg_language_name_index on pg_language using btree(lanname name_ops)); +DECLARE_UNIQUE_INDEX(pg_language_oid_index on pg_language using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_listener_relname_pid_index on pg_listener using btree(relname name_ops, listenerpid int4_ops)); +DECLARE_UNIQUE_INDEX(pg_opclass_deftype_index on pg_opclass using btree(opcdeftype oid_ops)); +DECLARE_UNIQUE_INDEX(pg_opclass_name_index on pg_opclass using btree(opcname name_ops)); +DECLARE_UNIQUE_INDEX(pg_operator_oid_index on pg_operator using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_k_index on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprkind char_ops)); +DECLARE_UNIQUE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oid8_ops)); +/* This following index is not used for a cache and is not unique */ DECLARE_INDEX(pg_relcheck_rcrelid_index on pg_relcheck using btree(rcrelid oid_ops)); - -DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index on pg_rewrite using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulename name_ops)); +/* +xDECLARE_UNIQUE_INDEX(pg_shadow_name_index on pg_shadow using btree(usename name_ops)); +xDECLARE_UNIQUE_INDEX(pg_shadow_sysid_index on pg_shadow using btree(usesysid int4_ops)); +*/ DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops)); DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops)); - -DECLARE_INDEX(pg_description_objoid_index on pg_description using btree(objoid oid_ops)); +DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname name_ops)); /* now build indices in the initialization scripts */ BUILD_INDICES diff --git a/src/include/catalog/pg_inheritproc.h b/src/include/catalog/pg_inheritproc.h index 3599315b85..e20735a2ba 100644 --- a/src/include/catalog/pg_inheritproc.h +++ b/src/include/catalog/pg_inheritproc.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_inheritproc.h,v 1.6 1999/02/13 23:21:10 momjian Exp $ + * $Id: pg_inheritproc.h,v 1.7 1999/11/22 17:56:37 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -33,8 +33,8 @@ CATALOG(pg_inheritproc) { NameData inhproname; - Oid inhargrel; - Oid inhdefrel; + Oid inhargrelid; + Oid inhdefrelid; Oid inhproc; } FormData_pg_inheritproc; @@ -51,8 +51,8 @@ typedef FormData_pg_inheritproc *Form_pg_inheritproc; */ #define Natts_pg_inheritproc 4 #define Anum_pg_inheritproc_inhproname 1 -#define Anum_pg_inheritproc_inhargrel 2 -#define Anum_pg_inheritproc_inhdefrel 3 +#define Anum_pg_inheritproc_inhargrelid 2 +#define Anum_pg_inheritproc_inhdefrelid 3 #define Anum_pg_inheritproc_inhproc 4 diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h index c078c6b966..21ea6e842a 100644 --- a/src/include/catalog/pg_inherits.h +++ b/src/include/catalog/pg_inherits.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_inherits.h,v 1.7 1999/02/13 23:21:10 momjian Exp $ + * $Id: pg_inherits.h,v 1.8 1999/11/22 17:56:37 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,7 +32,7 @@ */ CATALOG(pg_inherits) { - Oid inhrel; + Oid inhrelid; Oid inhparent; int4 inhseqno; } FormData_pg_inherits; @@ -49,7 +49,7 @@ typedef FormData_pg_inherits *Form_pg_inherits; * ---------------- */ #define Natts_pg_inherits 3 -#define Anum_pg_inherits_inhrel 1 +#define Anum_pg_inherits_inhrelid 1 #define Anum_pg_inherits_inhparent 2 #define Anum_pg_inherits_inhseqno 3 diff --git a/src/include/catalog/pg_ipl.h b/src/include/catalog/pg_ipl.h index 4b122bacc7..3fdcc77110 100644 --- a/src/include/catalog/pg_ipl.h +++ b/src/include/catalog/pg_ipl.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_ipl.h,v 1.6 1999/02/13 23:21:10 momjian Exp $ + * $Id: pg_ipl.h,v 1.7 1999/11/22 17:56:37 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,7 +32,7 @@ */ CATALOG(pg_ipl) { - Oid iplrel; + Oid iplrelid; Oid iplipl; int4 iplseqno; } FormData_pg_ipl; @@ -49,7 +49,7 @@ typedef FormData_pg_ipl *Form_pg_ipl; * ---------------- */ #define Natts_pg_ipl 3 -#define Anum_pg_ipl_iplrel 1 +#define Anum_pg_ipl_iplrelid 1 #define Anum_pg_ipl_iplipl 2 #define Anum_pg_ipl_iplseqno 3 diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index 267c19775c..0ed4e2a88c 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.20 1999/09/29 21:13:30 wieck Exp $ + * $Id: pg_opclass.h,v 1.21 1999/11/22 17:56:37 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -68,9 +68,11 @@ DATA(insert OID = 422 ( box_ops 603 )); DESCR(""); DATA(insert OID = 423 ( float8_ops 701 )); DESCR(""); -DATA(insert OID = 424 ( int24_ops 0 )); +/* Technically, deftype is wrong, but it must be unique for index, bjm */ +DATA(insert OID = 424 ( int24_ops 424 )); DESCR(""); -DATA(insert OID = 425 ( int42_ops 0 )); +/* Technically, deftype is wrong, but it must be unique for index, bjm */ +DATA(insert OID = 425 ( int42_ops 425 )); DESCR(""); DATA(insert OID = 426 ( int4_ops 23 )); DESCR(""); @@ -85,7 +87,8 @@ DATA(insert OID = 431 ( text_ops 25 )); DESCR(""); DATA(insert OID = 432 ( abstime_ops 702 )); DESCR(""); -DATA(insert OID = 433 ( bigbox_ops 603 )); +/* Technically, deftype is wrong, but it must be unique for index, bjm */ +DATA(insert OID = 433 ( bigbox_ops 433 )); DESCR(""); DATA(insert OID = 434 ( poly_ops 604 )); DESCR(""); @@ -109,13 +112,13 @@ DATA(insert OID = 1312 ( datetime_ops 1184 )); DESCR(""); DATA(insert OID = 1313 ( timespan_ops 1186 )); DESCR(""); -DATA(insert OID = 810 ( macaddr_ops 829 )); +DATA(insert OID = 810 ( macaddr_ops 829 )); DESCR(""); -DATA(insert OID = 935 ( network_ops 869 )); +DATA(insert OID = 935 ( inet_ops 869 )); DESCR(""); -DATA(insert OID = 652 ( network_ops 650 )); +DATA(insert OID = 652 ( cidr_ops 650 )); DESCR(""); -DATA(insert OID = 1768 ( numeric_ops 1700 )); +DATA(insert OID = 1768 ( numeric_ops 1700 )); DESCR(""); #endif /* PG_OPCLASS_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index c23f67a4c6..00d19560b9 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.60 1999/10/11 06:28:29 inoue Exp $ + * $Id: pg_operator.h,v 1.61 1999/11/22 17:56:37 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -274,7 +274,13 @@ DATA(insert OID = 1283 ( ";" PGUID 0 l t f 0 701 701 0 0 0 0 dlog1 - - )); DATA(insert OID = 1284 ( "|" PGUID 0 l t f 0 704 702 0 0 0 0 intervalstart - - )); DATA(insert OID = 606 ( "<#>" PGUID 0 b t f 702 702 704 0 0 0 0 mktinterval - - )); DATA(insert OID = 607 ( "=" PGUID 0 b t t 26 26 16 607 608 609 609 oideq eqsel eqjoinsel )); +#define MIN_OIDCMP 607 /* used by cache code */ DATA(insert OID = 608 ( "<>" PGUID 0 b t f 26 26 16 608 607 0 0 oidne neqsel neqjoinsel )); +DATA(insert OID = 609 ( "<" PGUID 0 b t f 26 26 16 610 612 0 0 int4lt intltsel intltjoinsel )); +DATA(insert OID = 610 ( ">" PGUID 0 b t f 26 26 16 609 611 0 0 int4gt intgtsel intgtjoinsel )); +DATA(insert OID = 611 ( "<=" PGUID 0 b t f 26 26 16 612 610 0 0 int4le intltsel intltjoinsel )); +DATA(insert OID = 612 ( ">=" PGUID 0 b t f 26 26 16 611 609 0 0 int4ge intgtsel intgtjoinsel )); +#define MAX_OIDCMP 612 /* used by cache code */ DATA(insert OID = 644 ( "<>" PGUID 0 b t f 30 30 16 644 649 0 0 oid8ne neqsel neqjoinsel )); DATA(insert OID = 645 ( "<" PGUID 0 b t f 30 30 16 646 648 0 0 oid8lt intltsel intltjoinsel )); @@ -283,11 +289,6 @@ DATA(insert OID = 647 ( "<=" PGUID 0 b t f 30 30 16 648 646 0 0 oid8l DATA(insert OID = 648 ( ">=" PGUID 0 b t f 30 30 16 647 645 0 0 oid8ge intgtsel intgtjoinsel )); DATA(insert OID = 649 ( "=" PGUID 0 b t t 30 30 16 649 644 645 645 oid8eq eqsel eqjoinsel )); -DATA(insert OID = 609 ( "<" PGUID 0 b t f 26 26 16 610 612 0 0 int4lt intltsel intltjoinsel )); -DATA(insert OID = 610 ( ">" PGUID 0 b t f 26 26 16 609 611 0 0 int4gt intgtsel intgtjoinsel )); -DATA(insert OID = 611 ( "<=" PGUID 0 b t f 26 26 16 612 610 0 0 int4le intltsel intltjoinsel )); -DATA(insert OID = 612 ( ">=" PGUID 0 b t f 26 26 16 611 609 0 0 int4ge intgtsel intgtjoinsel )); - DATA(insert OID = 613 ( "<->" PGUID 0 b t f 600 628 701 0 0 0 0 dist_pl - - )); DATA(insert OID = 614 ( "<->" PGUID 0 b t f 600 601 701 0 0 0 0 dist_ps - - )); DATA(insert OID = 615 ( "<->" PGUID 0 b t f 600 603 701 0 0 0 0 dist_pb - - )); diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 68cb079c4f..62b3d4ada7 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: syscache.h,v 1.20 1999/11/01 02:29:27 momjian Exp $ + * $Id: syscache.h,v 1.21 1999/11/22 17:56:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,39 +27,36 @@ * * The order of these must match the order * they are entered into the structure cacheinfo[] in syscache.c - * The best thing to do is to add yours at the END, because some - * code assumes that certain caches are at certain places in this - * array. + * Keep them in alphabeticall order. */ -#define AMOPOPID 0 -#define AMOPSTRATEGY 1 -#define ATTNAME 2 -#define ATTNUM 3 -#define INDEXRELID 4 -#define LANNAME 5 -#define OPRNAME 6 -#define OPROID 7 -#define PRONAME 8 -#define PROOID 9 -#define RELNAME 10 -#define RELOID 11 -#define TYPNAME 12 -#define TYPOID 13 -#define AMNAME 14 -#define CLANAME 15 -/* #define INDRELIDKEY 16 */ -#define INHRELID 16 -#define RULOID 17 -#define AGGNAME 18 -#define LISTENREL 19 -#define USENAME 20 -#define USESYSID 21 -#define GRONAME 22 -#define GROSYSID 23 -#define REWRITENAME 24 -#define CLADEFTYPE 25 -#define LANOID 26 +#define AGGNAME 0 +#define AMNAME 1 +#define AMOPOPID 2 +#define AMOPSTRATEGY 3 +#define ATTNAME 4 +#define ATTNUM 5 +#define CLADEFTYPE 6 +#define CLANAME 7 +#define GRONAME 8 +#define GROSYSID 9 +#define INDEXRELID 10 +#define INHRELID 11 +#define LANGNAME 12 +#define LANGOID 13 +#define LISTENREL 14 +#define OPERNAME 15 +#define OPEROID 16 +#define PROCNAME 17 +#define PROCOID 18 +#define RELNAME 19 +#define RELOID 20 +#define RULENAME 21 +#define RULEOID 22 +#define TYPENAME 23 +#define TYPEOID 24 +#define USERNAME 25 +#define USERSYSID 26 /* ---------------- * struct cachedesc: information needed for a call to InitSysCache() diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 49bc642f4f..6f908b48d2 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.12 1999/11/07 23:08:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.13 1999/11/22 17:56:39 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -132,7 +132,7 @@ plpgsql_compile(Oid fn_oid, int functype) * Lookup the pg_proc tuple by Oid * ---------- */ - procTup = SearchSysCacheTuple(PROOID, + procTup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(fn_oid), 0, 0, 0); if (!HeapTupleIsValid(procTup)) @@ -174,7 +174,7 @@ plpgsql_compile(Oid fn_oid, int functype) * Lookup the functions return type * ---------- */ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -205,7 +205,7 @@ plpgsql_compile(Oid fn_oid, int functype) * Get the parameters type * ---------- */ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -601,7 +601,7 @@ plpgsql_parse_word(char *word) * ---------- */ typeXlated = xlateSqlType(cp); - typeTup = SearchSysCacheTuple(TYPNAME, + typeTup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(typeXlated), 0, 0, 0); if (HeapTupleIsValid(typeTup)) { @@ -924,7 +924,7 @@ plpgsql_parse_wordtype(char *word) * ---------- */ typeXlated = xlateSqlType(cp); - typeTup = SearchSysCacheTuple(TYPNAME, + typeTup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(typeXlated), 0, 0, 0); if (HeapTupleIsValid(typeTup)) { @@ -1067,7 +1067,7 @@ plpgsql_parse_dblwordtype(char *string) } attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typetup)) { @@ -1143,7 +1143,7 @@ plpgsql_parse_wordrowtype(char *string) * Fetch the tables pg_type tuple too * ---------- */ - typetup = SearchSysCacheTuple(TYPNAME, + typetup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(word1), 0, 0, 0); if (!HeapTupleIsValid(typetup)) { @@ -1182,7 +1182,7 @@ plpgsql_parse_wordrowtype(char *string) } attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typetup)) { diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 59485f84a2..2c37943eb4 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.14 1999/11/07 23:08:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.15 1999/11/22 17:56:40 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1553,7 +1553,7 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) extval = ""; else { - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(var->datatype->typoid), 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed (1)", var->datatype->typoid); @@ -1958,7 +1958,7 @@ exec_assign_value(PLpgSQL_execstate * estate, */ atttype = SPI_gettypeid(rec->tupdesc, i + 1); atttypmod = rec->tupdesc->attrs[i]->atttypmod; - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(atttype), 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed", atttype); @@ -2389,7 +2389,7 @@ exec_cast_value(Datum value, Oid valtype, FmgrInfo finfo_output; char *extval; - typetup = SearchSysCacheTuple(TYPOID, + typetup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(valtype), 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed", valtype); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 8813dc3881..ea9a956e54 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -3,7 +3,7 @@ * procedural language (PL) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.14 1999/11/07 23:08:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.15 1999/11/22 17:56:41 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -467,7 +467,7 @@ pltcl_func_handler(FmgrInfo *proinfo, /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROOID, + procTup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(proinfo->fn_oid), 0, 0, 0); if (!HeapTupleIsValid(procTup)) @@ -482,7 +482,7 @@ pltcl_func_handler(FmgrInfo *proinfo, * Get the required information for input conversion of the * return value. ************************************************************/ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -512,7 +512,7 @@ pltcl_func_handler(FmgrInfo *proinfo, proc_internal_args[0] = '\0'; for (i = 0; i < proinfo->fn_nargs; i++) { - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -798,7 +798,7 @@ pltcl_trigger_handler(FmgrInfo *proinfo) /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROOID, + procTup = SearchSysCacheTuple(PROCOID, ObjectIdGetDatum(proinfo->fn_oid), 0, 0, 0); if (!HeapTupleIsValid(procTup)) @@ -1120,7 +1120,7 @@ pltcl_trigger_handler(FmgrInfo *proinfo) * Lookup the attribute type in the syscache * for the input function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -1592,7 +1592,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ************************************************************/ for (i = 0; i < nargs; i++) { - typeTup = SearchSysCacheTuple(TYPNAME, + typeTup = SearchSysCacheTuple(TYPENAME, PointerGetDatum(args[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -2137,7 +2137,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -2210,7 +2210,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPOID, + typeTup = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup))