From 4ab8e69094452286a5894f1b2b237304808f4391 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 9 Aug 2002 16:45:16 +0000 Subject: 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. --- contrib/dbsize/dbsize.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'contrib/dbsize/dbsize.c') diff --git a/contrib/dbsize/dbsize.c b/contrib/dbsize/dbsize.c index 44699aa693..0e5e63d1ee 100644 --- a/contrib/dbsize/dbsize.c +++ b/contrib/dbsize/dbsize.c @@ -8,12 +8,10 @@ #include "access/heapam.h" #include "catalog/catalog.h" -#include "catalog/catname.h" #include "catalog/namespace.h" -#include "catalog/pg_database.h" +#include "commands/dbcommands.h" #include "fmgr.h" #include "utils/builtins.h" -#include "utils/fmgroids.h" static char * @@ -46,32 +44,16 @@ database_size(PG_FUNCTION_ARGS) { Name dbname = PG_GETARG_NAME(0); - HeapTuple tuple; - Relation relation; - ScanKeyData scanKey; - HeapScanDesc scan; Oid dbid; char *dbpath; DIR *dirdesc; struct dirent *direntry; int64 totalsize; - relation = heap_openr(DatabaseRelationName, AccessShareLock); - ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname, - F_NAMEEQ, NameGetDatum(dbname)); - scan = heap_beginscan(relation, SnapshotNow, 1, &scanKey); - tuple = heap_getnext(scan, ForwardScanDirection); - - if (!HeapTupleIsValid(tuple)) + dbid = get_database_oid(NameStr(*dbname)); + if (!OidIsValid(dbid)) elog(ERROR, "database %s does not exist", NameStr(*dbname)); - dbid = HeapTupleGetOid(tuple); - if (dbid == InvalidOid) - elog(ERROR, "invalid database id"); - - heap_endscan(scan); - heap_close(relation, NoLock); - dbpath = GetDatabasePath(dbid); dirdesc = opendir(dbpath); -- cgit v1.2.1