summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-02-15 22:50:59 +0100
committerSergei Golubchik <serg@mariadb.org>2016-02-15 22:50:59 +0100
commit271fed41061e25faa47b7a28108cf101ebb3551d (patch)
tree733bf84d468a1d47c71c87cfcee33098a090e3c5 /sql/opt_subselect.cc
parentff26d93a8c25d667709180ad13a090309631990d (diff)
parente1385f2083f782d7064db3c0059fcca45bfcb2a4 (diff)
downloadmariadb-git-271fed41061e25faa47b7a28108cf101ebb3551d.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 3d470b6ff5c..de57143e61d 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -831,12 +831,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()) {
@@ -867,6 +869,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"));
@@ -5519,7 +5530,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: