mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-32879 Server crash in my_decimal::operator= or unexpected ER_DUP_ENTRY upon comparison with INET6 and similar types
During the 10.5->10.6 merge please use the 10.6 code on conflicts. This is the 10.5 version of the patch (a backport of the 10.6 version). Unlike 10.6 version, it makes changes in plugin/type_inet/sql_type_inet.* rather than in sql/sql_type_fixedbin.h Item_bool_rowready_func2, Item_func_between, Item_func_in did not check if a not-NULL argument of an arbitrary data type can produce a NULL value on conversion to INET6. This caused a crash on DBUG_ASSERT() in conversion failures, because the function returned SQL NULL for something that has Item::maybe_null() equal to false. Adding setting NULL-ability in such cases. Details: - Removing the code in Item_func::setup_args_and_comparator() performing character set aggregation with optional narrowing. This aggregation is done inside Arg_comparator::set_cmp_func_string(). So this code was redundant - Removing Item_func::setup_args_and_comparator() as it git simplified to just to two lines: convert_const_compared_to_int_field(thd); return cmp->set_cmp_func(thd, this, &args[0], &args[1], true); Using these lines directly in: - Item_bool_rowready_func2::fix_length_and_dec() - Item_func_nullif::fix_length_and_dec() - Adding a new virtual method: - Type_handler::Item_bool_rowready_func2_fix_length_and_dec(). - Adding tests detecting if the data type conversion can return SQL NULL into the following methods of Type_handler_inet6: - Item_bool_rowready_func2_fix_length_and_dec - Item_func_between_fix_length_and_dec - Item_func_in_fix_comparator_compatible_types
This commit is contained in:
@ -55,6 +55,7 @@ class Item_hybrid_func;
|
||||
class Item_func_min_max;
|
||||
class Item_func_hybrid_field_type;
|
||||
class Item_bool_func2;
|
||||
class Item_bool_rowready_func2;
|
||||
class Item_func_between;
|
||||
class Item_func_in;
|
||||
class Item_func_round;
|
||||
@ -3233,9 +3234,15 @@ public:
|
||||
bool agg_item_collations(DTCollation &c, const char *name,
|
||||
Item **items, uint nitems,
|
||||
uint flags, int item_sep);
|
||||
struct Single_coll_err
|
||||
{
|
||||
const DTCollation& coll;
|
||||
bool first;
|
||||
};
|
||||
bool agg_item_set_converter(const DTCollation &coll, const char *fname,
|
||||
Item **args, uint nargs,
|
||||
uint flags, int item_sep);
|
||||
uint flags, int item_sep,
|
||||
const Single_coll_err *single_item_err= NULL);
|
||||
|
||||
/*
|
||||
Collect arguments' character sets together.
|
||||
@ -4232,6 +4239,8 @@ public:
|
||||
}
|
||||
virtual bool Item_eq_value(THD *thd, const Type_cmp_attributes *attr,
|
||||
Item *a, Item *b) const= 0;
|
||||
virtual bool Item_bool_rowready_func2_fix_length_and_dec(THD *thd,
|
||||
Item_bool_rowready_func2 *func) const;
|
||||
virtual bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||
const char *name,
|
||||
Type_handler_hybrid_field_type *,
|
||||
|
Reference in New Issue
Block a user