1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-3959 1.5 make from_unixtimestamp msec aware

When using the function with decimal or float types, the fractional portion is the msec.
This commit is contained in:
David Hall
2020-04-23 09:54:33 -05:00
parent 2ec06046a0
commit 9bec66c36f

View File

@ -45,7 +45,8 @@ DateTime getDateTime(rowgroup::Row& row,
FunctionParm& parm, FunctionParm& parm,
bool& isNull) bool& isNull)
{ {
int64_t val; int64_t val = 0;
uint32_t msec = 0;
switch (parm[0]->data()->resultType().colDataType) switch (parm[0]->data()->resultType().colDataType)
{ {
@ -54,13 +55,10 @@ DateTime getDateTime(rowgroup::Row& row,
case execplan::CalpontSystemCatalog::DECIMAL: case execplan::CalpontSystemCatalog::DECIMAL:
{ {
double value = parm[0]->data()->getDoubleVal(row, isNull); double value = parm[0]->data()->getDoubleVal(row, isNull);
double fracpart, intpart;
if (value > 0) fracpart = modf(value, &intpart);
value += 0.5; val = (int64_t)intpart;
else if (value < 0) msec = (uint32_t)(fracpart * IDB_pow[parm[0]->data()->resultType().scale]);
value -= 0.5;
val = (int64_t)value;
break; break;
} }
@ -84,7 +82,7 @@ DateTime getDateTime(rowgroup::Row& row,
dt.hour = (int64_t) tmp_tm.tm_hour; dt.hour = (int64_t) tmp_tm.tm_hour;
dt.minute = (int64_t) tmp_tm.tm_min; dt.minute = (int64_t) tmp_tm.tm_min;
dt.second = (int64_t) tmp_tm.tm_sec; dt.second = (int64_t) tmp_tm.tm_sec;
dt.msecond = 0; dt.msecond = msec;
return dt; return dt;
} }
} }