1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-20 15:22:23 +03:00

Convenience routine for checking superuser status.

This commit is contained in:
Bryan Henderson
1996-11-02 02:06:47 +00:00
parent 675740a8f3
commit 763adb5235
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/*-------------------------------------------------------------------------
*
* 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.1 1996/11/02 02:06:47 bryanh Exp $
*
* DESCRIPTION
* See superuser().
*-------------------------------------------------------------------------
*/
#include <c.h>
#include <postgres.h>
#include <access/htup.h>
#include <utils/syscache.h>
#include <catalog/pg_user.h>
bool
superuser(void) {
/*--------------------------------------------------------------------------
The Postgres user running this command has Postgres superuser
privileges.
--------------------------------------------------------------------------*/
extern char *UserName; /* defined in global.c */
HeapTuple utup;
utup = SearchSysCacheTuple(USENAME, PointerGetDatum(UserName),
0,0,0);
Assert(utup != NULL);
return ((Form_pg_user)GETSTRUCT(utup))->usesuper;
}