1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-898 In func_if, handle isNull better

This commit is contained in:
David Hall
2017-10-06 13:34:22 -05:00
parent 1dc0ea5fb4
commit c10130d1b8

View File

@ -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);
@ -122,13 +123,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);
}
}
@ -140,14 +140,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);
}
}
@ -158,14 +156,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);
}
}
@ -176,14 +172,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);
}
}
@ -194,14 +188,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);
}
}
@ -212,14 +204,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);
}
}