From: Sergey Petrunia Date: December 21 2005 7:06am Subject: bk commit into 5.1 tree (sergefp:1.1972) List-Archive: http://lists.mysql.com/commits/310 Message-Id: <20051221070600.116B92C7D57@newbox.mylan> Below is the list of changes that have just been committed into a local 5.1 repository of psergey. When psergey does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1972 05/12/21 10:05:51 sergefp@stripped +1 -0 WL#2985 "Partition pruning" post-merge fixes: No matter if partitioning is compiled in or not, don't try to evaluate the condition on constant tables if there is a constant table tbl that 1) is not inner wrt some outer join, and 2) either range analysis or partition pruning on tbl inferred that no table records will satisfy the condition. sql/sql_select.cc 1.377 05/12/21 10:05:32 sergefp@stripped +9 -15 WL#2985 "Partition pruning" post-merge fixes: No matter if partitioning is compiled in or not, don't try to evaluate the condition on constant tables if there is a constant table tbl that 1) is not inner wrt some outer join, and 2) either range analysis or partition pruning on tbl inferred that no table records will satisfy the condition. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: sergefp # Host: newbox.mylan # Root: /home/psergey/mysql-5.1-ppruning-merge --- 1.376/sql/sql_select.cc 2005-12-20 23:03:59 +03:00 +++ 1.377/sql/sql_select.cc 2005-12-21 10:05:32 +03:00 @@ -1936,7 +1936,7 @@ if (select) { select->head=table; - table->reginfo.impossible_range=0; + DBUG_ASSERT(!table->reginfo.impossible_range); if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0, limit, 0)) == 1) DBUG_RETURN(select->quick->records); @@ -2245,9 +2245,9 @@ if (!s->table->pos_in_table_list->embedding) { + s->table->reginfo.impossible_range= FALSE; #ifdef WITH_PARTITION_STORAGE_ENGINE Item *pprune_cond= *s->on_expr_ref ? *s->on_expr_ref : conds; - s->table->reginfo.impossible_range= FALSE; if (prune_partitions(join->thd, s->table, pprune_cond, found_const_table_map)) { @@ -5282,24 +5282,18 @@ cond_tab->select_cond->quick_fix_field(); } } - /* - We're going to evaluate the table condition with 'default' field - values. In partitioning, it could be that the condition is - satisified with default values, but still we've inferred that no - records will match. To handle this case, check impossible_range - first. + /* + Before evaluating the const_cond, check if it has been identified + as false by range/partition pruning analysis. */ - bool partitioning_pruned_away= FALSE; -#ifdef WITH_PARTITION_STORAGE_ENGINE + bool const_cond_is_false= FALSE; for (JOIN_TAB *ctab= join->join_tab; ctab < join->join_tab + join->const_tables; ctab++) { - if (ctab->table->reginfo.impossible_range) - partitioning_pruned_away= TRUE; + if (!(*ctab->on_expr_ref) && ctab->table->reginfo.impossible_range) + const_cond_is_false= TRUE; } -#endif - if (partitioning_pruned_away || - const_cond && !const_cond->val_int()) + if (const_cond_is_false || (const_cond && !const_cond->val_int())) { DBUG_PRINT("info",("Found impossible WHERE condition")); DBUG_RETURN(1); // Impossible const condition