Visitar URL original
[BUG] JSQLParser Version : MySQL 8.x : Drop and add index SQL parse error · Issue #2369 · JSQLParser/JSqlParser · GitHub
Skip to content

[BUG] JSQLParser Version : MySQL 8.x : Drop and add index SQL parse error #2369

Description

@wxpid1

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

Drop and add index SQL parse error

SQL Example:

  • Simplified Query Example, focusing on the failing feature
                ALTER TABLE `wxp_dm`.`xqgl_req_report`s
                 DROP INDEX `index_name`,
                 ADD UNIQUE INDEX `index_name`(`report_name` ASC) USING BTREE;

Error Message:
Caused by: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ASC" "ASC"
at line 3, column 46.

Was expecting one of:

")"
","

at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:352)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:125)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:91)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:64)
at com.wxp.dm.utils.MysqlToDmUtils.alterTableSql(MysqlToDmUtils.java:690)
... 4 more

Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ASC" "ASC"
at line 3, column 46.

Was expecting one of:

")"
","

at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:345)
... 8 more

Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ASC" "ASC"
at line 3, column 46.

Was expecting one of:

")"
","

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:53111)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:52929)
at net.sf.jsqlparser.parser.CCJSqlParser.ColumnsNamesList(CCJSqlParser.java:28854)
at net.sf.jsqlparser.parser.CCJSqlParser.AlterExpression(CCJSqlParser.java:30776)
at net.sf.jsqlparser.parser.CCJSqlParser.AlterTable(CCJSqlParser.java:32492)
at net.sf.jsqlparser.parser.CCJSqlParser.Alter(CCJSqlParser.java:32406)
at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:547)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:413)

Activity

  1. dengliming commented on Feb 24, 2026

    @dengliming
    Contributor

    I solved this problem with minimal changes dengliming@f43531b, but not sure if this is the best solution, I see have introduced ColumnNamesWithParamsList before this, if unified use this, the change place is large and has a risk, can you help me look at it? @manticore-projects

  2. manticore-projects commented on Feb 24, 2026

    @manticore-projects
    Contributor

    @dengliming: In my opinion, we need to rework the ALTER TABLE ... stuff completely although I have very little interest in parsing DDL statements.

    So in my opinion, the approach of "minimal changes" here is good enough since ALTER TABLE ... is a big mess already and any more work around won't harm it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions