diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 93ce8a46e..4a2856530 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -8702,8 +8702,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro if ((gwi.subQuery /*|| select_lex.group_list.elements != 0 */ || !csep->unionVec().empty() || isUnion) && !hasNonSupportItem && (after_size - before_size) == 0 && - !(parseInfo & AGG_BIT) && !(parseInfo & SUB_BIT) && - string(ifp->func_name()) != "set_user_var") + !(parseInfo & AGG_BIT) && !(parseInfo & SUB_BIT) + ) { String val, *str = ifp->val_str(&val); string valStr; diff --git a/dbcon/mysql/ha_mcs_pushdown.cpp b/dbcon/mysql/ha_mcs_pushdown.cpp index 94ffe92b2..b84a8a946 100644 --- a/dbcon/mysql/ha_mcs_pushdown.cpp +++ b/dbcon/mysql/ha_mcs_pushdown.cpp @@ -267,6 +267,57 @@ void check_walk(const Item* item, void* arg) } } +/*@brief check_user_var_func - This traverses Item */ +/************************************************************ +* DESCRIPTION: +* This f() walks Item looking for the existence of +* "set_user_var" or "get_user_var" functions. +* PARAMETERS: +* Item * Item to traverse +* RETURN: +***********************************************************/ +void check_user_var_func(const Item* item, void* arg) +{ + bool* unsupported_feature = reinterpret_cast(arg); + + if (*unsupported_feature) + return; + + if (item->type() == Item::FUNC_ITEM) + { + const Item_func* ifp = reinterpret_cast(item); + std::string funcName = ifp->func_name(); + if (funcName == "set_user_var" || funcName == "get_user_var") + { + *unsupported_feature = true; + } + } +} + +void item_check(Item* item, bool* unsupported_feature) +{ + switch (item->type()) + { + case Item::COND_ITEM: + { + Item_cond *icp = reinterpret_cast(item); + icp->traverse_cond(check_user_var_func, unsupported_feature, Item::POSTFIX); + break; + } + case Item::FUNC_ITEM: + { + Item_func *ifp = reinterpret_cast(item); + ifp->traverse_cond(check_user_var_func, unsupported_feature, Item::POSTFIX); + break; + } + default: + { + item->traverse_cond(check_user_var_func, unsupported_feature, Item::POSTFIX); + break; + } + } +} + /*@brief create_calpont_group_by_handler- Creates handler*/ /*********************************************************** * DESCRIPTION: @@ -345,6 +396,19 @@ create_calpont_group_by_handler(THD* thd, Query* query) icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); } } + + // Iterate and traverse through the item list and do not create GBH + // if the unsupported (set/get_user_var) functions are present. + List_iterator_fast it(select_lex->item_list); + Item* item; + while ((item = it++)) + { + item_check(item, &unsupported_feature); + if (unsupported_feature) + { + return handler; + } + } } // unsupported features check ends here if (!unsupported_feature) @@ -438,6 +502,19 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived) on_icp->traverse_cond(check_walk, &unsupported_feature, Item::POSTFIX); on_icp->traverse_cond(save_join_predicates, &join_preds_list, Item::POSTFIX); } + + // Iterate and traverse through the item list and do not create DH + // if the unsupported (set/get_user_var) functions are present. + List_iterator_fast it(tl->select_lex->item_list); + Item* item; + while ((item = it++)) + { + item_check(item, &unsupported_feature); + if (unsupported_feature) + { + return handler; + } + } } // CROSS JOIN w/o conditions isn't supported until MCOL-301 @@ -673,6 +750,23 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex) } } + // Iterate and traverse through the item list and do not create SH + // if the unsupported (set/get_user_var) functions are present. + TABLE_LIST* table_ptr = select_lex->get_table_list(); + for (; !unsupported_feature && table_ptr; table_ptr = table_ptr->next_global) + { + List_iterator_fast it(table_ptr->select_lex->item_list); + Item* item; + while ((item = it++)) + { + item_check(item, &unsupported_feature); + if (unsupported_feature) + { + break; + } + } + } + if (!unsupported_feature) { handler= new ha_columnstore_select_handler(thd, select_lex);