diff --git a/sql/log_event.cc b/sql/log_event.cc index 145bab46f23e..0916f11349f4 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3035,6 +3035,15 @@ Slave_worker *Log_event::get_slave_worker(Relay_log_info *rli) { #ifndef NDEBUG w_rr++; #endif + } else if (opt_ctas_compatibility_mode && is_ctas()) { + /* + In ctas compatibility there will be intermediate commit + after CREATE TABLE. It will call pre_commit hook, which will call + Slave_worker::commit_positions() where we check the validity of + ptr_group->checkpoint_seqno. + */ + ptr_group->checkpoint_seqno = rli->rli_checkpoint_seqno; + rli->rli_checkpoint_seqno++; } return ret_worker; diff --git a/sql/log_event.h b/sql/log_event.h index 1d5a2116ae96..cbd8186dd43a 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1099,6 +1099,7 @@ class Log_event { false otherwise */ virtual bool ends_group() const { return false; } + virtual bool is_ctas() const { return false; } #ifdef MYSQL_SERVER /** Apply the event to the database. @@ -1471,6 +1472,12 @@ class Query_log_event : public virtual binary_log::Query_event, native_strncasecmp(query, STRING_WITH_LEN("ROLLBACK TO "))) || !strncmp(query, STRING_WITH_LEN("XA ROLLBACK")); } + + bool is_ctas() const override { + return (strstr(query, "CREATE TABLE") != nullptr) && + (strstr(query, "START TRANSACTION") != nullptr); + } + static size_t get_query(const char *buf, size_t length, const Format_description_event *fd_event, const char **query_arg);