Commit 6c36f383 authored by Stephen Frost's avatar Stephen Frost

Allow type_func_name_keywords in even more places

A while back, 2c92edad 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 2c92edad was.
parent 69c7a983
...@@ -334,7 +334,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); ...@@ -334,7 +334,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
oper_argtypes RuleActionList RuleActionMulti oper_argtypes RuleActionList RuleActionMulti
opt_column_list columnList opt_name_list opt_column_list columnList opt_name_list
sort_clause opt_sort_clause sortby_list index_params sort_clause opt_sort_clause sortby_list index_params
name_list from_clause from_list opt_array_bounds name_list role_list from_clause from_list opt_array_bounds
qualified_name_list any_name any_name_list qualified_name_list any_name any_name_list
any_operator expr_list attrs any_operator expr_list attrs
target_list opt_target_list insert_column_list set_target_list target_list opt_target_list insert_column_list set_target_list
...@@ -901,7 +901,7 @@ AlterOptRoleElem: ...@@ -901,7 +901,7 @@ AlterOptRoleElem:
$$ = makeDefElem("validUntil", (Node *)makeString($3)); $$ = makeDefElem("validUntil", (Node *)makeString($3));
} }
/* Supported but not documented for roles, for use by ALTER GROUP. */ /* Supported but not documented for roles, for use by ALTER GROUP. */
| USER name_list | USER role_list
{ {
$$ = makeDefElem("rolemembers", (Node *)$2); $$ = makeDefElem("rolemembers", (Node *)$2);
} }
...@@ -965,19 +965,19 @@ CreateOptRoleElem: ...@@ -965,19 +965,19 @@ CreateOptRoleElem:
{ {
$$ = makeDefElem("sysid", (Node *)makeInteger($2)); $$ = makeDefElem("sysid", (Node *)makeInteger($2));
} }
| ADMIN name_list | ADMIN role_list
{ {
$$ = makeDefElem("adminmembers", (Node *)$2); $$ = makeDefElem("adminmembers", (Node *)$2);
} }
| ROLE name_list | ROLE role_list
{ {
$$ = makeDefElem("rolemembers", (Node *)$2); $$ = makeDefElem("rolemembers", (Node *)$2);
} }
| IN_P ROLE name_list | IN_P ROLE role_list
{ {
$$ = makeDefElem("addroleto", (Node *)$3); $$ = makeDefElem("addroleto", (Node *)$3);
} }
| IN_P GROUP_P name_list | IN_P GROUP_P role_list
{ {
$$ = makeDefElem("addroleto", (Node *)$3); $$ = makeDefElem("addroleto", (Node *)$3);
} }
...@@ -1084,14 +1084,14 @@ AlterUserSetStmt: ...@@ -1084,14 +1084,14 @@ AlterUserSetStmt:
*****************************************************************************/ *****************************************************************************/
DropRoleStmt: DropRoleStmt:
DROP ROLE name_list DROP ROLE role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->missing_ok = FALSE; n->missing_ok = FALSE;
n->roles = $3; n->roles = $3;
$$ = (Node *)n; $$ = (Node *)n;
} }
| DROP ROLE IF_P EXISTS name_list | DROP ROLE IF_P EXISTS role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->missing_ok = TRUE; n->missing_ok = TRUE;
...@@ -1110,14 +1110,14 @@ DropRoleStmt: ...@@ -1110,14 +1110,14 @@ DropRoleStmt:
*****************************************************************************/ *****************************************************************************/
DropUserStmt: DropUserStmt:
DROP USER name_list DROP USER role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->missing_ok = FALSE; n->missing_ok = FALSE;
n->roles = $3; n->roles = $3;
$$ = (Node *)n; $$ = (Node *)n;
} }
| DROP USER IF_P EXISTS name_list | DROP USER IF_P EXISTS role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->roles = $5; n->roles = $5;
...@@ -1152,7 +1152,7 @@ CreateGroupStmt: ...@@ -1152,7 +1152,7 @@ CreateGroupStmt:
*****************************************************************************/ *****************************************************************************/
AlterGroupStmt: AlterGroupStmt:
ALTER GROUP_P RoleId add_drop USER name_list ALTER GROUP_P RoleId add_drop USER role_list
{ {
AlterRoleStmt *n = makeNode(AlterRoleStmt); AlterRoleStmt *n = makeNode(AlterRoleStmt);
n->role = $3; n->role = $3;
...@@ -1176,14 +1176,14 @@ add_drop: ADD_P { $$ = +1; } ...@@ -1176,14 +1176,14 @@ add_drop: ADD_P { $$ = +1; }
*****************************************************************************/ *****************************************************************************/
DropGroupStmt: DropGroupStmt:
DROP GROUP_P name_list DROP GROUP_P role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->missing_ok = FALSE; n->missing_ok = FALSE;
n->roles = $3; n->roles = $3;
$$ = (Node *)n; $$ = (Node *)n;
} }
| DROP GROUP_P IF_P EXISTS name_list | DROP GROUP_P IF_P EXISTS role_list
{ {
DropRoleStmt *n = makeNode(DropRoleStmt); DropRoleStmt *n = makeNode(DropRoleStmt);
n->missing_ok = TRUE; n->missing_ok = TRUE;
...@@ -5122,7 +5122,7 @@ DropOpFamilyStmt: ...@@ -5122,7 +5122,7 @@ DropOpFamilyStmt:
* *
*****************************************************************************/ *****************************************************************************/
DropOwnedStmt: DropOwnedStmt:
DROP OWNED BY name_list opt_drop_behavior DROP OWNED BY role_list opt_drop_behavior
{ {
DropOwnedStmt *n = makeNode(DropOwnedStmt); DropOwnedStmt *n = makeNode(DropOwnedStmt);
n->roles = $4; n->roles = $4;
...@@ -5132,7 +5132,7 @@ DropOwnedStmt: ...@@ -5132,7 +5132,7 @@ DropOwnedStmt:
; ;
ReassignOwnedStmt: ReassignOwnedStmt:
REASSIGN OWNED BY name_list TO name REASSIGN OWNED BY role_list TO name
{ {
ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt); ReassignOwnedStmt *n = makeNode(ReassignOwnedStmt);
n->roles = $4; n->roles = $4;
...@@ -5998,7 +5998,7 @@ function_with_argtypes: ...@@ -5998,7 +5998,7 @@ function_with_argtypes:
*****************************************************************************/ *****************************************************************************/
GrantRoleStmt: GrantRoleStmt:
GRANT privilege_list TO name_list opt_grant_admin_option opt_granted_by GRANT privilege_list TO role_list opt_grant_admin_option opt_granted_by
{ {
GrantRoleStmt *n = makeNode(GrantRoleStmt); GrantRoleStmt *n = makeNode(GrantRoleStmt);
n->is_grant = true; n->is_grant = true;
...@@ -6011,7 +6011,7 @@ GrantRoleStmt: ...@@ -6011,7 +6011,7 @@ GrantRoleStmt:
; ;
RevokeRoleStmt: RevokeRoleStmt:
REVOKE privilege_list FROM name_list opt_granted_by opt_drop_behavior REVOKE privilege_list FROM role_list opt_granted_by opt_drop_behavior
{ {
GrantRoleStmt *n = makeNode(GrantRoleStmt); GrantRoleStmt *n = makeNode(GrantRoleStmt);
n->is_grant = false; n->is_grant = false;
...@@ -6021,7 +6021,7 @@ RevokeRoleStmt: ...@@ -6021,7 +6021,7 @@ RevokeRoleStmt:
n->behavior = $6; n->behavior = $6;
$$ = (Node*)n; $$ = (Node*)n;
} }
| REVOKE ADMIN OPTION FOR privilege_list FROM name_list opt_granted_by opt_drop_behavior | REVOKE ADMIN OPTION FOR privilege_list FROM role_list opt_granted_by opt_drop_behavior
{ {
GrantRoleStmt *n = makeNode(GrantRoleStmt); GrantRoleStmt *n = makeNode(GrantRoleStmt);
n->is_grant = false; n->is_grant = false;
...@@ -6067,11 +6067,11 @@ DefACLOption: ...@@ -6067,11 +6067,11 @@ DefACLOption:
{ {
$$ = makeDefElem("schemas", (Node *)$3); $$ = makeDefElem("schemas", (Node *)$3);
} }
| FOR ROLE name_list | FOR ROLE role_list
{ {
$$ = makeDefElem("roles", (Node *)$3); $$ = makeDefElem("roles", (Node *)$3);
} }
| FOR USER name_list | FOR USER role_list
{ {
$$ = makeDefElem("roles", (Node *)$3); $$ = makeDefElem("roles", (Node *)$3);
} }
...@@ -12624,6 +12624,12 @@ Iconst: ICONST { $$ = $1; }; ...@@ -12624,6 +12624,12 @@ Iconst: ICONST { $$ = $1; };
Sconst: SCONST { $$ = $1; }; Sconst: SCONST { $$ = $1; };
RoleId: NonReservedWord { $$ = $1; }; RoleId: NonReservedWord { $$ = $1; };
role_list: RoleId
{ $$ = list_make1(makeString($1)); }
| role_list ',' RoleId
{ $$ = lappend($1, makeString($3)); }
;
SignedIconst: Iconst { $$ = $1; } SignedIconst: Iconst { $$ = $1; }
| '+' Iconst { $$ = + $2; } | '+' Iconst { $$ = + $2; }
| '-' Iconst { $$ = - $2; } | '-' Iconst { $$ = - $2; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment