diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2010-09-15 16:58:01 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2010-09-15 16:58:01 +0400 |
commit | 499b142ad512fcaf3b0bf2bf8073a4983445dc06 (patch) | |
tree | 9637fe02efbe10fb7bb3f9a70d26426263d3569d /sql | |
parent | 3a5c004bb5c860a337ec7469596d18ce1ae28702 (diff) | |
download | mariadb-git-499b142ad512fcaf3b0bf2bf8073a4983445dc06.tar.gz |
BUG#628785: multi_range_read.cc:430: int DsMrr_impl::dsmrr_init(): Assertion `do_sort_keys || do_rowid_fetch' failed
- Make Ds_MrrImpl::check_cpk_scan() follow the execution code' logic: don't
do MRR scans on clustered PK when mrr_sort_keys=off.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/multi_range_read.cc | 17 | ||||
-rw-r--r-- | sql/multi_range_read.h | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 31d3faa3205..b6c9a5e16ab 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -474,8 +474,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, } do_rowid_fetch= FALSE; - doing_cpk_scan= check_cpk_scan(h->inited == handler::INDEX? - h->active_index: h2->active_index, mode); + doing_cpk_scan= check_cpk_scan(thd, h->inited == handler::INDEX? + h->active_index: h2->active_index, mode); if (!doing_cpk_scan /* && !index_only_read */) { /* Will use rowid buffer to store/sort rowids, etc */ @@ -1370,12 +1370,13 @@ bool key_uses_partial_cols(TABLE *table, uint keyno) FALSE Otherwise */ -bool DsMrr_impl::check_cpk_scan(uint keyno, uint mrr_flags) +bool DsMrr_impl::check_cpk_scan(THD *thd, uint keyno, uint mrr_flags) { return test((mrr_flags & HA_MRR_SINGLE_POINT) && !(mrr_flags & HA_MRR_SORTED) && keyno == table->s->primary_key && - h->primary_key_is_clustered()); + h->primary_key_is_clustered() && + optimizer_flag(thd, OPTIMIZER_SWITCH_MRR_SORT_KEYS)); } @@ -1410,11 +1411,11 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, bool res; THD *thd= current_thd; - doing_cpk_scan= check_cpk_scan(keyno, *flags); + doing_cpk_scan= check_cpk_scan(thd, keyno, *flags); + bool using_cpk= test(keyno == table->s->primary_key && + h->primary_key_is_clustered()); if (thd->variables.optimizer_use_mrr == 2 || *flags & HA_MRR_INDEX_ONLY || - (keyno == table->s->primary_key && h->primary_key_is_clustered() && - !doing_cpk_scan) || - key_uses_partial_cols(table, keyno)) + (using_cpk && !doing_cpk_scan) || key_uses_partial_cols(table, keyno)) { /* Use the default implementation */ *flags |= HA_MRR_USE_DEFAULT_IMPL; diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 5eaff483c47..9cd1503596f 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -384,7 +384,7 @@ private: COST_VECT *cost); bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, uint *buffer_size, COST_VECT *cost); - bool check_cpk_scan(uint keyno, uint mrr_flags); + bool check_cpk_scan(THD *thd, uint keyno, uint mrr_flags); static int key_tuple_cmp(void* arg, uchar* key1, uchar* key2); int dsmrr_fill_rowid_buffer(); void dsmrr_fill_key_buffer(); |