From e37213b7b39d4b1653ff46cefcf3f772bb406c8d Mon Sep 17 00:00:00 2001 From: qichang Date: Mon, 17 Feb 2025 20:06:36 +0800 Subject: [PATCH] fix sys_table analyze error --- storage/ctc/ha_ctc.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index ca2d8a4..ccc1b0c 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -3201,12 +3201,29 @@ bool requires_stats_info(enum_sql_command sql_command) { } } +bool is_sys_table(const char* name) { + if (strcmp(name, "information_schema") == 0 || + strcmp(name, "mysql") == 0 || + strcmp(name, "performance_schema") == 0 || + strcmp(name, "sys") == 0) { + return true; + } + return false; +} + /* Handle the statistics are empty case, prevent full-table scan by query_sql with where_cond */ ct_errno_t ha_ctc::handle_cbo_stats_empty(THD* thd) { ct_errno_t ret = CT_SUCCESS; + + // sys_table can't analyzed + const char* db_name = thd->lex->query_tables->get_db_name(); + if (is_sys_table(db_name)) { + return CT_SUCCESS; + } + if (stats.records == 0 && requires_stats_info(thd->lex->sql_command) && thd->lex->query_block->where_cond() != nullptr) { std::lock_guard lock(analyze_mutex); -- Gitee