File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -890,6 +890,10 @@ pub enum Statement {
890
890
db_name : Option < Ident > ,
891
891
filter : Option < ShowStatementFilter > ,
892
892
} ,
893
+ /// SHOW COLLATION
894
+ ///
895
+ /// Note: this is a MySQL-specific statement.
896
+ ShowCollation { filter : Option < ShowStatementFilter > } ,
893
897
/// `{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...`
894
898
StartTransaction { modes : Vec < TransactionMode > } ,
895
899
/// `SET TRANSACTION ...`
@@ -1602,6 +1606,13 @@ impl fmt::Display for Statement {
1602
1606
}
1603
1607
Ok ( ( ) )
1604
1608
}
1609
+ Statement :: ShowCollation { filter } => {
1610
+ write ! ( f, "SHOW COLLATION" ) ?;
1611
+ if let Some ( filter) = filter {
1612
+ write ! ( f, " {}" , filter) ?;
1613
+ }
1614
+ Ok ( ( ) )
1615
+ }
1605
1616
Statement :: StartTransaction { modes } => {
1606
1617
write ! ( f, "START TRANSACTION" ) ?;
1607
1618
if !modes. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ define_keywords!(
128
128
CLUSTER ,
129
129
COALESCE ,
130
130
COLLATE ,
131
+ COLLATION ,
131
132
COLLECT ,
132
133
COLUMN ,
133
134
COLUMNS ,
Original file line number Diff line number Diff line change @@ -3283,6 +3283,8 @@ impl<'a> Parser<'a> {
3283
3283
Err ( ParserError :: ParserError (
3284
3284
"EXTENDED/FULL are not supported with this type of SHOW query" . to_string ( ) ,
3285
3285
) )
3286
+ } else if self . parse_keyword ( Keyword :: COLLATION ) {
3287
+ Ok ( self . parse_show_collation ( ) ?)
3286
3288
} else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
3287
3289
Ok ( self . parse_show_create ( ) ?)
3288
3290
} else if self . parse_one_of_keywords ( & [ Keyword :: VARIABLES ] ) . is_some ( ) {
@@ -3362,6 +3364,11 @@ impl<'a> Parser<'a> {
3362
3364
} )
3363
3365
}
3364
3366
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
+
3365
3372
fn parse_show_statement_filter ( & mut self ) -> Result < Option < ShowStatementFilter > , ParserError > {
3366
3373
if self . parse_keyword ( Keyword :: LIKE ) {
3367
3374
Ok ( Some ( ShowStatementFilter :: Like (
Original file line number Diff line number Diff line change @@ -162,6 +162,28 @@ fn parse_show_tables() {
162
162
mysql_and_generic ( ) . one_statement_parses_to ( "SHOW TABLES IN mydb" , "SHOW TABLES FROM mydb" ) ;
163
163
}
164
164
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
+
165
187
#[ test]
166
188
fn parse_show_create ( ) {
167
189
let obj_name = ObjectName ( vec ! [ Ident :: new( "myident" ) ] ) ;
You can’t perform that action at this time.
0 commit comments