From e4bb53341f8301e982764235b3f31cb7c15d95f7 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 17 Aug 2011 11:57:01 +0400 Subject: BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed - add_ref_to_table_cond() should not just overwrite pre_idx_push_select_cond with the contents tab->select_cond. pre_idx_push_select_cond exists precisely for the reason that it may contain a condition that is a strict superset of what is in tab->select_cond. The fix is to inject generated equality into pre_idx_push_select_cond. --- sql/sql_select.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 83da3d157de..e0b228fc45a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -19872,7 +19872,12 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) error=(int) cond->add(join_tab->select->cond); join_tab->select->cond= cond; if (join_tab->select->pre_idx_push_select_cond) - join_tab->select->pre_idx_push_select_cond= cond; + { + Item *new_cond= and_conds(join_tab->select->pre_idx_push_select_cond, cond); + if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond)) + error= 1; + join_tab->select->pre_idx_push_select_cond= new_cond; + } join_tab->set_select_cond(cond, __LINE__); } else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0, -- cgit v1.2.1