Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c36f38

Browse filesBrowse files
committed
Allow type_func_name_keywords in even more places
A while back, 2c92eda allowed type_func_name_keywords to be used in more places, including role identifiers. Unfortunately, that commit missed out on cases where name_list was used for lists-of-roles, eg: for DROP ROLE. This resulted in the unfortunate situation that you could CREATE a role with a type_func_name_keywords-allowed identifier, but not DROP it (directly- ALTER could be used to rename it to something which could be DROP'd). This extends allowing type_func_name_keywords to places where role lists can be used. Back-patch to 9.0, as 2c92eda was.
1 parent 69c7a98 commit 6c36f38
Copy full SHA for 6c36f38

File tree

Expand file treeCollapse file tree

1 file changed

+26
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-20
lines changed

‎src/backend/parser/gram.y

Copy file name to clipboardExpand all lines: src/backend/parser/gram.y
+26-20Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
334334
oper_argtypes RuleActionList RuleActionMulti
335335
opt_column_list columnList opt_name_list
336336
sort_clause opt_sort_clause sortby_list index_params
337-
name_list from_clause from_list opt_array_bounds
337+
name_list role_list from_clause from_list opt_array_bounds
338338
qualified_name_list any_name any_name_list
339339
any_operator expr_list attrs
340340
target_list opt_target_list insert_column_list set_target_list
@@ -901,7 +901,7 @@ AlterOptRoleElem:
901901
$$ = makeDefElem("validUntil", (Node *)makeString($3));
902902
}
903903
/* Supported but not documented for roles, for use by ALTER GROUP. */
904-
| USER name_list
904+
| USER role_list
905905
{
906906
$$ = makeDefElem("rolemembers", (Node *)$2);
907907
}
@@ -965,19 +965,19 @@ CreateOptRoleElem:
965965
{
966966
$$ = makeDefElem("sysid", (Node *)makeInteger($2));
967967
}
968-
| ADMIN name_list
968+
| ADMIN role_list
969969
{
970970
$$ = makeDefElem("adminmembers", (Node *)$2);
971971
}
972-
| ROLE name_list
972+
| ROLE role_list
973973
{
974974
$$ = makeDefElem("rolemembers", (Node *)$2);
975975
}
976-
| IN_P ROLE name_list
976+
| IN_P ROLE role_list
977977
{
978978
$$ = makeDefElem("addroleto", (Node *)$3);
979979
}
980-
| IN_P GROUP_P name_list
980+
| IN_P GROUP_P role_list
981981
{
982982
$$ = makeDefElem("addroleto", (Node *)$3);
983983
}
@@ -1084,14 +1084,14 @@ AlterUserSetStmt:
10841084
*****************************************************************************/
10851085

