Skip to content

mysql: DROP INDEX idx_xxx on t and an error occurs #1863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vimko opened this issue May 27, 2025 · 0 comments
Open

mysql: DROP INDEX idx_xxx on t and an error occurs #1863

vimko opened this issue May 27, 2025 · 0 comments

Comments

@vimko
Copy link

vimko commented May 27, 2025

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.

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.

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?

@vimko vimko changed the title mysql: DROP INDEX and an error occurs mysql: DROP INDEX idx_xxx on t and an error occurs May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant