summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-02-24 16:50:22 -0800
committerIgor Babaev <igor@askmonty.org>2012-02-24 16:50:22 -0800
commit841a74a4d6ebdaa2760ce615e7fc18f57100ee19 (patch)
treef3a656b6c3262d7a6b0847b0820848ad685480b0 /sql/opt_subselect.cc
parent567d871ff0c9cbdcaa4f9daa6810760edc901e14 (diff)
downloadmariadb-git-841a74a4d6ebdaa2760ce615e7fc18f57100ee19.tar.gz
Fixed LP bug #939009.
The result of materialization of the right part of an IN subquery predicate is placed into a temporary table. Each row of the materialized table is distinct. A unique key over all fields of the temporary table is defined and created. It allows to perform key look-ups into the table. The table created for a materialized subquery can be accessed by key as any other table. The function best_access-path search for the best access to join a table to a given partial join. With some where conditions this function considers a possibility of a ref_or_null access. If such access employs the unique key on the temporary table then when estimating the cost this access the function tries to use the array rec_per_key. Yet, such array is not built for this unique key. This causes a crash of the server. Rows returned by the subquery that contain nulls don't have to be placed into temporary table, as they cannot be match any row produced by the left part of the subquery predicate. So all fields of the temporary table can be defined as non-nullable. In this case any ref_or_null access to the temporary table does not make any sense and it does not make sense to estimate such an access. The fix makes sure that the temporary table for a materialized IN subquery is defined with columns that are all non-nullable. The also ensures that any row with nulls returned by the subquery is not placed into the temporary table.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index d01ef381806..a1d69ba759f 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3167,6 +3167,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm->sjm_table_cols.push_back(*p_item);
sjm->sjm_table_param.field_count= subq_select->item_list.elements;
+ sjm->sjm_table_param.force_not_null_cols= TRUE;
if (!(sjm->table= create_tmp_table(thd, &sjm->sjm_table_param,
sjm->sjm_table_cols, (ORDER*) 0,