You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-271 empty strings should not be NULLs (#2794)
This patch improves handling of NULLs in textual fields in ColumnStore. Previously empty strings were considered NULLs and it could be a problem if data scheme allows for empty strings. It was also one of major reasons of behavior difference between ColumnStore and other engines in MariaDB family. Also, this patch fixes some other bugs and incorrect behavior, for example, incorrect comparison for "column <= ''" which evaluates to constant True for all purposes before this patch.
This commit is contained in:
committed by
Roman Nozdrin
parent
0ea592da80
commit
b53c231ca6
@ -143,7 +143,7 @@ int64_t Func_cast_signed::getIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
const auto& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
{
|
||||
@ -151,7 +151,7 @@ int64_t Func_cast_signed::getIntVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return atoll(value.c_str());
|
||||
return atoll(value.str());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -259,7 +259,7 @@ uint64_t Func_cast_unsigned::getUintVal(Row& row, FunctionParm& parm, bool& isNu
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
const auto& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
{
|
||||
@ -267,7 +267,7 @@ uint64_t Func_cast_unsigned::getUintVal(Row& row, FunctionParm& parm, bool& isNu
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t ret = strtoul(value.c_str(), 0, 0);
|
||||
uint64_t ret = strtoul(value.str(), 0, 0);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
@ -336,14 +336,14 @@ string Func_cast_char::getStrVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
{
|
||||
// check for convert with 1 arg, return the argument
|
||||
if (parm.size() == 1)
|
||||
return parm[0]->data()->getStrVal(row, isNull);
|
||||
return parm[0]->data()->getStrVal(row, isNull).safeString("");
|
||||
;
|
||||
|
||||
int64_t length = parm[1]->data()->getIntVal(row, isNull);
|
||||
|
||||
// @bug3488, a dummy parm is appended even the optional N is not present.
|
||||
if (length < 0)
|
||||
return parm[0]->data()->getStrVal(row, isNull);
|
||||
return parm[0]->data()->getStrVal(row, isNull).safeString("");
|
||||
;
|
||||
|
||||
switch (parm[0]->data()->resultType().colDataType)
|
||||
@ -392,15 +392,15 @@ string Func_cast_char::getStrVal(Row& row, FunctionParm& parm, bool& isNull,
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
const utils::NullString& value = parm[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (isNull)
|
||||
{
|
||||
isNull = true;
|
||||
return value;
|
||||
return string("");
|
||||
}
|
||||
|
||||
return value.substr(0, length);
|
||||
return value.safeString("").substr(0, length);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -549,7 +549,7 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row, FunctionParm& parm, bo
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
val = dataconvert::DataConvert::stringToDate(parm[0]->data()->getStrVal(row, isNull));
|
||||
val = dataconvert::DataConvert::stringToDate(parm[0]->data()->getStrVal(row, isNull).safeString(""));
|
||||
|
||||
if (val == -1)
|
||||
isNull = true;
|
||||
@ -659,7 +659,7 @@ int64_t Func_cast_date::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& parm
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
val = dataconvert::DataConvert::stringToDatetime(parm[0]->data()->getStrVal(row, isNull));
|
||||
val = dataconvert::DataConvert::stringToDatetime(parm[0]->data()->getStrVal(row, isNull).safeString(""));
|
||||
|
||||
if (val == -1)
|
||||
isNull = true;
|
||||
@ -821,7 +821,7 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row, FunctionParm&
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
val = dataconvert::DataConvert::stringToDatetime(parm[0]->data()->getStrVal(row, isNull));
|
||||
val = dataconvert::DataConvert::stringToDatetime(parm[0]->data()->getStrVal(row, isNull).safeString(""));
|
||||
|
||||
if (val == -1)
|
||||
isNull = true;
|
||||
@ -932,7 +932,7 @@ int64_t Func_cast_datetime::getTimeIntVal(rowgroup::Row& row, FunctionParm& parm
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
val = dataconvert::DataConvert::stringToTime(parm[0]->data()->getStrVal(row, isNull));
|
||||
val = dataconvert::DataConvert::stringToTime(parm[0]->data()->getStrVal(row, isNull).safeString(""));
|
||||
|
||||
if (val == -1)
|
||||
isNull = true;
|
||||
@ -1286,14 +1286,14 @@ IDB_Decimal Func_cast_decimal::getDecimalVal(Row& row, FunctionParm& parm, bool&
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& strValue = parm[0]->data()->getStrVal(row, isNull);
|
||||
if (strValue.empty())
|
||||
const utils::NullString& strValue = parm[0]->data()->getStrVal(row, isNull);
|
||||
if (strValue.isNull())
|
||||
{
|
||||
isNull = true;
|
||||
return IDB_Decimal(); // need a null value for IDB_Decimal??
|
||||
}
|
||||
datatypes::DataCondition convError;
|
||||
return IDB_Decimal(strValue.data(), strValue.length(), convError, decimals, max_length);
|
||||
return IDB_Decimal(strValue.str(), strValue.length(), convError, decimals, max_length);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1515,9 +1515,9 @@ double Func_cast_double::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
{
|
||||
const string& strValue = parm[0]->data()->getStrVal(row, isNull);
|
||||
const utils::NullString& strValue = parm[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
dblval = strtod(strValue.c_str(), NULL);
|
||||
dblval = strtod(strValue.str(), NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user