File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -996,6 +996,10 @@ pub enum Statement {
996
996
///
997
997
/// Note: this is a PostgreSQL-specific statement.
998
998
ShowVariable { variable : Vec < Ident > } ,
999
+ /// SHOW VARIABLES
1000
+ ///
1001
+ /// Note: this is a MySQL-specific statement.
1002
+ ShowVariables { filter : Option < ShowStatementFilter > } ,
999
1003
/// SHOW CREATE TABLE
1000
1004
///
1001
1005
/// Note: this is a MySQL-specific statement.
@@ -1787,6 +1791,13 @@ impl fmt::Display for Statement {
1787
1791
}
1788
1792
Ok ( ( ) )
1789
1793
}
1794
+ Statement :: ShowVariables { filter } => {
1795
+ write ! ( f, "SHOW VARIABLES" ) ?;
1796
+ if filter. is_some ( ) {
1797
+ write ! ( f, " {}" , filter. as_ref( ) . unwrap( ) ) ?;
1798
+ }
1799
+ Ok ( ( ) )
1800
+ }
1790
1801
Statement :: ShowCreate { obj_type, obj_name } => {
1791
1802
write ! (
1792
1803
f,
Original file line number Diff line number Diff line change @@ -543,6 +543,7 @@ define_keywords!(
543
543
VALUE_OF ,
544
544
VARBINARY ,
545
545
VARCHAR ,
546
+ VARIABLES ,
546
547
VARYING ,
547
548
VAR_POP ,
548
549
VAR_SAMP ,
Original file line number Diff line number Diff line change @@ -3694,6 +3694,13 @@ impl<'a> Parser<'a> {
3694
3694
Ok ( self . parse_show_columns ( ) ?)
3695
3695
} else if self . parse_one_of_keywords ( & [ Keyword :: CREATE ] ) . is_some ( ) {
3696
3696
Ok ( self . parse_show_create ( ) ?)
3697
+ } else if self . parse_keyword ( Keyword :: VARIABLES )
3698
+ && dialect_of ! ( self is MySqlDialect | GenericDialect )
3699
+ {
3700
+ // TODO: Support GLOBAL|SESSION
3701
+ Ok ( Statement :: ShowVariables {
3702
+ filter : self . parse_show_statement_filter ( ) ?,
3703
+ } )
3697
3704
} else {
3698
3705
Ok ( Statement :: ShowVariable {
3699
3706
variable : self . parse_identifiers ( ) ?,
Original file line number Diff line number Diff line change @@ -820,6 +820,13 @@ fn parse_substring_in_select() {
820
820
}
821
821
}
822
822
823
+ #[ test]
824
+ fn parse_show_variables ( ) {
825
+ mysql_and_generic ( ) . verified_stmt ( "SHOW VARIABLES" ) ;
826
+ mysql_and_generic ( ) . verified_stmt ( "SHOW VARIABLES LIKE 'admin%'" ) ;
827
+ mysql_and_generic ( ) . verified_stmt ( "SHOW VARIABLES WHERE value = '3306'" ) ;
828
+ }
829
+
823
830
#[ test]
824
831
fn parse_kill ( ) {
825
832
let stmt = mysql_and_generic ( ) . verified_stmt ( "KILL CONNECTION 5" ) ;
You can’t perform that action at this time.
0 commit comments