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
Fix decimal to date/datetime casting
This commit is contained in:
@ -1805,6 +1805,14 @@ int64_t DataConvert::intToDate(int64_t data)
|
||||
//snprintf( buf, 10, "%llu", (long long unsigned int)data);
|
||||
//string date = buf;
|
||||
char buf[21] = {0};
|
||||
Date aday;
|
||||
if (data == 0)
|
||||
{
|
||||
aday.year = 0;
|
||||
aday.month = 0;
|
||||
aday.day = 0;
|
||||
return *(reinterpret_cast<uint32_t*>(&aday));
|
||||
}
|
||||
snprintf( buf, 15, "%llu", (long long unsigned int)data);
|
||||
|
||||
string year, month, day, hour, min, sec, msec;
|
||||
@ -1866,7 +1874,6 @@ int64_t DataConvert::intToDate(int64_t data)
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
Date aday;
|
||||
if (year.empty())
|
||||
{
|
||||
// MMDD format. assume current year
|
||||
|
@ -509,13 +509,6 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row,
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (parm[0]->data()->resultType().scale != 0)
|
||||
{
|
||||
isNull = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = dataconvert::DataConvert::intToDate(parm[0]->data()->getIntVal(row, isNull));
|
||||
if (val == -1)
|
||||
@ -524,7 +517,6 @@ int32_t Func_cast_date::getDateIntVal(rowgroup::Row& row,
|
||||
return val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
@ -714,19 +706,12 @@ int64_t Func_cast_datetime::getDatetimeIntVal(rowgroup::Row& row,
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
{
|
||||
if (parm[0]->data()->resultType().scale)
|
||||
{
|
||||
val = dataconvert::DataConvert::intToDatetime(parm[0]->data()->getIntVal(row, isNull));
|
||||
if (val == -1)
|
||||
isNull = true;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
isNull = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
|
Reference in New Issue
Block a user