1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-641 Fix alter table add wide decimal column.

This patch also removes CalpontSystemCatalog::BINARY and
ddlpackage::DDL_BINARY that were added during the initial
stages of the work on MCOL-641.
This commit is contained in:
Gagan Goel
2020-11-20 18:23:54 -05:00
parent ba4156fe13
commit 995cadef2d
32 changed files with 62 additions and 255 deletions

View File

@ -371,7 +371,6 @@ TypeHandler::find(SystemCatalog::ColDataType typeCode,
case SystemCatalog::NUM_OF_COL_DATA_TYPE:
case SystemCatalog::STRINT:
case SystemCatalog::UNDEFINED:
case SystemCatalog::BINARY:
break;
}
return NULL;
@ -452,7 +451,6 @@ TypeHandler::find_by_ddltype(const ddlpackage::ColumnType &ct)
case ddlpackage::DDL_UNSIGNED_FLOAT: return &mcs_type_handler_ufloat;
case ddlpackage::DDL_UNSIGNED_DOUBLE: return &mcs_type_handler_udouble;
case ddlpackage::DDL_BINARY: //return &mcs_type_handler_binary;
case ddlpackage::DDL_INVALID_DATATYPE:
break;
}

View File

@ -154,7 +154,6 @@ public:
LONGDOUBLE, /* @bug3241, dev and variance calculation only */
STRINT, /* @bug3532, string as int for fast comparison */
UNDEFINED, /*!< Undefined - used in UDAF API */
BINARY, /*!< BINARY type */
};
class TypeAttributesStd

View File

@ -178,45 +178,24 @@ class Decimal
static inline bool isWideDecimalNullValue(const int128_t& val)
{
const uint64_t* ptr = reinterpret_cast<const uint64_t*>(&val);
return (ptr[0] == utils::BINARYNULLVALUELOW && ptr[1] == utils::BINARYNULLVALUEHIGH);
return (val == TSInt128::NullValue);
}
static inline bool isWideDecimalEmptyValue(const int128_t& val)
{
const uint64_t* ptr = reinterpret_cast<const uint64_t*>(&val);
return (ptr[0] == utils::BINARYEMPTYVALUELOW && ptr[1] == utils::BINARYEMPTYVALUEHIGH);
return (val == TSInt128::EmptyValue);
}
static inline void setWideDecimalNullValue(int128_t& val)
{
uint64_t* ptr = reinterpret_cast<uint64_t*>(&val);
ptr[0] = utils::BINARYNULLVALUELOW;
ptr[1] = utils::BINARYNULLVALUEHIGH;
val = TSInt128::NullValue;
}
static inline void setWideDecimalEmptyValue(int128_t& val)
{
uint64_t* ptr = reinterpret_cast<uint64_t*>(&val);
ptr[0] = utils::BINARYEMPTYVALUELOW;
ptr[1] = utils::BINARYEMPTYVALUEHIGH;
val = TSInt128::EmptyValue;
}
static inline void setWideDecimalNullValue(int128_t* val)
{
uint64_t* ptr = reinterpret_cast<uint64_t*>(val);
ptr[0] = utils::BINARYNULLVALUELOW;
ptr[1] = utils::BINARYNULLVALUEHIGH;
}
static inline void setWideDecimalEmptyValue(int128_t* val)
{
uint64_t* ptr = reinterpret_cast<uint64_t*>(val);
ptr[0] = utils::BINARYEMPTYVALUELOW;
ptr[1] = utils::BINARYEMPTYVALUEHIGH;
}
static constexpr int128_t minInt128 = int128_t(0x8000000000000000LL) << 64;
static constexpr int128_t maxInt128 = (int128_t(0x7FFFFFFFFFFFFFFFLL) << 64) + 0xFFFFFFFFFFFFFFFFLL;

View File

@ -187,7 +187,7 @@ void ColumnDef::convertDecimal()
}
else if (fType->fPrecision > 18 && fType->fPrecision < 39)
{
fType->fType = DDL_BINARY;
fType->fType = DDL_DECIMAL;
fType->fLength = 16;
}
}

