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

RENAME TABLE does not check for existence of the table's engine

    XMLWordPrintable

Details

    • 10.0.20

    Description

      When RENAME TABLE is executed, it apparently does not check whether the engine is available (unlike ALTER TABLE .. RENAME, which does). It means that if the engine in question was not loaded on some reason, the table might become unusable, since the engine won't know about the change.

      It was an upstream bug, which existed in previous versions as well, but it seems to be fixed in 5.7. Given how many engines we have and how easy it is to get this problem accidentally, maybe it makes sense to consider backporting the fix into 10.0.

      The test case below uses InnoDB to be universal for MariaDB and MySQL, so it looks a bit of a stretch. In reality, I encountered the problem with TokuDB, and it was really just a human error:

      • started the server with plugin-dir where ha_tokudb.so lived;
      • installed TokuDB engine;
      • created a TokuDB table;
      • then at some point I restarted the server, but with a different plugin-dir which did not have TokuDB;
      • since TokuDB is not a default engine or anything, server didn't have any problem starting;
      • I then renamed the table, which it did happily;
      • then I restarted the server again with the right plugin-dir, but TokuDB would not recognize the table any longer.

      Test case:

      --source include/have_innodb.inc
       
      create table t1 (i int) engine=InnoDB;
       
      --enable_reconnect
       
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      wait
      EOF
      --shutdown_server 30
      --source include/wait_until_disconnected.inc
       
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      restart: --skip-innodb --default-storage-engine=myisam --loose-default-tmp-storage-engine=myisam
      EOF
       
      --source include/wait_until_connected_again.inc
       
      rename table t1 to t2;
       
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      wait
      EOF
      --shutdown_server 30
      --source include/wait_until_disconnected.inc
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      restart
      EOF
      --source include/wait_until_connected_again.inc
       
      show tables;
      show create table t2;

      Fixing it is not that easy, simple reverse rename does not work, you have to repeat the whole exercise – start server without the engine, rename the table back, start server with the engine...

      Attachments

        Issue Links

          Activity

            People

              svoj Sergey Vojtovich
              elenst Elena Stepanova
              Votes:
              1 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.