1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +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:
Tom Lane
2000-11-16 22:30:52 +00:00
parent cff23842a4
commit a933ee38bb
95 changed files with 2672 additions and 2314 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.53 2000/05/30 04:24:27 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.54 2000/11/16 22:30:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,7 +36,7 @@ static void printtup_cleanup(DestReceiver *self);
* getTypeOutAndElem -- get both typoutput and typelem for a type
*
* We used to fetch these with two separate function calls,
* typtoout() and gettypelem(), which each called SearchSysCacheTuple.
* typtoout() and gettypelem(), which each called SearchSysCache.
* This way takes half the time.
* ----------------
*/
@@ -44,25 +44,19 @@ int
getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem)
{
HeapTuple typeTuple;
Form_pg_type pt;
typeTuple = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(type),
0, 0, 0);
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "getTypeOutAndElem: Cache lookup of type %u failed", type);
pt = (Form_pg_type) GETSTRUCT(typeTuple);
if (HeapTupleIsValid(typeTuple))
{
Form_pg_type pt = (Form_pg_type) GETSTRUCT(typeTuple);
*typOutput = (Oid) pt->typoutput;
*typElem = (Oid) pt->typelem;
return OidIsValid(*typOutput);
}
elog(ERROR, "getTypeOutAndElem: Cache lookup of type %u failed", type);
*typOutput = InvalidOid;
*typElem = InvalidOid;
return 0;
*typOutput = pt->typoutput;
*typElem = pt->typelem;
ReleaseSysCache(typeTuple);
return OidIsValid(*typOutput);
}
/* ----------------

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.68 2000/11/08 22:09:53 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.69 2000/11/16 22:30:15 tgl Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -401,9 +401,9 @@ TupleDescInitEntry(TupleDesc desc,
* -cim 6/14/90
* ----------------
*/
tuple = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(oidtypeid),
0, 0, 0);
tuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(oidtypeid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
{
/* ----------------
@@ -455,25 +455,18 @@ TupleDescInitEntry(TupleDesc desc,
*/
if (attisset)
{
Type t = typeidType(OIDOID);
att->attlen = typeLen(t);
att->attbyval = typeByVal(t);
att->attlen = sizeof(Oid);
att->attbyval = true;
att->attstorage = 'p';
}
else
{
att->attlen = typeForm->typlen;
att->attbyval = typeForm->typbyval;
/*
* Default to the types storage
*/
#ifdef TUPLE_TOASTER_ACTIVE
att->attstorage = typeForm->typstorage;
#else
att->attstorage = 'p';
#endif
}
ReleaseSysCache(tuple);
return true;
}
@@ -496,12 +489,11 @@ TupleDescMakeSelfReference(TupleDesc desc,
char *relname)
{
Form_pg_attribute att;
Type t = typeidType(OIDOID);
att = desc->attrs[attnum - 1];
att->atttypid = TypeShellMake(relname);
att->attlen = typeLen(t);
att->attbyval = typeByVal(t);
att->attlen = sizeof(Oid);
att->attbyval = true;
att->attstorage = 'p';
att->attnelems = 0;
}
@@ -580,7 +572,7 @@ BuildDescForRelation(List *schema, char *relname)
}
if (!TupleDescInitEntry(desc, attnum, attname,
typeTypeId(typenameType(typename)),
typenameTypeId(typename),
atttypmod, attdim, attisset))
{
/* ----------------