1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00
Sergey Zefirov b53c231ca6 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.
2023-03-30 21:18:29 +03:00

106 lines
2.6 KiB
C++

/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id: row.cpp 9210 2013-01-21 14:10:42Z rdempsey $
*
*
***********************************************************************/
#include <limits>
#define DMLPKGROW_DLLEXPORT
#include "row.h"
#undef DMLPKGROW_DLLEXPORT
namespace dmlpackage
{
Row::Row() : fRowID(std::numeric_limits<WriteEngine::RID>::max())
{
}
Row::~Row()
{
for (unsigned int i = 0; i < fColumnList.size(); i++)
{
delete fColumnList[i];
}
fColumnList.clear();
}
Row::Row(const Row& row)
{
for (unsigned int i = 0; i < row.fColumnList.size(); i++)
{
const DMLColumn* aColumn = row.get_ColumnAt(i);
DMLColumn* newColumn = new DMLColumn(aColumn->get_Name(), aColumn->get_DataVector());
fColumnList.push_back(newColumn);
}
fRowID = row.fRowID;
}
int Row::read(messageqcpp::ByteStream& bytestream)
{
int retval = 1;
messageqcpp::ByteStream::octbyte rowID;
bytestream >> rowID;
set_RowID(rowID);
messageqcpp::ByteStream::quadbyte col_count;
bytestream >> col_count;
for (unsigned int i = 0; i < col_count; i++)
{
DMLColumn* aColumn = new DMLColumn();
retval = aColumn->read(bytestream);
fColumnList.push_back(aColumn);
}
return retval;
}
int Row::write(messageqcpp::ByteStream& bytestream)
{
int retval = 1;
messageqcpp::ByteStream::octbyte rowID = fRowID;
bytestream << rowID;
ColumnList::iterator colListPtr;
colListPtr = fColumnList.begin();
messageqcpp::ByteStream::quadbyte col_count = fColumnList.size();
bytestream << col_count;
for (; colListPtr != fColumnList.end(); ++colListPtr)
{
retval = (*colListPtr)->write(bytestream);
}
return retval;
}
const DMLColumn* Row::get_ColumnAt(unsigned int index) const
{
const DMLColumn* columnPtr = 0;
if (index < fColumnList.size())
{
columnPtr = fColumnList[index];
}
return columnPtr;
}
} // namespace dmlpackage