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

CHECK constraint fails on intermediate step of ALTER

    XMLWordPrintable

Details

    • 10.2.6-3

    Description

      MariaDB [test]> create table t1 (a int, check(a>0 or a is null));
      Query OK, 0 rows affected (0.41 sec)
       
      MariaDB [test]> insert into t1 values (null);
      Query OK, 1 row affected (0.06 sec)
       
      MariaDB [test]> alter table t1 modify a int auto_increment primary key;
      ERROR 4025 (23000): CONSTRAINT `CONSTRAINT_1` failed for `test`.`#sql-4c9e_4`
      

      If there were no CHECK, a column would have been given the value 1 which actually satisfies the condition.

      MariaDB [test]> set check_constraint_checks=0;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> alter table t1 modify a int auto_increment primary key;
      Query OK, 1 row affected (1.01 sec)
      Records: 1  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> select * from t1;
      +---+
      | a |
      +---+
      | 1 |
      +---+
      1 row in set (0.00 sec)
      

      But apparently the column gets the intermediate value 0 which is checked before the auto_increment is applied.

      Attachments

        Issue Links

          Activity

            People

              jacob-mathew Jacob Mathew (Inactive)
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.