Skip to content

Commit 9d396af

Browse files
committed
Fix up some loose ends for CURRENT_USER as RoleSpec
In commit 31eae60, 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.
1 parent 924bcf4 commit 9d396af

File tree

7 files changed

+10
-9
lines changed

7 files changed

+10
-9
lines changed

doc/src/sgml/ref/alter_policy.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PostgreSQL documentation
2323
<synopsis>
2424
ALTER POLICY <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable>
2525
[ RENAME TO <replaceable class="PARAMETER">new_name</replaceable> ]
26-
[ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC } [, ...] ]
26+
[ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ]
2727
[ USING ( <replaceable class="parameter">using_expression</replaceable> ) ]
2828
[ WITH CHECK ( <replaceable class="parameter">check_expression</replaceable> ) ]
2929
</synopsis>

doc/src/sgml/ref/create_policy.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PostgreSQL documentation
2323
<synopsis>
2424
CREATE POLICY <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table_name</replaceable>
2525
[ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
26-
[ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC } [, ...] ]
26+
[ TO { <replaceable class="parameter">role_name</replaceable> | PUBLIC | CURRENT_USER | SESSION_USER } [, ...] ]
2727
[ USING ( <replaceable class="parameter">using_expression</replaceable> ) ]
2828
[ WITH CHECK ( <replaceable class="parameter">check_expression</replaceable> ) ]
2929
</synopsis>

doc/src/sgml/ref/create_tablespace.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PostgreSQL documentation
2222
<refsynopsisdiv>
2323
<synopsis>
2424
CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
25-
[ OWNER <replaceable class="parameter">user_name</replaceable> ]
25+
[ OWNER { <replaceable>new_owner</replaceable> | CURRENT_USER | SESSION_USER } ]
2626
LOCATION '<replaceable class="parameter">directory</replaceable>'
2727
[ WITH ( <replaceable class="PARAMETER">tablespace_option</replaceable> = <replaceable class="PARAMETER">value</replaceable> [, ... ] ) ]
2828
</synopsis>

doc/src/sgml/ref/drop_owned.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
DROP OWNED BY <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
24+
DROP OWNED BY { <replaceable class="PARAMETER">name</replaceable> | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
2525
</synopsis>
2626
</refsynopsisdiv>
2727

doc/src/sgml/ref/reassign_owned.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
REASSIGN OWNED BY <replaceable class="PARAMETER">old_role</replaceable> [, ...] TO <replaceable class="PARAMETER">new_role</replaceable>
24+
REASSIGN OWNED BY { <replaceable class="PARAMETER">old_role</replaceable> | CURRENT_USER | SESSION_USER } [, ...]
25+
TO { <replaceable class="PARAMETER">new_role</replaceable> | CURRENT_USER | SESSION_USER }
2526
</synopsis>
2627
</refsynopsisdiv>
2728

src/backend/parser/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13216,13 +13216,13 @@ RoleId: RoleSpec
1321613216
case ROLESPEC_SESSION_USER:
1321713217
ereport(ERROR,
1321813218
(errcode(ERRCODE_RESERVED_NAME),
13219-
errmsg("%s cannot be used as a role name",
13219+
errmsg("%s cannot be used as a role name here",
1322013220
"SESSION_USER"),
1322113221
parser_errposition(@1)));
1322213222
case ROLESPEC_CURRENT_USER:
1322313223
ereport(ERROR,
1322413224
(errcode(ERRCODE_RESERVED_NAME),
13225-
errmsg("%s cannot be used as a role name",
13225+
errmsg("%s cannot be used as a role name here",
1322613226
"CURRENT_USER"),
1322713227
parser_errposition(@1)));
1322813228
}

src/test/regress/expected/rolenames.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ CREATE ROLE "current_user";
4343
CREATE ROLE "session_user";
4444
CREATE ROLE "user";
4545
CREATE ROLE current_user; -- error
46-
ERROR: CURRENT_USER cannot be used as a role name
46+
ERROR: CURRENT_USER cannot be used as a role name here
4747
LINE 1: CREATE ROLE current_user;
4848
^
4949
CREATE ROLE current_role; -- error
5050
ERROR: syntax error at or near "current_role"
5151
LINE 1: CREATE ROLE current_role;
5252
^
5353
CREATE ROLE session_user; -- error
54-
ERROR: SESSION_USER cannot be used as a role name
54+
ERROR: SESSION_USER cannot be used as a role name here
5555
LINE 1: CREATE ROLE session_user;
5656
^
5757
CREATE ROLE user; -- error

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy