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

RENAME TABLE allows InnoDB to replace mysql.general_log

    XMLWordPrintable

Details

    Description

      MariaDB 12.3.3 allows an atomic RENAME TABLE to replace the CSV-backed mysql.general_log table with an InnoDB table. The rename succeeds and information_schema.TABLES reports InnoDB for the protected log-table identity.

      This occurs when an atomic RENAME TABLE replaces a protected log table with a table using an ineligible storage engine.

      Reproducer

      Run the following as an administrative user. It disables general logging, performs the swap, records the installed engine, and immediately restores the original table and global setting.

      CREATE DATABASE IF NOT EXISTS test;
      SET @saved_general_log=@@GLOBAL.general_log;
      SET GLOBAL general_log=OFF;
      DROP TABLE IF EXISTS test.log_candidate;
      DROP TABLE IF EXISTS test.log_moved;
      CREATE TABLE test.log_candidate (a INT) ENGINE=InnoDB;
       
      SELECT ENGINE AS original_engine
      FROM information_schema.TABLES
      WHERE TABLE_SCHEMA='mysql' AND TABLE_NAME='general_log';
       
      RENAME TABLE
        mysql.general_log TO mysql.general_log_backup,
        test.log_candidate TO mysql.general_log;
       
      SELECT ENGINE AS installed_engine
      FROM information_schema.TABLES
      WHERE TABLE_SCHEMA='mysql' AND TABLE_NAME='general_log';
       
      RENAME TABLE
        mysql.general_log TO test.log_moved,
        mysql.general_log_backup TO mysql.general_log;
      DROP TABLE test.log_moved;
       
      SELECT ENGINE AS restored_engine
      FROM information_schema.TABLES
      WHERE TABLE_SCHEMA='mysql' AND TABLE_NAME='general_log';
      SET GLOBAL general_log=@saved_general_log;

      Observed result

      The first rename succeeds and installs the InnoDB table as mysql.general_log:

      original_engine
      CSV
      installed_engine
      InnoDB
      restored_engine
      CSV

      The inverse rename restores the original CSV table successfully.

      Expected result

      The first RENAME TABLE should fail and leave the CSV-backed mysql.general_log in place. MariaDB rejects InnoDB for this protected log-table identity through the engine-eligibility check used by CREATE and ALTER; changing the table's identity through RENAME should enforce the same invariant.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              imchifan 刘启帆
              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.