Fixed bug mdev-4367.

When calculating selectivity of conditions one should take into account
the cases when some tables to be joined are empty.
This commit is contained in:
Igor Babaev 2013-04-03 23:50:14 -07:00
commit 50d4d1ca18
5 changed files with 57 additions and 7 deletions

View file

@ -750,4 +750,18 @@ drop table t1;
set histogram_size=@save_histogram_size;
set histogram_type=@save_histogram_type;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
#
# Bug mdev-4367: join of a merged empty derived table
# when optimizer_use_condition_selectivity=3
#
SET optimizer_use_condition_selectivity=3;
CREATE TABLE t1 (a varchar(1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('j'),('k');
CREATE TABLE t2 (b varchar(1)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('x'),('y');
CREATE TABLE t3 (c varchar(1), KEY(c)) ENGINE=MyISAM;
SELECT * FROM t1 STRAIGHT_JOIN (t2 JOIN t3 ON c = b AND b > 'z');
a b c
DROP TABLE t1,t2,t3;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;