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 @@ -1027,6 +1027,10 @@ pub enum Statement {
1027
1027
db_name : Option < Ident > ,
1028
1028
filter : Option < ShowStatementFilter > ,
1029
1029
} ,
1030
+ /// SHOW COLLATION
1031
+ ///
1032
+ /// Note: this is a MySQL-specific statement.
1033
+ ShowCollation { filter : Option < ShowStatementFilter > } ,
1030
1034
/// USE
1031
1035
///
1032
1036
/// Note: this is a MySQL-specific statement.
@@ -1831,6 +1835,13 @@ impl fmt::Display for Statement {
1831
1835
}
1832
1836
Ok ( ( ) )
1833
1837
}
1838
+ Statement :: ShowCollation { filter } => {
1839
+ write ! ( f, "SHOW COLLATION" ) ?;
1840
+ if let Some ( filter) = filter {
1841
+ write ! ( f, " {}" , filter) ?;
1842
+ }
1843
+ Ok ( ( ) )
1844
+ }
1834
1845
Statement :: Use { db_name } => {
1835
1846
write ! ( f, "USE {}" , db_name) ?;
1836
1847
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ define_keywords!(
129
129
CLUSTER ,
130
130
COALESCE ,
131
131
COLLATE ,
132
+ COLLATION ,
132
133
COLLECT ,
133
134
COLUMN ,
134
135
COLUMNS ,
Original file line number Diff line number Diff line change @@ -3572,6 +3572,8 @@ impl<'a> Parser<'a> {
3572
3572
Err ( ParserError :: ParserError (
3573
3573
"EXTENDED/FULL are not supported with this type of SHOW query" . to_string ( ) ,
3574
3574
) )
3575
+ } else if self . parse_keyword ( Keyword :: COLLATION ) {
3576
+ Ok ( self . parse_show_collation ( ) ?)
3575
3577
} else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
3576
3578
Ok ( self . parse_show_create ( ) ?)
3577
3579
} else if self . parse_one_of_keywords ( & [ Keyword :: VARIABLES ] ) . is_some ( ) {
@@ -3651,6 +3653,11 @@ impl<'a> Parser<'a> {
3651
3653
} )
3652
3654
}
3653
3655
3656
+ fn parse_show_collation ( & mut self ) -> Result < Statement , ParserError > {
3657
+ let filter = self . parse_show_statement_filter ( ) ?;
3658
+ Ok ( Statement :: ShowCollation { filter } )
3659
+ }
3660
+
3654
3661
fn parse_show_statement_filter ( & mut self ) -> Result < Option < ShowStatementFilter > , ParserError > {
3655
3662
if self . parse_keyword ( Keyword :: LIKE ) {
3656
3663
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_use ( ) {
167
189
assert_eq ! (
You can’t perform that action at this time.
0 commit comments