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-4005 Fix handling of utf8 and \ for TEXT data type
when performing LDI using cpimport.
This commit is contained in:
@ -891,7 +891,11 @@ int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::ca
|
|||||||
if (current_thd->variables.sql_mode & MODE_PAD_CHAR_TO_FULL_LENGTH)
|
if (current_thd->variables.sql_mode & MODE_PAD_CHAR_TO_FULL_LENGTH)
|
||||||
{
|
{
|
||||||
// Pad to the full length of the field
|
// Pad to the full length of the field
|
||||||
escape.assign((char*)buf, ci.columnTypes[colpos].colWidth);
|
if (ci.utf8)
|
||||||
|
escape.assign((char*)buf, ci.columnTypes[colpos].colWidth * 3);
|
||||||
|
else
|
||||||
|
escape.assign((char*)buf, ci.columnTypes[colpos].colWidth);
|
||||||
|
|
||||||
boost::replace_all(escape, "\\", "\\\\");
|
boost::replace_all(escape, "\\", "\\\\");
|
||||||
|
|
||||||
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(),
|
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(),
|
||||||
@ -904,8 +908,10 @@ int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::ca
|
|||||||
bitmap_set_bit(table->read_set, field->field_index);
|
bitmap_set_bit(table->read_set, field->field_index);
|
||||||
String attribute;
|
String attribute;
|
||||||
field->val_str(&attribute);
|
field->val_str(&attribute);
|
||||||
|
|
||||||
escape.assign((char*)buf, attribute.length());
|
escape.assign((char*)buf, attribute.length());
|
||||||
boost::replace_all(escape, "\\", "\\\\");
|
boost::replace_all(escape, "\\", "\\\\");
|
||||||
|
|
||||||
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(),
|
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(),
|
||||||
escape.c_str(), ci.enclosed_by, ci.delimiter);
|
escape.c_str(), ci.enclosed_by, ci.delimiter);
|
||||||
}
|
}
|
||||||
@ -1777,32 +1783,35 @@ int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::ca
|
|||||||
case CalpontSystemCatalog::BLOB:
|
case CalpontSystemCatalog::BLOB:
|
||||||
case CalpontSystemCatalog::TEXT:
|
case CalpontSystemCatalog::TEXT:
|
||||||
{
|
{
|
||||||
|
// MCOL-4005 Note that we don't handle nulls as a special
|
||||||
|
// case here as we do for other datatypes, the below works
|
||||||
|
// as expected for nulls.
|
||||||
uint32_t dataLength = 0;
|
uint32_t dataLength = 0;
|
||||||
uintptr_t* dataptr;
|
uintptr_t* dataptr;
|
||||||
uchar* ucharptr;
|
uchar* ucharptr;
|
||||||
|
uint colWidthInBytes = (ci.utf8 ?
|
||||||
|
ci.columnTypes[colpos].colWidth * 3: ci.columnTypes[colpos].colWidth);
|
||||||
|
|
||||||
if (ci.columnTypes[colpos].colWidth < 256)
|
if (colWidthInBytes < 256)
|
||||||
{
|
{
|
||||||
dataLength = *(uint8_t*) buf;
|
dataLength = *(uint8_t*) buf;
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
else if (ci.columnTypes[colpos].colWidth < 65536)
|
else if (colWidthInBytes < 65536)
|
||||||
{
|
{
|
||||||
dataLength = *(uint16_t*) buf;
|
dataLength = *(uint16_t*) buf;
|
||||||
buf = buf + 2 ;
|
buf += 2;
|
||||||
}
|
}
|
||||||
else if (ci.columnTypes[colpos].colWidth < 16777216)
|
else if (colWidthInBytes < 16777216)
|
||||||
{
|
{
|
||||||
dataLength = *(uint16_t*) buf;
|
dataLength = *(uint16_t*) buf;
|
||||||
buf = buf + 2 ;
|
dataLength |= ((int) buf[2]) << 16;
|
||||||
if (*(uint8_t*)buf)
|
buf += 3;
|
||||||
dataLength += 256*256*(*(uint8_t*)buf) ;
|
|
||||||
buf++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataLength = *(uint32_t*) buf;
|
dataLength = *(uint32_t*) buf;
|
||||||
buf = buf + 4 ;
|
buf += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// buf contains pointer to blob, for example:
|
// buf contains pointer to blob, for example:
|
||||||
@ -1826,7 +1835,9 @@ int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::ca
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TEXT Column
|
// TEXT Column
|
||||||
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, dataLength, ucharptr, ci.enclosed_by, ci.delimiter);
|
escape.assign((char*)ucharptr, dataLength);
|
||||||
|
boost::replace_all(escape, "\\", "\\\\");
|
||||||
|
fprintf(ci.filePtr, "%c%.*s%c%c", ci.enclosed_by, (int)escape.length(), escape.c_str(), ci.enclosed_by, ci.delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user