You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-4779 Keep correct ranges during DML for short char columns
This commit is contained in:
@ -34,6 +34,7 @@
|
|||||||
#include<sys/time.h>
|
#include<sys/time.h>
|
||||||
#include "brmtypes.h"
|
#include "brmtypes.h"
|
||||||
#include "mcs_datatype.h"
|
#include "mcs_datatype.h"
|
||||||
|
#include "dataconvert.h"
|
||||||
#include "IDBDataFile.h"
|
#include "IDBDataFile.h"
|
||||||
#include "IDBPolicy.h"
|
#include "IDBPolicy.h"
|
||||||
|
|
||||||
@ -78,6 +79,11 @@ struct ExtCPInfo
|
|||||||
mm.int128Min = fCPInfo.bigMin;
|
mm.int128Min = fCPInfo.bigMin;
|
||||||
return datatypes::MinMaxInfo::isRangeInvalid(mm, fColType, fColWidth);
|
return datatypes::MinMaxInfo::isRangeInvalid(mm, fColType, fColWidth);
|
||||||
}
|
}
|
||||||
|
void fromToChars()
|
||||||
|
{
|
||||||
|
fCPInfo.max = static_cast<int64_t>(uint64ToStr(fCPInfo.max));
|
||||||
|
fCPInfo.min = static_cast<int64_t>(uint64ToStr(fCPInfo.min));
|
||||||
|
}
|
||||||
bool isBinaryColumn()
|
bool isBinaryColumn()
|
||||||
{
|
{
|
||||||
return fCPInfo.isBinaryColumn;
|
return fCPInfo.isBinaryColumn;
|
||||||
|
@ -331,6 +331,11 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_
|
|||||||
{
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
if (colType == WR_CHAR)
|
||||||
|
{
|
||||||
|
maxMin->toInvalid(); // simple and wrong solution.
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool isUnsigned = false; // TODO: should change with type.
|
bool isUnsigned = false; // TODO: should change with type.
|
||||||
switch (colType)
|
switch (colType)
|
||||||
{
|
{
|
||||||
@ -338,6 +343,7 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_
|
|||||||
case WR_USHORT:
|
case WR_USHORT:
|
||||||
case WR_UINT:
|
case WR_UINT:
|
||||||
case WR_ULONGLONG:
|
case WR_ULONGLONG:
|
||||||
|
case WR_CHAR:
|
||||||
{
|
{
|
||||||
isUnsigned = true;
|
isUnsigned = true;
|
||||||
break;
|
break;
|
||||||
@ -353,6 +359,14 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (colType == WR_CHAR)
|
||||||
|
{
|
||||||
|
idbassert(MAX_COLUMN_BOUNDARY == sizeof(uint64_t)); // have to check that - code below depends on that.
|
||||||
|
if (!maxMin->isInvalid())
|
||||||
|
{
|
||||||
|
maxMin->fromToChars();
|
||||||
|
}
|
||||||
|
}
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < totalOldRow; i++) {
|
for (i = 0; i < totalOldRow; i++) {
|
||||||
int64_t value = 0, oldValue = 0;
|
int64_t value = 0, oldValue = 0;
|
||||||
@ -409,6 +423,16 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_
|
|||||||
fetchNewOldValues<int128_t, int128_t>(bvalue, oldBValue, valArrayVoid, oldValArrayVoid, i, totalNewRow);
|
fetchNewOldValues<int128_t, int128_t>(bvalue, oldBValue, valArrayVoid, oldValArrayVoid, i, totalNewRow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case WR_CHAR:
|
||||||
|
{
|
||||||
|
fetchNewOldValues<uint64_t, uint64_t>(uvalue, oldUValue, valArrayVoid, oldValArrayVoid, i, totalNewRow);
|
||||||
|
// for characters (strings, actually), we fetched then in LSB order, on x86, at the very least.
|
||||||
|
// this means most significant byte of the string, which is first, is now in LSB of uvalue/oldValue.
|
||||||
|
// we must perform a conversion.
|
||||||
|
uvalue = uint64ToStr(uvalue);
|
||||||
|
oldValue = uint64ToStr(oldValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
idbassert_s(0, "unknown WR type tag");
|
idbassert_s(0, "unknown WR type tag");
|
||||||
return;
|
return;
|
||||||
@ -435,6 +459,12 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// the range will be kept.
|
||||||
|
// to handle character columns properly we need to convert range values back to strings.
|
||||||
|
if (colType == WR_CHAR)
|
||||||
|
{
|
||||||
|
maxMin->fromToChars();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*@convertValArray - Convert interface values to internal values
|
/*@convertValArray - Convert interface values to internal values
|
||||||
*/
|
*/
|
||||||
@ -1182,21 +1212,21 @@ getCPInfoToUpdateForUpdatableType(const ColStruct& colStruct, ExtCPInfo* current
|
|||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
switch(colStruct.colDataType)
|
switch(colStruct.colType)
|
||||||
{
|
{
|
||||||
// here we enumerate all supported types.
|
// here we enumerate all supported types.
|
||||||
case CalpontSystemCatalog::TINYINT:
|
case WR_BYTE:
|
||||||
case CalpontSystemCatalog::SMALLINT:
|
case WR_SHORT:
|
||||||
case CalpontSystemCatalog::DECIMAL:
|
case WR_INT:
|
||||||
case CalpontSystemCatalog::MEDINT:
|
case WR_LONGLONG:
|
||||||
case CalpontSystemCatalog::INT:
|
case WR_CHAR:
|
||||||
case CalpontSystemCatalog::BIGINT:
|
case WR_UBYTE:
|
||||||
case CalpontSystemCatalog::UTINYINT:
|
case WR_USHORT:
|
||||||
case CalpontSystemCatalog::USMALLINT:
|
case WR_UINT:
|
||||||
case CalpontSystemCatalog::UDECIMAL:
|
case WR_ULONGLONG:
|
||||||
case CalpontSystemCatalog::UMEDINT:
|
case WR_MEDINT:
|
||||||
case CalpontSystemCatalog::UINT:
|
case WR_UMEDINT:
|
||||||
case CalpontSystemCatalog::UBIGINT:
|
case WR_BINARY:
|
||||||
{
|
{
|
||||||
return currentCPInfo;
|
return currentCPInfo;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user