aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAgg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-16 22:30:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-16 22:30:52 +0000
commita933ee38bbb8dffbc48a3363a94ff6f2a9f7964d (patch)
tree1c32737389b2530e7152dc2287161b36d9001e8c /src/backend/executor/nodeAgg.c
parentcff23842a4c68301ddf34559c7af383bb5557054 (diff)
downloadpostgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.tar.gz
postgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.zip
Change SearchSysCache coding conventions so that a reference count is
maintained for each cache entry. A cache entry will not be freed until the matching ReleaseSysCache call has been executed. This eliminates worries about cache entries getting dropped while still in use. See my posting to pg-hackers of even date for more info.
Diffstat (limited to 'src/backend/executor/nodeAgg.c')
-rw-r--r--src/backend/executor/nodeAgg.c41
1 files changed, 20 insertions, 21 deletions
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;