diff --git a/mysql-test/mysql-source-code-meta.patch b/mysql-test/mysql-source-code-meta.patch index ebcd454c1bba67b6025aaf85ce8289c2f655b2ae..2bad40ac50886d5f5322fad8c27e9c44a24e5df1 100644 --- a/mysql-test/mysql-source-code-meta.patch +++ b/mysql-test/mysql-source-code-meta.patch @@ -1786,7 +1786,7 @@ index c171f0bb..6fc75f7c 100644 Initialize the transactional ddl context when executing CREATE TABLE ... SELECT command with engine which supports atomic DDL. diff --git a/sql/sql_class.h b/sql/sql_class.h -index 9f68530b..8a767cd7 100644 +index 9f68530b..21598829 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -841,6 +841,7 @@ class THD : public MDL_context_owner, @@ -1805,7 +1805,16 @@ index 9f68530b..8a767cd7 100644 /** Current query partial plans. @sa system_status_var::last_query_partial_plans -@@ -4417,6 +4419,29 @@ class THD : public MDL_context_owner, +@@ -2573,6 +2575,8 @@ class THD : public MDL_context_owner, + state here. This member is valid only when executing code during parsing. + */ + Parser_state *m_parser_state; ++ ++ size_t before_semic_length; + + Locked_tables_list locked_tables_list; + +@@ -4417,6 +4421,29 @@ class THD : public MDL_context_owner, @param thd parent session */ void copy_table_access_properties(THD *thd); @@ -2023,6 +2032,27 @@ index 70d9c1ff..c4a54c69 100644 } return error; } +diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc +index 15b1640f..88020d3c 100644 +--- a/sql/sql_parse.cc ++++ b/sql/sql_parse.cc +@@ -4931,9 +4931,14 @@ void dispatch_sql_command(THD *thd, Parser_state *parser_state) { + + if (!err) { + err = parse_sql(thd, parser_state, nullptr); +- if (!err) err = invoke_post_parse_rewrite_plugins(thd, false); +- + found_semicolon = parser_state->m_lip.found_semicolon; ++ thd->before_semic_length = 0; ++ if (!err && !thd->is_error()) { ++ if (found_semicolon && (ulong)(found_semicolon - thd->query().str)) { ++ thd->before_semic_length = static_cast(found_semicolon - thd->query().str - 1); ++ } ++ } ++ if (!err) err = invoke_post_parse_rewrite_plugins(thd, false); + } + + DEBUG_SYNC_C("sql_parse_before_rewrite"); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 3860d342..a8c14830 100644 --- a/sql/sql_plugin.cc @@ -3990,13 +4020,13 @@ index e949235a..d46fca83 100644 opened_table_validate(); diff --git a/cmake/info_macros.cmake.in b/cmake/info_macros.cmake.in -index 19110c7a..131a4c69 100644 +index 19110c7a..a9e35b58 100644 --- a/cmake/info_macros.cmake.in +++ b/cmake/info_macros.cmake.in @@ -106,6 +106,7 @@ MACRO(CREATE_INFO_SRC target_dir) ELSE() # This is a fall-back. FILE(WRITE ${INFO_SRC} "\nMySQL source ${VERSION}\n") -+ FILE(APPEND ${INFO_SRC} "\nCantian patch source 1.0.3\n") ++ FILE(APPEND ${INFO_SRC} "\nCantian patch source 1.0.4\n") ENDIF() - ENDMACRO(CREATE_INFO_SRC) \ No newline at end of file + ENDMACRO(CREATE_INFO_SRC) diff --git a/storage/ctc/ctc_ddl_rewriter_plugin.cc b/storage/ctc/ctc_ddl_rewriter_plugin.cc index 45fc29a76a2510f5712ead47446404ccd6ebb19c..54f21ae0c423a7c074f6855eb689c46216a062dd 100644 --- a/storage/ctc/ctc_ddl_rewriter_plugin.cc +++ b/storage/ctc/ctc_ddl_rewriter_plugin.cc @@ -1148,7 +1148,11 @@ int ctc_record_sql(MYSQL_THD thd, bool need_select_db) { broadcast_req.options |= CTC_NOT_NEED_CANTIAN_EXECUTE; broadcast_req.options |= (thd->lex->contains_plaintext_password ? CTC_CURRENT_SQL_CONTAIN_PLAINTEXT_PASSWORD : 0); - string sql = string(thd->query().str).substr(0, thd->query().length); + size_t len = thd->query().length; +#ifdef METADATA_NORMALIZED + len = thd->before_semic_length == 0 ? thd->query().length : thd->before_semic_length; +#endif + string sql = string(thd->query().str).substr(0, len); FILL_BROADCAST_BASE_REQ(broadcast_req, sql.c_str(), thd->m_main_security_ctx.priv_user().str, thd->m_main_security_ctx.priv_host().str, ctc_instance_id, (uint8_t)thd->lex->sql_command); diff --git a/storage/ctc/ctc_meta_data.cc b/storage/ctc/ctc_meta_data.cc index 89207c192b72488a347fbf0f559291f409cd7c11..586182c3b993c8fdb817ae18911824a94c45fbe4 100644 --- a/storage/ctc/ctc_meta_data.cc +++ b/storage/ctc/ctc_meta_data.cc @@ -430,6 +430,10 @@ template static typename std::enable_if::type ctc_invalidate_mysql_dd_cache_impl(ctc_handler_t *tch, ctc_invalidate_broadcast_request *broadcast_req, int *err_code) { UNUSED_PARAM(err_code); + if (!is_work_flow()) { + ctc_log_system("[ctc_invalidate_mysql_dd_cache_impl]: mysqld is not started."); + return 0; + } // 相同节点不用执行 if (broadcast_req->mysql_inst_id == ctc_instance_id) { ctc_log_note("ctc_invalidate_mysql_dd_cache curnode not need execute,mysql_inst_id:%u", broadcast_req->mysql_inst_id); @@ -618,6 +622,10 @@ static void ctc_init_mdl_request(ctc_lock_table_info *lock_info, MDL_request *md } int ctc_mdl_lock_thd(ctc_handler_t *tch, ctc_lock_table_info *lock_info, int *err_code) { + if (!is_work_flow()) { + ctc_log_system("[ctc_mdl_lock_thd]: mysqld is not started."); + return false; + } bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = ctc_get_conn_key(tch->inst_id, tch->thd_id, true); @@ -754,6 +762,10 @@ void ctc_mdl_unlock_tables_thd(ctc_handler_t *tch, MDL_request *mdl_request) } void ctc_mdl_unlock_thd(ctc_handler_t *tch, ctc_lock_table_info *lock_info) { + if (!is_work_flow()) { + ctc_log_system("[ctc_mdl_unlock_thd]: mysqld is not started."); + return; + } bool is_same_node = (tch->inst_id == ctc_instance_id); uint64_t mdl_thd_key = ctc_get_conn_key(tch->inst_id, tch->thd_id, true); diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index 94c4658d786e1193ad8548789f7308494bbe7778..772d26c38408e05517b3e065c42b18b105b4caf1 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -1520,10 +1520,13 @@ bool is_dml_cmd(const String& sql) static int ctc_commit(handlerton *hton, THD *thd, bool commit_trx) { DBUG_TRACE; BEGIN_RECORD_STATS - bool is_alter_copy = is_alter_table_copy(thd); - if (engine_ddl_passthru(thd) && (is_alter_copy || is_create_table_check(thd) || is_lock_table(thd))) { - END_RECORD_STATS(EVENT_TYPE_COMMIT) - return 0; + bool is_alter_copy = false; + if (engine_ddl_passthru(thd)) { + is_alter_copy = is_alter_table_copy(thd); + if (is_alter_copy || is_create_table_check(thd) || is_lock_table(thd)) { + END_RECORD_STATS(EVENT_TYPE_COMMIT) + return 0; + } } ctc_handler_t tch; diff --git a/storage/ctc/ha_ctc.h b/storage/ctc/ha_ctc.h index e635898c2d178d69661853822a35293ff7e0aa97..839fd81a65fadaecbd99a7dbb5abf972ea94eabe 100644 --- a/storage/ctc/ha_ctc.h +++ b/storage/ctc/ha_ctc.h @@ -1094,6 +1094,7 @@ int alloc_str_mysql_mem(ctc_cbo_stats_t *cbo_stats, uint32_t part_num, TABLE *ta void free_columns_cbo_stats(ctc_cbo_stats_column_t *ctc_cbo_stats_columns, bool *is_str_first_addr, TABLE *table); int32_t ctc_get_shm_file_num(uint32_t *shm_file_num); int32_t ctc_get_shm_usage(uint32_t *ctc_shm_usage); +bool is_work_flow(); #pragma GCC visibility pop #endif \ No newline at end of file