1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-17607 DATE(COALESCE(year_column)) returns a wrong result

C++ does not guarantee the order of parameter evaluation.
It was wrong to pass item->val_int() and item->null_value
at the same time to any function or constructor.
Adding a new helper class Longlong_null, and new methods
Item::to_longlong_null() and Item_func_hybrid_field_type::to_longlong_null_op(),
which make sure to properly call val_int()/int_op() and test null_value.
Reorganizing the rest of the code accordingly.
This commit is contained in:
Alexander Barkov
2018-11-04 07:13:07 +04:00
parent 2feac61e18
commit 563efeceec
7 changed files with 77 additions and 17 deletions

View File

@ -326,14 +326,13 @@ uint Year::year_precision(const Item *item) const
VYear::VYear(Item *item)
:Year_null(Year(item->val_int(), item->unsigned_flag,
year_precision(item)), item->null_value)
:Year_null(item->to_longlong_null(), item->unsigned_flag, year_precision(item))
{ }
VYear_op::VYear_op(Item_func_hybrid_field_type *item)
:Year_null(Year(item->int_op(), item->unsigned_flag,
year_precision(item)), item->null_value)
:Year_null(item->to_longlong_null_op(), item->unsigned_flag,
year_precision(item))
{ }