File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed
Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -3704,6 +3704,20 @@ pub enum Statement {
37043704 history : bool ,
37053705 show_options : ShowStatementOptions ,
37063706 } ,
3707+ // ```sql
3708+ // SHOW {CHARACTER SET | CHARSET} [like_or_where]
3709+ // ```
3710+ // where:
3711+ // like_or_where: {
3712+ // LIKE 'pattern'
3713+ // | WHERE expr
3714+ // }
3715+ // MySQL specific statement
3716+ // <https://dev.mysql.com/doc/refman/8.4/en/show.html#:~:text=SHOW%20%7BCHARACTER%20SET%20%7C%20CHARSET%7D%20%5Blike_or_where%5D>
3717+ ShowCharset {
3718+ is_shorthand : bool ,
3719+ filter : Option < ShowStatementFilter > ,
3720+ } ,
37073721 /// ```sql
37083722 /// SHOW OBJECTS LIKE 'line%' IN mydb.public
37093723 /// ```
@@ -5674,6 +5688,21 @@ impl fmt::Display for Statement {
56745688 }
56755689 Ok ( ( ) )
56765690 }
5691+ Statement :: ShowCharset {
5692+ is_shorthand,
5693+ filter,
5694+ } => {
5695+ write ! ( f, "SHOW" ) ?;
5696+ if * is_shorthand {
5697+ write ! ( f, " CHARSET" ) ?;
5698+ } else {
5699+ write ! ( f, " CHARACTER SET" ) ?;
5700+ }
5701+ if filter. is_some ( ) {
5702+ write ! ( f, " {}" , filter. as_ref( ) . unwrap( ) ) ?;
5703+ }
5704+ Ok ( ( ) )
5705+ }
56775706 Statement :: StartTransaction {
56785707 modes,
56795708 begin : syntax_begin,
Original file line number Diff line number Diff line change @@ -477,6 +477,7 @@ impl Spanned for Statement {
477477 Statement :: ShowColumns { .. } => Span :: empty ( ) ,
478478 Statement :: ShowTables { .. } => Span :: empty ( ) ,
479479 Statement :: ShowCollation { .. } => Span :: empty ( ) ,
480+ Statement :: ShowCharset { .. } => Span :: empty ( ) ,
480481 Statement :: Use ( u) => u. span ( ) ,
481482 Statement :: StartTransaction { .. } => Span :: empty ( ) ,
482483 Statement :: Comment { .. } => Span :: empty ( ) ,
Original file line number Diff line number Diff line change @@ -12505,13 +12505,25 @@ impl<'a> Parser<'a> {
1250512505 self.parse_show_databases(terse)
1250612506 } else if self.parse_keyword(Keyword::SCHEMAS) {
1250712507 self.parse_show_schemas(terse)
12508+ } else if self.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) {
12509+ self.parse_show_charset(false)
12510+ } else if self.parse_keyword(Keyword::CHARSET) {
12511+ self.parse_show_charset(true)
1250812512 } else {
1250912513 Ok(Statement::ShowVariable {
1251012514 variable: self.parse_identifiers()?,
1251112515 })
1251212516 }
1251312517 }
1251412518
12519+ fn parse_show_charset(&mut self, is_shorthand: bool) -> Result<Statement, ParserError> {
12520+ // parse one of keywords
12521+ Ok(Statement::ShowCharset {
12522+ is_shorthand,
12523+ filter: self.parse_show_statement_filter()?,
12524+ })
12525+ }
12526+
1251512527 fn parse_show_databases(&mut self, terse: bool) -> Result<Statement, ParserError> {
1251612528 let history = self.parse_keyword(Keyword::HISTORY);
1251712529 let show_options = self.parse_show_stmt_options()?;
Original file line number Diff line number Diff line change @@ -4143,3 +4143,11 @@ fn parse_json_member_of() {
41434143 _ => panic ! ( "Unexpected statement {stmt}" ) ,
41444144 }
41454145}
4146+
4147+ #[ test]
4148+ fn parse_show_charset ( ) {
4149+ let _ = mysql ( ) . verified_stmt ( "SHOW CHARACTER SET" ) ;
4150+ let _ = mysql ( ) . verified_stmt ( "SHOW CHARACTER SET LIKE 'utf8mb4%'" ) ;
4151+ let _ = mysql ( ) . verified_stmt ( "SHOW CHARSET WHERE charset = 'utf8mb4%'" ) ;
4152+ let _ = mysql ( ) . verified_stmt ( "SHOW CHARSET LIKE 'utf8mb4%'" ) ;
4153+ }
You can’t perform that action at this time.
0 commit comments