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

CREATE INDEX on virtual column ignores errors due to concurrent DML

    XMLWordPrintable

    Details

      Description

      A peculiar design constraint of MariaDB virtual columns is that evaluation errors for non-indexed virtual columns are allowed (only reported when attempting to read from the virtual column).

      If an index on a virtual column exists, then an INSERT that causes (say) a division by 0 would be rejected, like the test case below shows. But, we are not consistently enforcing this rule during online CREATE INDEX: we wrongly allow erroneous data to be inserted into the secondary indexes as NULL values.

      --source include/have_innodb.inc
      --source include/have_debug.inc
      --source include/have_debug_sync.inc
       
      CREATE TABLE t(a INT, b INT AS (a/a) VIRTUAL) ENGINE=InnoDB;
       
      INSERT INTO t SET a=0;
      SELECT * FROM t;
      DELETE FROM t;
       
      ALTER TABLE t ADD INDEX(b);
      --error ER_DIVISION_BY_ZERO
      INSERT INTO t SET a=0;
       
      ALTER TABLE t DROP INDEX b;
       
      connect (con1,localhost,root,,);
      SET DEBUG_SYNC = 'row_log_apply_before SIGNAL scanned WAIT_FOR apply';
      send ALTER TABLE t ADD INDEX(b);
       
      connection default;
      SET DEBUG_SYNC = 'now WAIT_FOR scanned';
      INSERT INTO t SET a=0;
      SET DEBUG_SYNC = 'now SIGNAL apply';
       
      connection con1;
      --echo # ERROR 1: The ALTER TABLE fails to fail!
      #--error ER_DIVISION_BY_ZERO
      reap;
      connection default;
       
      SELECT * FROM t;
      CHECK TABLE t;
       
      DELETE FROM t;
      ALTER TABLE t DROP INDEX b;
      connection con1;
      SET DEBUG_SYNC = 'row_log_apply_after SIGNAL applied WAIT_FOR commit';
      send ALTER TABLE t ADD INDEX(b);
       
      connection default;
      SET DEBUG_SYNC = 'now WAIT_FOR applied';
      INSERT INTO t SET a=0;
      SET DEBUG_SYNC = 'now SIGNAL commit';
       
      connection con1;
      --echo # ERROR 2: The ALTER TABLE fails to fail!
      #--error ER_DIVISION_BY_ZERO
      reap;
      connection default;
       
      CHECK TABLE t;
      SELECT * FROM t;
      SHOW CREATE TABLE t;
       
      SET DEBUG_SYNC = RESET;
      DROP TABLE t;
      

      I think that the logic needs to be fixed so that both ERROR cases highlighted by the test will be reported correctly.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nikitamalyavin Nikita Malyavin
              Reporter:
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.