apache / apache/datafusion-sqlparser-rs

mysql: `DROP INDEX idx_xxx on t` and an error occurs

未關閉
#1,863 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
3.5k
分支
774
平均合併
4 天 9 小時
30 天內合併 PR
17

描述

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?

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

透過 MySqlDialect 和 Parser::parse_sql,分別使用 DROP INDEX ... ON ... 和 ALTER TABLE ... DROP INDEX 兩種形式重現該故障。追蹤這些陳述式的解析方式,並驗證回歸測試涵蓋範圍能夠接受文件所述的 MySQL 語法,而不會出現回報的剖析器錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
mysql, rust
領域
databases
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。