Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-39985

Redundant CHECK in CREATE TABLE makes it bypass the type check

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 11.4, 11.8, 12.3, 13.1
    • N/A
    • Documentation, JSON
    • None

    Description

      Hi,

      I found that when creating a table with a JSON column, if there is another CHECK, the INSERT statement can bypass the type check. There is an example:

      CREATE TABLE t1 (
        j JSON CHECK (OCTET_LENGTH(j) > 0)
      );
       
      INSERT INTO t1 VALUES ('x'); -- success
      SELECT j, JSON_VALID(j) AS is_valid FROM t1 ORDER BY j; -- x    0
      

      If I remove the `CHECK (OCTET_LENGTH(j) > 0)` expression, the INSERT statement will trigger the error `CONSTRAINT `t1.j` failed for `codex_mariadb_json_batch_0321_typecheck`.`t1``

      Attachments

        Issue Links

          Activity

            People

              maxmether Max Mether
              ChiZhang Chi Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.