File tree Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Expand file tree Collapse file tree 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1036,6 +1036,10 @@ pub enum Statement {
1036
1036
db_name : Option < Ident > ,
1037
1037
filter : Option < ShowStatementFilter > ,
1038
1038
} ,
1039
+ /// SHOW COLLATION
1040
+ ///
1041
+ /// Note: this is a MySQL-specific statement.
1042
+ ShowCollation { filter : Option < ShowStatementFilter > } ,
1039
1043
/// USE
1040
1044
///
1041
1045
/// Note: This is a MySQL-specific statement.
@@ -1892,6 +1896,13 @@ impl fmt::Display for Statement {
1892
1896
write ! ( f, "USE {}" , db_name) ?;
1893
1897
Ok ( ( ) )
1894
1898
}
1899
+ Statement :: ShowCollation { filter } => {
1900
+ write ! ( f, "SHOW COLLATION" ) ?;
1901
+ if let Some ( filter) = filter {
1902
+ write ! ( f, " {}" , filter) ?;
1903
+ }
1904
+ Ok ( ( ) )
1905
+ }
1895
1906
Statement :: StartTransaction { modes } => {
1896
1907
write ! ( f, "START TRANSACTION" ) ?;
1897
1908
if !modes. is_empty ( ) {
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ define_keywords!(
131
131
CLUSTER ,
132
132
COALESCE ,
133
133
COLLATE ,
134
+ COLLATION ,
134
135
COLLECT ,
135
136
COLUMN ,
136
137
COLUMNS ,
Original file line number Diff line number Diff line change @@ -3758,6 +3758,8 @@ impl<'a> Parser<'a> {
3758
3758
) )
3759
3759
} else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
3760
3760
Ok ( self . parse_show_create ( ) ?)
3761
+ } else if self . parse_keyword ( Keyword :: COLLATION ) {
3762
+ Ok ( self . parse_show_collation ( ) ?)
3761
3763
} else if self . parse_keyword ( Keyword :: VARIABLES )
3762
3764
&& dialect_of ! ( self is MySqlDialect | GenericDialect )
3763
3765
{
@@ -3841,6 +3843,11 @@ impl<'a> Parser<'a> {
3841
3843
} )
3842
3844
}
3843
3845
3846
+ pub fn parse_show_collation ( & mut self ) -> Result < Statement , ParserError > {
3847
+ let filter = self . parse_show_statement_filter ( ) ?;
3848
+ Ok ( Statement :: ShowCollation { filter } )
3849
+ }
3850
+
3844
3851
pub fn parse_show_statement_filter (
3845
3852
& mut self ,
3846
3853
) -> Result < Option < ShowStatementFilter > , ParserError > {
Original file line number Diff line number Diff line change @@ -189,6 +189,12 @@ fn parse_show_extended_full() {
189
189
assert ! ( mysql_and_generic( )
190
190
. parse_sql_statements( "SHOW EXTENDED FULL CREATE TABLE mytable" )
191
191
. is_err( ) ) ;
192
+ assert ! ( mysql_and_generic( )
193
+ . parse_sql_statements( "SHOW EXTENDED FULL COLLATION" )
194
+ . is_err( ) ) ;
195
+ assert ! ( mysql_and_generic( )
196
+ . parse_sql_statements( "SHOW EXTENDED FULL VARIABLES" )
197
+ . is_err( ) ) ;
192
198
}
193
199
194
200
#[ test]
@@ -213,6 +219,28 @@ fn parse_show_create() {
213
219
}
214
220
}
215
221
222
+ #[ test]
223
+ fn parse_show_collation ( ) {
224
+ assert_eq ! (
225
+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION" ) ,
226
+ Statement :: ShowCollation { filter: None }
227
+ ) ;
228
+ assert_eq ! (
229
+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION LIKE 'pattern'" ) ,
230
+ Statement :: ShowCollation {
231
+ filter: Some ( ShowStatementFilter :: Like ( "pattern" . into( ) ) ) ,
232
+ }
233
+ ) ;
234
+ assert_eq ! (
235
+ mysql_and_generic( ) . verified_stmt( "SHOW COLLATION WHERE 1 = 2" ) ,
236
+ Statement :: ShowCollation {
237
+ filter: Some ( ShowStatementFilter :: Where (
238
+ mysql_and_generic( ) . verified_expr( "1 = 2" )
239
+ ) ) ,
240
+ }
241
+ ) ;
242
+ }
243
+
216
244
#[ test]
217
245
fn parse_use ( ) {
218
246
assert_eq ! (
You can’t perform that action at this time.
0 commit comments