apache / apache/datafusion-sqlparser-rs
mysql: `DROP INDEX idx_xxx on t` and an error occurs
- Ngôn ngữ chính
- Rust
- Star
- 3.5k
- Fork
- 772
- Merge trung bình
- 4 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 17
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Tái hiện lỗi thông qua MySqlDialect và Parser::parse_sql bằng cách sử dụng cả hai dạng DROP INDEX ... ON ... và ALTER TABLE ... DROP INDEX. Theo dõi cách các câu lệnh này được phân tích cú pháp và xác minh rằng phạm vi kiểm thử hồi quy chấp nhận cú pháp MySQL được ghi trong tài liệu mà không gặp lỗi parser đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- mysql, rust
- Lĩnh vực
- databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100