mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Problem: The following functions- - `Item_func_last_day::get_date` - `Item_date_typecast::get_date` - `Item_datetime_typecast::get_date` forwarded the TIME_INTERVAL_DAY / TIME_INTERVAL_hhmmssff flags, set by an enclosing EXTRACT, into the DATE/DATETIME conversion of their argument.This made, for ex: LAST_DAY(200012010000) and CAST(200012010000 AS DATETIME) parse number as TIME interval instead of a DATETIME. Under ZERO_DATE_TIME_CAST that hour became an out-of-range month, overflowing days_in_month in `check_date` and invalidating the Datetime. Fix: A DATE / DATETIME can never be an interval, so suppress the TIME_INTERVAL_hhmmssff / TIME_INTERVAL_DAY flags when `LAST_DAY` and `CAST` converts its argument. Also add a debug assert in `check_date` to catch any future caller that violates its "month is assumed valid" contract.