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

Instant ALTER allows to violate column check constraint

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      create table t (a int) engine=InnoDB;
      insert into t values (0);
      alter table t add b int default 0 check(b!=a);
      show create table t;
      select * from t;
       
      # Cleanup
      drop table t;
      

      10.4 ff3d4395

      alter table t add b int default 0 check(b!=a);
      show create table t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `a` int(11) DEFAULT NULL,
        `b` int(11) DEFAULT 0 CHECK (`b` <> `a`)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
      select * from t;
      a	b
      0	0
      

      An even simpler, but a degenerate test case is

      create table t (a int) engine=InnoDB;
      insert into t values (0);
      alter table t add b int check(a!=a);
      

      Result is the same.

      Not reproducible with algorithm=copy.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              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.