diff --git a/mysql-test/suite/tianmu/r/issue342.result b/mysql-test/suite/tianmu/r/issue342.result index fc905eaf8..efa78e1c3 100644 --- a/mysql-test/suite/tianmu/r/issue342.result +++ b/mysql-test/suite/tianmu/r/issue342.result @@ -1,9 +1,9 @@ USE test; CREATE TABLE `lineitem_i342` ( -`l_orderkey` int(11) NOT NULL, -`l_partkey` int(11) NOT NULL, -`l_suppkey` int(11) NOT NULL, -`l_linenumber` int(11) NOT NULL, +`l_orderkey` int NOT NULL, +`l_partkey` int NOT NULL, +`l_suppkey` int NOT NULL, +`l_linenumber` int NOT NULL, `l_quantity` decimal(15,2) NOT NULL, `l_extendedprice` decimal(15,2) NOT NULL, `l_discount` decimal(15,2) NOT NULL, diff --git a/mysql-test/suite/tianmu/t/issue342.testbak b/mysql-test/suite/tianmu/t/issue342.test similarity index 97% rename from mysql-test/suite/tianmu/t/issue342.testbak rename to mysql-test/suite/tianmu/t/issue342.test index 103c3caa6..ab9b4f40f 100644 --- a/mysql-test/suite/tianmu/t/issue342.testbak +++ b/mysql-test/suite/tianmu/t/issue342.test @@ -1,9 +1,9 @@ USE test; CREATE TABLE `lineitem_i342` ( -`l_orderkey` int(11) NOT NULL, -`l_partkey` int(11) NOT NULL, -`l_suppkey` int(11) NOT NULL, -`l_linenumber` int(11) NOT NULL, +`l_orderkey` int NOT NULL, +`l_partkey` int NOT NULL, +`l_suppkey` int NOT NULL, +`l_linenumber` int NOT NULL, `l_quantity` decimal(15,2) NOT NULL, `l_extendedprice` decimal(15,2) NOT NULL, `l_discount` decimal(15,2) NOT NULL, diff --git a/sql/sql_optimizer.cc b/sql/sql_optimizer.cc index b0e3ec170..7df1c9e52 100644 --- a/sql/sql_optimizer.cc +++ b/sql/sql_optimizer.cc @@ -9710,6 +9710,17 @@ static bool make_join_query_block(JOIN *join, Item *cond) { NO_PLAN_IDX))) return true; tab->set_condition(tmp); + //tianmu begin + /* Push condition to storage engine if this is enabled + and the condition is not guarded */ + if (thd->optimizer_switch_flag(OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) && first_inner == NO_PLAN_IDX) { + Item *push_cond = make_cond_for_table(thd, tmp, tab->table_ref->map(), tab->table_ref->map(), 0); + if (push_cond) { + /* Push condition to handler */ + if (!tab->table()->file->cond_push(push_cond)) tab->table()->file->pushed_cond = push_cond; + } + } + //tianmu end } else { tab->set_condition(nullptr); } @@ -10381,7 +10392,7 @@ bool optimize_cond(THD *thd, Item **cond, COND_EQUAL **cond_equal, /* change field = field to field = const for each found field = const Note: Since we disable multi-equalities in the hypergraph optimizer for now, - we also cannot run this optimization; it causes spurious “Impossible WHERE” + we also cannot run this optimization; it causes spurious "Impossible WHERE" in e.g. main.select_none. */ if (*cond && !thd->lex->using_hypergraph_optimizer) { @@ -10761,7 +10772,7 @@ ORDER *create_order_from_distinct(THD *thd, Ref_item_array ref_item_array, BIT type and will be returned to a client. @note setup_ref_array() needs to account for the extra space. @note We need to defer the actual adding to after the loop, - or we will invalidate the iterator to “fields”. + or we will invalidate the iterator to "fields". */ Item_field *new_item = new Item_field(thd, (Item_field *)item); ord->item = &item; // Temporary; for the duplicate check above. diff --git a/storage/tianmu/core/query_compile.cpp b/storage/tianmu/core/query_compile.cpp index 778e686ae..d74611d9b 100644 --- a/storage/tianmu/core/query_compile.cpp +++ b/storage/tianmu/core/query_compile.cpp @@ -267,7 +267,7 @@ bool Query::FieldUnmysterify(Item *item, TabID &tab, AttrID &col) { // Physical table in FROM - RCTable int field_num; for (field_num = 0; mysql_table->field[field_num]; field_num++) - if (mysql_table->field[field_num]->field_name == ifield->get_result_field()->field_name) break; + if (std::strcmp(mysql_table->field[field_num]->field_name, ifield->original_field_name()) == 0) break; if (!mysql_table->field[field_num]) continue; col = AttrID(field_num); return true; diff --git a/storage/tianmu/handler/ha_my_tianmu.cpp b/storage/tianmu/handler/ha_my_tianmu.cpp index 2974a4903..c2ab4969e 100644 --- a/storage/tianmu/handler/ha_my_tianmu.cpp +++ b/storage/tianmu/handler/ha_my_tianmu.cpp @@ -96,9 +96,9 @@ Query_route_to Tianmu_Handle_Query(THD *thd, Query_expression *qe, Query_result if (ret == DBHandler::Query_route_to::TO_MYSQL && AtLeastOneTianmuTableInvolved(qe) && ForbiddenMySQLQueryPath(qe)) { my_message(static_cast(common::ErrorCode::UNKNOWN_ERROR), - "The query includes syntax that is not supported by the storage engine. \ - Either restructure the query with supported syntax, or enable the MySQL core::Query Path \ - in config file to execute the query with reduced performance.", + "The query includes syntax that is not supported by the storage engine. " + "Either restructure the query with supported syntax, or enable the MySQL core::Query Path " + "in config file to execute the query with reduced performance.", MYF(0)); ret = Query_route_to::TO_TIANMU; } @@ -165,6 +165,6 @@ bool Tianmu_Load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) return false; } -bool Tianmu_Get_Insert_Delayed_Flag(THD *thd) { return tianmu_sysvar_insert_delayed; } +bool Tianmu_Get_Insert_Delayed_Flag([[maybe_unused]] THD *thd) { return tianmu_sysvar_insert_delayed; } } // namespace DBHandler } // namespace Tianmu diff --git a/storage/tianmu/handler/ha_my_tianmu.h b/storage/tianmu/handler/ha_my_tianmu.h index abcf9fb78..bc6fbd813 100644 --- a/storage/tianmu/handler/ha_my_tianmu.h +++ b/storage/tianmu/handler/ha_my_tianmu.h @@ -38,7 +38,7 @@ void Tianmu_UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *sourc // processing the load operation. bool Tianmu_Load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg); -bool Tianmu_Get_Insert_Delayed_Flag(THD *thd); +bool Tianmu_Get_Insert_Delayed_Flag([[maybe_unused]] THD *thd); } // namespace DBHandler } // namespace Tianmu diff --git a/storage/tianmu/handler/ha_tianmu.cpp b/storage/tianmu/handler/ha_tianmu.cpp index 15d207b55..8a76f7d29 100644 --- a/storage/tianmu/handler/ha_tianmu.cpp +++ b/storage/tianmu/handler/ha_tianmu.cpp @@ -45,8 +45,6 @@ namespace Tianmu { namespace DBHandler { -extern bool tianmu_bootstrap = 0; - char *strmov_str(char *dst, const char *src) { while ((*dst++ = *src++)) ; @@ -1714,8 +1712,6 @@ handler *rcbase_create_handler(handlerton *hton, TABLE_SHARE *table, bool partit } int rcbase_panic_func([[maybe_unused]] handlerton *hton, enum ha_panic_function flag) { - if (tianmu_bootstrap) return 0; - if (flag == HA_PANIC_CLOSE) { delete ha_rcengine_; ha_rcengine_ = nullptr; @@ -1823,8 +1819,6 @@ bool rcbase_show_status([[maybe_unused]] handlerton *hton, THD *thd, stat_print_ return false; } -extern bool tianmu_bootstrap; - static int init_variables() { opt_binlog_order_commits = false; return 0; @@ -1857,10 +1851,6 @@ int rcbase_init_func(void *p) { tianmu_hton->show_status = rcbase_show_status; tianmu_hton->file_extensions = ha_tianmu_exts; - // When mysqld runs as bootstrap mode, we do not need to initialize - // memmanager. - if (tianmu_bootstrap) DBUG_RETURN(0); - int ret = 1; ha_rcengine_ = nullptr;