diff options
author | Igor Babaev <igor@askmonty.org> | 2010-11-08 20:36:32 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2010-11-08 20:36:32 -0800 |
commit | 6b67bafc747e10815566178d730b190a84803fb7 (patch) | |
tree | a9e533da8cd7dc498310f3272f7e46f1591df1d3 /sql | |
parent | c670b9021e782ead4cdd0d20ead2421367626ea5 (diff) | |
download | mariadb-git-6b67bafc747e10815566178d730b190a84803fb7.tar.gz |
Fixed LP bug #668644.
The pushdown condition for the sorted table in a query can be complemented
by the conditions from HAVING. This transformation is done in JOIN::exec
pretty late after the original pushdown condition have been saved in the
field pre_idx_push_select_cond for the sorted table. So this field must
be updated after the inclusion of the condition from HAVING.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_index_cond_pushdown.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index 277343b81a5..f6437e04ec5 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -318,7 +318,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok) if (idx_cond) { Item *idx_remainder_cond= 0; - tab->pre_idx_push_select_cond= tab->select_cond; + tab->pre_idx_push_select_cond= tab->select->cond; /* For BKA cache we store condition to special BKA cache field because evaluation of the condition requires additional operations diff --git a/sql/sql_select.cc b/sql/sql_select.cc index debd1b07fe5..7c51d0e25bd 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2213,6 +2213,14 @@ JOIN::exec() DBUG_VOID_RETURN; curr_table->select->cond->fix_fields(thd, 0); } + if (curr_table->pre_idx_push_select_cond) + { + if (!(curr_table->pre_idx_push_select_cond= + new Item_cond_and(curr_table->pre_idx_push_select_cond, + sort_table_cond))) + DBUG_VOID_RETURN; + curr_table->pre_idx_push_select_cond->fix_fields(thd, 0); + } curr_table->set_select_cond(curr_table->select->cond, __LINE__); curr_table->select_cond->top_level_item(); DBUG_EXECUTE("where",print_where(curr_table->select->cond, @@ -6355,6 +6363,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table) join_tab->do_firstmatch= NULL; join_tab->loosescan_match_tab= NULL; join_tab->emb_sj_nest= NULL; + join_tab->pre_idx_push_select_cond= NULL; bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record)); temp_table->status=0; temp_table->null_row=0; |