1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +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

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.52 2000/11/03 19:01:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.53 2000/11/16 22:30:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -174,12 +174,13 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
switch (aip->ai_idtype)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(name),
0, 0, 0);
htup = SearchSysCache(SHADOWNAME,
PointerGetDatum(name),
0, 0, 0);
if (!HeapTupleIsValid(htup))
elog(ERROR, "aclparse: non-existent user \"%s\"", name);
aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htup))->usesysid;
ReleaseSysCache(htup);
break;
case ACL_IDTYPE_GID:
aip->ai_id = get_grosysid(name);
@ -272,9 +273,9 @@ aclitemout(PG_FUNCTION_ARGS)
switch (aip->ai_idtype)
{
case ACL_IDTYPE_UID:
htup = SearchSysCacheTuple(SHADOWSYSID,
ObjectIdGetDatum(aip->ai_id),
0, 0, 0);
htup = SearchSysCache(SHADOWSYSID,
ObjectIdGetDatum(aip->ai_id),
0, 0, 0);
if (!HeapTupleIsValid(htup))
{
/* Generate numeric UID if we don't find an entry */
@ -286,9 +287,12 @@ aclitemout(PG_FUNCTION_ARGS)
pfree(tmp);
}
else
{
strncat(p, (char *) &((Form_pg_shadow)
GETSTRUCT(htup))->usename,
sizeof(NameData));
ReleaseSysCache(htup);
}
break;
case ACL_IDTYPE_GID:
strcat(p, "group ");