summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2010-09-15 16:14:19 +0400
committerSergey Petrunya <psergey@askmonty.org>2010-09-15 16:14:19 +0400
commit3a5c004bb5c860a337ec7469596d18ce1ae28702 (patch)
tree5448f8adb15d5ad78da68fad69f0935a08a937e5 /sql
parent7f41516f4f3980a68808b4498f76b54c8bbe1969 (diff)
downloadmariadb-git-3a5c004bb5c860a337ec7469596d18ce1ae28702.tar.gz
BUG#625841: Assertion `!table || (!table->read_set || bitmap_is_set
- When find_all_keys() checks which table columns are needed for table scan that is done before the sorting, it should also analyze pushed index condition. This is achieved by remembering/checking pre-index-pushed condition.
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc15
-rw-r--r--sql/opt_index_cond_pushdown.cc1
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/opt_range.h7
4 files changed, 19 insertions, 6 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 41410929f15..f5c0b18ceb3 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -542,11 +542,6 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
current_thd->variables.read_buff_size);
}
- if (quick_select)
- {
- if (select->quick->reset())
- DBUG_RETURN(HA_POS_ERROR);
- }
/* Remember original bitmaps */
save_read_set= sort_form->read_set;
@@ -559,8 +554,18 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
if (select && select->cond)
select->cond->walk(&Item::register_field_in_read_map, 1,
(uchar*) sort_form);
+ if (select && select->pre_idx_push_select_cond)
+ select->pre_idx_push_select_cond->walk(&Item::register_field_in_read_map,
+ 1, (uchar*) sort_form);
+
sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set);
+ if (quick_select)
+ {
+ if (select->quick->reset())
+ DBUG_RETURN(HA_POS_ERROR);
+ }
+
for (;;)
{
if (quick_select)
diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc
index 277343b81a5..2e5ad795668 100644
--- a/sql/opt_index_cond_pushdown.cc
+++ b/sql/opt_index_cond_pushdown.cc
@@ -378,6 +378,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok)
QT_ORDINARY););
tab->select->cond= tab->select_cond;
+ tab->select->pre_idx_push_select_cond= tab->pre_idx_push_select_cond;
}
}
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 62e39faa272..a64dd67a2cd 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1119,7 +1119,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
}
-SQL_SELECT::SQL_SELECT() :quick(0),cond(0),free_cond(0)
+SQL_SELECT::SQL_SELECT() :quick(0),cond(0),pre_idx_push_select_cond(NULL),free_cond(0)
{
quick_keys.clear_all(); needed_reg.clear_all();
my_b_clear(&file);
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 5abad749b58..ac2aaf08057 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -738,6 +738,13 @@ class SQL_SELECT :public Sql_alloc {
public:
QUICK_SELECT_I *quick; // If quick-select used
COND *cond; // where condition
+
+ /*
+ When using Index Condition Pushdown: condition that we've had before
+ extracting and pushing index condition.
+ In other cases, NULL.
+ */
+ Item *pre_idx_push_select_cond;
TABLE *head;
IO_CACHE file; // Positions to used records
ha_rows records; // Records in use if read from file