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
@ -52,11 +52,11 @@ int64_t Func_inet_aton::getIntVal(rowgroup::Row& row, FunctionParm& fp, bool& is
|
||||
|
||||
int64_t iValue = joblist::NULL_INT64;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
iValue = iVal;
|
||||
@ -76,11 +76,11 @@ double Func_inet_aton::getDoubleVal(rowgroup::Row& row, FunctionParm& fp, bool&
|
||||
|
||||
double dValue = doubleNullVal();
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iValue = convertAton(sValue, isNull);
|
||||
int64_t iValue = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
dValue = iValue;
|
||||
@ -102,14 +102,18 @@ std::string Func_inet_aton::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool
|
||||
{
|
||||
// std::cout << "In Func_inet_aton::getStrVal" << std::endl;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
convertAton(sValue, isNull); // ignore return value
|
||||
convertAton(sValue.unsafeStringRef(), isNull); // ignore return valuea
|
||||
if (isNull)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
return sValue;
|
||||
return sValue.safeString("");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -122,11 +126,11 @@ bool Func_inet_aton::getBoolVal(rowgroup::Row& row, FunctionParm& fp, bool& isNu
|
||||
{
|
||||
bool bValue = false;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if ((!isNull) && (iVal != 0))
|
||||
bValue = true;
|
||||
@ -144,13 +148,13 @@ execplan::IDB_Decimal Func_inet_aton::getDecimalVal(rowgroup::Row& row, Function
|
||||
{
|
||||
execplan::CalpontSystemCatalog::ColType colType = fp[0]->data()->resultType();
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!datatypes::Decimal::isWideDecimalTypeByPrecision(colType.precision))
|
||||
{
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iValue = convertAton(sValue, isNull);
|
||||
int64_t iValue = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
return execplan::IDB_Decimal(iValue, colType.scale, colType.precision);
|
||||
@ -162,7 +166,7 @@ execplan::IDB_Decimal Func_inet_aton::getDecimalVal(rowgroup::Row& row, Function
|
||||
{
|
||||
if (!isNull)
|
||||
{
|
||||
int64_t iValue = convertAton(sValue, isNull);
|
||||
int64_t iValue = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
return execplan::IDB_Decimal(0, colType.scale, colType.precision, (int128_t)iValue);
|
||||
@ -182,11 +186,11 @@ int32_t Func_inet_aton::getDateIntVal(rowgroup::Row& row, FunctionParm& fp, bool
|
||||
{
|
||||
int32_t iValue = joblist::DATENULL;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
iValue = iVal;
|
||||
@ -206,11 +210,11 @@ int64_t Func_inet_aton::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& fp,
|
||||
{
|
||||
int64_t iValue = joblist::DATETIMENULL;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
iValue = iVal;
|
||||
@ -224,11 +228,11 @@ int64_t Func_inet_aton::getTimestampIntVal(rowgroup::Row& row, FunctionParm& fp,
|
||||
{
|
||||
int64_t iValue = joblist::TIMESTAMPNULL;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
iValue = iVal;
|
||||
@ -242,11 +246,11 @@ int64_t Func_inet_aton::getTimeIntVal(rowgroup::Row& row, FunctionParm& fp, bool
|
||||
{
|
||||
int64_t iValue = joblist::TIMENULL;
|
||||
|
||||
const std::string& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& sValue = fp[0]->data()->getStrVal(row, isNull);
|
||||
|
||||
if (!isNull)
|
||||
if (!sValue.isNull())
|
||||
{
|
||||
int64_t iVal = convertAton(sValue, isNull);
|
||||
int64_t iVal = convertAton(sValue.unsafeStringRef(), isNull);
|
||||
|
||||
if (!isNull)
|
||||
iValue = iVal;
|
||||
|
Reference in New Issue
Block a user