summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-11 12:35:19 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-11 12:35:19 +0400
commit6a7e646df339a0bf915548c500c99720af4976b3 (patch)
tree8fadd4b51c23652363135650a4a9e531b2cd8cbe /sql/item_cmpfunc.h
parent0718b8ecbf3be2351e65e63a5e21cd1db24355e1 (diff)
downloadmariadb-git-6a7e646df339a0bf915548c500c99720af4976b3.tar.gz
MDEV-23054 Assertion `!item->null_value' failed in Type_handler_inet6::make_sort_key_part (#2)
IFNULL(inet6_not_null_expr, 'foo') erroneously set its nullability to NOT NULL. Fix: - Moving the line "maybe_null= args[1]->maybe_null" before the call of fix_length_and_dec2(), so the call of Type_handler method Item_hybrid_func_fix_attributes() can reset it when desired. - Fixing Type_handler_inet6::Item_hybrid_func_fix_attributes() to ignore args[0] when detecting nullability of IFNULL().
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 40728f244f3..fe6cba607a7 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1117,9 +1117,19 @@ public:
bool native_op(THD *thd, Native *to);
bool fix_length_and_dec()
{
+ /*
+ Set nullability from args[1] by default.
+ Note, some type handlers may reset maybe_null
+ in Item_hybrid_func_fix_attributes() if args[1]
+ is NOT NULL but cannot always be converted to
+ the data type of "this" safely.
+ E.g. Type_handler_inet6 does:
+ IFNULL(inet6_not_null_expr, 'foo') -> INET6 NULL
+ IFNULL(inet6_not_null_expr, '::1') -> INET6 NOT NULL
+ */
+ maybe_null= args[1]->maybe_null;
if (Item_func_case_abbreviation2::fix_length_and_dec2(args))
return TRUE;
- maybe_null= args[1]->maybe_null;
return FALSE;
}
const char *func_name() const { return "ifnull"; }