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

Check constraints on INSERT on non-specified virtual columns not checked when NULL is allowed

    XMLWordPrintable

Details

    Description

      When there is a CHECK constraint on a virtual column that allows NULL and the column is not specified in an INSERT, then the constraint is not checked:

      CREATE TABLE tv2(c1 int, c2 int AS (c1 + 1) VIRTUAL, CHECK (c2 is null or c2 > 2));
      

      The following fails, which is correct:

      INSERT INTO tv2 VALUES(1,1);
      

      The following succeeds, which is also correct:

      INSERT INTO tv2 VALUES(2,1);
      

      The following though is also successful, which is incorrect (c2 will have the value 2):

      INSERT INTO tv2(c1) VALUES(1);
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              karlsson Anders Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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