diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 8531c141bd4..7650f558da7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -341,8 +341,9 @@ public: SEL_ARG(Field *field, uint8 part, uchar *min_value, uchar *max_value, uint8 min_flag, uint8 max_flag, uint8 maybe_flag); SEL_ARG(enum Type type_arg) - :min_flag(0),elements(1),use_count(1),left(0),right(0),next_key_part(0), - color(BLACK), type(type_arg) + :min_flag(0), max_part_no(0) /* first key part means 1. 0 mean 'no parts'*/, + elements(1),use_count(1),left(0),right(0), + next_key_part(0), color(BLACK), type(type_arg) {} inline bool is_same(SEL_ARG *arg) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 457b6e3e2d8..5241e6292e3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8521,7 +8521,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) //for (i=join->const_tables ; i < join->tables ; i++) for (tab= first_linear_tab(join, TRUE), i= join->const_tables; tab; - tab= next_linear_tab(join, tab, TRUE), i++) + tab= next_linear_tab(join, tab, TRUE)) { /* The approximation below for partial join cardinality is not good because @@ -8533,8 +8533,11 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) if ((tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab) || (tab == join->join_tab + join->const_tables)) prev_tab= NULL; + DBUG_ASSERT(tab->bush_children || tab->table == join->best_positions[i].table->table); tab->partial_join_cardinality= join->best_positions[i].records_read * (prev_tab? prev_tab->partial_join_cardinality : 1); + if (!tab->bush_children) + i++; } check_join_cache_usage_for_tables(join, options, no_jbuf_after);