summaryrefslogtreecommitdiff
path: root/mysql-test/t/selectivity.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2013-04-06 17:18:51 -0700
committerIgor Babaev <igor@askmonty.org>2013-04-06 17:18:51 -0700
commite3bf08d4b1c8d73072227f0920b6f4e8c6441591 (patch)
tree14c5fb482492bc2543b06352a244830d5e148fb2 /mysql-test/t/selectivity.test
parent10f0530b22d1b06c79be9fef26febebf3b9ec4a5 (diff)
downloadmariadb-git-e3bf08d4b1c8d73072227f0920b6f4e8c6441591.tar.gz
Fixed bug mdev-4363.
When calculating the selectivity of a range in the function get_column_range_cardinality a check whether NULL values are included into into the range must be done.
Diffstat (limited to 'mysql-test/t/selectivity.test')
-rw-r--r--mysql-test/t/selectivity.test34
1 files changed, 33 insertions, 1 deletions
diff --git a/mysql-test/t/selectivity.test b/mysql-test/t/selectivity.test
index f601d4f656a..d8ab19ac28a 100644
--- a/mysql-test/t/selectivity.test
+++ b/mysql-test/t/selectivity.test
@@ -483,7 +483,7 @@ INSERT INTO t2 VALUES (4),(5),(2),(5),(1),(1),(2);
ANALYZE TABLE t1, t2;
FLUSH TABLES;
-SET optimizer_use_condition_selectivity=3;
+set optimizer_use_condition_selectivity=3;
EXPLAIN EXTENDED
SELECT * FROM t1, t2 WHERE EXISTS ( SELECT 1 FROM t1, t2 ) AND a != b OR a <= 4;
@@ -495,4 +495,36 @@ DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
+--echo #
+--echo # Bug mdev-4363: selectivity of the condition a IS NULL OR IS NOT NULL
+--echo # with optimizer_use_condition_selectivity=3
+--echo #
+
+set use_stat_tables = PREFERABLY;
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES
+ (1),(7),(4),(7),(NULL),(2),(NULL),(4),(NULL),(NULL),(1),(3),(8),(8);
+
+ANALYZE TABLE t1;
+FLUSH TABLE t1;
+
+set optimizer_use_condition_selectivity=3;
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE a IS NULL;
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE a IS NOT NULL;
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE a IS NULL OR a IS NOT NULL;
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE a IS NULL OR a < 5;
+
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+
+DROP TABLE t1;
+
+set use_stat_tables=@save_use_stat_tables;
+
+
set use_stat_tables=@save_use_stat_tables;