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/utils/adt/acl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/backend/utils/adt/acl.c') diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 1a2b2ef953e..a8bc5e349a3 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -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 "); -- cgit v1.2.3