When I used ClickHouse's MaterializeMySQL feature to synchronize data from MySQL to ClickHouse, I had some problems. The Click House version I'm using is 20.10.3.30, and the MySQL version I'm using is 5.7.28-log.

The SQL statement I executed is as follows:
> SET allow_experimental_database_materialize_mysql = 1;
drop database if exists ck_test;
CREATE DATABASE if not exists ck_test ENGINE = MaterializeMySQL('x.x.x.x:3306', 'test', 'user', 'test');


After I executed the SQL statement, I saw the following information from the error log /var/log/clickhouse-server/clickhouse-server.err. Log:

> 2020.11.10 20:27:39.611578 [ 33057 ] {} <Error> MaterializeMySQLSyncThread: Code: 20, e.displayText() = DB::Exception: mysqlxx::UseQueryResult contains 4 columns while 2 expected, Stack trace (when copying this message, always include the lines below):

> 0. DB::MySQLBlockInputStream::MySQLBlockInputStream(mysqlxx::Pool::Entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Block const&, unsigned long, bool) @ 0xe587457 in /usr/bin/clickhouse

> 1. DB::MaterializeMetadata::MaterializeMetadata(mysqlxx::Pool::Entry&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdb1cbf3 in /usr/bin/clickhouse

> 2. DB::MaterializeMySQLSyncThread::prepareSynchronized(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdaf8bf1 in /usr/bin/clickhouse

> 3. DB::MaterializeMySQLSyncThread::synchronization(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0xdaf836a in /usr/bin/clickhouse

> 4. ? @ 0xdb1480d in /usr/bin/clickhouse

> 5. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x7b8963d in /usr/bin/clickhouse

> 6. ? @ 0x7b8d153 in /usr/bin/clickhouse

> 7. start_thread @ 0x7dd5 in /usr/lib64/libpthread-2.17.so

> 8. __clone @ 0xfdead in /usr/lib64/libc-2.17.so

>  (version 20.10.3.30 (official build))


Does anybody have a problem like this?
mysqlxx::Pool::Entry & connection, MaterializeMetadata & master_info,
    const String & query_prefix, const String & database_name, const String & mysql_database_name,
    const Context & context, const std::function<bool()> & is_cancelled)
{
    auto iterator = master_info.need_dumping_tables.begin();
    for (; iterator != master_info.need_dumping_tables.end() && !is_cancelled(); ++iterator)
    {
        const auto & table_name = iterator->first;
        Context query_context = createQueryContext(context);
        String comment = "Materialize MySQL step 1: execute MySQL DDL for dump data";
        tryToExecuteQuery(query_prefix + " " + iterator->second, query_context, database_name, comment); 
        auto out = std::make_shared<CountingBlockOutputStream>(getTableOutput(database_name, table_name, query_context));
        MySQLBlockInputStream input(
            connection, "SELECT * FROM " + backQuoteIfNeed(mysql_database_name) + "." + backQuoteIfNeed(table_name),
            out->getHeader(), DEFAULT_BLOCK_SIZE);
        Stopwatch watch;
        copyData(input, *out, is_cancelled);
        const Progress & progress = out->getProgress();
        LOG_INFO(&Poco::Logger::get("MaterializeMySQLSyncThread(" + database_name + ")"),
            "Materialize MySQL step 1: dump {}, {} rows, {} in {} sec., {} rows/sec., {}/sec."
            , table_name, formatReadableQuantity(progress.written_rows), formatReadableSizeWithBinarySuffix(progress.written_bytes)
            , watch.elapsedSeconds(), formatReadableQuantity(static_cast<size_t>(progress.written_rows / watch.elapsedSeconds()))
            , formatReadableSizeWithBinarySuffix(static_cast<size_t>(progress.written_bytes / watch.elapsedSeconds())));
    }
}
static inline UInt32 randomNumber()