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 @@ -886,6 +886,10 @@ pub enum Statement {
886
886
db_name : Option < Ident > ,
887
887
filter : Option < ShowStatementFilter > ,
888
888
} ,
889
+ /// SHOW COLLATION
890
+ ///
891
+ /// Note: this is a MySQL-specific statement.
892
+ ShowCollation { filter : Option < ShowStatementFilter > } ,
889
893
/// `{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...`
890
894
StartTransaction { modes : Vec < TransactionMode > } ,
891
895
/// `SET TRANSACTION ...`
@@ -1586,6 +1590,13 @@ impl fmt::Display for Statement {
1586
1590
}
1587
1591
Ok ( ( ) )
1588
1592
}
1593
+ Statement :: ShowCollation { filter } => {
1594
+ write ! ( f, "SHOW COLLATION" ) ?;
1595
+ if let Some ( filter) = filter {
1596
+ write ! ( f, " {}" , filter) ?;
1597
+ }
1598
+ Ok ( ( ) )
1599
+ }
1589
1600
Statement :: StartTransaction { modes } => {
1590
1601
write ! ( f, "START TRANSACTION" ) ?;
1591
1602
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 @@ -3141,6 +3141,8 @@ impl<'a> Parser<'a> {
3141
3141
Err ( ParserError :: ParserError (
3142
3142
"EXTENDED/FULL are not supported with this type of SHOW query" . to_string ( ) ,
3143
3143
) )
3144
+ } else if self . parse_keyword ( Keyword :: COLLATION ) {
3145
+ Ok ( self . parse_show_collation ( ) ?)
3144
3146
} else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
3145
3147
Ok ( self . parse_show_create ( ) ?)
3146
3148
} else if self . parse_one_of_keywords ( & [ Keyword :: VARIABLES ] ) . is_some ( ) {
@@ -3220,6 +3222,11 @@ impl<'a> Parser<'a> {
3220
3222
} )
3221
3223
}
3222
3224
3225
+ fn parse_show_collation ( & mut self ) -> Result < Statement , ParserError > {
3226
+ let filter = self . parse_show_statement_filter ( ) ?;
3227
+ Ok ( Statement :: ShowCollation { filter } )
3228
+ }
3229
+
3223
3230
fn parse_show_statement_filter ( & mut self ) -> Result < Option < ShowStatementFilter > , ParserError > {
3224
3231
if self . parse_keyword ( Keyword :: LIKE ) {
3225
3232
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