apache / apache/datafusion-sqlparser-rs
mysql: `DROP INDEX idx_xxx on t` and an error occurs
- Linguagem predominante
- Rust
- Estrelas
- 3.5k
- Forks
- 772
- Merge médio
- 4d 9h
- PRs com merge (30d)
- 17
Descrição
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?
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Reproduza a falha por meio de MySqlDialect e Parser::parse_sql usando tanto a forma DROP INDEX ... ON ... quanto a forma ALTER TABLE ... DROP INDEX. Rastreie como essas instruções são analisadas e verifique se a cobertura de regressão aceita a sintaxe documentada do MySQL sem o erro do parser relatado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- mysql, rust
- Domínio
- databases
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100