1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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.
This commit is contained in:
Tom Lane
2002-08-09 16:45:16 +00:00
parent 65dc2e0d8c
commit 4ab8e69094
12 changed files with 1325 additions and 282 deletions

View File

@ -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);