Skip to content

[BUG] 5.4-SNAPSHOT: MySQL CHECK constraint ENFORCED clauses fail to parse #2526

Description

@minleejae

Failing SQL feature

MySQL table-level CHECK constraints followed by ENFORCED or NOT ENFORCED cannot be parsed.

SQL example

CREATE TABLE mysql_check_enforcement (
    score INT,
    CONSTRAINT chk_positive CHECK (score >= 0) ENFORCED,
    CONSTRAINT chk_cap CHECK (score < 100) NOT ENFORCED
);

Actual behavior

JSqlParser 5.4-SNAPSHOT at 9a32ff568f580178d9a27b101596aa43eb45d0b7 throws ParseException at the first ENFORCED token. The same failure occurs when only NOT ENFORCED is present.

Expected behavior

The statement should parse as CreateTable, deparse losslessly, and expose the enforcement state on CheckConstraint as a structured enum or nullable Boolean.

Software information and server validation

This is separate from optional constraint/index names tracked in #1570.

AI assistance

OpenAI Codex was used to assemble and execute the parser/server comparison. The case was checked against the MySQL 8.4 documentation and an actual MySQL 8.4.11 server.

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