From a5f2f80bed670c9e2f07fa0c56c7899ad417793c Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 30 Apr 2018 10:41:52 +0100 Subject: [PATCH] MCOL-392 Fix case --- utils/funcexp/func_add_time.cpp | 2 +- utils/funcexp/func_case.cpp | 49 ++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/utils/funcexp/func_add_time.cpp b/utils/funcexp/func_add_time.cpp index 0fa379bfd..bb32dc79d 100644 --- a/utils/funcexp/func_add_time.cpp +++ b/utils/funcexp/func_add_time.cpp @@ -146,7 +146,7 @@ int64_t addTime(Time& dt1, Time& dt2) dt.second = 0; dt.msecond = 0; - int64_t hour, min, sec, msec, tmp; + int64_t min, sec, msec, tmp; msec = (signed)(dt1.msecond + dt2.msecond); dt.msecond = tmp = msec % 1000000; diff --git a/utils/funcexp/func_case.cpp b/utils/funcexp/func_case.cpp index 46a479491..f9d70cb75 100644 --- a/utils/funcexp/func_case.cpp +++ b/utils/funcexp/func_case.cpp @@ -65,8 +65,6 @@ inline uint64_t simple_case_cmp(Row& row, case execplan::CalpontSystemCatalog::INT: case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::DATE: - case execplan::CalpontSystemCatalog::DATETIME: - case execplan::CalpontSystemCatalog::TIME: { int64_t ev = parm[n]->data()->getIntVal(row, isNull); @@ -87,6 +85,49 @@ inline uint64_t simple_case_cmp(Row& row, break; } + case execplan::CalpontSystemCatalog::DATETIME: + { + int64_t ev = parm[n]->data()->getDatetimeIntVal(row, isNull); + + if (isNull) + break; + + for (i = 1; i <= whereCount; i++) + { + if (ev == parm[i]->data()->getDatetimeIntVal(row, isNull) && !isNull) + { + foundIt = true; + break; + } + else + isNull = false; + } + + break; + } + + case execplan::CalpontSystemCatalog::TIME: + { + int64_t ev = parm[n]->data()->getTimeIntVal(row, isNull); + + if (isNull) + break; + + for (i = 1; i <= whereCount; i++) + { + if (ev == parm[i]->data()->getTimeIntVal(row, isNull) && !isNull) + { + foundIt = true; + break; + } + else + isNull = false; + } + + break; + } + + case execplan::CalpontSystemCatalog::UBIGINT: case execplan::CalpontSystemCatalog::UINT: case execplan::CalpontSystemCatalog::UMEDINT: @@ -514,7 +555,7 @@ int64_t Func_simple_case::getTimeIntVal(rowgroup::Row& row, if (isNull) return joblist::TIMENULL; - return parm[i + 1]->data()->getTimeIntVal(row, isNull); + return parm[i]->data()->getTimeIntVal(row, isNull); } @@ -653,7 +694,7 @@ int64_t Func_searched_case::getTimeIntVal(rowgroup::Row& row, if (isNull) return joblist::TIMENULL; - return parm[i + 1]->data()->getTimeIntVal(row, isNull); + return parm[i]->data()->getTimeIntVal(row, isNull); } } // namespace funcexp