8000 Add missing ALTER USER variants · satanson/postgres@f2878a6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f2878a6

Browse files
committed
Add missing ALTER USER variants
ALTER USER ... SET did not support all the syntax variants of ALTER ROLE ... SET. Reported-by: Pavel Golub <pavel@microolap.com>
1 parent 65048cf commit f2878a6

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

doc/src/sgml/ref/alter_user.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> [ WIT
3939

4040
ALTER USER <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>new_name</replaceable>
4141

42-
ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
43-
ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
44-
ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> RESET <replaceable>configuration_parameter</replaceable>
45-
ALTER USER <replaceable class="PARAMETER">role_specification</replaceable> RESET ALL
42+
ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceab 8000 le>value</replaceable> | DEFAULT }
43+
ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
44+
ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] RESET <replaceable>configuration_parameter</replaceable>
45+
ALTER USER { <replaceable class="PARAMETER">role_specification</replaceable> | ALL } [ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ] RESET ALL
4646

4747
<phrase>where <replaceable class="PARAMETER">role_specification</replaceable> can be:</phrase>
4848

src/backend/parser/gram.y

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,12 +1116,20 @@ AlterUserStmt:
11161116

11171117

11181118
AlterUserSetStmt:
1119-
ALTER USER RoleSpec SetResetClause
1119+
ALTER USER RoleSpec opt_in_database SetResetClause
11201120
{
11211121
AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
11221122
n->role = $3;
1123-
n->database = NULL;
1124-
n->setstmt = $4;
1123+
n->database = $4;
1124+
n->setstmt = $5;
1125+
$$ = (Node *)n;
1126+
}
1127+
| ALTER USER ALL opt_in_database SetResetClause
1128+
{
1129+
AlterRoleSetStmt *n = makeNode(AlterRoleSetStmt);
1130+
n->role = NULL;
1131+
n->database = $4;
1132+
n->setstmt = $5;
11251133
$$ = (Node *)n;
11261134
}
11271135
;

src/test/regress/expected/rolenames.out

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ ERROR: syntax error at or near "CURRENT_ROLE"
298298
LINE 1: ALTER USER CURRENT_ROLE WITH LOGIN;
299299
^
300300
ALTER USER ALL WITH REPLICATION; -- error
301-
ERROR: syntax error at or near "ALL"
301+
ERROR: syntax error at or near "WITH"
302302
LINE 1: ALTER USER ALL WITH REPLICATION;
303-
^
303+
^
304304
ALTER USER SESSION_ROLE WITH NOREPLICATION; -- error
305305
ERROR: role "session_role" does not exist
306306
ALTER USER PUBLIC WITH NOREPLICATION; -- error
@@ -380,9 +380,6 @@ ALTER USER SESSION_USER SET application_name to 'BAR';
380380
ALTER USER "current_user" SET application_name to 'FOOFOO';
381381
ALTER USER "Public" SET application_name to 'BARBAR';
382382
ALTER USER ALL SET application_name to 'SLAP';
383-
ERROR: syntax error at or near "ALL"
384-
LINE 1: ALTER USER ALL SET application_name to 'SLAP';
385-
^
386383
SELECT * FROM chksetconfig();
387384
db | role | rolkeyword | setconfig
388385
-----+--------------+--------------+---------------------------
@@ -407,9 +404,6 @@ ALTER USER SESSION_USER RESET application_name;
407404
ALTER USER "current_user" RESET application_name;
408405
ALTER USER "Public" RESET application_name;
409406
ALTER USER ALL RESET application_name;
410-
ERROR: syntax error at or near "ALL"
411-
LINE 1: ALTER USER ALL RESET application_name;
412-
^
413407
SELECT * FROM chksetconfig();
414408
db | role | rolkeyword | setconfig
415409
----+------+------------+-----------

0 commit comments

Comments
 (0)
0