From a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 16 Nov 2000 22:30:52 +0000 Subject: 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. --- src/backend/parser/parse_agg.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/backend/parser/parse_agg.c') diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index e7d8fe8d3b7..1dc31dc1f07 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.42 2000/09/29 18:21:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.43 2000/11/16 22:30:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -190,18 +190,18 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, List *args, bool agg_star, bool agg_distinct, int precedence) { - HeapTuple theAggTuple; + HeapTuple aggtuple; Form_pg_aggregate aggform; Aggref *aggref; - theAggTuple = SearchSysCacheTuple(AGGNAME, - PointerGetDatum(aggname), - ObjectIdGetDatum(basetype), - 0, 0); + aggtuple = SearchSysCache(AGGNAME, + PointerGetDatum(aggname), + ObjectIdGetDatum(basetype), + 0, 0); /* shouldn't happen --- caller should have checked already */ - if (!HeapTupleIsValid(theAggTuple)) + if (!HeapTupleIsValid(aggtuple)) agg_error("ParseAgg", aggname, basetype); - aggform = (Form_pg_aggregate) GETSTRUCT(theAggTuple); + aggform = (Form_pg_aggregate) GETSTRUCT(aggtuple); /* * There used to be a really ugly hack for count(*) here. @@ -225,6 +225,8 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, aggref->aggstar = agg_star; aggref->aggdistinct = agg_distinct; + ReleaseSysCache(aggtuple); + pstate->p_hasAggs = true; return aggref; -- cgit v1.2.3