From 9d396af46357df1243aff4a9ca4f4987e4fe6024 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 30 Apr 2015 16:57:05 -0300 Subject: [PATCH] Fix up some loose ends for CURRENT_USER as RoleSpec In commit 31eae6028eca4, some documents were not updated to show the new capability; fix that. Also, the error message you get when CURRENT_USER and SESSION_USER are used in a context that doesn't accept them could be clearer about it being a problem only in those contexts; so add the word "here". Author: Kyotaro HORIGUCHI His patch submission also included changes to GRANT/REVOKE, but those seemed more controversial, so I left them out. We can reconsider these changes later. --- doc/src/sgml/ref/alter_policy.sgml | 2 +- doc/src/sgml/ref/create_policy.sgml | 2 +- doc/src/sgml/ref/create_tablespace.sgml | 2 +- doc/src/sgml/ref/drop_owned.sgml | 2 +- doc/src/sgml/ref/reassign_owned.sgml | 3 ++- src/backend/parser/gram.y | 4 ++-- src/test/regress/expected/rolenames.out | 4 ++-- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ref/alter_policy.sgml b/doc/src/sgml/ref/alter_policy.sgml index 6d03db5547..2e63206014 100644 --- a/doc/src/sgml/ref/alter_policy.sgml +++ b/doc/src/sgml/ref/alter_policy.sgml @@ -23,7 +23,7 @@ PostgreSQL documentation ALTER POLICY name ON table_name [ RENAME TO new_name ] - [ TO { role_name | PUBLIC } [, ...] ] + [ TO { role_name | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ] [ USING ( using_expression ) ] [ WITH CHECK ( check_expression ) ] diff --git a/doc/src/sgml/ref/create_policy.sgml b/doc/src/sgml/ref/create_policy.sgml index 49eaadc259..457911e0c3 100644 --- a/doc/src/sgml/ref/create_policy.sgml +++ b/doc/src/sgml/ref/create_policy.sgml @@ -23,7 +23,7 @@ PostgreSQL documentation CREATE POLICY name ON table_name [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ] - [ TO { role_name | PUBLIC } [, ...] ] + [ TO { role_name | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ] [ USING ( using_expression ) ] [ WITH CHECK ( check_expression ) ] diff --git a/doc/src/sgml/ref/create_tablespace.sgml b/doc/src/sgml/ref/create_tablespace.sgml index 9072d077cd..5756c3e080 100644 --- a/doc/src/sgml/ref/create_tablespace.sgml +++ b/doc/src/sgml/ref/create_tablespace.sgml @@ -22,7 +22,7 @@ PostgreSQL documentation CREATE TABLESPACE tablespace_name - [ OWNER user_name ] + [ OWNER { new_owner | CURRENT_USER | SESSION_USER } ] LOCATION 'directory' [ WITH ( tablespace_option = value [, ... ] ) ] diff --git a/doc/src/sgml/ref/drop_owned.sgml b/doc/src/sgml/ref/drop_owned.sgml index 1cd8e60e40..64906efd3d 100644 --- a/doc/src/sgml/ref/drop_owned.sgml +++ b/doc/src/sgml/ref/drop_owned.sgml @@ -21,7 +21,7 @@ PostgreSQL documentation -DROP OWNED BY name [, ...] [ CASCADE | RESTRICT ] +DROP OWNED BY { name | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ] diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml index d7d6abb9d8..382cba337b 100644 --- a/doc/src/sgml/ref/reassign_owned.sgml +++ b/doc/src/sgml/ref/reassign_owned.sgml @@ -21,7 +21,8 @@ PostgreSQL documentation -REASSIGN OWNED BY old_role [, ...] TO new_role +REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...] + TO { new_role | CURRENT_USER | SESSION_USER } diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 962a69d22a..0180530a30 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -13216,13 +13216,13 @@ RoleId: RoleSpec case ROLESPEC_SESSION_USER: ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), - errmsg("%s cannot be used as a role name", + errmsg("%s cannot be used as a role name here", "SESSION_USER"), parser_errposition(@1))); case ROLESPEC_CURRENT_USER: ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), - errmsg("%s cannot be used as a role name", + errmsg("%s cannot be used as a role name here", "CURRENT_USER"), parser_errposition(@1))); } diff --git a/src/test/regress/expected/rolenames.out b/src/test/regress/expected/rolenames.out index 1879337ea0..8f88c025e8 100644 --- a/src/test/regress/expected/rolenames.out +++ b/src/test/regress/expected/rolenames.out @@ -43,7 +43,7 @@ CREATE ROLE "current_user"; CREATE ROLE "session_user"; CREATE ROLE "user"; CREATE ROLE current_user; -- error -ERROR: CURRENT_USER cannot be used as a role name +ERROR: CURRENT_USER cannot be used as a role name here LINE 1: CREATE ROLE current_user; ^ CREATE ROLE current_role; -- error @@ -51,7 +51,7 @@ ERROR: syntax error at or near "current_role" LINE 1: CREATE ROLE current_role; ^ CREATE ROLE session_user; -- error -ERROR: SESSION_USER cannot be used as a role name +ERROR: SESSION_USER cannot be used as a role name here LINE 1: CREATE ROLE session_user; ^ CREATE ROLE user; -- error -- 2.40.0