From 887a210ffc5c38cf9623ad308b68094510f1bfbb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 22 Mar 2014 12:44:39 -0700 Subject: Fixed bug mdev-5931. After constant table row substitution the where condition may be converted to always true. The function calculate_cond_selectivity_for_table() should take into account this possibility. --- mysql-test/t/selectivity.test | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'mysql-test/t/selectivity.test') diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test index 8b7dfdff09f..8774afdc554 100644 --- a/mysql-test/t/selectivity.test +++ b/mysql-test/t/selectivity.test @@ -889,4 +889,27 @@ set histogram_type=@save_histogram_type; set histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +--echo # +--echo # Bug mdev-5931: no where condition after constant table row substitution +--echo # with optimizer_use_condition_selectivity=3 +--echo # + +CREATE TABLE t1 (a varchar(3), b varchar(3)) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('foo', 'foo'); + +CREATE TABLE t2 (c INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1), (2); + +set optimizer_use_condition_selectivity=3; + +EXPLAIN EXTENDED +SELECT * FROM t1, t2 WHERE c >= 0 OR a = b ; + +SELECT * FROM t1, t2 WHERE c >= 0 OR a = b ; + +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +DROP TABLE t1,t2; + set use_stat_tables=@save_use_stat_tables; -- cgit v1.2.1