1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2026-01-06 08:21:10 +03:00

MCOL-1433 Fix several functions for TIME handling

This fixes hex() so that it outputs the hex of the ASCII for the time
data to make it aligned with MariaDB. It also fixes the following
functions so that they use NOW() as a DATETIME with the input TIME added
to it:

* weekday()
* yearweek()
* monthname()
* last_day()
* year()
* weekofyear()
* week()
* to_days()
* quarter()
* month()
* dayofyear()
* dayofweek()
* dayofmonth()
* day()
* date()
This commit is contained in:
Andrew Hutchings
2018-06-08 14:58:08 +01:00
parent 12b1d99f51
commit d9e6ba90ad
18 changed files with 380 additions and 174 deletions

View File

@@ -59,6 +59,9 @@ int64_t Func_to_days::getIntVal(rowgroup::Row& row,
month = 0,
day = 0;
DateTime aDateTime;
Time aTime;
switch (type)
{
case execplan::CalpontSystemCatalog::DATE:
@@ -82,6 +85,21 @@ int64_t Func_to_days::getIntVal(rowgroup::Row& row,
break;
}
// Time adds to now() and then gets value
case CalpontSystemCatalog::TIME:
{
int64_t val;
aDateTime = static_cast<DateTime>(nowDatetime());
aTime = parm[0]->data()->getTimeIntVal(row, isNull);
aTime.day = 0;
val = addTime(aDateTime, aTime);
year = (uint32_t)((val >> 48) & 0xffff);
month = (uint32_t)((val >> 44) & 0xf);
day = (uint32_t)((val >> 38) & 0x3f);
return helpers::calc_mysql_daynr(year, month, day);
break;
}
case execplan::CalpontSystemCatalog::VARCHAR: // including CHAR'
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::TEXT: