!384 MOT bug fixes
Merge pull request !384 from Vinoth Veeraraghavan/master
This commit is contained in:
@ -1081,11 +1081,13 @@ void Table::Serialize(char* dataOut)
|
|||||||
|
|
||||||
void Table::Deserialize(const char* in)
|
void Table::Deserialize(const char* in)
|
||||||
{
|
{
|
||||||
|
// m_numIndexes will be incremented during each index addition
|
||||||
|
uint16_t savedNumIndexes = 0;
|
||||||
SetDeserialized(false);
|
SetDeserialized(false);
|
||||||
char* dataIn = (char*)in;
|
char* dataIn = (char*)in;
|
||||||
dataIn = SerializableSTR::Deserialize(dataIn, m_tableName);
|
dataIn = SerializableSTR::Deserialize(dataIn, m_tableName);
|
||||||
dataIn = SerializableSTR::Deserialize(dataIn, m_longTableName);
|
dataIn = SerializableSTR::Deserialize(dataIn, m_longTableName);
|
||||||
dataIn = SerializablePOD<uint16_t>::Deserialize(dataIn, m_numIndexes);
|
dataIn = SerializablePOD<uint16_t>::Deserialize(dataIn, savedNumIndexes);
|
||||||
dataIn = SerializablePOD<uint32_t>::Deserialize(dataIn, m_tableId);
|
dataIn = SerializablePOD<uint32_t>::Deserialize(dataIn, m_tableId);
|
||||||
dataIn = SerializablePOD<uint64_t>::Deserialize(dataIn, m_tableExId);
|
dataIn = SerializablePOD<uint64_t>::Deserialize(dataIn, m_tableExId);
|
||||||
dataIn = SerializablePOD<bool>::Deserialize(dataIn, m_fixedLengthRows);
|
dataIn = SerializablePOD<bool>::Deserialize(dataIn, m_fixedLengthRows);
|
||||||
@ -1096,7 +1098,7 @@ void Table::Deserialize(const char* in)
|
|||||||
MOT_LOG_DEBUG("Table::%s: %s num indexes: %d current Id: %u counter: %u",
|
MOT_LOG_DEBUG("Table::%s: %s num indexes: %d current Id: %u counter: %u",
|
||||||
__func__,
|
__func__,
|
||||||
m_longTableName.c_str(),
|
m_longTableName.c_str(),
|
||||||
m_numIndexes,
|
savedNumIndexes,
|
||||||
m_tableId,
|
m_tableId,
|
||||||
tableCounter.load());
|
tableCounter.load());
|
||||||
if (m_tableId >= tableCounter.load()) {
|
if (m_tableId >= tableCounter.load()) {
|
||||||
@ -1104,9 +1106,7 @@ void Table::Deserialize(const char* in)
|
|||||||
MOT_LOG_DEBUG("Setting tableCounter to %u", tableCounter.load());
|
MOT_LOG_DEBUG("Setting tableCounter to %u", tableCounter.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t savedNumIndexes = m_numIndexes;
|
|
||||||
uint32_t saveFieldCount = m_fieldCnt;
|
uint32_t saveFieldCount = m_fieldCnt;
|
||||||
m_numIndexes = 1; /* primary always exists */
|
|
||||||
// OA: use interleaved allocation for table columns
|
// OA: use interleaved allocation for table columns
|
||||||
if (!Init(m_tableName.c_str(), m_longTableName.c_str(), m_fieldCnt, m_tableExId)) {
|
if (!Init(m_tableName.c_str(), m_longTableName.c_str(), m_fieldCnt, m_tableExId)) {
|
||||||
MOT_LOG_ERROR("Table::Deserialize - failed to init table");
|
MOT_LOG_ERROR("Table::Deserialize - failed to init table");
|
||||||
@ -1142,6 +1142,7 @@ void Table::Deserialize(const char* in)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MOT_ASSERT(m_numIndexes == savedNumIndexes);
|
||||||
SetDeserialized(true);
|
SetDeserialized(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2520,12 +2520,22 @@ void MOTAdaptor::DatumToMOTKey(
|
|||||||
case VARCHAROID:
|
case VARCHAROID:
|
||||||
case CLOBOID:
|
case CLOBOID:
|
||||||
case BPCHAROID: {
|
case BPCHAROID: {
|
||||||
if (expr && expr->expr && IsA(expr->expr, Const)) { // OA: LLVM passes nullptr for expr parameter
|
if (expr != nullptr) { // OA: LLVM passes nullptr for expr parameter
|
||||||
Const* c = (Const*)expr->expr;
|
bool noValue = false;
|
||||||
|
switch (expr->resultType) {
|
||||||
if (c->constbyval) {
|
case BYTEAOID:
|
||||||
errno_t erc = memset_s(data, len, 0x00, len);
|
case TEXTOID:
|
||||||
securec_check(erc, "\0", "\0");
|
case VARCHAROID:
|
||||||
|
case CLOBOID:
|
||||||
|
case BPCHAROID:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
noValue = true;
|
||||||
|
errno_t erc = memset_s(data, len, 0x00, len);
|
||||||
|
securec_check(erc, "\0", "\0");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (noValue) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2560,10 +2570,8 @@ void MOTAdaptor::DatumToMOTKey(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FLOAT4OID: {
|
case FLOAT4OID: {
|
||||||
if (expr && expr->expr && IsA(expr->expr, Const)) { // OA: LLVM passes nullptr for expr parameter
|
if (expr != nullptr) { // OA: LLVM passes nullptr for expr parameter
|
||||||
Const* c = (Const*)expr->expr;
|
if (expr->resultType == FLOAT8OID) {
|
||||||
|
|
||||||
if (c->consttype == FLOAT8OID) {
|
|
||||||
MOT::DoubleConvT dc;
|
MOT::DoubleConvT dc;
|
||||||
MOT::FloatConvT fc;
|
MOT::FloatConvT fc;
|
||||||
dc.m_r = (uint64_t)datum;
|
dc.m_r = (uint64_t)datum;
|
||||||
@ -2573,6 +2581,8 @@ void MOTAdaptor::DatumToMOTKey(
|
|||||||
} else {
|
} else {
|
||||||
col->PackKey(data, datum, col->m_size);
|
col->PackKey(data, datum, col->m_size);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
col->PackKey(data, datum, col->m_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2586,36 +2596,48 @@ void MOTAdaptor::DatumToMOTKey(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIMESTAMPOID: {
|
case TIMESTAMPOID: {
|
||||||
if (expr->resultType == TIMESTAMPTZOID) {
|
if (expr != nullptr) {
|
||||||
Timestamp result = DatumGetTimestamp(DirectFunctionCall1(timestamptz_timestamp, datum));
|
if (expr->resultType == TIMESTAMPTZOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
Timestamp result = DatumGetTimestamp(DirectFunctionCall1(timestamptz_timestamp, datum));
|
||||||
} else if (expr->resultType == DATEOID) {
|
col->PackKey(data, result, col->m_size);
|
||||||
Timestamp result = DatumGetTimestamp(DirectFunctionCall1(date_timestamp, datum));
|
} else if (expr->resultType == DATEOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
Timestamp result = DatumGetTimestamp(DirectFunctionCall1(date_timestamp, datum));
|
||||||
|
col->PackKey(data, result, col->m_size);
|
||||||
|
} else {
|
||||||
|
col->PackKey(data, datum, col->m_size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
col->PackKey(data, datum, col->m_size);
|
col->PackKey(data, datum, col->m_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIMESTAMPTZOID: {
|
case TIMESTAMPTZOID: {
|
||||||
if (expr->resultType == TIMESTAMPOID) {
|
if (expr != nullptr) {
|
||||||
TimestampTz result = DatumGetTimestampTz(DirectFunctionCall1(timestamp_timestamptz, datum));
|
if (expr->resultType == TIMESTAMPOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
TimestampTz result = DatumGetTimestampTz(DirectFunctionCall1(timestamp_timestamptz, datum));
|
||||||
} else if (expr->resultType == DATEOID) {
|
col->PackKey(data, result, col->m_size);
|
||||||
TimestampTz result = DatumGetTimestampTz(DirectFunctionCall1(date_timestamptz, datum));
|
} else if (expr->resultType == DATEOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
TimestampTz result = DatumGetTimestampTz(DirectFunctionCall1(date_timestamptz, datum));
|
||||||
|
col->PackKey(data, result, col->m_size);
|
||||||
|
} else {
|
||||||
|
col->PackKey(data, datum, col->m_size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
col->PackKey(data, datum, col->m_size);
|
col->PackKey(data, datum, col->m_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DATEOID: {
|
case DATEOID: {
|
||||||
if (expr->resultType == TIMESTAMPOID) {
|
if (expr != nullptr) {
|
||||||
DateADT result = DatumGetDateADT(DirectFunctionCall1(timestamp_date, datum));
|
if (expr->resultType == TIMESTAMPOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
DateADT result = DatumGetDateADT(DirectFunctionCall1(timestamp_date, datum));
|
||||||
} else if (expr->resultType == TIMESTAMPTZOID) {
|
col->PackKey(data, result, col->m_size);
|
||||||
DateADT result = DatumGetDateADT(DirectFunctionCall1(timestamptz_date, datum));
|
} else if (expr->resultType == TIMESTAMPTZOID) {
|
||||||
col->PackKey(data, result, col->m_size);
|
DateADT result = DatumGetDateADT(DirectFunctionCall1(timestamptz_date, datum));
|
||||||
|
col->PackKey(data, result, col->m_size);
|
||||||
|
} else {
|
||||||
|
col->PackKey(data, datum, col->m_size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
col->PackKey(data, datum, col->m_size);
|
col->PackKey(data, datum, col->m_size);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user