@@ -458,18 +458,18 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
458
458
CREATE ~ USER ~ ( IF ~ NOT ~ EXISTS ) ?
459
459
~ #user_identity
460
460
~ IDENTIFIED ~ ( WITH ~ ^#auth_type ) ? ~ ( BY ~ ^#literal_string ) ?
461
- ~ ( WITH ~ ^#role_option+ ) ?
461
+ ~ ( WITH ~ ^#comma_separated_list1 ( user_option ) ) ?
462
462
} ,
463
- |( _, _, opt_if_not_exists, user, _, opt_auth_type, opt_password, opt_role_options ) | {
463
+ |( _, _, opt_if_not_exists, user, _, opt_auth_type, opt_password, opt_user_option ) | {
464
464
Statement :: CreateUser ( CreateUserStmt {
465
465
if_not_exists : opt_if_not_exists. is_some ( ) ,
466
466
user,
467
467
auth_option : AuthOption {
468
468
auth_type : opt_auth_type. map ( |( _, auth_type) | auth_type) ,
469
469
password : opt_password. map ( |( _, password) | password) ,
470
470
} ,
471
- role_options : opt_role_options
472
- . map ( |( _, role_options ) | role_options )
471
+ user_options : opt_user_option
472
+ . map ( |( _, user_options ) | user_options )
473
473
. unwrap_or_default ( ) ,
474
474
} )
475
475
} ,
@@ -478,17 +478,17 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
478
478
rule ! {
479
479
ALTER ~ USER ~ ( #map( rule! { USER ~ "(" ~ ")" } , |_| None ) | #map( user_identity, Some ) )
480
480
~ ( IDENTIFIED ~ ( WITH ~ ^#auth_type ) ? ~ ( BY ~ ^#literal_string ) ? ) ?
481
- ~ ( WITH ~ ^#role_option+ ) ?
481
+ ~ ( WITH ~ ^#comma_separated_list1 ( user_option ) ) ?
482
482
} ,
483
- |( _, _, user, opt_auth_option, opt_role_options ) | {
483
+ |( _, _, user, opt_auth_option, opt_user_option ) | {
484
484
Statement :: AlterUser ( AlterUserStmt {
485
485
user,
486
486
auth_option : opt_auth_option. map ( |( _, opt_auth_type, opt_password) | AuthOption {
487
487
auth_type : opt_auth_type. map ( |( _, auth_type) | auth_type) ,
488
488
password : opt_password. map ( |( _, password) | password) ,
489
489
} ) ,
490
- role_options : opt_role_options
491
- . map ( |( _, role_options ) | role_options )
490
+ user_options : opt_user_option
491
+ . map ( |( _, user_options ) | user_options )
492
492
. unwrap_or_default ( ) ,
493
493
} )
494
494
} ,
@@ -813,8 +813,8 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
813
813
) ,
814
814
rule ! (
815
815
#show_users : "`SHOW USERS`"
816
- | #create_user : "`CREATE USER [IF NOT EXISTS] '<username>'@'hostname' IDENTIFIED [WITH <auth_type>] [BY <password>] [WITH <role_option> ...]`"
817
- | #alter_user : "`ALTER USER ('<username>'@'hostname' | USER()) [IDENTIFIED [WITH <auth_type>] [BY <password>]] [WITH <role_option> ...]`"
816
+ | #create_user : "`CREATE USER [IF NOT EXISTS] '<username>'@'hostname' IDENTIFIED [WITH <auth_type>] [BY <password>] [WITH <user_option>, ...]`"
817
+ | #alter_user : "`ALTER USER ('<username>'@'hostname' | USER()) [IDENTIFIED [WITH <auth_type>] [BY <password>]] [WITH <user_option>, ...]`"
818
818
| #drop_user : "`DROP USER [IF EXISTS] '<username>'@'hostname'`"
819
819
| #show_roles : "`SHOW ROLES`"
820
820
| #create_role : "`CREATE ROLE [IF NOT EXISTS] '<role_name>']`"
@@ -1310,12 +1310,25 @@ pub fn database_engine(i: Input) -> IResult<DatabaseEngine> {
1310
1310
) ( i)
1311
1311
}
1312
1312
1313
- pub fn role_option ( i : Input ) -> IResult < RoleOption > {
1313
+ pub fn user_option ( i : Input ) -> IResult < UserOptionItem > {
1314
+ let default_role_option = map (
1315
+ rule ! {
1316
+ "DEFAULT_ROLE" ~ "=" ~ #literal_string
1317
+ } ,
1318
+ |( _, _, role) | UserOptionItem :: DefaultRole ( role) ,
1319
+ ) ;
1314
1320
alt ( (
1315
- value ( RoleOption :: TenantSetting , rule ! { TENANTSETTING } ) ,
1316
- value ( RoleOption :: NoTenantSetting , rule ! { NOTENANTSETTING } ) ,
1317
- value ( RoleOption :: ConfigReload , rule ! { CONFIGRELOAD } ) ,
1318
- value ( RoleOption :: NoConfigReload , rule ! { NOCONFIGRELOAD } ) ,
1321
+ value ( UserOptionItem :: TenantSetting ( true ) , rule ! { TENANTSETTING } ) ,
1322
+ value (
1323
+ UserOptionItem :: TenantSetting ( false ) ,
1324
+ rule ! { NOTENANTSETTING } ,
1325
+ ) ,
1326
+ value ( UserOptionItem :: ConfigReload ( true ) , rule ! { CONFIGRELOAD } ) ,
1327
+ value (
1328
+ UserOptionItem :: ConfigReload ( false ) ,
1329
+ rule ! { NOCONFIGRELOAD } ,
1330
+ ) ,
1331
+ default_role_option,
1319
1332
) ) ( i)
1320
1333
}
1321
1334
0 commit comments