File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -890,6 +890,10 @@ pub enum Statement {
890890 db_name : Option < Ident > ,
891891 filter : Option < ShowStatementFilter > ,
892892 } ,
893+ /// SHOW COLLATION
894+ ///
895+ /// Note: this is a MySQL-specific statement.
896+ ShowCollation { filter : Option < ShowStatementFilter > } ,
893897 /// `{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...`
894898 StartTransaction { modes : Vec < TransactionMode > } ,
895899 /// `SET TRANSACTION ...`
@@ -1602,6 +1606,13 @@ impl fmt::Display for Statement {
16021606 }
16031607 Ok ( ( ) )
16041608 }
1609+ Statement :: ShowCollation { filter } => {
1610+ write ! ( f, "SHOW COLLATION" ) ?;
1611+ if let Some ( filter) = filter {
1612+ write ! ( f, " {}" , filter) ?;
1613+ }
1614+ Ok ( ( ) )
1615+ }
16051616 Statement :: StartTransaction { modes } => {
16061617 write ! ( f, "START TRANSACTION" ) ?;
16071618 if !modes. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ define_keywords!(
128128 CLUSTER ,
129129 COALESCE ,
130130 COLLATE ,
131+ COLLATION ,
131132 COLLECT ,
132133 COLUMN ,
133134 COLUMNS ,
Original file line number Diff line number Diff line change @@ -3283,6 +3283,8 @@ impl<'a> Parser<'a> {
32833283 Err ( ParserError :: ParserError (
32843284 "EXTENDED/FULL are not supported with this type of SHOW query" . to_string ( ) ,
32853285 ) )
3286+ } else if self . parse_keyword ( Keyword :: COLLATION ) {
3287+ Ok ( self . parse_show_collation ( ) ?)
32863288 } else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
32873289 Ok ( self . parse_show_create ( ) ?)
32883290 } else if self . parse_one_of_keywords ( & [ Keyword :: VARIABLES ] ) . is_some ( ) {
@@ -3362,6 +3364,11 @@ impl<'a> Parser<'a> {
33623364 } )
33633365 }
33643366
3367+ fn parse_show_collation ( & mut self ) -> Result < Statement , ParserError > {
3368+ let filter = self . parse_show_statement_filter ( ) ?;
3369+ Ok ( Statement :: ShowCollation { filter } )
3370+ }
3371+
33653372 fn parse_show_statement_filter ( & mut self ) -> Result < Option < ShowStatementFilter > , ParserError > {
33663373 if self . parse_keyword ( Keyword :: LIKE ) {
33673374 Ok ( Some ( ShowStatementFilter :: Like (
Original file line number Diff line number Diff line change @@ -162,6 +162,28 @@ fn parse_show_tables() {
162162 mysql_and_generic ( ) . one_statement_parses_to ( "SHOW TABLES IN mydb" , "SHOW TABLES FROM mydb" ) ;
163163}
164164
165+ #[ test]
166+ fn parse_show_collation ( ) {
167+ assert_eq ! (
168+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION" ) ,
169+ Statement :: ShowCollation { filter: None }
170+ ) ;
171+ assert_eq ! (
172+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION LIKE 'pattern'" ) ,
173+ Statement :: ShowCollation {
174+ filter: Some ( ShowStatementFilter :: Like ( "pattern" . into( ) ) ) ,
175+ }
176+ ) ;
177+ assert_eq ! (
178+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION WHERE 1 = 2" ) ,
179+ Statement :: ShowCollation {
180+ filter: Some ( ShowStatementFilter :: Where (
181+ mysql_and_generic( ) . verified_expr( "1 = 2" )
182+ ) ) ,
183+ }
184+ ) ;
185+ }
186+
165187#[ test]
166188fn parse_show_create ( ) {
167189 let obj_name = ObjectName ( vec ! [ Ident :: new( "myident" ) ] ) ;
You can’t perform that action at this time.
0 commit comments