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

MCOL-392 Fix cpimport and >8bit positive hour

This commit is contained in:
Andrew Hutchings
2018-04-26 17:13:24 +01:00
parent edb2e2f36d
commit dba04e8b72
5 changed files with 53 additions and 37 deletions

View File

@@ -1886,11 +1886,11 @@ int64_t DataConvert::convertColumnTime(
unsigned int dataOrgLen ) unsigned int dataOrgLen )
{ {
status = 0; status = 0;
const char* p; char* p;
p = dataOrg; char* savePoint = NULL;
char fld[10]; p = const_cast<char*>(dataOrg);
int16_t value = 0; int64_t value = 0;
int inYear, inMonth, inDay, inHour, inMinute, inSecond, inMicrosecond; int inHour, inMinute, inSecond, inMicrosecond;
inHour = 0; inHour = 0;
inMinute = 0; inMinute = 0;
inSecond = 0; inSecond = 0;
@@ -1901,43 +1901,58 @@ int64_t DataConvert::convertColumnTime(
return value; return value;
} }
memcpy( fld, p, 2); errno = 0;
fld[2] = '\0';
inHour = strtol(fld, 0, 10); p = strtok_r(p, ":.", &savePoint);
inHour = strtol(p, 0, 10);
if (!isdigit(p[2]) || !isdigit(p[3])) if (errno)
{ {
status = -1; status = -1;
return value; return value;
} }
memcpy( fld, p + 2, 2); p = strtok_r(NULL, ":.", &savePoint);
fld[2] = '\0'; if (p == NULL)
inMinute = strtol(fld, 0, 10);
if (!isdigit(p[4]) || !isdigit(p[5]))
{ {
status = -1; status = -1;
return value; return value;
} }
memcpy( fld, p + 4, 2); inMinute = strtol(p, 0, 10);
fld[2] = '\0';
inSecond = strtol(fld, 0, 10); if (errno)
if (dataOrgLen > 9)
{ {
unsigned int microFldLen = dataOrgLen - 9; status = -1;
return value;
}
if (microFldLen > (sizeof(fld) - 1)) p = strtok_r(NULL, ":.", &savePoint);
microFldLen = sizeof(fld) - 1;
memcpy( fld, p + 9, microFldLen); if (p == NULL)
fld[microFldLen] = '\0'; {
inMicrosecond = strtol(fld, 0, 10); status = -1;
return value;
}
inSecond = strtol(p, 0, 10);
if (errno)
{
status = -1;
return value;
}
p = strtok_r(NULL, ":.", &savePoint);
if (p != NULL)
{
inMicrosecond = strtol(p, 0, 10);
if (errno)
{
status = -1;
return value;
}
} }
if ( isTimeValid (inHour, inMinute, inSecond, inMicrosecond) ) if ( isTimeValid (inHour, inMinute, inSecond, inMicrosecond) )

View File

@@ -568,7 +568,7 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
{ {
// Handle negative correctly // Handle negative correctly
int hour = 0; int hour = 0;
if ((timevalue >> 40) & 0xf00) if ((timevalue >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;
} }

View File

@@ -166,7 +166,7 @@ int64_t Func_bitand::getIntVal(Row& row,
sec = 0, sec = 0,
msec = 0; msec = 0;
// Handle negative correctly // Handle negative correctly
if ((time >> 40) & 0xf00) if ((time >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;
} }

View File

@@ -1543,7 +1543,7 @@ void RowAggregation::doBitOp(const Row& rowIn, int64_t colIn, int64_t colOut, in
int64_t dtm = rowIn.getUintField(colIn); int64_t dtm = rowIn.getUintField(colIn);
// Handle negative correctly // Handle negative correctly
int hour = 0; int hour = 0;
if ((dtm >> 40) & 0xf00) if ((dtm >> 40) & 0x800)
{ {
hour = 0xfffff000; hour = 0xfffff000;
} }

View File

@@ -161,7 +161,8 @@ const char ColDataTypeStr[execplan::CalpontSystemCatalog::NUM_OF_COL_DATA_TYPE]
"unsigned-float", "unsigned-float",
"unsigned-bigint", "unsigned-bigint",
"unsigned-double", "unsigned-double",
"text" "text",
"time"
}; };
enum FuncType { FUNC_WRITE_ENGINE, FUNC_INDEX, FUNC_DICTIONARY }; enum FuncType { FUNC_WRITE_ENGINE, FUNC_INDEX, FUNC_DICTIONARY };