mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user