From 07d68aa8b10c46e975371cbd1367f0dfcad2f77f Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 6 Oct 2017 13:34:22 -0500 Subject: [PATCH] MCOL-898 In func_if, handle isNull better --- utils/funcexp/func_if.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/utils/funcexp/func_if.cpp b/utils/funcexp/func_if.cpp index bd3cf9dd0..f62d0d5ce 100644 --- a/utils/funcexp/func_if.cpp +++ b/utils/funcexp/func_if.cpp @@ -35,9 +35,10 @@ using namespace rowgroup; namespace { -bool boolVal(SPTP& parm, Row& row, bool& isNull) +bool boolVal(SPTP& parm, Row& row) { bool ret = true; + bool isNull = false; // Keep it local. We don't want to mess with the global one here. try { ret = parm->getBoolVal(row, isNull); @@ -119,13 +120,12 @@ int64_t Func_if::getIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull) && !isNull) + if (boolVal(parm[0], row)) { return parm[1]->data()->getIntVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getIntVal(row, isNull); } } @@ -137,14 +137,12 @@ string Func_if::getStrVal(Row& row, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull)) + if (boolVal(parm[0], row)) { - isNull = false; return parm[1]->data()->getStrVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getStrVal(row, isNull); } } @@ -155,14 +153,12 @@ IDB_Decimal Func_if::getDecimalVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull)) + if (boolVal(parm[0], row)) { - isNull = false; return parm[1]->data()->getDecimalVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getDecimalVal(row, isNull); } } @@ -173,14 +169,12 @@ double Func_if::getDoubleVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull)) + if (boolVal(parm[0], row)) { - isNull = false; return parm[1]->data()->getDoubleVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getDoubleVal(row, isNull); } } @@ -191,14 +185,12 @@ int32_t Func_if::getDateIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull)) + if (boolVal(parm[0], row)) { - isNull = false; return parm[1]->data()->getDateIntVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getDateIntVal(row, isNull); } } @@ -209,14 +201,12 @@ int64_t Func_if::getDatetimeIntVal(Row& row, bool& isNull, CalpontSystemCatalog::ColType&) { - if (boolVal(parm[0], row, isNull)) + if (boolVal(parm[0], row)) { - isNull = false; return parm[1]->data()->getDatetimeIntVal(row, isNull); } else { - isNull = false; return parm[2]->data()->getDatetimeIntVal(row, isNull); } }