postgres/src/backend/utils/misc/superuser.c

38 lines
1.0 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* superuser.c
*
* The superuser() function. Determines if user has superuser privilege.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.13 2000/01/14 22:11:36 petere Exp $
*
* DESCRIPTION
* See superuser().
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/pg_shadow.h"
1999-07-16 05:23:30 +00:00
#include "utils/syscache.h"
#include "miscadmin.h"
bool
superuser(void)
{
/*--------------------------------------------------------------------------
The Postgres user running this command has Postgres superuser
privileges.
--------------------------------------------------------------------------*/
HeapTuple utup;
utup = SearchSysCacheTuple(SHADOWNAME,
PointerGetDatum(GetPgUserName()),
0, 0, 0);
Assert(utup != NULL);
return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
}