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

MCOL-5480 LOAD DATA INFILE incorrectly loads values for MEDIUMINT datatype.

Internal memory representation of MEDIUMINT datatype uses 24 bits. This is
true for both MariaDB server as well as ColumnStore. MCS plugin code uses
TypeHandlerSInt24 and TypeHandlerUInt24 classes to respectively convert the
binary representation of the signed and unsigned MEDIUMINT values passed by
the server to the plugin. The plugin then outputs the text representation
of these values into an open file descriptor which is piped to cpimport
for the final load into the MCS db files.

The TypeHandlerXInt24 classes were earlier incorrectly using
WriteBatchField::ColWriteBatchXInt32() functions which operate on a 4 byte
buffer. This resulted in incorrect parsing of MEDIUMINT values. As a fix,
we implement WriteBatchField::ColWriteBatchXInt24() functions which
correctly handle the 24 bit input buffer used for MEDIUMINT datatype.
This commit is contained in:
Gagan Goel
2023-05-19 18:30:52 -04:00
parent 611087fe7c
commit 10f1a7abbc
4 changed files with 316 additions and 2 deletions

View File

@ -448,6 +448,40 @@ class WriteBatchFieldMariaDB : public WriteBatchField
return 4;
}
size_t ColWriteBatchSInt24(const uchar* buf, bool nullVal, ColBatchWriter& ci) override
{
if (nullVal && (m_type.constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
{
fprintf(ci.filePtr(), "%c", ci.delimiter());
}
else
{
int32_t tmp = (
(*const_cast<uint8_t*>(buf) << 8) |
(*const_cast<uint8_t*>(buf+1) << 16) |
(*const_cast<uint8_t*>(buf+2) << 24)
) >> 8;
fprintf(ci.filePtr(), "%d%c", tmp, ci.delimiter());
}
return 3;
}
size_t ColWriteBatchUInt24(const uchar* buf, bool nullVal, ColBatchWriter& ci) override
{
if (nullVal && (m_type.constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
fprintf(ci.filePtr(), "%c", ci.delimiter());
else
{
uint32_t tmp = (
(*const_cast<uint8_t*>(buf)) |
(*const_cast<uint8_t*>(buf+1) << 8) |
(*const_cast<uint8_t*>(buf+2) << 16)
);
fprintf(ci.filePtr(), "%u%c", tmp, ci.delimiter());
}
return 3;
}
size_t ColWriteBatchSInt16(const uchar* buf, bool nullVal, ColBatchWriter& ci) override
{
if (nullVal && (m_type.constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))