mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge bk-internal:/home/bk/mysql-4.1/
into serg.mylan:/usr/home/serg/Abk/mysql-4.1 mysql-test/r/mysqldump.result: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged
This commit is contained in:
@ -42,9 +42,6 @@ SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
|
|||||||
a
|
a
|
||||||
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
||||||
a
|
a
|
||||||
SELECT @a, @b;
|
|
||||||
@a @b
|
|
||||||
0 6
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
create table t1 (a int, b int);
|
create table t1 (a int, b int);
|
||||||
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
|
insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
|
||||||
|
@ -80,4 +80,4 @@ insert into t1 values ("Alas");
|
|||||||
use test;
|
use test;
|
||||||
SET TIMESTAMP=1000000000;
|
SET TIMESTAMP=1000000000;
|
||||||
insert into t1 values ("Alas");
|
insert into t1 values ("Alas");
|
||||||
drop table t1;
|
drop table t1, t2;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DROP TABLE IF EXISTS t1;
|
DROP TABLE IF EXISTS t1, `"t"1`;
|
||||||
CREATE TABLE t1(a int);
|
CREATE TABLE t1(a int);
|
||||||
INSERT INTO t1 VALUES (1), (2);
|
INSERT INTO t1 VALUES (1), (2);
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
@ -18,21 +18,22 @@ INSERT INTO t1 VALUES (1), (2);
|
|||||||
</database>
|
</database>
|
||||||
</mysqldump>
|
</mysqldump>
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
CREATE TABLE `t"1` (`a"b"c"` char(2));
|
CREATE TABLE `"t"1` (`a"b"` char(2));
|
||||||
INSERT INTO `t"1` VALUES ("\"1"), ("2\"");
|
INSERT INTO `"t"1` VALUES ("1\""), ("\"2");
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<mysqldump>
|
<mysqldump>
|
||||||
<database name="test">
|
<database name="test">
|
||||||
<table_structure name="t"1">
|
<table_structure name=""t"1">
|
||||||
<field Field="a"b"c"" Type="char(2)" Null="YES" />
|
<field Field="a"b"" Type="char(2)" Null="YES" />
|
||||||
</table_structure>
|
</table_structure>
|
||||||
<table_data name="t"1">
|
<table_data name=""t"1">
|
||||||
<row>
|
<row>
|
||||||
<field name="a"b"c"">"1</field>
|
<field name="a"b"">1"</field>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<field name="a"b"c"">2"</field>
|
<field name="a"b"">"2</field>
|
||||||
</row>
|
</row>
|
||||||
</table_data>
|
</table_data>
|
||||||
</database>
|
</database>
|
||||||
</mysqldump>
|
</mysqldump>
|
||||||
|
DROP TABLE `"t"1`;
|
||||||
|
382
mysql-test/r/negation_elimination.result
Normal file
382
mysql-test/r/negation_elimination.result
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
drop table if exists t1;
|
||||||
|
create table t1 (a int, key (a));
|
||||||
|
insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
|
||||||
|
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
|
||||||
|
explain select * from t1 where not(not(a));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
|
||||||
|
select * from t1 where not(not(a));
|
||||||
|
a
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(not(not(a > 10)));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||||
|
select * from t1 where not(not(not(a > 10)));
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
explain select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index
|
||||||
|
select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||||
|
a
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
explain select * from t1 where not(a = 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index
|
||||||
|
select * from t1 where not(a = 10);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(a != 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
|
||||||
|
select * from t1 where not(a != 1);
|
||||||
|
a
|
||||||
|
1
|
||||||
|
explain select * from t1 where not(a < 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||||
|
select * from t1 where not(a < 10);
|
||||||
|
a
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(a >= 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 9 Using where; Using index
|
||||||
|
select * from t1 where not(a >= 10);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
explain select * from t1 where not(a > 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||||
|
select * from t1 where not(a > 10);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
explain select * from t1 where not(a <= 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||||
|
select * from t1 where not(a <= 10);
|
||||||
|
a
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(a is null);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
|
||||||
|
select * from t1 where not(a is null);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(a is not null);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
|
||||||
|
select * from t1 where not(a is not null);
|
||||||
|
a
|
||||||
|
NULL
|
||||||
|
explain select * from t1 where not(a < 5 or a > 15);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||||
|
select * from t1 where not(a < 5 or a > 15);
|
||||||
|
a
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
explain select * from t1 where not(a < 15 and a > 5);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||||
|
select * from t1 where not(a < 15 and a > 5);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where a = 2 or not(a < 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||||
|
select * from t1 where a = 2 or not(a < 10);
|
||||||
|
a
|
||||||
|
2
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where a > 5 and not(a > 10);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
|
||||||
|
select * from t1 where a > 5 and not(a > 10);
|
||||||
|
a
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
explain select * from t1 where a > 5 xor a < 10;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
|
||||||
|
select * from t1 where a > 5 xor a < 10;
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||||
|
select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||||
|
a
|
||||||
|
2
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
explain select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 13 Using where; Using index
|
||||||
|
select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
7
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where NULL or not(a < 15 and a > 5);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
|
||||||
|
select * from t1 where NULL or not(a < 15 and a > 5);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not(NULL and a > 5);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 6 Using where; Using index
|
||||||
|
select * from t1 where not(NULL and a > 5);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
explain select * from t1 where not(NULL or a);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||||
|
select * from t1 where not(NULL or a);
|
||||||
|
a
|
||||||
|
explain select * from t1 where not(NULL and a);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
|
||||||
|
select * from t1 where not(NULL and a);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
|
||||||
|
select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||||
|
a
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 15 Using where; Using index
|
||||||
|
select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
|
||||||
|
a
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
|
||||||
|
select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||||
|
a
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
drop table t1;
|
@ -26,7 +26,6 @@ SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
|
|||||||
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
|
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
|
||||||
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
|
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
|
||||||
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
|
||||||
SELECT @a, @b;
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,4 +100,4 @@ select "--- --position --" as "";
|
|||||||
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
|
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
drop table t1;
|
drop table t1, t2;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--disable_warnings
|
--disable_warnings
|
||||||
DROP TABLE IF EXISTS t1;
|
DROP TABLE IF EXISTS t1, `"t"1`;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
# XML output
|
# XML output
|
||||||
@ -13,7 +13,7 @@ DROP TABLE t1;
|
|||||||
# Bug #1707
|
# Bug #1707
|
||||||
#
|
#
|
||||||
|
|
||||||
CREATE TABLE `t"1` (`a"b"c"` char(2));
|
CREATE TABLE `"t"1` (`a"b"` char(2));
|
||||||
INSERT INTO `t"1` VALUES ("\"1"), ("2\"");
|
INSERT INTO `"t"1` VALUES ("1\""), ("\"2");
|
||||||
--exec $MYSQL_DUMP --skip-all -X test
|
--exec $MYSQL_DUMP --skip-all -X test \"t\"1
|
||||||
DROP TABLE `t"1`;
|
DROP TABLE `"t"1`;
|
||||||
|
68
mysql-test/t/negation_elimination.test
Normal file
68
mysql-test/t/negation_elimination.test
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#
|
||||||
|
# Test negation elimination
|
||||||
|
#
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
create table t1 (a int, key (a));
|
||||||
|
insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
|
||||||
|
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
|
||||||
|
|
||||||
|
explain select * from t1 where not(not(a));
|
||||||
|
select * from t1 where not(not(a));
|
||||||
|
explain select * from t1 where not(not(not(a > 10)));
|
||||||
|
select * from t1 where not(not(not(a > 10)));
|
||||||
|
explain select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||||
|
select * from t1 where not(not(not(a < 5) and not(a > 10)));
|
||||||
|
explain select * from t1 where not(a = 10);
|
||||||
|
select * from t1 where not(a = 10);
|
||||||
|
explain select * from t1 where not(a != 10);
|
||||||
|
select * from t1 where not(a != 1);
|
||||||
|
explain select * from t1 where not(a < 10);
|
||||||
|
select * from t1 where not(a < 10);
|
||||||
|
explain select * from t1 where not(a >= 10);
|
||||||
|
select * from t1 where not(a >= 10);
|
||||||
|
explain select * from t1 where not(a > 10);
|
||||||
|
select * from t1 where not(a > 10);
|
||||||
|
explain select * from t1 where not(a <= 10);
|
||||||
|
select * from t1 where not(a <= 10);
|
||||||
|
explain select * from t1 where not(a is null);
|
||||||
|
select * from t1 where not(a is null);
|
||||||
|
explain select * from t1 where not(a is not null);
|
||||||
|
select * from t1 where not(a is not null);
|
||||||
|
explain select * from t1 where not(a < 5 or a > 15);
|
||||||
|
select * from t1 where not(a < 5 or a > 15);
|
||||||
|
explain select * from t1 where not(a < 15 and a > 5);
|
||||||
|
select * from t1 where not(a < 15 and a > 5);
|
||||||
|
|
||||||
|
explain select * from t1 where a = 2 or not(a < 10);
|
||||||
|
select * from t1 where a = 2 or not(a < 10);
|
||||||
|
explain select * from t1 where a > 5 and not(a > 10);
|
||||||
|
select * from t1 where a > 5 and not(a > 10);
|
||||||
|
explain select * from t1 where a > 5 xor a < 10;
|
||||||
|
select * from t1 where a > 5 xor a < 10;
|
||||||
|
|
||||||
|
explain select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||||
|
select * from t1 where a = 2 or not(a < 5 or a > 15);
|
||||||
|
explain select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||||
|
select * from t1 where a = 7 or not(a < 15 and a > 5);
|
||||||
|
|
||||||
|
explain select * from t1 where NULL or not(a < 15 and a > 5);
|
||||||
|
select * from t1 where NULL or not(a < 15 and a > 5);
|
||||||
|
explain select * from t1 where not(NULL and a > 5);
|
||||||
|
select * from t1 where not(NULL and a > 5);
|
||||||
|
explain select * from t1 where not(NULL or a);
|
||||||
|
select * from t1 where not(NULL or a);
|
||||||
|
explain select * from t1 where not(NULL and a);
|
||||||
|
select * from t1 where not(NULL and a);
|
||||||
|
|
||||||
|
explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||||
|
select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
|
||||||
|
explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
|
||||||
|
select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
|
||||||
|
explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||||
|
select * from t1 where ((a between 5 and 15) and (not(a like 10)));
|
||||||
|
|
||||||
|
drop table t1;
|
@ -220,6 +220,9 @@ public:
|
|||||||
virtual void bring_value() {}
|
virtual void bring_value() {}
|
||||||
|
|
||||||
Field *tmp_table_field_from_field_type(TABLE *table);
|
Field *tmp_table_field_from_field_type(TABLE *table);
|
||||||
|
|
||||||
|
/* Used in sql_select.cc:eliminate_not_funcs() */
|
||||||
|
virtual Item *neg_transformer() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "mysql_priv.h"
|
#include "mysql_priv.h"
|
||||||
#include <m_ctype.h>
|
#include <m_ctype.h>
|
||||||
|
#include "sql_select.h"
|
||||||
|
|
||||||
static Item_result item_store_type(Item_result a,Item_result b)
|
static Item_result item_store_type(Item_result a,Item_result b)
|
||||||
{
|
{
|
||||||
@ -477,6 +478,7 @@ longlong Item_func_eq::val_int()
|
|||||||
return value == 0 ? 1 : 0;
|
return value == 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Same as Item_func_eq, but NULL = NULL */
|
/* Same as Item_func_eq, but NULL = NULL */
|
||||||
|
|
||||||
void Item_func_equal::fix_length_and_dec()
|
void Item_func_equal::fix_length_and_dec()
|
||||||
@ -1722,6 +1724,19 @@ void Item_cond::print(String *str)
|
|||||||
str->append(')');
|
str->append(')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Item_cond::neg_arguments()
|
||||||
|
{
|
||||||
|
List_iterator<Item> li(list);
|
||||||
|
Item *item;
|
||||||
|
while ((item= li++)) /* Apply not transformation to the arguments */
|
||||||
|
{
|
||||||
|
Item *new_item= item->neg_transformer();
|
||||||
|
VOID(li.replace(new_item ? new_item : new Item_func_not(item)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Evalution of AND(expr, expr, expr ...)
|
Evalution of AND(expr, expr, expr ...)
|
||||||
|
|
||||||
@ -2335,3 +2350,91 @@ longlong Item_cond_xor::val_int()
|
|||||||
}
|
}
|
||||||
return (longlong) result;
|
return (longlong) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Apply NOT transformation to the item and return a new one.
|
||||||
|
|
||||||
|
SYNPOSIS
|
||||||
|
neg_transformer()
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Transform the item using next rules:
|
||||||
|
a AND b AND ... -> NOT(a) OR NOT(b) OR ...
|
||||||
|
a OR b OR ... -> NOT(a) AND NOT(b) AND ...
|
||||||
|
NOT(a) -> a
|
||||||
|
a = b -> a != b
|
||||||
|
a != b -> a = b
|
||||||
|
a < b -> a >= b
|
||||||
|
a >= b -> a < b
|
||||||
|
a > b -> a <= b
|
||||||
|
a <= b -> a > b
|
||||||
|
IS NULL(a) -> IS NOT NULL(a)
|
||||||
|
IS NOT NULL(a) -> IS NULL(a)
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
This method is used in the eliminate_not_funcs() function.
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
New item or
|
||||||
|
NULL if we cannot apply NOT transformation (see Item::neg_transformer()).
|
||||||
|
*/
|
||||||
|
|
||||||
|
Item *Item_func_not::neg_transformer() /* NOT(x) -> x */
|
||||||
|
{
|
||||||
|
/* We should apply negation elimination to the argument of the NOT function */
|
||||||
|
return eliminate_not_funcs(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_eq::neg_transformer() /* a = b -> a != b */
|
||||||
|
{
|
||||||
|
return new Item_func_ne(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_ne::neg_transformer() /* a != b -> a = b */
|
||||||
|
{
|
||||||
|
return new Item_func_eq(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_lt::neg_transformer() /* a < b -> a >= b */
|
||||||
|
{
|
||||||
|
return new Item_func_ge(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_ge::neg_transformer() /* a >= b -> a < b */
|
||||||
|
{
|
||||||
|
return new Item_func_lt(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_gt::neg_transformer() /* a > b -> a <= b */
|
||||||
|
{
|
||||||
|
return new Item_func_le(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_le::neg_transformer() /* a <= b -> a > b */
|
||||||
|
{
|
||||||
|
return new Item_func_gt(args[0], args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_isnull::neg_transformer() /* a IS NULL -> a IS NOT NULL */
|
||||||
|
{
|
||||||
|
return new Item_func_isnotnull(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_func_isnotnull::neg_transformer() /* a IS NOT NULL -> a IS NULL */
|
||||||
|
{
|
||||||
|
return new Item_func_isnull(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_cond_and::neg_transformer() /* NOT(a AND b AND ...) -> */
|
||||||
|
/* NOT a OR NOT b OR ... */
|
||||||
|
{
|
||||||
|
neg_arguments();
|
||||||
|
return new Item_cond_or(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *Item_cond_or::neg_transformer() /* NOT(a OR b OR ...) -> */
|
||||||
|
/* NOT a AND NOT b AND ... */
|
||||||
|
{
|
||||||
|
neg_arguments();
|
||||||
|
return new Item_cond_and(list);
|
||||||
|
}
|
||||||
|
@ -153,7 +153,9 @@ class Item_func_not :public Item_bool_func
|
|||||||
public:
|
public:
|
||||||
Item_func_not(Item *a) :Item_bool_func(a) {}
|
Item_func_not(Item *a) :Item_bool_func(a) {}
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
|
enum Functype functype() const { return NOT_FUNC; }
|
||||||
const char *func_name() const { return "not"; }
|
const char *func_name() const { return "not"; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_not_all :public Item_func_not
|
class Item_func_not_all :public Item_func_not
|
||||||
@ -164,6 +166,8 @@ public:
|
|||||||
virtual void top_level_item() { abort_on_null= 1; }
|
virtual void top_level_item() { abort_on_null= 1; }
|
||||||
bool top_level() { return abort_on_null; }
|
bool top_level() { return abort_on_null; }
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
|
enum Functype functype() const { return NOT_ALL_FUNC; }
|
||||||
|
const char *func_name() const { return "not_all"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_eq :public Item_bool_rowready_func2
|
class Item_func_eq :public Item_bool_rowready_func2
|
||||||
@ -175,6 +179,7 @@ public:
|
|||||||
enum Functype rev_functype() const { return EQ_FUNC; }
|
enum Functype rev_functype() const { return EQ_FUNC; }
|
||||||
cond_result eq_cmp_result() const { return COND_TRUE; }
|
cond_result eq_cmp_result() const { return COND_TRUE; }
|
||||||
const char *func_name() const { return "="; }
|
const char *func_name() const { return "="; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_func_equal :public Item_bool_rowready_func2
|
class Item_func_equal :public Item_bool_rowready_func2
|
||||||
@ -199,6 +204,7 @@ public:
|
|||||||
enum Functype rev_functype() const { return LE_FUNC; }
|
enum Functype rev_functype() const { return LE_FUNC; }
|
||||||
cond_result eq_cmp_result() const { return COND_TRUE; }
|
cond_result eq_cmp_result() const { return COND_TRUE; }
|
||||||
const char *func_name() const { return ">="; }
|
const char *func_name() const { return ">="; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -211,6 +217,7 @@ public:
|
|||||||
enum Functype rev_functype() const { return LT_FUNC; }
|
enum Functype rev_functype() const { return LT_FUNC; }
|
||||||
cond_result eq_cmp_result() const { return COND_FALSE; }
|
cond_result eq_cmp_result() const { return COND_FALSE; }
|
||||||
const char *func_name() const { return ">"; }
|
const char *func_name() const { return ">"; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +230,7 @@ public:
|
|||||||
enum Functype rev_functype() const { return GE_FUNC; }
|
enum Functype rev_functype() const { return GE_FUNC; }
|
||||||
cond_result eq_cmp_result() const { return COND_TRUE; }
|
cond_result eq_cmp_result() const { return COND_TRUE; }
|
||||||
const char *func_name() const { return "<="; }
|
const char *func_name() const { return "<="; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -235,6 +243,7 @@ public:
|
|||||||
enum Functype rev_functype() const { return GT_FUNC; }
|
enum Functype rev_functype() const { return GT_FUNC; }
|
||||||
cond_result eq_cmp_result() const { return COND_FALSE; }
|
cond_result eq_cmp_result() const { return COND_FALSE; }
|
||||||
const char *func_name() const { return "<"; }
|
const char *func_name() const { return "<"; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -247,6 +256,7 @@ public:
|
|||||||
cond_result eq_cmp_result() const { return COND_FALSE; }
|
cond_result eq_cmp_result() const { return COND_FALSE; }
|
||||||
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
|
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
|
||||||
const char *func_name() const { return "<>"; }
|
const char *func_name() const { return "<>"; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -689,6 +699,7 @@ public:
|
|||||||
}
|
}
|
||||||
table_map not_null_tables() const { return 0; }
|
table_map not_null_tables() const { return 0; }
|
||||||
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
|
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Functions used by HAVING for rewriting IN subquery */
|
/* Functions used by HAVING for rewriting IN subquery */
|
||||||
@ -721,6 +732,7 @@ public:
|
|||||||
const char *func_name() const { return "isnotnull"; }
|
const char *func_name() const { return "isnotnull"; }
|
||||||
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
|
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
|
||||||
table_map not_null_tables() const { return 0; }
|
table_map not_null_tables() const { return 0; }
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -800,7 +812,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/* Item_cond() is only used to create top level items */
|
/* Item_cond() is only used to create top level items */
|
||||||
Item_cond() : Item_bool_func(), abort_on_null(1) { const_item_cache=0; }
|
Item_cond(): Item_bool_func(), abort_on_null(1)
|
||||||
|
{ const_item_cache=0; }
|
||||||
Item_cond(Item *i1,Item *i2)
|
Item_cond(Item *i1,Item *i2)
|
||||||
:Item_bool_func(), abort_on_null(0)
|
:Item_bool_func(), abort_on_null(0)
|
||||||
{
|
{
|
||||||
@ -808,6 +821,8 @@ public:
|
|||||||
list.push_back(i2);
|
list.push_back(i2);
|
||||||
}
|
}
|
||||||
Item_cond(THD *thd, Item_cond &item);
|
Item_cond(THD *thd, Item_cond &item);
|
||||||
|
Item_cond(List<Item> &nlist)
|
||||||
|
:Item_bool_func(), list(nlist), abort_on_null(0) {}
|
||||||
~Item_cond() { list.delete_elements(); }
|
~Item_cond() { list.delete_elements(); }
|
||||||
bool add(Item *item) { return list.push_back(item); }
|
bool add(Item *item) { return list.push_back(item); }
|
||||||
bool fix_fields(THD *, struct st_table_list *, Item **ref);
|
bool fix_fields(THD *, struct st_table_list *, Item **ref);
|
||||||
@ -821,8 +836,8 @@ public:
|
|||||||
friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
|
friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
|
||||||
void top_level_item() { abort_on_null=1; }
|
void top_level_item() { abort_on_null=1; }
|
||||||
void copy_andor_arguments(THD *thd, Item_cond *item);
|
void copy_andor_arguments(THD *thd, Item_cond *item);
|
||||||
|
|
||||||
bool walk(Item_processor processor, byte *arg);
|
bool walk(Item_processor processor, byte *arg);
|
||||||
|
void neg_arguments();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -832,6 +847,7 @@ public:
|
|||||||
Item_cond_and() :Item_cond() {}
|
Item_cond_and() :Item_cond() {}
|
||||||
Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {}
|
Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {}
|
||||||
Item_cond_and(THD *thd, Item_cond_and &item) :Item_cond(thd, item) {}
|
Item_cond_and(THD *thd, Item_cond_and &item) :Item_cond(thd, item) {}
|
||||||
|
Item_cond_and(List<Item> &list): Item_cond(list) {}
|
||||||
enum Functype functype() const { return COND_AND_FUNC; }
|
enum Functype functype() const { return COND_AND_FUNC; }
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
const char *func_name() const { return "and"; }
|
const char *func_name() const { return "and"; }
|
||||||
@ -842,6 +858,7 @@ public:
|
|||||||
item->copy_andor_arguments(thd, this);
|
item->copy_andor_arguments(thd, this);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_cond_or :public Item_cond
|
class Item_cond_or :public Item_cond
|
||||||
@ -850,6 +867,7 @@ public:
|
|||||||
Item_cond_or() :Item_cond() {}
|
Item_cond_or() :Item_cond() {}
|
||||||
Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {}
|
Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {}
|
||||||
Item_cond_or(THD *thd, Item_cond_or &item) :Item_cond(thd, item) {}
|
Item_cond_or(THD *thd, Item_cond_or &item) :Item_cond(thd, item) {}
|
||||||
|
Item_cond_or(List<Item> &list): Item_cond(list) {}
|
||||||
enum Functype functype() const { return COND_OR_FUNC; }
|
enum Functype functype() const { return COND_OR_FUNC; }
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
const char *func_name() const { return "or"; }
|
const char *func_name() const { return "or"; }
|
||||||
@ -861,6 +879,7 @@ public:
|
|||||||
item->copy_andor_arguments(thd, this);
|
item->copy_andor_arguments(thd, this);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
Item *neg_transformer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ public:
|
|||||||
SP_TOUCHES_FUNC,SP_CROSSES_FUNC,SP_WITHIN_FUNC,
|
SP_TOUCHES_FUNC,SP_CROSSES_FUNC,SP_WITHIN_FUNC,
|
||||||
SP_CONTAINS_FUNC,SP_OVERLAPS_FUNC,
|
SP_CONTAINS_FUNC,SP_OVERLAPS_FUNC,
|
||||||
SP_STARTPOINT,SP_ENDPOINT,SP_EXTERIORRING,
|
SP_STARTPOINT,SP_ENDPOINT,SP_EXTERIORRING,
|
||||||
SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN};
|
SP_POINTN,SP_GEOMETRYN,SP_INTERIORRINGN,
|
||||||
|
NOT_FUNC, NOT_ALL_FUNC};
|
||||||
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL };
|
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL };
|
||||||
enum Type type() const { return FUNC_ITEM; }
|
enum Type type() const { return FUNC_ITEM; }
|
||||||
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
|
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
|
||||||
|
@ -564,7 +564,7 @@ public:
|
|||||||
List<TABLE> temporary_tables_should_be_free; // list of temporary tables
|
List<TABLE> temporary_tables_should_be_free; // list of temporary tables
|
||||||
List <MYSQL_ERROR> warn_list;
|
List <MYSQL_ERROR> warn_list;
|
||||||
uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
|
uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
|
||||||
uint total_warn_count, old_total_warn_count;
|
uint total_warn_count;
|
||||||
ulong query_id, warn_id, version, options, thread_id, col_access;
|
ulong query_id, warn_id, version, options, thread_id, col_access;
|
||||||
ulong current_stmt_id;
|
ulong current_stmt_id;
|
||||||
ulong rand_saved_seed1, rand_saved_seed2;
|
ulong rand_saved_seed1, rand_saved_seed2;
|
||||||
|
@ -1653,11 +1653,6 @@ mysql_execute_command(THD *thd)
|
|||||||
*/
|
*/
|
||||||
if (tables || &lex->select_lex != lex->all_selects_list)
|
if (tables || &lex->select_lex != lex->all_selects_list)
|
||||||
mysql_reset_errors(thd);
|
mysql_reset_errors(thd);
|
||||||
/*
|
|
||||||
Save old warning count to be able to send to client how many warnings we
|
|
||||||
got
|
|
||||||
*/
|
|
||||||
thd->old_total_warn_count= thd->total_warn_count;
|
|
||||||
|
|
||||||
#ifdef HAVE_REPLICATION
|
#ifdef HAVE_REPLICATION
|
||||||
if (thd->slave_thread)
|
if (thd->slave_thread)
|
||||||
|
@ -4172,6 +4172,60 @@ propagate_cond_constants(I_List<COND_CMP> *save_list,COND *and_father,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Eliminate NOT functions from the condition tree.
|
||||||
|
|
||||||
|
SYNPOSIS
|
||||||
|
eliminate_not_funcs()
|
||||||
|
cond condition tree
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
Eliminate NOT functions from the condition tree where it's possible.
|
||||||
|
Recursively traverse condition tree to find all NOT functions.
|
||||||
|
Call neg_transformer() method for negated arguments.
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
If neg_transformer() returned a new condition we call fix_fields().
|
||||||
|
We don't delete any items as it's not needed. They will be deleted
|
||||||
|
later at once.
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
New condition tree
|
||||||
|
*/
|
||||||
|
|
||||||
|
COND *eliminate_not_funcs(COND *cond)
|
||||||
|
{
|
||||||
|
if (!cond)
|
||||||
|
return cond;
|
||||||
|
if (cond->type() == Item::COND_ITEM) /* OR or AND */
|
||||||
|
{
|
||||||
|
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
|
||||||
|
Item *item;
|
||||||
|
while ((item= li++))
|
||||||
|
{
|
||||||
|
Item *new_item= eliminate_not_funcs(item);
|
||||||
|
if (item != new_item)
|
||||||
|
VOID(li.replace(new_item)); /* replace item with a new condition */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cond->type() == Item::FUNC_ITEM && /* 'NOT' operation? */
|
||||||
|
((Item_func*) cond)->functype() == Item_func::NOT_FUNC)
|
||||||
|
{
|
||||||
|
COND *new_cond= ((Item_func*) cond)->arguments()[0]->neg_transformer();
|
||||||
|
if (new_cond)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Here we can delete the NOT function. Something like: delete cond;
|
||||||
|
But we don't need to do it. All items will be deleted later at once.
|
||||||
|
*/
|
||||||
|
new_cond->fix_fields(current_thd, 0, &new_cond);
|
||||||
|
cond= new_cond;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cond;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static COND *
|
static COND *
|
||||||
optimize_cond(COND *conds,Item::cond_result *cond_value)
|
optimize_cond(COND *conds,Item::cond_result *cond_value)
|
||||||
{
|
{
|
||||||
@ -4180,8 +4234,11 @@ optimize_cond(COND *conds,Item::cond_result *cond_value)
|
|||||||
*cond_value= Item::COND_TRUE;
|
*cond_value= Item::COND_TRUE;
|
||||||
return conds;
|
return conds;
|
||||||
}
|
}
|
||||||
/* change field = field to field = const for each found field = const */
|
|
||||||
DBUG_EXECUTE("where",print_where(conds,"original"););
|
DBUG_EXECUTE("where",print_where(conds,"original"););
|
||||||
|
/* eliminate NOT operators */
|
||||||
|
conds= eliminate_not_funcs(conds);
|
||||||
|
DBUG_EXECUTE("where", print_where(conds, "after negation elimination"););
|
||||||
|
/* change field = field to field = const for each found field = const */
|
||||||
propagate_cond_constants((I_List<COND_CMP> *) 0,conds,conds);
|
propagate_cond_constants((I_List<COND_CMP> *) 0,conds,conds);
|
||||||
/*
|
/*
|
||||||
Remove all instances of item == item
|
Remove all instances of item == item
|
||||||
|
@ -414,3 +414,4 @@ bool error_if_full_join(JOIN *join);
|
|||||||
void relink_tables(SELECT_LEX *select_lex);
|
void relink_tables(SELECT_LEX *select_lex);
|
||||||
int report_error(TABLE *table, int error);
|
int report_error(TABLE *table, int error);
|
||||||
int safe_index_read(JOIN_TAB *tab);
|
int safe_index_read(JOIN_TAB *tab);
|
||||||
|
COND *eliminate_not_funcs(COND *cond);
|
||||||
|
Reference in New Issue
Block a user