From fc6b6435b4c3f5203e6ffc3de289f0413a7ef33f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 6 Sep 2011 17:06:04 +0400 Subject: BUG#823930: Wrong result with semijoin materialization and blob fields - Make subquery_types_allow_materialization() detect a case where create_tmp_table() would create a blob column which would make it impossible to use materialization Non-semi-join materialization worked because it detected that this case and felt back to use IN->EXISTS. Semi-join Materialization cannot easily fallback, so we have to detect this case early. --- sql/opt_subselect.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sql/opt_subselect.cc') diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 9ea55390fc5..3cb13b0b88c 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -559,6 +559,16 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs) if (inner->field_type() == MYSQL_TYPE_BLOB || inner->field_type() == MYSQL_TYPE_GEOMETRY) DBUG_RETURN(FALSE); + /* + Materialization also is unable to work when create_tmp_table() will + create a blob column because item->max_length is too big. + The following check is copied from Item::make_string_field(): + */ + if (inner->max_length / inner->collation.collation->mbmaxlen > + CONVERT_IF_BIGGER_TO_BLOB) + { + DBUG_RETURN(FALSE); + } break; case TIME_RESULT: if (mysql_type_to_time_type(outer->field_type()) != -- cgit v1.2.1