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

UNIQUE column checks fail in InnoDB resulting in table corruption

    XMLWordPrintable

Details

    Description

      SET autocommit=0,foreign_key_checks=0,unique_checks=0;
      CREATE TABLE t (c1 INT KEY,c2 INT,UNIQUE (c2)) ENGINE=InnoDB;
      INSERT INTO t VALUES (1,0),(2,0);  # Should fail with ERROR 1062 (23000): Duplicate entry '0' for key 'c2'
      CREATE TABLE t (c2 INT);
      CHECK TABLE t;
      

      Leads to:

      10.7.1 12eb8ad7b98b03a6a7659fce7b75bdc8696ccaf6 (Optimized/Debug)

      10.7.1-dbg>SET autocommit=0,foreign_key_checks=0,unique_checks=0;
      Query OK, 0 rows affected (0.000 sec)
       
      10.7.1-dbg>CREATE TABLE t (c1 INT KEY,c2 INT,UNIQUE (c2));
      Query OK, 0 rows affected (0.023 sec)
       
      10.7.1-dbg>INSERT INTO t VALUES (1,0),(2,0);  # Should fail with ERROR 1062 (23000): Duplicate entry '0' for key 'c2'
      Query OK, 2 rows affected (0.007 sec)
      Records: 2  Duplicates: 0  Warnings: 0
       
      10.7.1-dbg>CREATE TABLE t (c2 INT);
      ERROR 1050 (42S01): Table 't' already exists
      10.7.1-dbg>CHECK TABLE t;
      +--------+-------+----------+-----------------------------------------------------+
      | Table  | Op    | Msg_type | Msg_text                                            |
      +--------+-------+----------+-----------------------------------------------------+
      | test.t | check | Warning  | InnoDB: Index 'c2' contains 0 entries, should be 2. |
      | test.t | check | error    | Corrupt                                             |
      +--------+-------+----------+-----------------------------------------------------+
      2 rows in set (0.002 sec)
      

      10.7.1 12eb8ad7b98b03a6a7659fce7b75bdc8696ccaf6 (Optimized/Debug)

      2021-11-01  8:41:40 4 [ERROR] InnoDB: Flagged corruption of `c2` in table `test`.`t` in CHECK TABLE; Wrong count
      

      Bug confirmed present in:
      MariaDB: 10.7.1 (dbg), 10.7.1 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.41 (dbg), 10.2.41 (opt), 10.3.32 (dbg), 10.3.32 (opt), 10.4.22 (dbg), 10.4.22 (opt), 10.5.13 (dbg), 10.5.13 (opt), 10.6.5 (dbg), 10.6.5 (opt)

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              Roel Roel Van de Paar
              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.