diff --git a/dbcon/mysql/ha_mcs_opt_rewrites.cpp b/dbcon/mysql/ha_mcs_opt_rewrites.cpp index f3260995e..28acfa0a8 100644 --- a/dbcon/mysql/ha_mcs_opt_rewrites.cpp +++ b/dbcon/mysql/ha_mcs_opt_rewrites.cpp @@ -276,6 +276,8 @@ void in_subselect_rewrite_walk(const Item* item_arg, void* arg) *result= sub->create_in_to_exists_cond(join); *result= (*result) ? *result : sub->inject_in_to_exists_cond(join); + sub->unit->first_select()->prep_where= + join->conds ? join->conds->copy_andor_structure(current_thd) : 0; } else if (typeid(*item) == typeid(Item_singlerow_subselect)) { diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 8278fcf38..725a404fc 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -796,8 +796,14 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) handler= new ha_columnstore_select_handler(thd, select_lex); JOIN *join= select_lex->join; { + Query_arena *arena, backup; + arena= thd->activate_stmt_arena_if_needed(&backup); + disable_indices_for_CEJ(thd); + if (arena) + thd->restore_active_arena(arena, &backup); + if (select_lex->handle_derived(thd->lex, DT_MERGE)) { unsupported_feature = true; @@ -815,7 +821,6 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) if (sel->first_cond_optimization) { create_explain_query_if_not_exists(thd->lex, thd->mem_root); - Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup); sel->first_cond_optimization= false; @@ -826,7 +831,16 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) sel->where= conds; if (isPS) - sel->prep_where= conds; + { + sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; + + if (in_subselect_rewrite(sel)) + { + unsupported_feature = true; + handler->err_msg.assign("create_columnstore_select_handler(): \ + Internal error occured in in_subselect_rewrite()"); + } + } select_lex->update_used_tables(); @@ -848,13 +862,12 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) // MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add // an equi-JOIN condition. - if (!unsupported_feature && in_subselect_rewrite(select_lex)) + if (!unsupported_feature && !isPS && in_subselect_rewrite(select_lex)) { unsupported_feature = true; handler->err_msg.assign("create_columnstore_select_handler(): \ Internal error occured in in_subselect_rewrite()"); } - } // We shouldn't raise error now so set an error to raise it later in init_SH.