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-4174 Review/refactor frontend/connector code
This commit is contained in:
committed by
Roman Nozdrin
parent
68244ab957
commit
129d5b5a0f
@ -15,7 +15,8 @@ set(WriteEngineServer_SRCS
|
||||
we_cleartablelockcmd.cpp
|
||||
we_cpifeederthread.cpp
|
||||
we_getfilesizes.cpp
|
||||
../../utils/common/crashtrace.cpp)
|
||||
../../utils/common/crashtrace.cpp
|
||||
../../datatypes/mcs_datatype.cpp)
|
||||
|
||||
add_executable(WriteEngineServer ${WriteEngineServer_SRCS})
|
||||
|
||||
|
@ -213,12 +213,12 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err)
|
||||
else if (INIT_COL == column.tableColName.column)
|
||||
{
|
||||
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (NEXT_COL == column.tableColName.column)
|
||||
{
|
||||
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (AUTOINC_COL == column.tableColName.column)
|
||||
{
|
||||
@ -226,7 +226,7 @@ uint8_t WE_DDLCommandProc::writeSystable(ByteStream& bs, std::string& err)
|
||||
}
|
||||
else
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
|
||||
colStruct.dataOid = column.oid;
|
||||
@ -588,7 +588,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
|
||||
else
|
||||
{
|
||||
tmpStr = "";
|
||||
//colTuple.data = getNullValueForType(column.colType);
|
||||
//colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
|
||||
}
|
||||
@ -629,16 +629,16 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
|
||||
}
|
||||
else
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
}
|
||||
else if (LISTOBJID_COL == column.tableColName.column)
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (TREEOBJID_COL == column.tableColName.column)
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (MINVAL_COL == column.tableColName.column)
|
||||
{
|
||||
@ -664,7 +664,7 @@ uint8_t WE_DDLCommandProc::writeCreateSyscolumn(ByteStream& bs, std::string& err
|
||||
}
|
||||
else
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
|
||||
colStruct.dataOid = column.oid;
|
||||
@ -982,7 +982,7 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
|
||||
else
|
||||
{
|
||||
tmpStr = "";
|
||||
//colTuple.data = getNullValueForType(column.colType);
|
||||
//colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1023,16 +1023,16 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
|
||||
}
|
||||
else
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
}
|
||||
else if (LISTOBJID_COL == column.tableColName.column)
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (TREEOBJID_COL == column.tableColName.column)
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
else if (MINVAL_COL == column.tableColName.column)
|
||||
{
|
||||
@ -1058,7 +1058,7 @@ uint8_t WE_DDLCommandProc::writeSyscolumn(ByteStream& bs, std::string& err)
|
||||
}
|
||||
else
|
||||
{
|
||||
colTuple.data = getNullValueForType(column.colType);
|
||||
colTuple.data = column.colType.getNullValueForType();
|
||||
}
|
||||
|
||||
colStruct.dataOid = column.oid;
|
||||
@ -3646,7 +3646,7 @@ uint8_t WE_DDLCommandProc::fillNewColumn(ByteStream& bs, std::string& err)
|
||||
colType.scale = scale;
|
||||
colType.precision = precision;
|
||||
bool pushWarning = false;
|
||||
defaultVal.data = DataConvert::convertColumnData(colType, defaultValStr, pushWarning, timeZone, isNULL, false, false);
|
||||
defaultVal.data = colType.convertColumnData(defaultValStr, pushWarning, timeZone, isNULL, false, false);
|
||||
fWEWrapper.setTransId(txnID);
|
||||
fWEWrapper.setIsInsert(true);
|
||||
fWEWrapper.setBulkFlag(true);
|
||||
|
@ -143,239 +143,6 @@ inline void getColumnsForTable(uint32_t sessionID, std::string schema, std::str
|
||||
|
||||
}
|
||||
|
||||
inline boost::any getNullValueForType(const execplan::CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
boost::any value;
|
||||
|
||||
switch (colType.colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIT:
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
{
|
||||
char tinyintvalue = joblist::TINYINTNULL;
|
||||
value = tinyintvalue;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
{
|
||||
uint8_t tinyintvalue = joblist::UTINYINTNULL;
|
||||
value = tinyintvalue;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
{
|
||||
short smallintvalue = joblist::SMALLINTNULL;
|
||||
value = smallintvalue;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
{
|
||||
uint16_t smallintvalue = joblist::USMALLINTNULL;
|
||||
value = smallintvalue;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
{
|
||||
int intvalue = joblist::INTNULL;
|
||||
value = intvalue;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
{
|
||||
uint32_t intvalue = joblist::UINTNULL;
|
||||
value = intvalue;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
{
|
||||
long long bigint = joblist::BIGINTNULL;
|
||||
value = bigint;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
{
|
||||
uint64_t bigint = joblist::UBIGINTNULL;
|
||||
value = bigint;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
{
|
||||
short smallintvalue = joblist::SMALLINTNULL;
|
||||
value = smallintvalue;
|
||||
}
|
||||
else if (colType.colWidth <= 9)
|
||||
{
|
||||
int intvalue = joblist::INTNULL;
|
||||
value = intvalue;
|
||||
}
|
||||
else if (colType.colWidth <= 18)
|
||||
{
|
||||
long long eightbyte = joblist::BIGINTNULL;
|
||||
value = eightbyte;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteEngine::Token nullToken;
|
||||
value = nullToken;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
{
|
||||
uint32_t jlfloatnull = joblist::FLOATNULL;
|
||||
float* fp = reinterpret_cast<float*>(&jlfloatnull);
|
||||
value = *fp;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
{
|
||||
uint64_t jldoublenull = joblist::DOUBLENULL;
|
||||
double* dp = reinterpret_cast<double*>(&jldoublenull);
|
||||
value = *dp;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE:
|
||||
{
|
||||
int d = joblist::DATENULL;
|
||||
value = d;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME:
|
||||
{
|
||||
long long d = joblist::DATETIMENULL;
|
||||
value = d;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
{
|
||||
long long d = joblist::TIMENULL;
|
||||
value = d;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
{
|
||||
long long d = joblist::TIMESTAMPNULL;
|
||||
value = d;
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR1NULL;
|
||||
charnull = "\376";
|
||||
value = charnull;
|
||||
}
|
||||
else if (colType.colWidth == execplan::CalpontSystemCatalog::TWO_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR2NULL;
|
||||
charnull = "\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR4NULL;
|
||||
charnull = "\377\377\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteEngine::Token nullToken;
|
||||
value = nullToken;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR2NULL;
|
||||
charnull = "\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR4NULL;
|
||||
charnull = "\377\377\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteEngine::Token nullToken;
|
||||
value = nullToken;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::BLOB:
|
||||
case execplan::CalpontSystemCatalog::TEXT:
|
||||
case execplan::CalpontSystemCatalog::VARBINARY:
|
||||
{
|
||||
std::string charnull;
|
||||
|
||||
if (colType.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR2NULL;
|
||||
charnull = "\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
{
|
||||
//charnull = joblist::CHAR4NULL;
|
||||
charnull = "\377\377\377\376";
|
||||
value = charnull;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteEngine::Token nullToken;
|
||||
value = nullToken;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
inline int convertDataType(int dataType)
|
||||
{
|
||||
|
@ -370,7 +370,7 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
|
||||
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
|
||||
datavalue = colType.convertColumnData(indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -1245,7 +1245,7 @@ uint8_t WE_DMLCommandProc::processBatchInsert(messageqcpp::ByteStream& bs, std::
|
||||
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
|
||||
datavalue = colType.convertColumnData(indata, pushWarning, insertPkg.get_TimeZone(), isNULL, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -2996,12 +2996,12 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
if (fetchColColwidths[fetchColPos] == datatypes::MAXDECIMALWIDTH)
|
||||
{
|
||||
int128_t* dec;
|
||||
char buf[utils::MAXLENGTH16BYTES];
|
||||
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
|
||||
dec = row.getBinaryField<int128_t>(fetchColPos);
|
||||
|
||||
dataconvert::DataConvert::decimalToString(dec,
|
||||
(unsigned)fetchColScales[fetchColPos], buf,
|
||||
sizeof(buf), fetchColTypes[fetchColPos]);
|
||||
(uint8_t) sizeof(buf), fetchColTypes[fetchColPos]);
|
||||
|
||||
value.assign(buf);
|
||||
|
||||
@ -3362,12 +3362,12 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
{
|
||||
// WIP MCOL-641
|
||||
int128_t* dec;
|
||||
char buf[utils::MAXLENGTH16BYTES];
|
||||
char buf[datatypes::Decimal::MAXLENGTH16BYTES];
|
||||
dec = row.getBinaryField<int128_t>(fetchColPos);
|
||||
|
||||
dataconvert::DataConvert::decimalToString(dec,
|
||||
(unsigned)fetchColScales[fetchColPos], buf,
|
||||
sizeof(buf), fetchColTypes[fetchColPos]);
|
||||
(uint8_t) sizeof(buf), fetchColTypes[fetchColPos]);
|
||||
|
||||
value = buf;
|
||||
|
||||
@ -3527,7 +3527,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, colType.defaultValue, pushWarn, timeZone, isNull, false, false);
|
||||
datavalue = colType.convertColumnData(colType.defaultValue, pushWarn, timeZone, isNull, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -3559,7 +3559,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
{
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, value, pushWarn, timeZone, isNull, false, false);
|
||||
datavalue = colType.convertColumnData(value, pushWarn, timeZone, isNull, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -3656,7 +3656,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, inData, pushWarn, timeZone, isNull, false, false);
|
||||
datavalue = colType.convertColumnData(inData, pushWarn, timeZone, isNull, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -3702,7 +3702,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
{
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, colType.defaultValue, pushWarn, timeZone, isNull, false, false);
|
||||
datavalue = colType.convertColumnData(colType.defaultValue, pushWarn, timeZone, isNull, false, false);
|
||||
}
|
||||
catch (exception&)
|
||||
{
|
||||
@ -3735,7 +3735,7 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
|
||||
{
|
||||
try
|
||||
{
|
||||
datavalue = DataConvert::convertColumnData(colType, inData, pushWarn, timeZone, isNull, false, true);
|
||||
datavalue = colType.convertColumnData(inData, pushWarn, timeZone, isNull, false, true);
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user