You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-330 Fix datetime to int conversion
Datetime has internal int value which is very different to MySQL's int value. This patch differentiates between the two and also fixes a column width issue which appeared once the datetime handling was fixed.
This commit is contained in:
@ -448,6 +448,17 @@ int fetchNextRow(uchar *buf, cal_table_info& ti, cal_connection_info* ci)
|
|||||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||||
intColVal = row.getUintField<8>(s);
|
intColVal = row.getUintField<8>(s);
|
||||||
DataConvert::datetimeToString(intColVal, tmp, 255);
|
DataConvert::datetimeToString(intColVal, tmp, 255);
|
||||||
|
|
||||||
|
/* setting the field_length is a sort-of hack. The length
|
||||||
|
* at this point can be long enough to include mseconds.
|
||||||
|
* ColumnStore doesn't fully support mseconds yet so if
|
||||||
|
* they are requested, trim them off.
|
||||||
|
* At a later date we should set this more intelligently
|
||||||
|
* based on the result set.
|
||||||
|
*/
|
||||||
|
if ((*f)->field_length > 19)
|
||||||
|
(*f)->field_length = strlen(tmp);
|
||||||
|
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
Field_varstring* f2 = (Field_varstring*)*f;
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
f2->store(tmp, strlen(tmp), f2->charset());
|
||||||
break;
|
break;
|
||||||
|
@ -227,7 +227,7 @@ string Func_date_format::getStrVal(rowgroup::Row& row,
|
|||||||
dt.day = (uint32_t)((val >> 6) & 0x3f);
|
dt.day = (uint32_t)((val >> 6) & 0x3f);
|
||||||
break;
|
break;
|
||||||
case CalpontSystemCatalog::DATETIME:
|
case CalpontSystemCatalog::DATETIME:
|
||||||
val = parm[0]->data()->getIntVal(row, isNull);
|
val = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||||
dt.year = (uint32_t)((val >> 48) & 0xffff);
|
dt.year = (uint32_t)((val >> 48) & 0xffff);
|
||||||
dt.month = (uint32_t)((val >> 44) & 0xf);
|
dt.month = (uint32_t)((val >> 44) & 0xf);
|
||||||
dt.day = (uint32_t)((val >> 38) & 0x3f);
|
dt.day = (uint32_t)((val >> 38) & 0x3f);
|
||||||
|
@ -61,7 +61,7 @@ DateTime getDateTime(rowgroup::Row& row,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
val = parm[0]->data()->getIntVal(row, isNull);
|
val = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val < 0 || val > helpers::TIMESTAMP_MAX_VALUE)
|
if (val < 0 || val > helpers::TIMESTAMP_MAX_VALUE)
|
||||||
@ -146,7 +146,6 @@ int64_t Func_from_unixtime::getIntVal(rowgroup::Row& row,
|
|||||||
bool& isNull,
|
bool& isNull,
|
||||||
CalpontSystemCatalog::ColType& ct)
|
CalpontSystemCatalog::ColType& ct)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
DateTime dt = getDateTime(row, parm, isNull);
|
DateTime dt = getDateTime(row, parm, isNull);
|
||||||
if (*reinterpret_cast<int64_t*>(&dt) == 0)
|
if (*reinterpret_cast<int64_t*>(&dt) == 0)
|
||||||
{
|
{
|
||||||
@ -154,12 +153,10 @@ int64_t Func_from_unixtime::getIntVal(rowgroup::Row& row,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char buf[32]; // actual string guaranteed to be 22
|
char buf[32]; // actual string guaranteed to be 22
|
||||||
snprintf( buf, 32, "%04d%02d%02d%02d%02d%02",
|
snprintf( buf, 32, "%04d%02d%02d%02d%02d%02d",
|
||||||
dt.year, dt.month, dt.day, dt.hour,
|
dt.year, dt.month, dt.day, dt.hour,
|
||||||
dt.minute, dt.second );
|
dt.minute, dt.second );
|
||||||
return atoll(buf);
|
return atoll(buf);
|
||||||
#endif
|
|
||||||
return getDatetimeIntVal(row, parm, isNull, ct);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double Func_from_unixtime::getDoubleVal(rowgroup::Row& row,
|
double Func_from_unixtime::getDoubleVal(rowgroup::Row& row,
|
||||||
|
@ -257,7 +257,7 @@ void FuncExp::evaluate(rowgroup::Row& row, std::vector<execplan::SRCP>& expressi
|
|||||||
}
|
}
|
||||||
case CalpontSystemCatalog::DATETIME:
|
case CalpontSystemCatalog::DATETIME:
|
||||||
{
|
{
|
||||||
int64_t val = expression[i]->getIntVal(row, isNull);
|
int64_t val = expression[i]->getDatetimeIntVal(row, isNull);
|
||||||
if (isNull)
|
if (isNull)
|
||||||
row.setUintField<8>(DATETIMENULL, expression[i]->outputIndex());
|
row.setUintField<8>(DATETIMENULL, expression[i]->outputIndex());
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user