mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Allow CURRENT/SESSION_USER to be used in certain commands
Commands such as ALTER USER, ALTER GROUP, ALTER ROLE, GRANT, and the various ALTER OBJECT / OWNER TO, as well as ad-hoc clauses related to roles such as the AUTHORIZATION clause of CREATE SCHEMA, the FOR clause of CREATE USER MAPPING, and the FOR ROLE clause of ALTER DEFAULT PRIVILEGES can now take the keywords CURRENT_USER and SESSION_USER as user specifiers in place of an explicit user name. This commit also fixes some quite ugly handling of special standards- mandated syntax in CREATE USER MAPPING, which in particular would fail to work in presence of a role named "current_user". The special role specifiers PUBLIC and NONE also have more consistent handling now. Also take the opportunity to add location tracking to user specifiers. Authors: Kyotaro Horiguchi. Heavily reworked by Álvaro Herrera. Reviewed by: Rushabh Lathia, Adam Brightwell, Marti Raudsepp.
This commit is contained in:
@ -3507,7 +3507,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
break;
|
||||
case AT_ChangeOwner: /* ALTER OWNER */
|
||||
ATExecChangeOwner(RelationGetRelid(rel),
|
||||
get_role_oid(cmd->name, false),
|
||||
get_rolespec_oid(cmd->newowner, false),
|
||||
false, lockmode);
|
||||
break;
|
||||
case AT_ClusterOn: /* CLUSTER ON */
|
||||
@ -9388,7 +9388,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
|
||||
HeapTuple tuple;
|
||||
Oid orig_tablespaceoid;
|
||||
Oid new_tablespaceoid;
|
||||
List *role_oids = roleNamesToIds(stmt->roles);
|
||||
List *role_oids = roleSpecsToIds(stmt->roles);
|
||||
|
||||
/* Ensure we were not asked to move something we can't */
|
||||
if (stmt->objtype != OBJECT_TABLE && stmt->objtype != OBJECT_INDEX &&
|
||||
|
Reference in New Issue
Block a user