summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-08-26 16:35:38 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-08-26 16:35:38 +0400
commitd39dbd1084467494fec0799afc598a9f1bb52fa0 (patch)
treef8f8abb235d98bb13f4b8b1d0036fe1765c3fb47
parent2c379a1e26bcc3ca363be781e45f37b640ed6f41 (diff)
parent756076bd23d9e194d5730745d07ee86aa543d4e5 (diff)
downloadmariadb-git-d39dbd1084467494fec0799afc598a9f1bb52fa0.tar.gz
Automerge.
-rw-r--r--mysql-test/r/range.result13
-rw-r--r--mysql-test/t/range.test12
-rw-r--r--sql/opt_range.cc4
3 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index aa04bfc25ea..62acb2a7710 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -1653,4 +1653,17 @@ a b
0 0
1 1
DROP TABLE t1;
+#
+# Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL c_key NULL NULL NULL 3 Using where
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key c_notkey
+1 1
+3 3
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 5d5ad180f1a..0ad3d3e8504 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -1313,4 +1313,16 @@ SELECT * FROM t1 FORCE INDEX (PRIMARY)
DROP TABLE t1;
+--echo #
+--echo # Bug #54802: 'NOT BETWEEN' evaluation is incorrect
+--echo #
+
+CREATE TABLE t1 (c_key INT, c_notkey INT, KEY(c_key));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+
+EXPLAIN SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index af5b4b7c7d6..b9819def54d 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -5620,7 +5620,11 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
SEL_TREE *tmp= get_full_func_mm_tree(param, cond_func,
field_item, (Item*)(intptr)i, inv);
if (inv)
+ {
tree= !tree ? tmp : tree_or(param, tree, tmp);
+ if (tree == NULL)
+ break;
+ }
else
tree= tree_and(param, tree, tmp);
}