View File

@ -238,7 +238,6 @@ enum DDL_DATATYPES
DDL_TEXT,
DDL_TIME,
DDL_TIMESTAMP,
DDL_BINARY,
DDL_INVALID_DATATYPE
};
@ -278,7 +277,6 @@ const std::string DDLDatatypeString[] =
"text",
"time",
"timestamp",
"binary",
""
};

View File

@ -247,11 +247,6 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
break;
case (CalpontSystemCatalog::BINARY):
if (newType.fType == DDL_BINARY && colType.colWidth == newType.fLength) return true;
break;
default:
break;
}

View File

@ -253,10 +253,6 @@ execplan::CalpontSystemCatalog::ColDataType DDLPackageProcessor::convertDataType
colDataType = CalpontSystemCatalog::TEXT;
break;
case ddlpackage::DDL_BINARY:
colDataType = CalpontSystemCatalog::BINARY;
break;
default:
throw runtime_error("Unsupported datatype!");

View File

@ -227,10 +227,6 @@ const string colDataTypeToString(CalpontSystemCatalog::ColDataType cdt)
return "udouble";
break;
case CalpontSystemCatalog::BINARY:
return "binary";
break;
default:
break;
}

View File

@ -1076,13 +1076,6 @@ inline bool isNull(int64_t val, const execplan::CalpontSystemCatalog::ColType& c
break;
}
case execplan::CalpontSystemCatalog::BINARY:
{
ret = false;
break;
}
default:
break;
}

View File

@ -703,15 +703,6 @@ void SimpleColumn::evaluate(Row& row, bool& isNull)
break;
}
case CalpontSystemCatalog::BINARY:
{
// WIP MCOL-641 Binary representation could contain \0.
std::string value(row.getBinaryField<char>(fInputIndex));
fResult.strVal.swap(value);
break;
}
default: // treat as int64
{
fResult.intVal = row.getUintField<8>(fInputIndex);

View File

@ -219,7 +219,6 @@ const string SimpleFilter::data() const
fRhs->resultType().colDataType == CalpontSystemCatalog::DATE ||
fRhs->resultType().colDataType == CalpontSystemCatalog::DATETIME ||
fRhs->resultType().colDataType == CalpontSystemCatalog::TIMESTAMP ||
fRhs->resultType().colDataType == CalpontSystemCatalog::BINARY ||
fRhs->resultType().colDataType == CalpontSystemCatalog::TIME))
rhs = "'" + SimpleFilter::escapeString(fRhs->data()) + "'";
else
@ -234,7 +233,6 @@ const string SimpleFilter::data() const
fLhs->resultType().colDataType == CalpontSystemCatalog::DATE ||
fLhs->resultType().colDataType == CalpontSystemCatalog::TIME ||
fLhs->resultType().colDataType == CalpontSystemCatalog::TIMESTAMP ||
fLhs->resultType().colDataType == CalpontSystemCatalog::BINARY ||
fLhs->resultType().colDataType == CalpontSystemCatalog::DATETIME))
lhs = "'" + SimpleFilter::escapeString(fLhs->data()) + "'";
else

View File

@ -666,10 +666,6 @@ inline const std::string& TreeNode::getStrVal(const std::string& timeZone)
break;
}
case CalpontSystemCatalog::BINARY:
{
break;
}
default:
throw logging::InvalidConversionExcept("TreeNode::getStrVal: Invalid conversion.");
}
@ -1027,7 +1023,6 @@ inline IDB_Decimal TreeNode::getDecimalVal()
case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::BLOB:
case CalpontSystemCatalog::BINARY:
throw logging::InvalidConversionExcept("TreeNode::getDecimalVal: non-support conversion from binary string");
case CalpontSystemCatalog::BIGINT:

View File

