diff options
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execUtils.c | 10 | ||||
-rw-r--r-- | src/backend/executor/functions.c | 21 | ||||
-rw-r--r-- | src/backend/executor/nodeAgg.c | 41 | ||||
-rw-r--r-- | src/backend/executor/nodeGroup.c | 7 | ||||
-rw-r--r-- | src/backend/executor/nodeHash.c | 15 | ||||
-rw-r--r-- | src/backend/executor/nodeMergejoin.c | 20 | ||||
-rw-r--r-- | src/backend/executor/spi.c | 11 |
7 files changed, 66 insertions, 59 deletions
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index ecdda594188..3b05a78e83a 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.68 2000/11/12 00:36:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.69 2000/11/16 22:30:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -740,9 +740,9 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo) * Get the pg_index tuple for the index * ---------------- */ - indexTuple = SearchSysCacheTuple(INDEXRELID, - ObjectIdGetDatum(indexOid), - 0, 0, 0); + indexTuple = SearchSysCache(INDEXRELID, + ObjectIdGetDatum(indexOid), + 0, 0, 0); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "ExecOpenIndices: index %u not found", indexOid); @@ -752,6 +752,8 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo) */ ii = BuildIndexInfo(indexTuple); + ReleaseSysCache(indexTuple); + relationDescs[i] = indexDesc; indexInfoArray[i] = ii; i++; diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index ca9c48e294d..98b28c61e10 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.40 2000/11/12 00:36:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.41 2000/11/16 22:30:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -183,14 +183,11 @@ init_sql_fcache(FmgrInfo *finfo) /* ---------------- * get the procedure tuple corresponding to the given function Oid - * - * NB: use SearchSysCacheTupleCopy to ensure tuple lives long enough * ---------------- */ - procedureTuple = SearchSysCacheTupleCopy(PROCOID, - ObjectIdGetDatum(foid), - 0, 0, 0); - + procedureTuple = SearchSysCache(PROCOID, + ObjectIdGetDatum(foid), + 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) elog(ERROR, "init_sql_fcache: Cache lookup failed for procedure %u", foid); @@ -201,10 +198,9 @@ init_sql_fcache(FmgrInfo *finfo) * get the return type from the procedure tuple * ---------------- */ - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procedureStruct->prorettype), - 0, 0, 0); - + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procedureStruct->prorettype), + 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "init_sql_fcache: Cache lookup failed for type %u", procedureStruct->prorettype); @@ -286,7 +282,8 @@ init_sql_fcache(FmgrInfo *finfo) pfree(src); - heap_freetuple(procedureTuple); + ReleaseSysCache(typeTuple); + ReleaseSysCache(procedureTuple); finfo->fn_extra = (void *) fcache; } diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index fae1a5b0d87..827001384f6 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -34,7 +34,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.71 2000/08/24 03:29:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.72 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -51,6 +51,7 @@ #include "parser/parse_expr.h" #include "parser/parse_oper.h" #include "parser/parse_type.h" +#include "utils/lsyscache.h" #include "utils/syscache.h" #include "utils/tuplesort.h" #include "utils/datum.h" @@ -105,7 +106,7 @@ typedef struct AggStatePerAggData * We need the len and byval info for the agg's input, result, and * transition data types in order to know how to copy/delete values. */ - int inputtypeLen, + int16 inputtypeLen, resulttypeLen, transtypeLen; bool inputtypeByVal, @@ -827,7 +828,6 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) char *aggname = aggref->aggname; HeapTuple aggTuple; Form_pg_aggregate aggform; - Type typeInfo; Oid transfn_oid, finalfn_oid; @@ -837,23 +837,23 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) /* Fill in the peraggstate data */ peraggstate->aggref = aggref; - aggTuple = SearchSysCacheTupleCopy(AGGNAME, - PointerGetDatum(aggname), - ObjectIdGetDatum(aggref->basetype), - 0, 0); + aggTuple = SearchSysCache(AGGNAME, + PointerGetDatum(aggname), + ObjectIdGetDatum(aggref->basetype), + 0, 0); if (!HeapTupleIsValid(aggTuple)) elog(ERROR, "ExecAgg: cache lookup failed for aggregate %s(%s)", aggname, - typeidTypeName(aggref->basetype)); + aggref->basetype ? + typeidTypeName(aggref->basetype) : (char *) ""); aggform = (Form_pg_aggregate) GETSTRUCT(aggTuple); - typeInfo = typeidType(aggform->aggfinaltype); - peraggstate->resulttypeLen = typeLen(typeInfo); - peraggstate->resulttypeByVal = typeByVal(typeInfo); - - typeInfo = typeidType(aggform->aggtranstype); - peraggstate->transtypeLen = typeLen(typeInfo); - peraggstate->transtypeByVal = typeByVal(typeInfo); + get_typlenbyval(aggform->aggfinaltype, + &peraggstate->resulttypeLen, + &peraggstate->resulttypeByVal); + get_typlenbyval(aggform->aggtranstype, + &peraggstate->transtypeLen, + &peraggstate->transtypeByVal); peraggstate->initValue = AggNameGetInitVal(aggname, @@ -901,23 +901,22 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) Form_pg_operator pgopform; peraggstate->inputType = inputType; - typeInfo = typeidType(inputType); - peraggstate->inputtypeLen = typeLen(typeInfo); - peraggstate->inputtypeByVal = typeByVal(typeInfo); + get_typlenbyval(inputType, + &peraggstate->inputtypeLen, + &peraggstate->inputtypeByVal); eq_operator = oper("=", inputType, inputType, true); if (!HeapTupleIsValid(eq_operator)) - { elog(ERROR, "Unable to identify an equality operator for type '%s'", typeidTypeName(inputType)); - } pgopform = (Form_pg_operator) GETSTRUCT(eq_operator); fmgr_info(pgopform->oprcode, &(peraggstate->equalfn)); + ReleaseSysCache(eq_operator); peraggstate->sortOperator = any_ordering_op(inputType); peraggstate->sortstate = NULL; } - heap_freetuple(aggTuple); + ReleaseSysCache(aggTuple); } return TRUE; diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index 8fc319a77f0..88b4cd27335 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -15,7 +15,7 @@ * locate group boundaries. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.38 2000/08/24 03:29:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.39 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -28,6 +28,8 @@ #include "executor/nodeGroup.h" #include "parser/parse_oper.h" #include "parser/parse_type.h" +#include "utils/lsyscache.h" +#include "utils/syscache.h" static TupleTableSlot *ExecGroupEveryTuple(Group *node); static TupleTableSlot *ExecGroupOneTuple(Group *node); @@ -498,12 +500,11 @@ execTuplesMatchPrepare(TupleDesc tupdesc, eq_operator = oper("=", typid, typid, true); if (!HeapTupleIsValid(eq_operator)) - { elog(ERROR, "Unable to identify an equality operator for type '%s'", typeidTypeName(typid)); - } pgopform = (Form_pg_operator) GETSTRUCT(eq_operator); fmgr_info(pgopform->oprcode, &eqfunctions[i]); + ReleaseSysCache(eq_operator); } return eqfunctions; diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 9cd85195cdc..1969c5f0bd6 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $Id: nodeHash.c,v 1.52 2000/08/24 03:29:03 tgl Exp $ + * $Id: nodeHash.c,v 1.53 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ #include "executor/nodeHashjoin.h" #include "miscadmin.h" #include "parser/parse_expr.h" -#include "parser/parse_type.h" #include "utils/memutils.h" +#include "utils/lsyscache.h" static int hashFunc(Datum key, int len, bool byVal); @@ -237,7 +237,6 @@ ExecHashTableCreate(Hash *node) int totalbuckets; int bucketsize; int i; - Type typeInfo; MemoryContext oldcxt; /* ---------------- @@ -353,9 +352,9 @@ ExecHashTableCreate(Hash *node) * Get info about the datatype of the hash key. * ---------------- */ - typeInfo = typeidType(exprType(node->hashkey)); - hashtable->typByVal = typeByVal(typeInfo); - hashtable->typLen = typeLen(typeInfo); + get_typlenbyval(exprType(node->hashkey), + &hashtable->typLen, + &hashtable->typByVal); /* ---------------- * Create temporary memory contexts in which to keep the hashtable @@ -546,7 +545,9 @@ ExecHashGetBucket(HashJoinTable hashtable, } else { - bucketno = hashFunc(keyval, hashtable->typLen, hashtable->typByVal) + bucketno = hashFunc(keyval, + (int) hashtable->typLen, + hashtable->typByVal) % hashtable->totalbuckets; } diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 9d4ca0a8d54..dbeaa7a2a53 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.38 2000/09/12 21:06:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.39 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -147,26 +147,29 @@ MJFormSkipQual(List *qualList, char *replaceopname) * if we search with the actual operand types. * ---------------- */ - optup = get_operator_tuple(op->opno); + optup = SearchSysCache(OPEROID, + ObjectIdGetDatum(op->opno), + 0, 0, 0); if (!HeapTupleIsValid(optup)) /* shouldn't happen */ elog(ERROR, "MJFormSkipQual: operator %u not found", op->opno); opform = (Form_pg_operator) GETSTRUCT(optup); oprleft = opform->oprleft; oprright = opform->oprright; + ReleaseSysCache(optup); /* ---------------- * Now look up the matching "<" or ">" operator. If there isn't one, * whoever marked the "=" operator mergejoinable was a loser. * ---------------- */ - optup = SearchSysCacheTuple(OPERNAME, - PointerGetDatum(replaceopname), - ObjectIdGetDatum(oprleft), - ObjectIdGetDatum(oprright), - CharGetDatum('b')); + optup = SearchSysCache(OPERNAME, + PointerGetDatum(replaceopname), + ObjectIdGetDatum(oprleft), + ObjectIdGetDatum(oprright), + CharGetDatum('b')); if (!HeapTupleIsValid(optup)) elog(ERROR, - "MJFormSkipQual: mergejoin operator %u has no matching %s op", + "MJFormSkipQual: mergejoin operator %u has no matching %s op", op->opno, replaceopname); opform = (Form_pg_operator) GETSTRUCT(optup); @@ -177,6 +180,7 @@ MJFormSkipQual(List *qualList, char *replaceopname) op->opno = optup->t_data->t_oid; op->opid = opform->oprcode; op->op_fcache = NULL; + ReleaseSysCache(optup); } return qualCopy; diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 07a05561a64..74a5dc44415 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.48 2000/10/26 21:35:15 tgl Exp $ + * $Id: spi.c,v 1.49 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -447,6 +447,7 @@ char * SPI_gettype(TupleDesc tupdesc, int fnumber) { HeapTuple typeTuple; + char *result; SPI_result = 0; if (tupdesc->natts < fnumber || fnumber <= 0) @@ -455,9 +456,9 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - typeTuple = SearchSysCacheTuple(TYPEOID, + typeTuple = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) { @@ -465,7 +466,9 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - return pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname)); + result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname)); + ReleaseSysCache(typeTuple); + return result; } Oid |