File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -3324,14 +3324,27 @@ impl<'a> Parser<'a> {
3324
3324
self . expect_one_of_keywords ( & [ Keyword :: COLUMNS , Keyword :: FIELDS ] ) ?;
3325
3325
self . expect_one_of_keywords ( & [ Keyword :: FROM , Keyword :: IN ] ) ?;
3326
3326
let table_name = self . parse_object_name ( ) ?;
3327
- // MySQL also supports FROM <database> here. In other words, MySQL
3328
- // allows both FROM <table> FROM <database> and FROM <database>.<table>,
3329
- // while we only support the latter for now.
3327
+ let double_from = self . parse_one_of_keywords ( & [ Keyword :: FROM , Keyword :: IN ] ) ;
3328
+ let db_name = if double_from. is_some ( ) {
3329
+ Some ( self . parse_object_name ( ) ?)
3330
+ } else {
3331
+ None
3332
+ } ;
3333
+ let object_name = match db_name {
3334
+ Some ( db_name) => ObjectName (
3335
+ db_name
3336
+ . 0
3337
+ . into_iter ( )
3338
+ . chain ( table_name. 0 . into_iter ( ) )
3339
+ . collect ( ) ,
3340
+ ) ,
3341
+ None => table_name,
3342
+ } ;
3330
3343
let filter = self . parse_show_statement_filter ( ) ?;
3331
3344
Ok ( Statement :: ShowColumns {
3332
3345
extended,
3333
3346
full,
3334
- table_name,
3347
+ table_name : object_name ,
3335
3348
filter,
3336
3349
} )
3337
3350
}
Original file line number Diff line number Diff line change @@ -95,12 +95,10 @@ fn parse_show_columns() {
95
95
. one_statement_parses_to ( "SHOW COLUMNS IN mytable" , "SHOW COLUMNS FROM mytable" ) ;
96
96
mysql_and_generic ( )
97
97
. one_statement_parses_to ( "SHOW FIELDS IN mytable" , "SHOW COLUMNS FROM mytable" ) ;
98
-
99
- // unhandled things are truly unhandled
100
- match mysql_and_generic ( ) . parse_sql_statements ( "SHOW COLUMNS FROM mytable FROM mydb" ) {
101
- Err ( _) => { }
102
- Ok ( val) => panic ! ( "unexpected successful parse: {:?}" , val) ,
103
- }
98
+ mysql_and_generic ( ) . one_statement_parses_to (
99
+ "SHOW COLUMNS FROM mytable FROM mydb" ,
100
+ "SHOW COLUMNS FROM mydb.mytable" ,
101
+ ) ;
104
102
}
105
103
106
104
#[ test]
You can’t perform that action at this time.
0 commit comments