summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/opt_index_cond_pushdown.cc2
-rw-r--r--sql/sql_select.cc9
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;