diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/acl.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/arrayfuncs.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/regproc.c | 8 | ||||
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 16 | ||||
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/sets.c | 6 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 119 | ||||
-rw-r--r-- | src/backend/utils/cache/fcache.c | 10 | ||||
-rw-r--r-- | src/backend/utils/cache/lsyscache.c | 34 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 6 | ||||
-rw-r--r-- | src/backend/utils/cache/syscache.c | 329 | ||||
-rw-r--r-- | src/backend/utils/fmgr/dfmgr.c | 4 | ||||
-rw-r--r-- | src/backend/utils/fmgr/fmgr.c | 6 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 4 | ||||
-rw-r--r-- | src/backend/utils/misc/superuser.c | 4 |
16 files changed, 317 insertions, 251 deletions
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 3793c749b9c..15db9b30416 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 57d7a08a9ea..b8b023575d5 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 74dd671e968..f5ebcdf0eb3 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 6f69479ba35..e3b6030541b 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 89febb159b9..a342daba8ba 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 e14e5375553..3e2d123df14 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 46dbca9d698..964012a31e4 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 e5a1684041c..96e8288916a 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) - return (HeapTuple)0; - if (!indexSelfOid) + if (cache->id == INDEXRELID) { - 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); + 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; } - if ((Oid)cache->cc_skey[0].sk_argument != indexSelfOid) - return (HeapTuple)0; - if (!indexSelfTuple) + else if (cache->id == OPEROID) { - 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); + /* 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; - 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 33ba637b13c..69ef78af096 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 d2b097ed2f5..ab9f74c0ae1 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 b6684744119..c2f5a7d655c 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 aa532d99bd3..e851c40d286 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,19 +310,19 @@ static struct cachedesc cacheinfo[] = { }, CLASS_TUPLE_SIZE, ClassOidIndex, - (ScanFunc) ClassOidIndexScan}, - {TypeRelationName, /* TYPNAME */ + ClassOidIndexScan}, + {RewriteRelationName, /* REWRITENAME */ 1, { - Anum_pg_type_typname, + Anum_pg_rewrite_rulename, 0, 0, 0 }, - offsetof(FormData_pg_type, typalign) +sizeof(char), - TypeNameIndex, - TypeNameIndexScan}, - {TypeRelationName, /* TYPOID */ + offsetof(FormData_pg_rewrite, ev_qual), + RewriteRulenameIndex, + RewriteRulenameIndexScan}, + {RewriteRelationName, /* RULEOID */ 1, { ObjectIdAttributeNumber, @@ -202,43 +330,21 @@ static struct cachedesc cacheinfo[] = { 0, 0 }, - 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 */ + offsetof(FormData_pg_rewrite, ev_qual), + RewriteOidIndex, + RewriteOidIndexScan}, + {TypeRelationName, /* TYPENAME */ 1, { - Anum_pg_opclass_opcname, - 0, + Anum_pg_type_typname, 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 */ + offsetof(FormData_pg_type, typalign) +sizeof(char), + TypeNameIndex, + TypeNameIndexScan}, + {TypeRelationName, /* TYPEOID */ 1, { ObjectIdAttributeNumber, @@ -246,32 +352,10 @@ static struct cachedesc cacheinfo[] = { 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 */ + offsetof(FormData_pg_type, typalign) +sizeof(char), + TypeOidIndex, + TypeOidIndexScan}, + {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 18f573d6d16..8182e9edd54 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 6b95c4c11e3..6506f4a5192 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 11ac3580260..0f6c376e8a0 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 22263a3ab4a..cffaacdd7fa 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); |