10861086
DropRoleStmt:
1087-
DROP ROLE name_list
1087+
DROP ROLE role_list
10881088
{
10891089
DropRoleStmt *n = makeNode(DropRoleStmt);
10901090
n->missing_ok = FALSE;
10911091
n->roles = $3;
10921092
$$ = (Node *)n;
10931093
}
1094-
| DROP ROLE IF_P EXISTS name_list
1094+
| DROP ROLE IF_P EXISTS role_list
10951095
{
10961096
DropRoleStmt *n = makeNode(DropRoleStmt);
10971097
n->missing_ok = TRUE;
@@ -1110,14 +1110,14 @@ DropRoleStmt:
11101110
*****************************************************************************/
11111111

11121112
DropUserStmt:
1113-
DROP USER name_list
1113+
DROP USER role_list
11141114
{
11151115
DropRoleStmt *n = makeNode(DropRoleStmt);
11161116
n->missing_ok = FALSE;
11171117
n->roles = $3;
11181118
$$ = (Node *)n;
11191119
}
1120-
| DROP USER IF_P EXISTS name_list
1120+
| DROP USER IF_P EXISTS role_list
11211121
{
11221122
DropRoleStmt *n = makeNode(DropRoleStmt);
11231123
n->roles = $5;
@@ -1152,7 +1152,7 @@ CreateGroupStmt:
11521152
*****************************************************************************/
11531153

11541154
AlterGroupStmt:
1155-
ALTER GROUP_P RoleId add_drop USER name_list
1155+
ALTER GROUP_P RoleId add_drop USER role_list
11561156
{
11571157
AlterRoleStmt *n = makeNode(AlterRoleStmt);
11581158
n->role = $3;
@@ -1176,14 +1176,14 @@ add_drop: ADD_P { $$ = +1; }
11761176
*****************************************************************************/
11771177

11781178
DropGroupStmt:
1179-
DROP GROUP_P name_list
1179+
DROP GROUP_P role_list
11801180
{
11811181
DropRoleStmt *n = makeNode(DropRoleStmt);
11821182
n->missing_ok = FALSE;
11831183
n->roles = $3;
11841184
$$ = (Node *)n;
11851185
}
1186-
| DROP GROUP_P IF_P EXISTS name_list
1186+
| DROP GROUP_P IF_P EXISTS role_list
11871187
{
11881188
DropRoleStmt *n = makeNode(DropRoleStmt);
11891189
n->missing_ok = TRUE;
@@ -5122,7 +5122,7 @@ DropOpFamilyStmt:
51225122
*
51235123
*****************************************************************************/
51245124
DropOwnedStmt:
5125-
DROP OWNED BY name_list opt_drop_behavior
5125+
DROP OWNED BY role_list opt_drop_behavior
51265126
{
51275127
DropOwnedStmt *n = makeNode(DropOwnedStmt);
51285128
n->roles = $4;
@@ -5132,7 +5132,7 @@ DropOwnedStmt:
51325132
;
51335133

51345134
ReassignOwnedStmt:
5135-
REASSIGN OWNED BY name_list TO name
5135+
REASSIGN OWNED BY role_list TO name
51365136
{
51375137
ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt);
51385138
n->roles = $4;
@@ -5998,7 +5998,7 @@ function_with_argtypes:
59985998
*****************************************************************************/
59995999

60006000
GrantRoleStmt:
6001-
GRANT privilege_list TO name_list opt_grant_admin_option opt_granted_by
6001+
GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
60026002
{
60036003
GrantRoleStmt *n = makeNode(GrantRoleStmt);
60046004
n->is_grant = true;
@@ -6011,7 +6011,7 @@ GrantRoleStmt:
60116011
;
60126012

60136013
RevokeRoleStmt:
6014-
REVOKE privilege_list FROM name_list opt_granted_by opt_drop_behavior
6014+
REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
60156015
{
60166016
GrantRoleStmt *n = makeNode(GrantRoleStmt);
60176017
n->is_grant = false;
@@ -6021,7 +6021,7 @@ RevokeRoleStmt:
60216021
n->behavior = $6;
60226022
$$ = (Node*)n;
60236023
}
6024-
| REVOKE ADMIN OPTION FOR privilege_list FROM name_list opt_granted_by opt_drop_behavior
6024+
| REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
60256025
{
60266026
GrantRoleStmt *n = makeNode(GrantRoleStmt);
60276027
n->is_grant = false;
@@ -6067,11 +6067,11 @@ DefACLOption:
60676067
{
60686068
$$ = makeDefElem("schemas", (Node *)$3);
60696069
}
6070-
| FOR ROLE name_list
6070+
| FOR ROLE role_list
60716071
{
60726072
$$ = makeDefElem("roles", (Node *)$3);
60736073
}
6074-
| FOR USER name_list
6074+
| FOR USER role_list
60756075
{
60766076
$$ = makeDefElem("roles", (Node *)$3);
60776077
}
@@ -12624,6 +12624,12 @@ Iconst: ICONST { $$ = $1; };
1262412624
Sconst: SCONST { $$ = $1; };
1262512625
RoleId: NonReservedWord { $$ = $1; };
1262612626

12627+
role_list: RoleId
12628+
{ $$ = list_make1(makeString($1)); }
12629+
| role_list ',' RoleId
12630+
{ $$ = lappend($1, makeString($3)); }
12631+
;
12632+
1262712633
SignedIconst: Iconst { $$ = $1; }
1262812634
| '+' Iconst { $$ = + $2; }
1262912635
| '-' Iconst { $$ = - $2; }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.