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

@@ -48,6 +48,8 @@ int64_t Func_year::getIntVal(rowgroup::Row& row,
CalpontSystemCatalog::ColType& op_ct)
{
int64_t val = 0;
DateTime aDateTime;
Time aTime;
switch (parm[0]->data()->resultType().colDataType)
{
@@ -59,6 +61,15 @@ int64_t Func_year::getIntVal(rowgroup::Row& row,
val = parm[0]->data()->getIntVal(row, isNull);
return (unsigned)((val >> 48) & 0xffff);
// Time adds to now() and then gets value
case CalpontSystemCatalog::TIME:
aDateTime = static_cast<DateTime>(nowDatetime());
aTime = parm[0]->data()->getTimeIntVal(row, isNull);
aTime.day = 0;
val = addTime(aDateTime, aTime);
return (unsigned)((val >> 48) & 0xffff);
break;
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::VARCHAR: