From 9d5a8bd663cb06161201a6870eb0d07f06382b9d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 13 Mar 2024 16:05:42 +0300 Subject: [PATCH] MDEV-33665: MSAN failure due to uninitialized Item_func::not_null_tables_cache eliminate_item_equal() uses quick_fix_field() for Item objects it creates. It computes some of their attributes on its own (see update_used_tables() call) but it doesn't update not_null_tables_cache. Recompute not_null_tables_cache also. Not computing it is currently harmless, except for producing MSAN error when some other code propagates the wrong value of not_null_tables_cache to other item. --- sql/sql_select.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f762cfd7ac4..aac35d6ef17 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16209,6 +16209,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, if (!eq_item || eq_item->set_cmp_func(thd)) return 0; + eq_item->eval_not_null_tables(0); eq_item->quick_fix_field(); } current_sjm= field_sjm; @@ -16266,6 +16267,7 @@ Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, { res->quick_fix_field(); res->update_used_tables(); + res->eval_not_null_tables(0); } return res;