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

Keys can be disabled in partitions inconsistently, leading to error "Wrong index given to a function"

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • 11.4, 11.8, 12.3
    • Partitioning
    • None

    Description

      --source include/have_partition.inc
       
      CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM
      PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
      INSERT INTO t1 VALUES (1),(1);
      ALTER TABLE t1 DISABLE KEYS;
      CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (2),(2),(2);
      ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
       
      SELECT COUNT(*) FROM t1 WHERE a = 1;
       
      DROP TABLE t1, t2;
      

      main f6d172c03bf3cd71fd30ac9cc7b24fd64497b472

      mysqltest: At line 11: query 'SELECT COUNT(*) FROM t1 WHERE a = 1' failed: ER_GET_ERRNO (1030): Got error 124 "Wrong index given to a function" from storage engine MyISAM
      

      Also reproducible with Aria.

      There was a similar bug MDEV-3978 with REBUILD PARTITION, apparently the fix wasn't generic enough.

      A more obscure effect of the same problem is a replication failure:

      --source include/have_partition.inc
      --source include/have_binlog_format_row.inc
      --source include/master-slave.inc
       
      CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM
      PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
      INSERT INTO t1 VALUES (1);
      ALTER TABLE t1 DISABLE KEYS;
      CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (2),(2);
      ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
      DELETE FROM t1;
      --sync_slave_with_master
       
      --connection master
      DROP TABLE t1, t2;
      --source include/rpl_end.inc 
      

      Last_Errno      1030
      Last_Error      Could not execute Delete_rows_v1 event on table test.t1; Got error 124 "Wrong index given to a function" from storage engine MyISAM, Error_code: 1030; handler error HA_ERR_WRONG_INDEX; the event's master log master-bin.000001, end_log_pos 0
      

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              elenst Elena Stepanova
              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.