From: Roy Lyseng Date: May 29 2012 10:51am Subject: bzr push into mysql-trunk branch (roy.lyseng:3915 to 3916) Bug#13980954 List-Archive: http://lists.mysql.com/commits/143991 X-Bug: 13980954 Message-Id: <201205291051.q4TApaY3000114@khepri07.no.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3916 Roy Lyseng 2012-05-29 Bug#13980954: Missing data on left join + null value + where..in Followup patch after review. modified: sql/sql_optimizer.cc sql/sql_select.h 3915 Roy Lyseng 2012-05-29 Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() Followup of review comment modified: sql/sql_executor.cc === modified file 'sql/sql_optimizer.cc' --- a/sql/sql_optimizer.cc 2012-05-25 10:09:27 +0000 +++ b/sql/sql_optimizer.cc 2012-05-29 10:48:54 +0000 @@ -2823,7 +2823,7 @@ static void update_depend_map(JOIN *join /** Assign set of available (prefix) tables to all tables in query block. - Also set added tables, ie the tables added in one JOIN_TAB compared to the + Also set added tables, ie the tables added in each JOIN_TAB compared to the previous JOIN_TAB. This function must be called for every query block after the table order has been determined. @@ -2832,9 +2832,8 @@ static void update_depend_map(JOIN *join void JOIN::set_prefix_tables() { /* - Const tables are available together with the first non-const table in - the join order. All outer references and references to const tables - are available, so these may be evaluated together with the first table. + The const tables and outer references are available together with the + first non-const table in the join order: */ table_map current_tables_map= const_table_map | OUTER_REF_TABLE_BIT; table_map prev_tables_map= (table_map) 0; @@ -2853,11 +2852,9 @@ void JOIN::set_prefix_tables() @see Item_equal::get_subst_item() @see eliminate_item_equal() */ - const uint sj_strategy= tab->get_sj_strategy(); - const table_map sjm_inner_tables= sj_is_materialize_strategy(sj_strategy) ? - tab->emb_sj_nest->sj_inner_tables : (table_map) 0; - if (sjm_inner_tables) + if (sj_is_materialize_strategy(tab->get_sj_strategy())) { + const table_map sjm_inner_tables= tab->emb_sj_nest->sj_inner_tables; if (!(sjm_inner_tables & current_tables_map)) { saved_tables_map= current_tables_map; @@ -2880,7 +2877,7 @@ void JOIN::set_prefix_tables() are available in the table prefix (the necessary fields are copied back from the materialized temporary table). */ - if (sj_strategy == SJ_OPT_MATERIALIZE_SCAN) + if (tab->get_sj_strategy() == SJ_OPT_MATERIALIZE_SCAN) { current_tables_map|= sjm_inner_tables; prev_tables_map|= sjm_inner_tables; @@ -7543,6 +7540,7 @@ static bool make_join_select(JOIN *join, Opt_trace_array trace_attached_comp(trace, "attached_conditions_computation"); + // Helper object for correct processing of SJM-scan: table_map outer_used_tables= (table_map) 0; for (uint i=join->const_tables ; i < join->tables ; i++) === modified file 'sql/sql_select.h' --- a/sql/sql_select.h 2012-05-24 11:55:37 +0000 +++ b/sql/sql_select.h 2012-05-29 10:48:54 +0000 @@ -340,12 +340,24 @@ typedef struct st_join_table : public Sq table_map added_tables() const { return added_tables_map; } + /** + Set available tables for a table in a join plan. + + @param prefix_tables: Set of tables available for this plan + @param prev_tables: Set of tables available for previous table, used to + calculate set of tables added for this table. + */ void set_prefix_tables(table_map prefix_tables, table_map prev_tables) { prefix_tables_map= prefix_tables; added_tables_map= prefix_tables & ~prev_tables; } + /** + Add an available set of tables for a table in a join plan. + + @param tables: Set of tables added for this table in plan. + */ void add_prefix_tables(table_map tables) { prefix_tables_map|= tables; added_tables_map|= tables; } No bundle (reason: useless for push emails).