You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +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
@ -930,13 +930,13 @@ void XMLJob::fillInXMLDataAsLoaded(execplan::CalpontSystemCatalog::RIDList& colR
|
||||
void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
execplan::CalpontSystemCatalog::ColType& colType, JobColumn& col)
|
||||
{
|
||||
const std::string col_defaultValue(colType.defaultValue);
|
||||
const NullString col_defaultValue(colType.defaultValue);
|
||||
|
||||
if (colType.constraintType == execplan::CalpontSystemCatalog::NOTNULL_CONSTRAINT)
|
||||
{
|
||||
col.fNotNull = true;
|
||||
|
||||
if (!col_defaultValue.empty())
|
||||
if (!col_defaultValue.isNull())
|
||||
col.fWithDefault = true;
|
||||
}
|
||||
else if (colType.constraintType == execplan::CalpontSystemCatalog::DEFAULT_CONSTRAINT)
|
||||
@ -963,7 +963,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
{
|
||||
errno = 0;
|
||||
col.fDefaultInt = strtoll(col_defaultValue.c_str(), 0, 10);
|
||||
col.fDefaultInt = strtoll(col_defaultValue.str(), 0, 10);
|
||||
|
||||
if (errno == ERANGE)
|
||||
bDefaultConvertError = true;
|
||||
@ -978,7 +978,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
{
|
||||
errno = 0;
|
||||
col.fDefaultUInt = strtoull(col_defaultValue.c_str(), 0, 10);
|
||||
col.fDefaultUInt = strtoull(col_defaultValue.str(), 0, 10);
|
||||
|
||||
if (errno == ERANGE)
|
||||
bDefaultConvertError = true;
|
||||
@ -991,11 +991,11 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
{
|
||||
if (LIKELY(colType.colWidth == datatypes::MAXDECIMALWIDTH))
|
||||
{
|
||||
col.fDefaultWideDecimal = colType.decimal128FromString(col_defaultValue, &bDefaultConvertError);
|
||||
col.fDefaultWideDecimal = colType.decimal128FromString(col_defaultValue.safeString(), &bDefaultConvertError);
|
||||
}
|
||||
else
|
||||
{
|
||||
col.fDefaultInt = Convertor::convertDecimalString(col_defaultValue.c_str(),
|
||||
col.fDefaultInt = Convertor::convertDecimalString(col_defaultValue.str(),
|
||||
col_defaultValue.length(), colType.scale);
|
||||
|
||||
if (errno == ERANGE)
|
||||
@ -1008,7 +1008,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
int convertStatus;
|
||||
int32_t dt = dataconvert::DataConvert::convertColumnDate(col_defaultValue.c_str(),
|
||||
int32_t dt = dataconvert::DataConvert::convertColumnDate(col_defaultValue.str(),
|
||||
dataconvert::CALPONTDATE_ENUM, convertStatus,
|
||||
col_defaultValue.length());
|
||||
|
||||
@ -1023,7 +1023,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
{
|
||||
int convertStatus;
|
||||
int64_t dt = dataconvert::DataConvert::convertColumnDatetime(
|
||||
col_defaultValue.c_str(), dataconvert::CALPONTDATETIME_ENUM, convertStatus,
|
||||
col_defaultValue.str(), dataconvert::CALPONTDATETIME_ENUM, convertStatus,
|
||||
col_defaultValue.length());
|
||||
|
||||
if (convertStatus != 0)
|
||||
@ -1037,7 +1037,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
{
|
||||
int convertStatus;
|
||||
int64_t dt = dataconvert::DataConvert::convertColumnTimestamp(
|
||||
col_defaultValue.c_str(), dataconvert::CALPONTDATETIME_ENUM, convertStatus,
|
||||
col_defaultValue.str(), dataconvert::CALPONTDATETIME_ENUM, convertStatus,
|
||||
col_defaultValue.length(), fTimeZone);
|
||||
|
||||
if (convertStatus != 0)
|
||||
@ -1050,7 +1050,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
int convertStatus;
|
||||
int64_t dt = dataconvert::DataConvert::convertColumnTime(col_defaultValue.c_str(),
|
||||
int64_t dt = dataconvert::DataConvert::convertColumnTime(col_defaultValue.str(),
|
||||
dataconvert::CALPONTTIME_ENUM, convertStatus,
|
||||
col_defaultValue.length());
|
||||
|
||||
@ -1067,7 +1067,7 @@ void XMLJob::fillInXMLDataNotNullDefault(const std::string& fullTblName,
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
errno = 0;
|
||||
col.fDefaultDbl = strtod(col_defaultValue.c_str(), 0);
|
||||
col.fDefaultDbl = strtod(col_defaultValue.str(), 0);
|
||||
|
||||
if (errno == ERANGE)
|
||||
bDefaultConvertError = true;
|
||||
|
Reference in New Issue
Block a user