apache / apache/datafusion-sqlparser-rs
mysql: `DROP INDEX idx_xxx on t` and an error occurs
- Lenguaje dominante
- Rust
- Estrellas
- 3.5k
- Forks
- 772
- Merge medio
- 4 d 9 h
- PR fusionados (30 d)
- 17
Descripción
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?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduzca el fallo mediante MySqlDialect y Parser::parse_sql utilizando tanto las formas DROP INDEX ... ON ... como ALTER TABLE ... DROP INDEX. Rastree cómo se analizan estas sentencias y verifique que la cobertura de regresión acepta la sintaxis documentada de MySQL sin el error del analizador informado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- mysql, rust
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100