summaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/superuser.c
diff options
context:
space:
mode:
authorTom Lane2002-08-09 16:45:16 +0000
committerTom Lane2002-08-09 16:45:16 +0000
commit4ab8e69094452286a5894f1b2b237304808f4391 (patch)
tree53d99383e8b52541832c510308f8d0ddb3bbc20f /src/backend/utils/misc/superuser.c
parent65dc2e0d8c1200a63e5d293f0cfa95a836eb984c (diff)
has_table_privilege spawns scions has_database_privilege, has_function_privilege,
has_language_privilege, has_schema_privilege to let SQL queries test all the new privilege types in 7.3. Also, add functions pg_table_is_visible, pg_type_is_visible, pg_function_is_visible, pg_operator_is_visible, pg_opclass_is_visible to test whether objects contained in schemas are visible in the current search path. Do some minor cleanup to centralize accesses to pg_database, as well.
Diffstat (limited to 'src/backend/utils/misc/superuser.c')
-rw-r--r--src/backend/utils/misc/superuser.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c
index 9652b5c01aa..735ad7adf32 100644
--- a/src/backend/utils/misc/superuser.c
+++ b/src/backend/utils/misc/superuser.c
@@ -10,19 +10,17 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.23 2002/06/20 20:29:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.24 2002/08/09 16:45:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/heapam.h"
-#include "catalog/catname.h"
-#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
+#include "commands/dbcommands.h"
#include "utils/syscache.h"
#include "miscadmin.h"
-#include "utils/fmgroids.h"
/*
@@ -69,25 +67,9 @@ superuser_arg(Oid userid)
bool
is_dbadmin(Oid dbid)
{
- Relation pg_database;
- ScanKeyData entry[1];
- HeapScanDesc scan;
- HeapTuple dbtuple;
- int32 dba;
+ Oid dba;
- /* There's no syscache for pg_database, so must look the hard way */
- pg_database = heap_openr(DatabaseRelationName, AccessShareLock);
- ScanKeyEntryInitialize(&entry[0], 0x0,
- ObjectIdAttributeNumber, F_OIDEQ,
- ObjectIdGetDatum(dbid));
- scan = heap_beginscan(pg_database, SnapshotNow, 1, entry);
- dbtuple = heap_getnext(scan, ForwardScanDirection);
- if (!HeapTupleIsValid(dbtuple))
- elog(ERROR, "database %u does not exist", dbid);
- dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
- heap_endscan(scan);
- heap_close(pg_database, AccessShareLock);
+ dba = get_database_owner(dbid);
- /* XXX some confusion about whether userids are OID or int4 ... */
- return (GetUserId() == (Oid) dba);
+ return (GetUserId() == dba);
}