diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2014-04-07 13:49:48 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2014-04-07 13:49:48 +0400 |
commit | 2bbca99018422b80306443a93f524a2d58373ecd (patch) | |
tree | 79ab0b41df5b90d8d6521686a1490c6548f3441d /sql/sql_select.cc | |
parent | a7962ea53e74cf2bca5efbd8f9e9b77526644261 (diff) | |
download | mariadb-git-2bbca99018422b80306443a93f524a2d58373ecd.tar.gz |
MDEV-6041: ORDER BY+subqueries: subquery_table.key=outer_table.col is not recongized as binding
- Make JOIN::const_key_parts include keyparts for which
the WHERE clause has an equality in form
"t.key_part=reference_outside_this_select"
- This allows to avoid filesort'ing in some cases (and also
avoid a difficult choice between using filesort or using an index)
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e7c93b89303..7a47dd309c1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5274,7 +5274,8 @@ static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse, { if (!use->is_for_hash_join()) { - if (!use->used_tables && use->optimize != KEY_OPTIMIZE_REF_OR_NULL) + if (!(use->used_tables & ~OUTER_REF_TABLE_BIT) && + use->optimize != KEY_OPTIMIZE_REF_OR_NULL) use->table->const_key_parts[use->key]|= use->keypart_map; if (use->keypart != FT_KEYPART) { @@ -14912,7 +14913,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) static bool test_if_equality_guarantees_uniqueness(Item *l, Item *r) { - return r->const_item() && + return (r->const_item() || !(r->used_tables() & ~OUTER_REF_TABLE_BIT)) && item_cmp_type(l->cmp_type(), r->cmp_type()) == l->cmp_type() && (l->cmp_type() != STRING_RESULT || l->collation.collation == r->collation.collation); |