diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-13 21:44:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-13 21:44:41 +0000 |
commit | 1a6bb6d877f60c377635c4e83a1b75ca2f437951 (patch) | |
tree | 842ea6e49fcfda307f33a325356a24c27c5cda33 /src/backend/commands/indexcmds.c | |
parent | f21e3407e6f8b706dc2a490365e13a8e613523de (diff) | |
download | postgresql-1a6bb6d877f60c377635c4e83a1b75ca2f437951.tar.gz postgresql-1a6bb6d877f60c377635c4e83a1b75ca2f437951.zip |
Allow a non-superuser database owner to vacuum all tables in his
database, including system catalogs (but not the shared catalogs,
since they don't really belong to his database). This is per recent
mailing list discussion. Clean up some other code that also checks
for database ownerness by introducing a test function is_dbadmin().
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 373a68fbf30..108c4ea3780 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.49 2001/05/31 18:16:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.50 2001/06/13 21:44:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,6 @@ #include "catalog/pg_opclass.h" #include "catalog/pg_operator.h" #include "catalog/pg_proc.h" -#include "catalog/pg_shadow.h" #include "commands/defrem.h" #include "miscadmin.h" #include "optimizer/clauses.h" @@ -712,14 +711,9 @@ ReindexTable(const char *name, bool force) void ReindexDatabase(const char *dbname, bool force, bool all) { - Relation relation, - relationRelation; - HeapTuple dbtuple, - tuple; + Relation relationRelation; HeapScanDesc scan; - int4 db_owner; - Oid db_id; - ScanKeyData scankey; + HeapTuple tuple; MemoryContext private_context; MemoryContext old; int relcnt, @@ -730,24 +724,12 @@ ReindexDatabase(const char *dbname, bool force, bool all) AssertArg(dbname); - relation = heap_openr(DatabaseRelationName, AccessShareLock); - ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname, - F_NAMEEQ, NameGetDatum(dbname)); - scan = heap_beginscan(relation, 0, SnapshotNow, 1, &scankey); - dbtuple = heap_getnext(scan, 0); - if (!HeapTupleIsValid(dbtuple)) - elog(ERROR, "Database \"%s\" does not exist", dbname); - db_id = dbtuple->t_data->t_oid; - db_owner = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba; - heap_endscan(scan); - heap_close(relation, NoLock); + if (strcmp(dbname, DatabaseName) != 0) + elog(ERROR, "REINDEX DATABASE: Can be executed only on the currently open database."); - if (GetUserId() != db_owner && !superuser()) + if (! (superuser() || is_dbadmin(MyDatabaseId))) elog(ERROR, "REINDEX DATABASE: Permission denied."); - if (db_id != MyDatabaseId) - elog(ERROR, "REINDEX DATABASE: Can be executed only on the currently open database."); - /* * We cannot run inside a user transaction block; if we were inside a * transaction, then our commit- and start-transaction-command calls |