mirror of
https://github.com/postgres/postgres.git
synced 2025-12-22 17:42:17 +03:00
Back out pg_shadow changes to allow create table and locking permissions.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.78 2000/06/09 15:50:43 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.79 2000/06/12 03:40:29 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The PortalExecutorHeapMemory crap needs to be eliminated
|
||||
@@ -30,7 +30,6 @@
|
||||
#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"
|
||||
@@ -1212,21 +1211,6 @@ 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))
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
*
|
||||
* IDENTIFICATION
|
||||
<<<<<<< creatinh.c
|
||||
* $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.61 2000/06/12 03:40:29 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.61 2000/06/12 03:40:29 momjian Exp $
|
||||
>>>>>>> 1.58
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -26,10 +26,8 @@
|
||||
#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
|
||||
@@ -65,22 +63,6 @@ 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);
|
||||
|
||||
@@ -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.59 2000/06/09 15:50:43 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.60 2000/06/12 03:40:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -250,10 +250,6 @@ 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
|
||||
*/
|
||||
@@ -267,8 +263,6 @@ 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)
|
||||
@@ -358,8 +352,7 @@ AlterUser(AlterUserStmt *stmt)
|
||||
|
||||
/* must be superuser or just want to change your own password */
|
||||
if (!superuser() &&
|
||||
!(stmt->createdb==0 && stmt->createuser==0 && stmt->createtable==0
|
||||
&& stmt->locktable==0 && !stmt->validUntil
|
||||
!(stmt->createdb == 0 && stmt->createuser == 0 && !stmt->validUntil
|
||||
&& stmt->password && strcmp(GetPgUserName(), stmt->user) == 0))
|
||||
elog(ERROR, "ALTER USER: permission denied");
|
||||
|
||||
@@ -387,32 +380,8 @@ AlterUser(AlterUserStmt *stmt)
|
||||
/*
|
||||
* Build a tuple to update, perusing the information just obtained
|
||||
*/
|
||||
|
||||
/* 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] = ' ';
|
||||
}
|
||||
new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user));
|
||||
new_record_nulls[Anum_pg_shadow_usename - 1] = ' ';
|
||||
|
||||
/* sysid - leave as is */
|
||||
new_record[Anum_pg_shadow_usesysid - 1] = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null);
|
||||
|
||||
Reference in New Issue
Block a user