summaryrefslogtreecommitdiff
path: root/contrib/dbsize/dbsize.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-09 16:45:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-09 16:45:16 +0000
commit4ab8e69094452286a5894f1b2b237304808f4391 (patch)
tree53d99383e8b52541832c510308f8d0ddb3bbc20f /contrib/dbsize/dbsize.c
parent65dc2e0d8c1200a63e5d293f0cfa95a836eb984c (diff)
downloadpostgresql-4ab8e69094452286a5894f1b2b237304808f4391.tar.gz
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 'contrib/dbsize/dbsize.c')
-rw-r--r--contrib/dbsize/dbsize.c24
1 files changed, 3 insertions, 21 deletions
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);