diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index c536a5950..49ef3093e 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -3576,7 +3576,8 @@ ReturnedColumn* buildFunctionColumn( Item_func* ifp, gp_walk_info& gwi, bool& nonSupport, - bool pushdownHand) + bool pushdownHand, + bool selectBetweenIn) { if (get_fe_conn_info_ptr() == NULL) set_fe_conn_info_ptr((void*)new cal_connection_info()); @@ -3643,9 +3644,9 @@ ReturnedColumn* buildFunctionColumn( return NULL; } - if (ifp->arguments()[0]->type() == Item::FIELD_ITEM || + if (!selectBetweenIn && (ifp->arguments()[0]->type() == Item::FIELD_ITEM || (ifp->arguments()[0]->type() == Item::REF_ITEM && - (*(((Item_ref*)ifp->arguments()[0])->ref))->type() == Item::FIELD_ITEM)) + (*(((Item_ref*)ifp->arguments()[0])->ref))->type() == Item::FIELD_ITEM))) { bool fe = false; @@ -6642,7 +6643,18 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, return ER_CHECK_NOT_IMPLEMENTED; } - ReturnedColumn* rc = buildFunctionColumn(ifp, gwi, hasNonSupportItem); + // if "IN" or "BETWEEN" are in the SELECT clause, build function column + string funcName = ifp->func_name(); + ReturnedColumn* rc; + if (funcName == "in" || funcName == " IN " || funcName == "between") + { + rc = buildFunctionColumn(ifp, gwi, hasNonSupportItem, false, true); + } + else + { + rc = buildFunctionColumn(ifp, gwi, hasNonSupportItem); + } + SRCP srcp(rc); if (rc) diff --git a/dbcon/mysql/ha_calpont_impl_if.h b/dbcon/mysql/ha_calpont_impl_if.h index 967299aaf..3bf4b9bf6 100644 --- a/dbcon/mysql/ha_calpont_impl_if.h +++ b/dbcon/mysql/ha_calpont_impl_if.h @@ -359,7 +359,7 @@ bool isMCSTable(TABLE* table_ptr); // execution plan util functions prototypes execplan::ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); -execplan::ReturnedColumn* buildFunctionColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); +execplan::ReturnedColumn* buildFunctionColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false, bool selectBetweenIn = false); execplan::ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool pushdownHand = false); execplan::ConstantColumn* buildDecimalColumn(Item* item, gp_walk_info& gwi); execplan::SimpleColumn* buildSimpleColumn(Item_field* item, gp_walk_info& gwi); diff --git a/utils/funcexp/func_case.cpp b/utils/funcexp/func_case.cpp index 5c429a669..1a5f511ab 100644 --- a/utils/funcexp/func_case.cpp +++ b/utils/funcexp/func_case.cpp @@ -485,7 +485,7 @@ bool Func_simple_case::getBoolVal(Row& row, uint64_t i = simple_case_cmp(row, parm, isNull, operationColType); if (isNull) - return joblist::BIGINTNULL; + return false; ParseTree* lop = parm[i]->left(); ParseTree* rop = parm[i]->right(); @@ -651,7 +651,7 @@ bool Func_searched_case::getBoolVal(Row& row, uint64_t i = searched_case_cmp(row, parm, isNull); if (isNull) - return joblist::BIGINTNULL; + return false; ParseTree* lop = parm[i]->left(); ParseTree* rop = parm[i]->right(); diff --git a/utils/funcexp/func_in.cpp b/utils/funcexp/func_in.cpp index ab691ed1f..2de6359e7 100644 --- a/utils/funcexp/func_in.cpp +++ b/utils/funcexp/func_in.cpp @@ -315,7 +315,6 @@ CalpontSystemCatalog::ColType Func_in::operationType( FunctionParm& fp, CalpontS ct = fp[0]->data()->resultType(); bool allString = true; - bool allNonToken = true; for (uint32_t i = 0; i < fp.size(); i++) { @@ -328,31 +327,14 @@ CalpontSystemCatalog::ColType Func_in::operationType( FunctionParm& fp, CalpontS op.setOpType(ct, fp[i]->data()->resultType()); ct = op.operationType(); } - else - { - if ((fp[i]->data()->resultType().colDataType == CalpontSystemCatalog::CHAR && - fp[i]->data()->resultType().colWidth > 8) || - (fp[i]->data()->resultType().colDataType == CalpontSystemCatalog::VARCHAR && - fp[i]->data()->resultType().colWidth >= 8) || - (fp[i]->data()->resultType().colDataType == CalpontSystemCatalog::TEXT && - fp[i]->data()->resultType().colWidth >= 8)) - allNonToken = false; - } } - if (allString && !allNonToken) + if (allString) { ct.colDataType = CalpontSystemCatalog::VARCHAR; ct.colWidth = 255; } - else if (allString && allNonToken) - { - ct.colDataType = CalpontSystemCatalog::BIGINT; - ct.colWidth = 8; - } - - // convert date const value according to the compare type here. if (op.operationType().colDataType == CalpontSystemCatalog::DATE) {