diff --git a/writeengine/shared/we_brm.h b/writeengine/shared/we_brm.h index 2aa8b8b09..2b43397b4 100644 --- a/writeengine/shared/we_brm.h +++ b/writeengine/shared/we_brm.h @@ -34,6 +34,7 @@ #include #include "brmtypes.h" #include "mcs_datatype.h" +#include "dataconvert.h" #include "IDBDataFile.h" #include "IDBPolicy.h" @@ -78,6 +79,11 @@ struct ExtCPInfo mm.int128Min = fCPInfo.bigMin; return datatypes::MinMaxInfo::isRangeInvalid(mm, fColType, fColWidth); } + void fromToChars() + { + fCPInfo.max = static_cast(uint64ToStr(fCPInfo.max)); + fCPInfo.min = static_cast(uint64ToStr(fCPInfo.min)); + } bool isBinaryColumn() { return fCPInfo.isBinaryColumn; diff --git a/writeengine/wrapper/writeengine.cpp b/writeengine/wrapper/writeengine.cpp index fe4aeff49..b15233b72 100644 --- a/writeengine/wrapper/writeengine.cpp +++ b/writeengine/wrapper/writeengine.cpp @@ -331,6 +331,11 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_ { return ; } + if (colType == WR_CHAR) + { + maxMin->toInvalid(); // simple and wrong solution. + return; + } bool isUnsigned = false; // TODO: should change with type. switch (colType) { @@ -338,6 +343,7 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_ case WR_USHORT: case WR_UINT: case WR_ULONGLONG: + case WR_CHAR: { isUnsigned = true; break; @@ -353,6 +359,14 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_ 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; for (i = 0; i < totalOldRow; i++) { int64_t value = 0, oldValue = 0; @@ -409,6 +423,16 @@ void WriteEngineWrapper::updateMaxMinRange(const size_t totalNewRow, const size_ fetchNewOldValues(bvalue, oldBValue, valArrayVoid, oldValArrayVoid, i, totalNewRow); break; } + case WR_CHAR: + { + fetchNewOldValues(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: idbassert_s(0, "unknown WR type tag"); 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 */ @@ -1182,21 +1212,21 @@ getCPInfoToUpdateForUpdatableType(const ColStruct& colStruct, ExtCPInfo* current { return nullptr; } - switch(colStruct.colDataType) + switch(colStruct.colType) { // here we enumerate all supported types. - case CalpontSystemCatalog::TINYINT: - case CalpontSystemCatalog::SMALLINT: - case CalpontSystemCatalog::DECIMAL: - case CalpontSystemCatalog::MEDINT: - case CalpontSystemCatalog::INT: - case CalpontSystemCatalog::BIGINT: - case CalpontSystemCatalog::UTINYINT: - case CalpontSystemCatalog::USMALLINT: - case CalpontSystemCatalog::UDECIMAL: - case CalpontSystemCatalog::UMEDINT: - case CalpontSystemCatalog::UINT: - case CalpontSystemCatalog::UBIGINT: + case WR_BYTE: + case WR_SHORT: + case WR_INT: + case WR_LONGLONG: + case WR_CHAR: + case WR_UBYTE: + case WR_USHORT: + case WR_UINT: + case WR_ULONGLONG: + case WR_MEDINT: + case WR_UMEDINT: + case WR_BINARY: { return currentCPInfo; }