diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-02-25 18:19:55 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-02-25 18:19:55 +0100 |
commit | 00d1db7a38b17d4512a6ba5147926608aca5624d (patch) | |
tree | c2b28145304e9eacf79fcabaeb962a20d79fec93 /sql/opt_subselect.cc | |
parent | 0485328d030f4b742dac7b667e8ed099beb9e9f2 (diff) | |
parent | 0251232f8c3bca33b4dd15d6668105f3de9d024d (diff) | |
download | mariadb-git-00d1db7a38b17d4512a6ba5147926608aca5624d.tar.gz |
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index fa04f6d2637..c1052869c8f 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -833,12 +833,14 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs) in_subs->sjm_scan_allowed= FALSE; bool all_are_fields= TRUE; + uint32 total_key_length = 0; for (uint i= 0; i < elements; i++) { Item *outer= in_subs->left_expr->element_index(i); Item *inner= it++; all_are_fields &= (outer->real_item()->type() == Item::FIELD_ITEM && inner->real_item()->type() == Item::FIELD_ITEM); + total_key_length += inner->max_length; if (outer->cmp_type() != inner->cmp_type()) DBUG_RETURN(FALSE); switch (outer->cmp_type()) { @@ -869,6 +871,15 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs) } } + /* + Make sure that create_tmp_table will not fail due to too long keys. + See MDEV-7122. This check is performed inside create_tmp_table also and + we must do it so that we know the table has keys created. + */ + if (total_key_length > tmp_table_max_key_length() || + elements > tmp_table_max_key_parts()) + DBUG_RETURN(FALSE); + in_subs->types_allow_materialization= TRUE; in_subs->sjm_scan_allowed= all_are_fields; DBUG_PRINT("info",("subquery_types_allow_materialization: ok, allowed")); @@ -5533,7 +5544,8 @@ bool JOIN::choose_subquery_plan(table_map join_tables) outer join has not been optimized yet). */ if (outer_join && outer_join->table_count > 0 && // (1) - outer_join->join_tab) // (2) + outer_join->join_tab && // (2) + !in_subs->const_item()) { /* TODO: |