Skip to content

Commit c0e6169

Browse 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 27ab1eb commit c0e6169

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/backend/parser/gram.y

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
306306
oper_argtypes RuleActionList RuleActionMulti
307307
opt_column_list columnList opt_name_list
308308
sort_clause opt_sort_clause sortby_list index_params
309-
name_list from_clause from_list opt_array_bounds
309+
name_list role_list from_clause from_list opt_array_bounds
310310
qualified_name_list any_name any_name_list
311311
any_operator expr_list attrs
312312
target_list insert_column_list set_target_list
@@ -860,7 +860,7 @@ AlterOptRoleElem:
860860
$$ = makeDefElem("validUntil", (Node *)makeString($3));
861861
}
862862
/* Supported but not documented for roles, for use by ALTER GROUP. */
863-
| USER name_list
863+
| USER role_list
864864
{
865865
$$ = makeDefElem("rolemembers", (Node *)$2);
866866
}
@@ -924,19 +924,19 @@ CreateOptRoleElem:
924924
{
925925
$$ = makeDefElem("sysid", (Node *)makeInteger($2));
926926
}
927-
| ADMIN name_list
927+
| ADMIN role_list
928928
{
929929
$$ = makeDefElem("adminmembers", (Node *)$2);
930930
}
931-
| ROLE name_list
931+
| ROLE role_list
932932
{
933933
$$ = makeDefElem("rolemembers", (Node *)$2);
934934
}
935-
| IN_P ROLE name_list
935+
| IN_P ROLE role_list
936936
{
937937
$$ = makeDefElem("addroleto", (Node *)$3);
938938
}
939-
| IN_P GROUP_P name_list
939+
| IN_P GROUP_P role_list
940940
{
941941
$$ = makeDefElem("addroleto", (Node *)$3);
942942
}
@@ -1035,14 +1035,14 @@ AlterUserSetStmt:
10351035
*****************************************************************************/
10361036

10371037
DropRoleStmt:
1038-
DROP ROLE name_list
1038+
DROP ROLE role_list
10391039
{
10401040
DropRoleStmt *n = makeNode(DropRoleStmt);
10411041
n->missing_ok = FALSE;
10421042
n->roles = $3;
10431043
$$ = (Node *)n;
10441044
}
1045-
| DROP ROLE IF_P EXISTS name_list
1045+
| DROP ROLE IF_P EXISTS role_list
10461046
{
10471047
DropRoleStmt *n = makeNode(DropRoleStmt);
10481048
n->missing_ok = TRUE;
@@ -1061,14 +1061,14 @@ DropRoleStmt:
10611061
*****************************************************************************/
10621062

10631063
DropUserStmt:
1064-
DROP USER name_list
1064+
DROP USER role_list
10651065
{
10661066
DropRoleStmt *n = makeNode(DropRoleStmt);
10671067
n->missing_ok = FALSE;
10681068
n->roles = $3;
10691069
$$ = (Node *)n;
10701070
}
1071-
| DROP USER IF_P EXISTS name_list
1071+
| DROP USER IF_P EXISTS role_list
10721072
{
10731073
DropRoleStmt *n = makeNode(DropRoleStmt);
10741074
n->roles = $5;
@@ -1103,7 +1103,7 @@ CreateGroupStmt:
11031103
*****************************************************************************/
11041104

11051105
AlterGroupStmt:
1106-
ALTER GROUP_P RoleId add_drop USER name_list
1106+
ALTER GROUP_P RoleId add_drop USER role_list
11071107
{
11081108
AlterRoleStmt *n = makeNode(AlterRoleStmt);
11091109
n->role = $3;
@@ -1127,14 +1127,14 @@ add_drop: ADD_P { $$ = +1; }
11271127
*****************************************************************************/
11281128

11291129
DropGroupStmt:
1130-
DROP GROUP_P name_list
1130+
DROP GROUP_P role_list
11311131
{
11321132
DropRoleStmt *n = makeNode(DropRoleStmt);
11331133
n->missing_ok = FALSE;
11341134
n->roles = $3;
11351135
$$ = (Node *)n;
11361136
}
1137-
| DROP GROUP_P IF_P EXISTS name_list
1137+
| DROP GROUP_P IF_P EXISTS role_list
11381138
{
11391139
DropRoleStmt *n = makeNode(DropRoleStmt);
11401140
n->missing_ok = TRUE;
@@ -4790,7 +4790,7 @@ DropOpFamilyStmt:
47904790
*
47914791
*****************************************************************************/
47924792
DropOwnedStmt:
4793-
DROP OWNED BY name_list opt_drop_behavior
4793+
DROP OWNED BY role_list opt_drop_behavior
47944794
{
47954795
DropOwnedStmt *n = makeNode(DropOwnedStmt);
47964796
n->roles = $4;
@@ -4800,7 +4800,7 @@ DropOwnedStmt:
48004800
;
48014801

48024802
ReassignOwnedStmt:
4803-
REASSIGN OWNED BY name_list TO name
4803+
REASSIGN OWNED BY role_list TO name
48044804
{
48054805
ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt);
48064806
n->roles = $4;
@@ -5682,7 +5682,7 @@ function_with_argtypes:
56825682
*****************************************************************************/
56835683

56845684
GrantRoleStmt:
5685-
GRANT privilege_list TO name_list opt_grant_admin_option opt_granted_by
5685+
GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
56865686
{
56875687
GrantRoleStmt *n = makeNode(GrantRoleStmt);
56885688
n->is_grant = true;
@@ -5695,7 +5695,7 @@ GrantRoleStmt:
56955695
;
56965696

56975697
RevokeRoleStmt:
5698-
REVOKE privilege_list FROM name_list opt_granted_by opt_drop_behavior
5698+
REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
56995699
{
57005700
GrantRoleStmt *n = makeNode(GrantRoleStmt);
57015701
n->is_grant = false;
@@ -5705,7 +5705,7 @@ RevokeRoleStmt:
57055705
n->behavior = $6;
57065706
$$ = (Node*)n;
57075707
}
5708-
| REVOKE ADMIN OPTION FOR privilege_list FROM name_list opt_granted_by opt_drop_behavior
5708+
| REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
57095709
{
57105710
GrantRoleStmt *n = makeNode(GrantRoleStmt);
57115711
n->is_grant = false;
@@ -5751,11 +5751,11 @@ DefACLOption:
57515751
{
57525752
$$ = makeDefElem("schemas", (Node *)$3);
57535753
}
5754-
| FOR ROLE name_list
5754+
| FOR ROLE role_list
57555755
{
57565756
$$ = makeDefElem("roles", (Node *)$3);
57575757
}
5758-
| FOR USER name_list
5758+
| FOR USER role_list
57595759
{
57605760
$$ = makeDefElem("roles", (Node *)$3);
57615761
}
@@ -12204,6 +12204,12 @@ Iconst: ICONST { $$ = $1; };
1220412204
Sconst: SCONST { $$ = $1; };
1220512205
RoleId: NonReservedWord { $$ = $1; };
1220612206

12207+
role_list: RoleId
12208+
{ $$ = list_make1(makeString($1)); }
12209+
| role_list ',' RoleId
12210+
{ $$ = lappend($1, makeString($3)); }
12211+
;
12212+
1220712213
SignedIconst: Iconst { $$ = $1; }
1220812214
| '+' Iconst { $$ = + $2; }
1220912215
| '-' Iconst { $$ = - $2; }

0 commit comments

Comments
 (0)