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.
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* superuser.c
|
|
*
|
|
* The superuser() function. Determines if user has superuser privilege.
|
|
*
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
*
|
|
* IDENTIFICATION
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.16 2000/11/16 22:30:40 tgl Exp $
|
|
*
|
|
* DESCRIPTION
|
|
* See superuser().
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
#include "catalog/pg_shadow.h"
|
|
#include "utils/syscache.h"
|
|
#include "miscadmin.h"
|
|
|
|
bool
|
|
superuser(void)
|
|
{
|
|
/*--------------------------------------------------------------------------
|
|
The Postgres user running this command has Postgres superuser
|
|
privileges.
|
|
--------------------------------------------------------------------------*/
|
|
HeapTuple utup;
|
|
bool result;
|
|
|
|
utup = SearchSysCache(SHADOWSYSID,
|
|
ObjectIdGetDatum(GetUserId()),
|
|
0, 0, 0);
|
|
if (HeapTupleIsValid(utup))
|
|
{
|
|
result = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
|
|
ReleaseSysCache(utup);
|
|
return result;
|
|
}
|
|
return false;
|
|
}
|