From 5a0fff50f87e20c4e95a84143a0a3bb67e03e29e Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sun, 26 Feb 2017 15:40:18 -0800 Subject: Fixed bug mdev-12099. The function mysql_derived_merge() erroneously did not mark newly formed AND formulas in ON conditions with the flag abort_on_null. As a result not_null_tables() calculated incorrectly for these conditions. This could prevent conversion of embedded outer joins into inner joins. Changed a test case from table_elim.test to preserve the former execution plan. --- sql/sql_derived.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 44395599961..20fca2de8cf 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -446,6 +446,9 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) { Item *expr= derived->on_expr; expr= and_conds(expr, dt_select->join ? dt_select->join->conds : 0); + if (expr) + expr->top_level_item(); + if (expr && (derived->prep_on_expr || expr != derived->on_expr)) { derived->on_expr= expr; -- cgit v1.2.1