apache / apache/datafusion-sqlparser-rs

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

オープン
#1,863 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
3.5k
フォーク
772
平均マージ
4日 9時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。