1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

bug(priproc) make last_day type a bit more accurate

This fixes discrepance with the server, which assigns DATE type to
last_day()'s result.

Now we also assigns DATE result type and, also, use proper
dataconvert::Day data structure to return date.

Tests agree with InnoDB.

Also, this patch includes test for MCOL-5669, to show we fixed it.
This commit is contained in:
Leonid Fedorov
2024-03-18 14:30:54 +00:00
committed by Leonid Fedorov
parent ef451af860
commit bfe49a8345
6 changed files with 280 additions and 6 deletions

View File

@ -163,6 +163,12 @@ int64_t Func_last_day::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& i
uint32_t lastday = day;
if (month < 1 || month > 12)
{
isNull = true;
return -1;
}
if (isLeapYear(year) && (month == 2))
{
lastday = 29;
@ -182,16 +188,13 @@ int64_t Func_last_day::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& i
return -1;
}
dataconvert::DateTime aDay;
dataconvert::Date aDay;
aDay.year = year;
aDay.month = month;
aDay.day = lastday;
aDay.hour = 0;
aDay.minute = 0;
aDay.second = 0;
aDay.msecond = 0;
val = *(reinterpret_cast<uint64_t*>(&aDay));
val = *(reinterpret_cast<uint32_t*>(&aDay));
return val;
}
} // namespace funcexp