@ -333,8 +333,7 @@ string extractTableAlias(const SSC& sc)
//------------------------------------------------------------------------------
CalpontSystemCatalog::OID isDictCol(const CalpontSystemCatalog::ColType& colType)
{
if (colType.isWideDecimalType() ||
colType.colDataType == CalpontSystemCatalog::BINARY) return 0;
if (colType.isWideDecimalType()) return 0;
if (colType.colWidth > 8) return colType.ddn.dictOID;

View File

@ -83,12 +83,6 @@ const uint16_t NULL_UINT16 = USMALLINTNULL;
const uint32_t NULL_UINT32 = UINTNULL;
const uint64_t NULL_UINT64 = UBIGINTNULL;
const uint64_t BINARYNULLVALUELOW = 0ULL;
const uint64_t BINARYNULLVALUEHIGH = 0x8000000000000000ULL;
const uint64_t BINARYEMPTYVALUELOW = 1ULL;
const uint64_t BINARYEMPTYVALUEHIGH = 0x8000000000000000ULL;
const uint64_t BINARYEMPTYROW = 0ULL;
const std::string CPNULLSTRMARK("_CpNuLl_");
const std::string CPSTRNOTFOUND("_CpNoTf_");

View File

@ -175,7 +175,6 @@ pColScanStep::pColScanStep(
}
// MCOL-641 WIP
else if (fColType.colWidth > 8
&& fColType.colDataType != CalpontSystemCatalog::BINARY
&& fColType.colDataType != CalpontSystemCatalog::DECIMAL
&& fColType.colDataType != CalpontSystemCatalog::UDECIMAL)
{

View File

@ -179,7 +179,6 @@ pColStep::pColStep(
}
// WIP MCOL-641
else if (fColType.colWidth > 8
&& fColType.colDataType != CalpontSystemCatalog::BINARY
&& fColType.colDataType != CalpontSystemCatalog::DECIMAL
&& fColType.colDataType != CalpontSystemCatalog::UDECIMAL)
{

View File

@ -164,7 +164,7 @@ class PrimTest : public CppUnit::TestFixture
// binary data type
CPPUNIT_TEST(p_Col_bin_16);
CPPUNIT_TEST(p_Col_bin_32);
// CPPUNIT_TEST(p_Col_bin_32);
CPPUNIT_TEST_SUITE_END();
@ -3801,7 +3801,7 @@ public:
args = reinterpret_cast<ColArgs*>(&input[sizeof(NewColRequestHeader)]);
in->DataSize = sizeof(binary16);
in->DataType = execplan::CalpontSystemCatalog::BINARY;
in->DataType = execplan::CalpontSystemCatalog::DECIMAL;
in->OutputType = OT_DATAVALUE;
in->NOPS = 3;
in->BOP = BOP_OR;

View File

@ -83,10 +83,6 @@ void getEmptyRowValue(const execplan::CalpontSystemCatalog::ColDataType colDataT
datatypes::Decimal::setWideDecimalEmptyValue(*(reinterpret_cast<int128_t*>(emptyVal)));
break;
//case CalpontSystemCatalog::BINARY:
// emptyVal = joblist::BINARYEMPTYROW;
// break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::DATE:

View File

@ -126,9 +126,6 @@ uint64_t getNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidth)
case CalpontSystemCatalog::UBIGINT:
return joblist::UBIGINTNULL;
case CalpontSystemCatalog::BINARY:
return joblist::BINARYNULLVALUELOW;
case CalpontSystemCatalog::VARBINARY:
default:
ostringstream os;
@ -247,9 +244,6 @@ int64_t getSignedNullValue(CalpontSystemCatalog::ColDataType t, uint32_t colWidt
case CalpontSystemCatalog::LONGDOUBLE:
return (int64_t)joblist::LONGDOUBLENULL;
case CalpontSystemCatalog::BINARY:
return (int64_t)joblist::BINARYNULLVALUELOW;
case CalpontSystemCatalog::VARBINARY:
default:
ostringstream os;

View File

@ -23,11 +23,6 @@
namespace utils
{
const uint64_t BINARYNULLVALUELOW = 0ULL;
const uint64_t BINARYNULLVALUEHIGH = 0x8000000000000000ULL;
const uint64_t BINARYEMPTYVALUELOW = 1ULL;
const uint64_t BINARYEMPTYVALUEHIGH = 0x8000000000000000ULL;
const int128_t minInt128 = int128_t(0x8000000000000000LL) << 64;
const int128_t maxInt128 = (int128_t(0x7FFFFFFFFFFFFFFFLL) << 64) + 0xFFFFFFFFFFFFFFFFLL;

View File

@ -131,15 +131,6 @@ string Func_hex::getStrVal(rowgroup::Row& row,
return string(hexPtr.get(), hexLen);
}
case CalpontSystemCatalog::BINARY:
{
const string& arg = parm[0]->data()->getStrVal(row, isNull);
uint64_t hexLen = arg.size() * 2;
scoped_array<char> hexPtr(new char[hexLen + 1]); // "+ 1" for the last \0
octet2hex(hexPtr.get(), arg.data(), arg.size());
return string(hexPtr.get(), hexLen);
}
default:
{
dec = (uint64_t)parm[0]->data()->getIntVal(row, isNull);

View File

@ -632,10 +632,7 @@ string Row::toString() const
os << " " << dec;
break;
}
// WIP MCOL-641
case CalpontSystemCatalog::BINARY:
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
break;
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
if (colWidths[i] == datatypes::MAXDECIMALWIDTH)
@ -709,9 +706,6 @@ string Row::toCSV() const
os << dec;
break;
}
case CalpontSystemCatalog::BINARY:
std::cout << __FILE__<< __LINE__ << ":" << "toCSV"<< std::endl;
//fallthrough
default:
os << getIntField(i);
@ -876,11 +870,6 @@ void Row::initToNull()
case CalpontSystemCatalog::UBIGINT:
*((uint64_t*) &data[offsets[i]]) = joblist::UBIGINTNULL;
break;
case CalpontSystemCatalog::BINARY:
{
datatypes::Decimal::setWideDecimalNullValue(reinterpret_cast<int128_t&>(data[offsets[i]]));
}
break;
default:
ostringstream os;
@ -903,29 +892,6 @@ inline bool Row::isNullValue_offset(uint32_t offset) const
throw logic_error(os.str());
}
// WIP Method template resolution could impose some perf degradation
// Compare perf with switch-case
template<>
inline bool
Row::isNullValue_offset<execplan::CalpontSystemCatalog::BINARY,32>(
uint32_t offset) const
{
const uint64_t *intPtr = reinterpret_cast<const uint64_t*>(&data[offset]);
return ((intPtr[0] == static_cast<uint64_t>(utils::BINARYNULLVALUELOW)) &&
(intPtr[1] == static_cast<uint64_t>(utils::BINARYNULLVALUELOW)) &&
(intPtr[2] == static_cast<uint64_t>(utils::BINARYNULLVALUELOW)) &&
(intPtr[3] == static_cast<uint64_t>(utils::BINARYEMPTYVALUEHIGH)));
}
template<>
inline bool
Row::isNullValue_offset<execplan::CalpontSystemCatalog::BINARY,16>(
uint32_t offset) const
{
const int128_t *intPtr = reinterpret_cast<const int128_t*>(&data[offset]);
return datatypes::Decimal::isWideDecimalNullValue (*intPtr);
}
template<>
inline bool
Row::isNullValue_offset<execplan::CalpontSystemCatalog::DECIMAL,16>(
@ -1114,15 +1080,6 @@ bool Row::isNullValue(uint32_t colIndex) const
return (*((long double*) &data[offsets[colIndex]]) == joblist::LONGDOUBLENULL);
break;
case CalpontSystemCatalog::BINARY:
{
const uint32_t len = 16;
uint32_t* lenPtr = const_cast<uint32_t*>(&len);
*lenPtr = getColumnWidth(colIndex);
return isNullValue_offset
<execplan::CalpontSystemCatalog::BINARY,len>(offsets[colIndex]);
}
default:
{
ostringstream os;
@ -1787,9 +1744,6 @@ void RowGroup::addToSysDataList(execplan::CalpontSystemCatalog::NJLSysDataList&
cr->PutData(row.getUintField<4>(j));
break;
case CalpontSystemCatalog::BINARY:
std::cout << __FILE__<< __LINE__ << __func__<< std::endl;
//fallthrough
default:
cr->PutData(row.getIntField<8>(j));
}

View File

@ -69,12 +69,6 @@ boost::shared_ptr<WindowFunctionType> WF_count<T>::makeFunction(int id, const st
break;
}
case CalpontSystemCatalog::BINARY:
{
std::cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << std::endl;
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{

View File

@ -491,9 +491,7 @@ bool WF_udaf::dropValues(int64_t b, int64_t e)
datum.columnData = valIn;
break;
}
case CalpontSystemCatalog::BINARY:
cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << endl;
//fallthrough
default:
{
string errStr = "(" + colType2String[(int)datum.dataType] + ")";
@ -768,9 +766,7 @@ void WF_udaf::SetUDAFValue(static_any::any& valOut, int64_t colOut,
setValue(colDataType, b, e, c, &strOut);
}
break;
case CalpontSystemCatalog::BINARY:
cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << endl;
//fallthrough
default:
{
std::ostringstream errmsg;
@ -1150,9 +1146,7 @@ void WF_udaf::operator()(int64_t b, int64_t e, int64_t c)
datum.columnData = valIn;
break;
}
case CalpontSystemCatalog::BINARY:
cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << endl;
//fallthrough
default:
{
string errStr = "(" + colType2String[(int)datum.dataType] + ")";

View File

@ -800,9 +800,7 @@ void* WindowFunctionType::getNullValueByType(int ct, int pos)
case CalpontSystemCatalog::LONGDOUBLE:
v = &longDoubleNull;
break;
case CalpontSystemCatalog::BINARY:
cout << __FILE__<< ":" <<__LINE__ << " Fix for 16 Bytes ?" << endl;
//fallthrough
case CalpontSystemCatalog::VARBINARY:
default:
std::ostringstream oss;

View File

@ -510,16 +510,6 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
throw std::runtime_error(os.str());
}
else if (dataType == CalpontSystemCatalog::BINARY
&& ! (colDefPtr->fType->fLength == 16
|| colDefPtr->fType->fLength == 32))
{
ostringstream os;
os << "binary length may not be other than 16 or 32";
throw std::runtime_error(os.str());
}
unsigned int i = 0;
column_iterator = columns.begin();
@ -871,10 +861,10 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
if (dataType == CalpontSystemCatalog::DECIMAL ||
dataType == CalpontSystemCatalog::UDECIMAL)
{
if (colDefPtr->fType->fPrecision > 18) //@Bug 5717 precision cannot be over 18.
if (colDefPtr->fType->fPrecision > 38) //@Bug 5717 precision cannot be over 38.
{
ostringstream os;
os << "Syntax error: The maximum precision (total number of digits) that can be specified is 18";
os << "Syntax error: The maximum precision (total number of digits) that can be specified is 38";
throw std::runtime_error(os.str());
}
else if (colDefPtr->fType->fPrecision < colDefPtr->fType->fScale)

View File

@ -263,10 +263,6 @@ inline int convertDataType(int dataType)
calpontDataType = execplan::CalpontSystemCatalog::UDOUBLE;
break;
case ddlpackage::DDL_BINARY:
calpontDataType = execplan::CalpontSystemCatalog::BINARY;
break;
default:
throw runtime_error("Unsupported datatype!");

View File

@ -91,7 +91,7 @@ CPPUNIT_TEST(setUp);
// Extent & dict related testing
CPPUNIT_TEST( testExtensionWOPrealloc );
CPPUNIT_TEST( testDictExtensionWOPrealloc );
CPPUNIT_TEST( testExtentCrWOPreallocBin );
// CPPUNIT_TEST( testExtentCrWOPreallocBin );
// Semaphore related testing
// CPPUNIT_TEST( testSem );
@ -1571,7 +1571,6 @@ public:
fileOp.deleteFile(fileName);
CPPUNIT_ASSERT(fileOp.exists(fileName) == false);
//binary16 emptyVal = blockOp.getEmptyBinRowValue( execplan::CalpontSystemCatalog::BINARY, 16 );
uint64_t emptyVal = blockOp.getEmptyRowValue(execplan::CalpontSystemCatalog::BIGINT, 8);
int width = blockOp.getCorrectRowWidth(execplan::CalpontSystemCatalog::BINARY, sizeof (binary16));
int nBlocks = INITIAL_EXTENT_ROWS_TO_DISK / BYTE_PER_BLOCK * width;

View File

@ -953,7 +953,7 @@ int BRMWrapper::rollBack(const VER_t transID, int sessionId)
CalpontSystemCatalog::ColDataType colDataType = colType.colDataType;
ColType weColType;
Convertor::convertColType(colDataType, weColType);
Convertor::convertColType(colDataType, colType.colWidth, weColType);
column.colWidth = Convertor::getCorrectRowWidth(colDataType, colType.colWidth);
column.colType = weColType;
column.colDataType = colDataType;
@ -1240,7 +1240,7 @@ int BRMWrapper::rollBackBlocks(const VER_t transID, int sessionId)
CalpontSystemCatalog::ColDataType colDataType = colType.colDataType;
ColType weColType;
Convertor::convertColType(colDataType, weColType);
Convertor::convertColType(colDataType, colType.colWidth, weColType);
column.colWidth = Convertor::getCorrectRowWidth(colDataType, colType.colWidth);
column.colType = weColType;
column.colDataType = colDataType;

View File

@ -328,9 +328,8 @@ void Convertor::mapErrnoToString(int errNum, std::string& errString)
* none
******************************************************************************/
/* static */
// TODO MCOL-641
void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType,
ColType& internalType, bool isToken)
int colWidth, ColType& internalType, bool isToken)
{
if (isToken)
{
@ -382,6 +381,36 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType,
internalType = WriteEngine::WR_DOUBLE;
break;
// Map DECIMAL to applicable integer type
case CalpontSystemCatalog::DECIMAL :
case CalpontSystemCatalog::UDECIMAL :
{
switch (colWidth)
{
case 1 :
internalType = WriteEngine::WR_BYTE;
break;
case 2 :
internalType = WriteEngine::WR_SHORT;
break;
case 4 :
internalType = WriteEngine::WR_INT;
break;
case 8:
internalType = WriteEngine::WR_LONGLONG;
break;
default:
internalType = WriteEngine::WR_BINARY;
break;
}
break;
}
// Map BLOB to WR_BLOB
case CalpontSystemCatalog::BLOB :
internalType = WriteEngine::WR_BLOB;
@ -397,13 +426,6 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType,
internalType = WriteEngine::WR_VARBINARY;
break;
// Map DECIMAL to applicable WR_CHAR
// We can't map them to their proper int size, since in this version
// of convertColType(), we don't know what that is. Hopefully
// this is never used for DECIMAL.
case CalpontSystemCatalog::DECIMAL :
case CalpontSystemCatalog::UDECIMAL:
// Map CHAR, VARCHAR, and CLOB to WR_CHAR
case CalpontSystemCatalog::CHAR :
case CalpontSystemCatalog::VARCHAR :
@ -436,11 +458,6 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType,
internalType = WriteEngine::WR_ULONGLONG;
break;
// Map BINARY to WR_BINARY
case CalpontSystemCatalog::BINARY:
internalType = WriteEngine::WR_BINARY;
break;
default:
internalType = WriteEngine::WR_CHAR;
break;
@ -693,11 +710,6 @@ void Convertor::convertColType(ColStruct* curStruct)
*internalType = WriteEngine::WR_ULONGLONG;
break;
// Map BINARY to WR_BINARY
case CalpontSystemCatalog::BINARY:
*internalType = WriteEngine::WR_BINARY;
break;
default:
*internalType = WriteEngine::WR_CHAR;
break;
@ -783,10 +795,6 @@ int Convertor::getCorrectRowWidth(CalpontSystemCatalog::ColDataType dataType, in
newWidth = 8;
break;
case CalpontSystemCatalog::BINARY:
newWidth = width;
break;
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY: // treat same as varchar for now

View File

@ -98,7 +98,8 @@ public:
*/
//BUG931
EXPORT static void convertColType(execplan::CalpontSystemCatalog::ColDataType dataType,
ColType& internalType, bool isToken = false);
int colWidth, ColType& internalType,
bool isToken = false);
/**
* @brief Convert specified internal storage type (ColType) to
* ColDataType

View File

@ -397,17 +397,8 @@ void WriteEngineWrapper::convertValue(const execplan::CalpontSystemCatalog::ColT
case WriteEngine::WR_BINARY:
{
size = cscColType.colWidth;
if (cscColType.colDataType == CalpontSystemCatalog::DECIMAL ||
cscColType.colDataType == CalpontSystemCatalog::UDECIMAL)
{
int128_t val = boost::any_cast<int128_t>(data);
memcpy(value, &val, size);
}
else // for CalpontSystemCatalog::BINARY
{
char val = boost::any_cast<char>(data);
memcpy(value, &val, size);
}
int128_t val = boost::any_cast<int128_t>(data);
memcpy(value, &val, size);
}
break;
@ -515,21 +506,10 @@ void WriteEngineWrapper::convertValue(const CalpontSystemCatalog::ColType& cscCo
((Token*)valArray)[pos] = boost::any_cast<Token>(data);
break;
// WIP MCOL-641
case WriteEngine::WR_BINARY:
size_t size = cscColType.colWidth;
if (cscColType.colDataType == CalpontSystemCatalog::DECIMAL ||
cscColType.colDataType == CalpontSystemCatalog::UDECIMAL)
{
int128_t val = boost::any_cast<int128_t>(data);
memcpy((uint8_t*)valArray + pos * size, &val, size);
}
else // for CalpontSystemCatalog::BINARY
{
char val = boost::any_cast<char>(data);
memcpy((uint8_t*)valArray + pos * size, &val, size);
}
int128_t val = boost::any_cast<int128_t>(data);
memcpy((uint8_t*)valArray + pos * size, &val, size);
break;
} // end of switch (colType)
}
@ -596,23 +576,11 @@ void WriteEngineWrapper::convertValue(const CalpontSystemCatalog::ColType& cscCo
case WriteEngine::WR_TOKEN:
data = ((Token*)valArray)[pos];
break;
// WIP MCOL-641
case WriteEngine::WR_BINARY :
if (cscColType.colDataType == CalpontSystemCatalog::DECIMAL ||
cscColType.colDataType == CalpontSystemCatalog::UDECIMAL)
{
data = ((int128_t*)valArray)[pos];
}
else // for CalpontSystemCatalog::BINARY
{
// WIP do we need tmp here?
size_t size = cscColType.colWidth;
char *tmp = (char*) alloca (sizeof(char) * size);
memcpy(tmp, (uint8_t*)valArray + pos * size, size);
curStr = tmp;
data = curStr;
}
break;
case WriteEngine::WR_BINARY:
data = ((int128_t*)valArray)[pos];
break;
} // end of switch (colType)
} // end of if
}
@ -709,7 +677,7 @@ int WriteEngineWrapper::fillColumn(const TxnID& txnid, const OID& dataOid,
isToken = true;
}
Convertor::convertColType(colType.colDataType, newColType, isToken);
Convertor::convertColType(colType.colDataType, colType.colWidth, newColType, isToken);
// WIP
// replace with isDictCol
@ -729,7 +697,7 @@ int WriteEngineWrapper::fillColumn(const TxnID& txnid, const OID& dataOid,
newDataWidth >>= 1;
}
Convertor::convertColType(refColDataType, refColType, isToken);
Convertor::convertColType(refColDataType, refColWidth, refColType, isToken);
refColOp->setColParam(refCol, 0, refColOp->getCorrectRowWidth(refColDataType, refColWidth),
refColDataType, refColType, (FID)refColOID, refCompressionType, dbRoot);
colOpNewCol->setColParam(newCol, 0, newDataWidth,