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
@ -54,11 +54,11 @@ namespace funcexp
|
||||
{
|
||||
const static int wildOne = '_';
|
||||
const static int wildMany = '%';
|
||||
int Func_json_search::cmpJSValWild(json_engine_t* jsEg, const string_view& cmpStr, const CHARSET_INFO* cs)
|
||||
int Func_json_search::cmpJSValWild(json_engine_t* jsEg, const utils::NullString& cmpStr, const CHARSET_INFO* cs)
|
||||
{
|
||||
if (jsEg->value_type != JSON_VALUE_STRING || !jsEg->value_escaped)
|
||||
return cs->wildcmp((const char*)jsEg->value, (const char*)(jsEg->value + jsEg->value_len),
|
||||
(const char*)cmpStr.data(), (const char*)cmpStr.data() + cmpStr.size(), escape,
|
||||
(const char*)cmpStr.str(), (const char*)cmpStr.end(), escape,
|
||||
wildOne, wildMany)
|
||||
? 0
|
||||
: 1;
|
||||
@ -71,7 +71,7 @@ int Func_json_search::cmpJSValWild(json_engine_t* jsEg, const string_view& cmpSt
|
||||
(uchar*)buf, (uchar*)(buf + strLen))) <= 0)
|
||||
return 0;
|
||||
|
||||
return cs->wildcmp(buf, buf + strLen, cmpStr.data(), cmpStr.data() + cmpStr.size(), escape, wildOne,
|
||||
return cs->wildcmp(buf, buf + strLen, cmpStr.str(), cmpStr.end(), escape, wildOne,
|
||||
wildMany)
|
||||
? 0
|
||||
: 1;
|
||||
@ -89,8 +89,8 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i
|
||||
{
|
||||
string ret;
|
||||
bool isNullJS = false, isNullVal = false;
|
||||
const string_view js = fp[0]->data()->getStrVal(row, isNull);
|
||||
const string_view cmpStr = fp[2]->data()->getStrVal(row, isNull);
|
||||
const auto& js = fp[0]->data()->getStrVal(row, isNull);
|
||||
const auto& cmpStr = fp[2]->data()->getStrVal(row, isNull);
|
||||
if (isNullJS || isNullVal)
|
||||
{
|
||||
isNull = true;
|
||||
@ -102,9 +102,10 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i
|
||||
if (!isModeConst)
|
||||
isModeConst = (dynamic_cast<ConstantColumn*>(fp[1]->data()) != nullptr);
|
||||
|
||||
string mode = fp[1]->data()->getStrVal(row, isNull);
|
||||
const auto& mode_ns = fp[1]->data()->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
return "";
|
||||
string mode = mode_ns.safeString("");
|
||||
|
||||
transform(mode.begin(), mode.end(), mode.begin(), ::tolower);
|
||||
if (mode != "one" && mode != "all")
|
||||
@ -125,13 +126,13 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i
|
||||
return "";
|
||||
}
|
||||
bool isNullEscape = false;
|
||||
const string_view escapeStr = fp[3]->data()->getStrVal(row, isNullEscape);
|
||||
if (escapeStr.size() > 1)
|
||||
const auto& escapeStr = fp[3]->data()->getStrVal(row, isNullEscape);
|
||||
if (escapeStr.length() > 1)
|
||||
{
|
||||
isNull = true;
|
||||
return "";
|
||||
}
|
||||
escape = isNullEscape ? '\\' : escapeStr[0];
|
||||
escape = isNullEscape ? '\\' : escapeStr.safeString("")[0];
|
||||
}
|
||||
|
||||
json_engine_t jsEg;
|
||||
@ -159,7 +160,7 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i
|
||||
}
|
||||
}
|
||||
|
||||
json_get_path_start(&jsEg, cs, (const uchar*)js.data(), (const uchar*)js.data() + js.size(), &p);
|
||||
json_get_path_start(&jsEg, cs, (const uchar*)js.str(), (const uchar*)js.end(), &p);
|
||||
|
||||
while (json_get_path_next(&jsEg, &p) == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user