apache / apache/datafusion-sqlparser-rs
mysql: `DROP INDEX idx_xxx on t` and an error occurs
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
With v0.56.0 using the mysql dialect, use the `parse_sql` function to parse `DROP INDEX idx_name ON table_demo;` or `ALTER TABLE tbl_name DROP INDEX idx_name;` and an error occurs.
```rust
use sqlparser::dialect::MySqlDialect;
use sqlparser::parser::Parser;
fn main() {
let sql = "DROP INDEX idx_name ON table_demo;";
let dialect = MySqlDialect {}; // or AnsiDialect, or your own dialect ...
let ast = Parser::parse_sql(&dialect, sql).unwrap();
println!("AST: {:?}", ast);
}
```
Report the following error:
```
called `Result::unwrap()` on an `Err` value: ParserError("Expected: end of statement, found: ON at Line: 1, Column: 21")
```
In the official documentation of MySQL, when deleting an index, you need to specify the table where the index is located.
```sql
DROP INDEX index_name ON tbl_name
[algorithm_option | lock_option] ...
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}
```
https://dev.mysql.com/doc/refman/8.0/en/drop-index.html
Would you classify this as a bug?
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure through MySqlDialect and Parser::parse_sql using both DROP INDEX ... ON ... and ALTER TABLE ... DROP INDEX forms. Trace how these statements are parsed and verify that regression coverage accepts the documented MySQL syntax without the reported parser error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100