]> granicus.if.org Git - postgresql/blob - src/backend/utils/misc/superuser.c
Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.
[postgresql] / src / backend / utils / misc / superuser.c
1 /*-------------------------------------------------------------------------
2  *
3  * superuser.c
4  *
5  *        The superuser() function.  Determines if user has superuser privilege.
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  *        $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.17 2001/01/24 19:43:16 momjian Exp $
13  *
14  * DESCRIPTION
15  *        See superuser().
16  *-------------------------------------------------------------------------
17  */
18
19 #include "postgres.h"
20 #include "catalog/pg_shadow.h"
21 #include "utils/syscache.h"
22 #include "miscadmin.h"
23
24 bool
25 superuser(void)
26 {
27 /*--------------------------------------------------------------------------
28         The Postgres user running this command has Postgres superuser
29         privileges.
30 --------------------------------------------------------------------------*/
31         HeapTuple       utup;
32         bool            result;
33
34         utup = SearchSysCache(SHADOWSYSID,
35                                                   ObjectIdGetDatum(GetUserId()),
36                                                   0, 0, 0);
37         if (HeapTupleIsValid(utup))
38         {
39                 result = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
40                 ReleaseSysCache(utup);
41                 return result;
42         }
43         return false;
44 }