diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-20 09:15:28 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-20 09:15:28 +0300 |
commit | 48c67038b9173887254a25ae05eb232d95ff8bc8 (patch) | |
tree | 253e371658c99a6f940e8ac1c74a64a5885d3311 /sql/sql_select.cc | |
parent | 12e3ac04febe16dd3ee15cd99f9196a60261f1b4 (diff) | |
parent | bc89b1c5582ac4044317a84e8a73d97fd1db9041 (diff) | |
download | mariadb-git-48c67038b9173887254a25ae05eb232d95ff8bc8.tar.gz |
Merge 10.1 into 10.2
For MDEV-15955, the fix in create_tmp_field_from_item() would cause a
compilation error. After a discussion with Alexander Barkov, the fix
was omitted and only the test case was kept.
In 10.3 and later, MDEV-15955 is fixed properly by overriding
create_tmp_field() in Item_func_user_var.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bdab9cf76cf..1b82b11fce6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7961,6 +7961,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, KEYUSE *keyuse= pos->key; KEYUSE *prev_ref_keyuse= keyuse; uint key= keyuse->key; + bool used_range_selectivity= false; /* Check if we have a prefix of key=const that matches a quick select. @@ -7986,6 +7987,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, keyparts++; } sel /= (double)table->quick_rows[key] / (double) table->stat_records(); + used_range_selectivity= true; } } @@ -8021,13 +8023,14 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, if (keyparts > keyuse->keypart) { /* Ok this is the keyuse that will be used for ref access */ - uint fldno; - if (is_hash_join_key_no(key)) - fldno= keyuse->keypart; - else - fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1; - if (keyuse->val->const_item()) + if (!used_range_selectivity && keyuse->val->const_item()) { + uint fldno; + if (is_hash_join_key_no(key)) + fldno= keyuse->keypart; + else + fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1; + if (table->field[fldno]->cond_selectivity > 0) { sel /= table->field[fldno]->cond_selectivity; @@ -16344,10 +16347,9 @@ Field *Item::create_tmp_field(bool group, TABLE *table, uint convert_int_length) static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, Item ***copy_func, bool modify_item) { - Field *UNINIT_VAR(new_field); DBUG_ASSERT(thd == table->in_use); - new_field= item->Item::create_tmp_field(false, table); - + Field *new_field= item->Item::create_tmp_field(false, table); + if (copy_func && (item->is_result_field() || (item->real_item()->is_result_field()))) |