@@ -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
} ,
@@ -802,8 +802,8 @@ pub fn statement(i: Input) -> IResult<StatementMsg> {
802
802
) ,
803
803
rule ! (
804
804
#show_users : "`SHOW USERS`"
805
- | #create_user : "`CREATE USER [IF NOT EXISTS] '<username>'@'hostname' IDENTIFIED [WITH <auth_type>] [BY <password>] [WITH <role_option> ...]`"
806
- | #alter_user : "`ALTER USER ('<username>'@'hostname' | USER()) [IDENTIFIED [WITH <auth_type>] [BY <password>]] [WITH <role_option> ...]`"
805
+ | #create_user : "`CREATE USER [IF NOT EXISTS] '<username>'@'hostname' IDENTIFIED [WITH <auth_type>] [BY <password>] [WITH <user_option>, ...]`"
806
+ | #alter_user : "`ALTER USER ('<username>'@'hostname' | USER()) [IDENTIFIED [WITH <auth_type>] [BY <password>]] [WITH <user_option>, ...]`"
807
807
| #drop_user : "`DROP USER [IF EXISTS] '<username>'@'hostname'`"
808
808
| #show_roles : "`SHOW ROLES`"
809
809
| #create_role : "`CREATE ROLE [IF NOT EXISTS] '<role_name>']`"
@@ -1298,12 +1298,25 @@ pub fn database_engine(i: Input) -> IResult<DatabaseEngine> {
1298
1298
) ( i)
1299
1299
}
1300
1300
1301
- pub fn role_option ( i : Input ) -> IResult < RoleOption > {
1301
+ pub fn user_option ( i : Input ) -> IResult < UserOptionItem > {
1302
+ let default_role_option = map (
1303
+ rule ! {
1304
+ "DEFAULT_ROLE" ~ "=" ~ #literal_string
1305
+ } ,
1306
+ |( _, _, role) | UserOptionItem :: DefaultRole ( role) ,
1307
+ ) ;
1302
1308
alt ( (
1303
- value ( RoleOption :: TenantSetting , rule ! { TENANTSETTING } ) ,
1304
- value ( RoleOption :: NoTenantSetting , rule ! { NOTENANTSETTING } ) ,
1305
- value ( RoleOption :: ConfigReload , rule ! { CONFIGRELOAD } ) ,
1306
- value ( RoleOption :: NoConfigReload , rule ! { NOCONFIGRELOAD } ) ,
1309
+ value ( UserOptionItem :: TenantSetting ( true ) , rule ! { TENANTSETTING } ) ,
1310
+ value (
1311
+ UserOptionItem :: TenantSetting ( false ) ,
1312
+ rule ! { NOTENANTSETTING } ,
1313
+ ) ,
1314
+ value ( UserOptionItem :: ConfigReload ( true ) , rule ! { CONFIGRELOAD } ) ,
1315
+ value (
1316
+ UserOptionItem :: ConfigReload ( false ) ,
1317
+ rule ! { NOCONFIGRELOAD } ,
1318
+ ) ,
1319
+ default_role_option,
1307
1320
) ) ( i)
1308
1321
}
1309
1322
0 commit comments