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

CREATE TABLE .. LIKE I_S table is replicated with a wrong character set

    XMLWordPrintable

Details

    Description

      Note: GLOBAL_STATUS is taken as an example, the same can be reproduced with different information_schema tables.

      --source include/have_binlog_format_row.inc
      --source include/master-slave.inc
       
      # Not needed for MTR, but just in case
      CREATE DATABASE db CHARACTER SET latin1;
       
      CREATE TABLE db.t LIKE information_schema.GLOBAL_STATUS;
      SHOW CREATE TABLE db.t;
       
      --sync_slave_with_master
       
      SHOW CREATE TABLE db.t;
       
      --connection master
      INSERT INTO db.t VALUES ('foo','bar');
       
      --sync_slave_with_master
       
      # Cleanup
      --connection master
      DROP DATABASE db;
      --source include/rpl_end.inc
      

      10.4 f5dceafd

      SHOW CREATE TABLE db.t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `VARIABLE_NAME` varchar(64) NOT NULL,
        `VARIABLE_VALUE` varchar(2048) NOT NULL
      ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
      connection slave;
      SHOW CREATE TABLE db.t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `VARIABLE_NAME` varchar(64) NOT NULL,
        `VARIABLE_VALUE` varchar(2048) NOT NULL
      ) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
      

      2023-06-27 22:16:37 13 [ERROR] Slave SQL: Column 0 of table 'db.t' cannot be converted from type 'varchar(192 octets)' to type 'varchar(64 octets) character set latin1', Gtid 0-1-3, Internal MariaDB error code: 1677
      

      The problem can already be seen after CREATE, as the table's character set is different on master and slave. Further INSERT only shows how replication actually breaks.

      On master, CREATE ... LIKE works properly and creates a table with the same character set as the I_S table, which is utf8.
      However, when it is written into the binlog, it is converted from CREATE .. LIKE into an explicit CREATE statement. Probably it's special logic for information_schema, as it doesn't seem to happen for just any table.
      All in all, the event in the binlog looks like this:

      #230627 22:16:37 server id 1  end_log_pos 705 CRC32 0x9a36f132  Query   thread_id=9     exec_time=0     error_code=0
      use `test`/*!*/;
      SET TIMESTAMP=1687893397/*!*/;
      CREATE TABLE `db`.`t` (
        `VARIABLE_NAME` varchar(64) NOT NULL,
        `VARIABLE_VALUE` varchar(2048) NOT NULL
      ) ENGINE=MEMORY
      /*!*/;
      

      Note that it doesn't specify the character set, so it's created with the database's default, which is in this case latin1.

      Attachments

        Activity

          People

            Elkin Andrei Elkin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.