1
0
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:
Sergey Zefirov
2023-03-30 17:26:45 +01:00
committed by Roman Nozdrin
parent 0ea592da80
commit b53c231ca6
417 changed files with 12459 additions and 3520 deletions

View File

@ -73,6 +73,8 @@ using namespace joblist;
#include "ha_mcs_datatype.h"
#include "nullstring.h"
namespace
{
#define BATCH_INSERT_GROUP_ROWS_FOR_CACHE 100000
@ -95,12 +97,14 @@ uint32_t buildValueList(TABLE* table, cal_connection_info& ci)
int columnPos = 0;
double dbval;
ci.nullValuesBitset.reset();
NullString null;
for (Field** field = table->field; *field; field++)
{
if ((*field)->is_null())
{
ci.tableValuesMap[columnPos].push_back(""); // currently, empty string is treated as null.
ci.tableValuesMap[columnPos].push_back(null);
ci.nullValuesBitset[columnPos] = true;
}
else
@ -117,21 +121,23 @@ uint32_t buildValueList(TABLE* table, cal_connection_info& ci)
char buf[maxlen];
memset(buf, 0, maxlen);
snprintf(buf, maxlen, "%.1024f", dbval);
ci.tableValuesMap[columnPos].push_back(buf);
NullString value(buf, strlen(buf));
ci.tableValuesMap[columnPos].push_back(value);
}
else
{
// fetch different data type
(*field)->val_str(&attribute, &attribute);
if (attribute.length() == 0)
{
ci.tableValuesMap[columnPos].push_back(""); // currently, empty string is treated as null.
}
else
// if (attribute.length() == 0)
// {
// ci.tableValuesMap[columnPos].push_back(null); // currently, empty string is treated as null.
// }
// else
{
string val(attribute.ptr(), attribute.length());
ci.tableValuesMap[columnPos].push_back(val);
NullString nonNull(val);
ci.tableValuesMap[columnPos].push_back(nonNull);
}
}
}