!384 MOT bug fixes

Merge pull request !384 from Vinoth Veeraraghavan/master
This commit is contained in:
opengauss-bot
2020-11-09 08:03:40 +08:00
committed by Gitee
2 changed files with 55 additions and 32 deletions

View File

@ -1081,11 +1081,13 @@ void Table::Serialize(char* dataOut)
void Table::Deserialize(const char* in)
{
// m_numIndexes will be incremented during each index addition
uint16_t savedNumIndexes = 0;
SetDeserialized(false);
char* dataIn = (char*)in;
dataIn = SerializableSTR::Deserialize(dataIn, m_tableName);
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<uint64_t>::Deserialize(dataIn, m_tableExId);
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",
__func__,
m_longTableName.c_str(),
m_numIndexes,
savedNumIndexes,
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());
}
uint16_t savedNumIndexes = m_numIndexes;
uint32_t saveFieldCount = m_fieldCnt;
m_numIndexes = 1; /* primary always exists */
// OA: use interleaved allocation for table columns
if (!Init(m_tableName.c_str(), m_longTableName.c_str(), m_fieldCnt, m_tableExId)) {
MOT_LOG_ERROR("Table::Deserialize - failed to init table");
@ -1142,6 +1142,7 @@ void Table::Deserialize(const char* in)
return;
}
}
MOT_ASSERT(m_numIndexes == savedNumIndexes);
SetDeserialized(true);
}

View File

@ -2520,14 +2520,24 @@ void MOTAdaptor::DatumToMOTKey(
case VARCHAROID:
case CLOBOID:
case BPCHAROID: {
if (expr && expr->expr && IsA(expr->expr, Const)) { // OA: LLVM passes nullptr for expr parameter
Const* c = (Const*)expr->expr;
if (c->constbyval) {
if (expr != nullptr) { // OA: LLVM passes nullptr for expr parameter
bool noValue = false;
switch (expr->resultType) {
case BYTEAOID:
case TEXTOID:
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;
}
}
bytea* txt = DatumGetByteaP(datum);
size_t size = VARSIZE(txt); // includes header len VARHDRSZ
@ -2560,10 +2570,8 @@ void MOTAdaptor::DatumToMOTKey(
break;
}
case FLOAT4OID: {
if (expr && expr->expr && IsA(expr->expr, Const)) { // OA: LLVM passes nullptr for expr parameter
Const* c = (Const*)expr->expr;
if (c->consttype == FLOAT8OID) {
if (expr != nullptr) { // OA: LLVM passes nullptr for expr parameter
if (expr->resultType == FLOAT8OID) {
MOT::DoubleConvT dc;
MOT::FloatConvT fc;
dc.m_r = (uint64_t)datum;
@ -2573,6 +2581,8 @@ void MOTAdaptor::DatumToMOTKey(
} else {
col->PackKey(data, datum, col->m_size);
}
} else {
col->PackKey(data, datum, col->m_size);
}
break;
}
@ -2586,6 +2596,7 @@ void MOTAdaptor::DatumToMOTKey(
break;
}
case TIMESTAMPOID: {
if (expr != nullptr) {
if (expr->resultType == TIMESTAMPTZOID) {
Timestamp result = DatumGetTimestamp(DirectFunctionCall1(timestamptz_timestamp, datum));
col->PackKey(data, result, col->m_size);
@ -2595,9 +2606,13 @@ void MOTAdaptor::DatumToMOTKey(
} else {
col->PackKey(data, datum, col->m_size);
}
} else {
col->PackKey(data, datum, col->m_size);
}
break;
}
case TIMESTAMPTZOID: {
if (expr != nullptr) {
if (expr->resultType == TIMESTAMPOID) {
TimestampTz result = DatumGetTimestampTz(DirectFunctionCall1(timestamp_timestamptz, datum));
col->PackKey(data, result, col->m_size);
@ -2607,9 +2622,13 @@ void MOTAdaptor::DatumToMOTKey(
} else {
col->PackKey(data, datum, col->m_size);
}
} else {
col->PackKey(data, datum, col->m_size);
}
break;
}
case DATEOID: {
if (expr != nullptr) {
if (expr->resultType == TIMESTAMPOID) {
DateADT result = DatumGetDateADT(DirectFunctionCall1(timestamp_date, datum));
col->PackKey(data, result, col->m_size);
@ -2619,6 +2638,9 @@ void MOTAdaptor::DatumToMOTKey(
} else {
col->PackKey(data, datum, col->m_size);
}
} else {
col->PackKey(data, datum, col->m_size);
}
break;
}
default: