Commit 6ea960c8 authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

opt_range.cc:

  Fixed bug #11853.
  Corrected the code of the range optimization for
  NOT IN and NOT BETWEEN.
range.test, range.result:
  Fixed bug #11853.
parent 8b0adacb
...@@ -744,3 +744,27 @@ a b ...@@ -744,3 +744,27 @@ a b
1 3 1 3
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name));
INSERT INTO t1 VALUES ('Betty'), ('Anna');
SELECT * FROM t1;
name
Anna
Betty
DELETE FROM t1 WHERE name NOT LIKE 'A%a';
SELECT * FROM t1;
name
Anna
DROP TABLE t1;
CREATE TABLE t1 (a int, KEY idx(a));
INSERT INTO t1 VALUES (NULL), (1), (2), (3);
SELECT * FROM t1;
a
NULL
1
2
3
DELETE FROM t1 WHERE NOT(a <=> 2);
SELECT * FROM t1;
a
2
DROP TABLE t1;
...@@ -553,3 +553,26 @@ SELECT a,b FROM v1 WHERE a < 2 and b=3; ...@@ -553,3 +553,26 @@ SELECT a,b FROM v1 WHERE a < 2 and b=3;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #11853: DELETE statement with a NOT (LIKE/<=>) where condition
# for an indexed attribute
#
CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name));
INSERT INTO t1 VALUES ('Betty'), ('Anna');
SELECT * FROM t1;
DELETE FROM t1 WHERE name NOT LIKE 'A%a';
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a int, KEY idx(a));
INSERT INTO t1 VALUES (NULL), (1), (2), (3);
SELECT * FROM t1;
DELETE FROM t1 WHERE NOT(a <=> 2);
SELECT * FROM t1;
DROP TABLE t1;
...@@ -3531,7 +3531,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -3531,7 +3531,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
if (arg->type() != Item::FUNC_ITEM) if (arg->type() != Item::FUNC_ITEM)
DBUG_RETURN(0); DBUG_RETURN(0);
cond_func= (Item_func*) arg; cond_func= (Item_func*) arg;
if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) if (cond_func->functype() != Item_func::BETWEEN &&
cond_func->functype() != Item_func::IN_FUNC)
DBUG_RETURN(0); DBUG_RETURN(0);
inv= TRUE; inv= TRUE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment