diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 0e52ebb65..6dfb2eaaa 100755 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -4149,6 +4149,14 @@ ReturnedColumn* buildFunctionColumn( #endif fc->operationType(functor->operationType(funcParms, fc->resultType())); + // For some reason, MDB has MYSQL_TYPE_DATETIME2 for functions on a TIMESTAMP + if (fc->operationType().colDataType == CalpontSystemCatalog::TIMESTAMP) + { + CalpontSystemCatalog::ColType ct = fc->resultType(); + ct.colDataType = CalpontSystemCatalog::TIMESTAMP; + ct.colWidth = 8; + fc->resultType(ct); + } fc->expressionId(ci->expressionId++); // A few functions use a different collation than that found in // the base ifp class diff --git a/utils/funcexp/func_floor.cpp b/utils/funcexp/func_floor.cpp index 170963541..98ca9d10f 100644 --- a/utils/funcexp/func_floor.cpp +++ b/utils/funcexp/func_floor.cpp @@ -114,27 +114,14 @@ int64_t Func_floor::getIntVal(Row& row, case execplan::CalpontSystemCatalog::DATETIME: { - string str = - DataConvert::datetimeToString1(parm[0]->data()->getDatetimeIntVal(row, isNull)); + ret = parm[0]->data()->getDatetimeIntVal(row, isNull); - // strip off micro seconds - str = str.substr(0, 14); - - if (!isNull) - ret = atoll(str.c_str()); } break; case execplan::CalpontSystemCatalog::TIMESTAMP: { - string str = - DataConvert::timestampToString1(parm[0]->data()->getTimestampIntVal(row, isNull), timeZone()); - - // strip off micro seconds - str = str.substr(0, 14); - - if (!isNull) - ret = atoll(str.c_str()); + ret = parm[0]->data()->getTimestampIntVal(row, isNull); } break;