mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-21 19:45:56 +03:00
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.
89 lines
2.6 KiB
C++
89 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: func_concat.cpp 3918 2013-06-19 13:54:34Z bwilkinson $
|
|
*
|
|
*
|
|
****************************************************************************/
|
|
|
|
#include <string>
|
|
using namespace std;
|
|
|
|
#include "functor_str.h"
|
|
#include "functioncolumn.h"
|
|
using namespace execplan;
|
|
|
|
#include "rowgroup.h"
|
|
using namespace rowgroup;
|
|
|
|
#include "dataconvert.h"
|
|
using namespace dataconvert;
|
|
|
|
namespace funcexp
|
|
{
|
|
CalpontSystemCatalog::ColType Func_concat::operationType(FunctionParm& fp,
|
|
CalpontSystemCatalog::ColType& resultType)
|
|
{
|
|
// operation type is not used by this functor
|
|
int widSum = 0;
|
|
for (const auto& fpi : fp)
|
|
{
|
|
switch (fpi->data()->resultType().colDataType)
|
|
{
|
|
case execplan::CalpontSystemCatalog::DECIMAL:
|
|
case execplan::CalpontSystemCatalog::UDECIMAL:
|
|
widSum += fpi->data()->resultType().precision + 2;
|
|
break;
|
|
default:
|
|
widSum += fpi->data()->resultType().colWidth * 3; // overprovision for bytes converted into decomals.
|
|
break;
|
|
}
|
|
}
|
|
if (widSum < resultType.colWidth)
|
|
{
|
|
widSum = resultType.colWidth;
|
|
}
|
|
auto temp = fp[0]->data()->resultType();
|
|
temp.colWidth = widSum;
|
|
resultType.colWidth = widSum;
|
|
return temp;
|
|
}
|
|
|
|
// Returns the string that results from concatenating the arguments.
|
|
// concat() returns NULL if any argument is NULL.
|
|
//
|
|
string Func_concat::getStrVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType&)
|
|
{
|
|
string ret;
|
|
string tmp;
|
|
stringValue(parm[0], row, isNull, ret);
|
|
|
|
// TODO: do a better job of cutting down the number re-allocations.
|
|
// look at Item_func_concat::realloc_result for ideas and use
|
|
// std::string:resize() appropriatly.
|
|
for (unsigned int id = 1; id < parm.size(); id++)
|
|
{
|
|
stringValue(parm[id], row, isNull, tmp);
|
|
ret.append(tmp);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
} // namespace funcexp
|