]> granicus.if.org Git - postgresql/commitdiff
Add missing ALTER USER variants
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 4 Aug 2017 00:49:07 +0000 (20:49 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 4 Aug 2017 00:49:07 +0000 (20:49 -0400)
ALTER USER ... SET did not support all the syntax variants of ALTER ROLE
...  SET.

Reported-by: Pavel Golub <pavel@microolap.com>
doc/src/sgml/ref/alter_user.sgml
src/backend/parser/gram.y
src/test/regress/expected/rolenames.out

index 5962a8e166c6f0fa8fce791a10c47d6d342f23ca..50bfae6cc3b6ba339986b861b0ebc34d3f93f7e2 100644 (file)
@@ -38,10 +38,10 @@ ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> [ WIT
 
 ALTER USER <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>new_name</replaceable>
 
-ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
-ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
-ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> RESET <replaceable>configuration_parameter</replaceable>
-ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> RESET ALL
+ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
+ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
+ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] RESET <replaceable>configuration_parameter</replaceable>
+ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] RESET ALL
 
 <phrase>where <replaceable class="PARAMETER">role_specification</replaceable> can be:</phrase>
 
index c080cf9ea0815e4b0aaf17cb2ef6e5dd7d5c1189..9e170f7536148e9ad2bcad6528c749455fefe8e4 100644 (file)
@@ -1111,12 +1111,20 @@ AlterUserStmt:
 
 
 AlterUserSetStmt:
-                       ALTER USER RoleSpec SetResetClause
+                       ALTER USER RoleSpec opt_in_database SetResetClause
                                {
                                        AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
                                        n->role = $3;
-                                       n->database = NULL;
-                                       n->setstmt = $4;
+                                       n->database = $4;
+                                       n->setstmt = $5;
+                                       $$ = (Node *)n;
+                               }
+                       | ALTER USER ALL opt_in_database SetResetClause
+                               {
+                                       AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
+                                       n->role = NULL;
+                                       n->database = $4;
+                                       n->setstmt = $5;
                                        $$ = (Node *)n;
                                }
                        ;
index fd058e4f7d2d94eb7f7dd264789d3e3f0797c006..dce82f5de7ef9ec7f9b5e4cb2a41ed42476b12c8 100644 (file)
@@ -310,9 +310,9 @@ ERROR:  syntax error at or near "CURRENT_ROLE"
 LINE 1: ALTER USER CURRENT_ROLE WITH LOGIN;
                    ^
 ALTER USER ALL WITH REPLICATION; -- error
-ERROR:  syntax error at or near "ALL"
+ERROR:  syntax error at or near "WITH"
 LINE 1: ALTER USER ALL WITH REPLICATION;
-                   ^
+                       ^
 ALTER USER SESSION_ROLE WITH NOREPLICATION; -- error
 ERROR:  role "session_role" does not exist
 ALTER USER PUBLIC WITH NOREPLICATION; -- error
@@ -392,9 +392,6 @@ ALTER USER SESSION_USER SET application_name to 'BAR';
 ALTER USER "current_user" SET application_name to 'FOOFOO';
 ALTER USER "Public" SET application_name to 'BARBAR';
 ALTER USER ALL SET application_name to 'SLAP';
-ERROR:  syntax error at or near "ALL"
-LINE 1: ALTER USER ALL SET application_name to 'SLAP';
-                   ^
 SELECT * FROM chksetconfig();
  db  |       role       |  rolkeyword  |         setconfig         
 -----+------------------+--------------+---------------------------
@@ -419,9 +416,6 @@ ALTER USER SESSION_USER RESET application_name;
 ALTER USER "current_user" RESET application_name;
 ALTER USER "Public" RESET application_name;
 ALTER USER ALL RESET application_name;
-ERROR:  syntax error at or near "ALL"
-LINE 1: ALTER USER ALL RESET application_name;
-                   ^
 SELECT * FROM chksetconfig();
  db | role | rolkeyword | setconfig 
 ----+------+------------+-----------