diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/command.c | 18 | ||||
-rw-r--r-- | src/backend/commands/creatinh.c | 22 | ||||
-rw-r--r-- | src/backend/commands/user.c | 39 |
3 files changed, 72 insertions, 7 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 38cee644b22..48d2b4cbc34 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.77 2000/06/04 22:04:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.78 2000/06/09 15:50:43 momjian Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -30,6 +30,7 @@ #include "commands/command.h" #include "executor/spi.h" #include "catalog/heap.h" +#include "catalog/pg_shadow.h" #include "miscadmin.h" #include "optimizer/prep.h" #include "utils/acl.h" @@ -1211,6 +1212,21 @@ LockTableCommand(LockStmt *lockstmt) { Relation rel; int aclresult; + HeapTuple tup; + + + /* ---------- + * Check pg_shadow for global lock setting + * ---------- + */ + tup = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(GetPgUserName()), 0, 0, 0); + + if (!HeapTupleIsValid(tup)) + elog(ERROR, "LOCK TABLE: look at pg_shadow failed"); + + if (!((Form_pg_shadow) GETSTRUCT(tup))->uselocktable) + elog(ERROR, "LOCK TABLE: permission denied"); + rel = heap_openr(lockstmt->relname, NoLock); if (!RelationIsValid(rel)) diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index f33d301ded2..4d52b9aad76 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -9,9 +9,9 @@ * * IDENTIFICATION <<<<<<< creatinh.c - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.60 2000/06/09 15:50:43 momjian Exp $ ======= - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.60 2000/06/09 15:50:43 momjian Exp $ >>>>>>> 1.58 * *------------------------------------------------------------------------- @@ -26,8 +26,10 @@ #include "catalog/pg_inherits.h" #include "catalog/pg_ipl.h" #include "catalog/pg_type.h" +#include "catalog/pg_shadow.h" #include "commands/creatinh.h" #include "utils/syscache.h" +#include "miscadmin.h" /* ---------------- * local stuff @@ -63,6 +65,22 @@ DefineRelation(CreateStmt *stmt, char relkind) int i; AttrNumber attnum; + if (!stmt->istemp) { + HeapTuple tup; + + /* ---------- + * Check pg_shadow for global createTable setting + * ---------- + */ + tup = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(GetPgUserName()), 0, 0, 0); + + if (!HeapTupleIsValid(tup)) + elog(ERROR, "CREATE TABLE: look at pg_shadow failed"); + + if (!((Form_pg_shadow) GETSTRUCT(tup))->usecreatetable) + elog(ERROR, "CREATE TABLE: permission denied"); + } + if (strlen(stmt->relname) >= NAMEDATALEN) elog(ERROR, "the relation name %s is >= %d characters long", stmt->relname, NAMEDATALEN); diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 55dcd55adf1..512c5b4c2a3 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.58 2000/06/09 01:11:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.59 2000/06/09 15:50:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -250,6 +250,10 @@ CreateUser(CreateUserStmt *stmt) return; } + AssertState(BoolIsValid(stmt->createtable)); + new_record[Anum_pg_shadow_usecreatetable-1] = (Datum)(stmt->createtable); + AssertState(BoolIsValid(stmt->locktable)); + new_record[Anum_pg_shadow_uselocktable-1] = (Datum)(stmt->locktable); /* * Build a tuple to insert */ @@ -263,6 +267,8 @@ CreateUser(CreateUserStmt *stmt) AssertState(BoolIsValid(stmt->createuser)); new_record[Anum_pg_shadow_usesuper - 1] = (Datum) (stmt->createuser); /* superuser gets catupd right by default */ + new_record_nulls[Anum_pg_shadow_usecreatetable-1] = ' '; + new_record_nulls[Anum_pg_shadow_uselocktable-1] = ' '; new_record[Anum_pg_shadow_usecatupd - 1] = (Datum) (stmt->createuser); if (stmt->password) @@ -352,7 +358,8 @@ AlterUser(AlterUserStmt *stmt) /* must be superuser or just want to change your own password */ if (!superuser() && - !(stmt->createdb == 0 && stmt->createuser == 0 && !stmt->validUntil + !(stmt->createdb==0 && stmt->createuser==0 && stmt->createtable==0 + && stmt->locktable==0 && !stmt->validUntil && stmt->password && strcmp(GetPgUserName(), stmt->user) == 0)) elog(ERROR, "ALTER USER: permission denied"); @@ -380,8 +387,32 @@ AlterUser(AlterUserStmt *stmt) /* * Build a tuple to update, perusing the information just obtained */ - new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user)); - new_record_nulls[Anum_pg_shadow_usename - 1] = ' '; + + /* createtable */ + if (stmt->createtable == 0) + { + /* don't change */ + new_record[Anum_pg_shadow_usecreatetable-1] = heap_getattr(tuple, Anum_pg_shadow_usecreatetable, pg_shadow_dsc, &null); + new_record_nulls[Anum_pg_shadow_usecreatetable-1] = null ? 'n' : ' '; + } + else + { + new_record[Anum_pg_shadow_usecreatetable-1] = (Datum)(stmt->createtable > 0 ? true : false); + new_record_nulls[Anum_pg_shadow_usecreatetable-1] = ' '; + } + + /* locktable */ + if (stmt->locktable == 0) + { + /* don't change */ + new_record[Anum_pg_shadow_uselocktable-1] = heap_getattr(tuple, Anum_pg_shadow_uselocktable, pg_shadow_dsc, &null); + new_record_nulls[Anum_pg_shadow_uselocktable-1] = null ? 'n' : ' '; + } + else + { + new_record[Anum_pg_shadow_uselocktable-1] = (Datum)(stmt->locktable > 0 ? true : false); + new_record_nulls[Anum_pg_shadow_uselocktable-1] = ' '; + } /* sysid - leave as is */ new_record[Anum_pg_shadow_usesysid - 1] = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null); |