JSQLParser / JSqlParser

JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
https://github.com/JSQLParser/JSqlParser/wiki
Apache License 2.0
5.34k stars 1.34k forks source link

[BUG] 5.0 : MySQL : Parsing ALTER TABLE statement with `CHARACTER SET` fails #2027

Closed jakobmerrild closed 2 months ago

jakobmerrild commented 3 months ago

Failing SQL Feature:

Trying to parse an ALTER TABLE statement for MySQL fails when the column definition contains the CHARACTER SET keywords. Encountering the following error

ParseException: Encountered unexpected token: "SET" "SET"
    at line 2, column 55.

Was expecting one of:

    ","
    <EOF>
    <ST_SEMICOLON>

SQL Example:

ALTER TABLE `foo_bar`
    ADD COLUMN `baz` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
    ALGORITHM = INSTANT;

Software Information:

Additional information

The failing code is

CCJSqlParserUtil.parseStatements(fileContent)

where fileContent is a String containing the entire content of the SQL file.

manticore-projects commented 3 months ago

Greetings.

a PR was needed and you would need to either provide or sponsor this specific implementation.