diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-10-01 14:07:42 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-10-01 14:07:42 +0400 |
commit | b50c607056e1d4b25e274a8ab87a7e8e4c918c45 (patch) | |
tree | aa2d20dd3172f9b3e8aa93c095e5ef13ed7ea15c /sql/item_func.h | |
parent | 3266216f2c8f90c866b371fbd4a8bf6b0c628996 (diff) | |
download | mariadb-git-b50c607056e1d4b25e274a8ab87a7e8e4c918c45.tar.gz |
MDEV-4848 Wrong metadata or column type for LEAST(1.0,'10')
MDEV-8873 Wrong field type or metadata for LEAST(int_column,string_column)
Diffstat (limited to 'sql/item_func.h')
-rw-r--r-- | sql/item_func.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sql/item_func.h b/sql/item_func.h index 74a18c1edfe..eda1572d610 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -986,19 +986,28 @@ public: }; -class Item_func_min_max :public Item_func +/** + Item_func_min_max does not derive from Item_func_hybrid_field_type + because the way how its methods val_xxx() and get_date() work depend + not only by its arguments, but also on the context in which + LEAST() and GREATEST() appear. + For example, using Item_func_min_max in a CAST like this: + CAST(LEAST('11','2') AS SIGNED) + forces Item_func_min_max to compare the arguments as numbers rather + than strings. + Perhaps this should be changed eventually (see MDEV-5893). +*/ +class Item_func_min_max :public Item_func, + public Type_handler_hybrid_field_type { - Item_result cmp_type; String tmp_value; int cmp_sign; /* An item used for issuing warnings while string to DATETIME conversion. */ Item *compare_as_dates; THD *thd; -protected: - enum_field_types cached_field_type; public: Item_func_min_max(THD *thd, List<Item> &list, int cmp_sign_arg): - Item_func(thd, list), cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), + Item_func(thd, list), cmp_sign(cmp_sign_arg), compare_as_dates(0) {} double val_real(); longlong val_int(); @@ -1006,8 +1015,12 @@ public: my_decimal *val_decimal(my_decimal *); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); void fix_length_and_dec(); - enum Item_result result_type () const { return cmp_type; } - enum_field_types field_type() const { return cached_field_type; } + enum Item_result cmp_type() const + { return Type_handler_hybrid_field_type::cmp_type(); } + enum Item_result result_type() const + { return Type_handler_hybrid_field_type::result_type(); } + enum_field_types field_type() const + { return Type_handler_hybrid_field_type::field_type(); } }; class Item_func_min :public Item_func_min_max |