summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-11-04 19:32:32 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-11-04 19:32:32 +0400
commit5e68c5ce7db95610c2084f9d9c6d01473ae243db (patch)
treec553dcf91d5ed7d9677daa44328491454683e3d3 /sql
parentbe0be7af47fcc75b798fcf7aa98dda9c7d31cc15 (diff)
parent39e7072d64f5ff36d61bf81970ec398f8d937cfd (diff)
downloadmariadb-git-5e68c5ce7db95610c2084f9d9c6d01473ae243db.tar.gz
Merge 5.5 -> 10.0-serg
Diffstat (limited to 'sql')
-rw-r--r--sql/opt_range.cc7
-rw-r--r--sql/sql_select.cc27
-rw-r--r--sql/sql_select.h1
3 files changed, 22 insertions, 13 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 183e4dbe90d..67bc1639f2d 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -10959,6 +10959,13 @@ int QUICK_RANGE_SELECT::reset()
last_range= NULL;
cur_range= (QUICK_RANGE**) ranges.buffer;
RANGE_SEQ_IF seq_funcs= {NULL, quick_range_seq_init, quick_range_seq_next, 0, 0};
+
+ if (file->inited == handler::RND)
+ {
+ /* Handler could be left in this state by MRR */
+ if ((error= file->ha_rnd_end()))
+ DBUG_RETURN(error);
+ }
if (in_ror_merged_scan)
head->column_bitmaps_set_no_signal(&column_bitmap, &column_bitmap);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 89d6e993b1d..92bf3b47ca1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -19065,6 +19065,20 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
save_pre_sort_join_tab= join->pre_sort_join_tab;
join->pre_sort_join_tab= NULL;
}
+ else
+ {
+ /*
+ Save index #, save index condition. Do it right now, because MRR may
+ */
+ if (table->file->inited == handler::INDEX)
+ {
+ join->pre_sort_index= table->file->active_index;
+ join->pre_sort_idx_pushed_cond= table->file->pushed_idx_cond;
+ // no need to save key_read
+ }
+ else
+ join->pre_sort_index= MAX_KEY;
+ }
/* Currently ORDER BY ... LIMIT is not supported in subqueries. */
DBUG_ASSERT(join->group_list || !join->is_in_subquery());
@@ -19155,17 +19169,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
*(join->pre_sort_join_tab)= *tab;
- if (table->file->inited == handler::INDEX)
- {
- // Save index #, save index condition
- join->pre_sort_index= table->file->active_index;
- join->pre_sort_idx_pushed_cond= table->file->pushed_idx_cond;
- // no need to save key_read?
- err= table->file->ha_index_end();
- }
- else
- join->pre_sort_index= MAX_KEY;
-
/*TODO: here, close the index scan, cancel index-only read. */
#if 0
/* MariaDB doesn't need the following: */
@@ -19211,8 +19214,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
#endif
tab->select=NULL;
tab->set_select_cond(NULL, __LINE__);
-// tab->last_inner= 0;
-// tab->first_unmatched= 0;
tab->type=JT_ALL; // Read with normal read_record
tab->read_first_record= join_init_read_record;
tab->table->file->ha_index_or_rnd_end();
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 586019cae23..f789dce9cc8 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -895,6 +895,7 @@ protected:
public:
JOIN_TAB *join_tab, **best_ref;
+
/*
For "Using temporary+Using filesort" queries, JOIN::join_tab can point to
either: