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/misc/superuser.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/backend/utils/misc/superuser.c') diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index 1852b35e465..5139247291d 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.15 2000/09/06 14:15:22 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.16 2000/11/16 22:30:40 tgl Exp $ * * DESCRIPTION * See superuser(). @@ -29,10 +29,16 @@ superuser(void) privileges. --------------------------------------------------------------------------*/ HeapTuple utup; + bool result; - utup = SearchSysCacheTuple(SHADOWSYSID, - ObjectIdGetDatum(GetUserId()), - 0, 0, 0); - Assert(utup != NULL); - return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper; + utup = SearchSysCache(SHADOWSYSID, + ObjectIdGetDatum(GetUserId()), + 0, 0, 0); + if (HeapTupleIsValid(utup)) + { + result = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper; + ReleaseSysCache(utup); + return result; + } + return false; } -- cgit v1.2.3