Fix up some loose ends for CURRENT_USER as RoleSpec
authorAlvaro Herrera
Thu, 30 Apr 2015 19:57:05 +0000 (16:57 -0300)
committerAlvaro Herrera
Thu, 30 Apr 2015 19:57:05 +0000 (16:57 -0300)
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
doc/src/sgml/ref/create_policy.sgml
doc/src/sgml/ref/create_tablespace.sgml
doc/src/sgml/ref/drop_owned.sgml
doc/src/sgml/ref/reassign_owned.sgml
src/backend/parser/gram.y
src/test/regress/expected/rolenames.out

index 6d03db5547d52a61f8868299c316d051a2c2accf..2e63206014ce5dc894c72f52f34dae6d70f1d3b8 100644 (file)
@@ -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 ) ]
 
index 49eaadc259806996980bb92c6d56fcf22b076d45..457911e0c30708934b09942d173de6c792dbc640 100644 (file)
@@ -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 ) ]
 
index 9072d077cdb6344738cf961221dc6b9dd5f7b11b..5756c3e080f9be3802e6364b2af6341b98995a51 100644 (file)
@@ -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 [, ... ] ) ]
 
index 1cd8e60e400aa083d83cf4298d8c747125b9f135..64906efd3dcfc3c253a42ba47805b79a7df52742 100644 (file)
@@ -21,7 +21,7 @@ PostgreSQL documentation
 
  
 
-DROP OWNED BY name [, ...] [ CASCADE | RESTRICT ]
+DROP OWNED BY name | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
 
  
 
index d7d6abb9d8c81dbe6748be04f5b0585958e52d9c..382cba337bd491d7aa1f92fa7acb59d5b85f2bb9 100644 (file)
@@ -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 }
 
  
 
index 962a69d22a6ca98699bf5dd11168cd6f3a112bdf..0180530a30929784ee4c28c9aa49baf196f9015e 100644 (file)
@@ -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)));
                    }
index 1879337ea0de36bddabb458d5810de153cffa711..8f88c025e8fb10f6203ca86ee4584acbe11a0f09 100644 (file)
@@ -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