From 9cf4750ec3cfa97ee839bb84cc25629c5512bab2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Aug 2006 21:08:22 +0400 Subject: BUG#21282: Incorrect query results for "t.key NOT IN () In fix for BUG#15872, a condition of type "t.key NOT IN (c1, .... cN)" where N>1000, was incorrectly converted to (-inf < X < c_min) OR (c_max < X) Now this conversion is removed, we dont produce any range lists for such conditions. mysql-test/r/range.result: BUG#21282: Testcase mysql-test/t/range.test: BUG#21282: Testcase sql/opt_range.cc: BUG#21282: Incorrect query results for "t.key NOT IN () In fix for BUG#15872, a condition of type "t.key NOT IN (c1, .... cN)" where N>1000, was incorrectly converted to (-inf < X < c_min) OR (c_max < X) Now this conversion is removed, we dont produce any range lists for such conditions. --- mysql-test/t/range.test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mysql-test/t/range.test') diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index d53b05b98b1..57b5ab8f419 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -656,3 +656,28 @@ explain select * from t1 where a not between 'b' and 'b'; select a, hex(filler) from t1 where a not between 'b' and 'b'; drop table t1,t2,t3; + +# +# BUG#21282 +# +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, key(a)); +insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C; + +set @a="select * from t2 force index (a) where a NOT IN(0"; +select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z; +set @a=concat(@a, ')'); + +insert into t2 values (11),(13),(15); + +set @b= concat("explain ", @a); + +prepare stmt1 from @b; +execute stmt1; + +prepare stmt1 from @a; +execute stmt1; + +drop table t1, t2; +# End of 5.0 tests -- cgit v1.2.1 From c8cafde703bdeb5de636a095f1cf97dc566e80f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Aug 2006 09:37:19 -0700 Subject: Fixed bug #18165. Made [NOT]BETWEEN predicates SARGable in respect to the second and the third arguments. mysql-test/r/range.result: Added a test case to bug #18165. mysql-test/t/range.test: Added a test case to bug #18165. sql/opt_range.cc: Fixed bug #18165. Made [NOT]BETWEEN predicates SARGable in respect to the second and the third arguments. Put in a separate function called get_full_func_mm_tree the functionality that builds a conjunction of all SEL_TREEs for a simple predicate of the form (f op c), where f was a field and c was a constant, applying different equalities f=f' with f' being another field. --- mysql-test/t/range.test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'mysql-test/t/range.test') diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 57b5ab8f419..776c1a466ca 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -680,4 +680,34 @@ prepare stmt1 from @a; execute stmt1; drop table t1, t2; + +# +# Bug #18165: range access for BETWEEN with a constant for the first argument +# + +CREATE TABLE t1 ( + id int NOT NULL DEFAULT '0', + b int NOT NULL DEFAULT '0', + c int NOT NULL DEFAULT '0', + INDEX idx1(b,c), INDEX idx2(c)); + +INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8); + +INSERT INTO t1(b,c) VALUES (3,4), (3,4); + +SELECT * FROM t1 WHERE b<=3 AND 3<=c; +SELECT * FROM t1 WHERE 3 BETWEEN b AND c; + +EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c; +EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c; + +SELECT * FROM t1 WHERE 0 < b OR 0 > c; +SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; + +EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c; +EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c; + +DROP TABLE t1; + + # End of 5.0 tests -- cgit v1.2.1