Commit 3e03c9ea authored by Igor Babaev's avatar Igor Babaev

After constant row substitution the optimizer should call the method

update_used_tables for the the where condition to update cached
indicators of constant subexpressions. It should be done before further
possible simplification of the where condition.

This change caused simplification of the executed where conditions 
in many test cases.
parent 6ebaa493
...@@ -2243,7 +2243,7 @@ EXPLAIN EXTENDED SELECT a FROM v1 WHERE a > 100 ORDER BY b; ...@@ -2243,7 +2243,7 @@ EXPLAIN EXTENDED SELECT a FROM v1 WHERE a > 100 ORDER BY b;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select 4 AS `a` from `test`.`t1` where (4 > 100) order by 1 Note 1003 select 4 AS `a` from `test`.`t1` where 0 order by 1
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE IF NOT EXISTS `galleries` ( CREATE TABLE IF NOT EXISTS `galleries` (
......
...@@ -102,7 +102,6 @@ a ...@@ -102,7 +102,6 @@ a
foo foo
Warnings: Warnings:
Error 1259 ZLIB: Input data corrupted Error 1259 ZLIB: Input data corrupted
Error 1259 ZLIB: Input data corrupted
explain select *, uncompress(a) from t1; explain select *, uncompress(a) from t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 1 SIMPLE t1 system NULL NULL NULL NULL 1
......
...@@ -52,7 +52,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text ...@@ -52,7 +52,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp 'is a test of some long text to') Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where 1
select * from t1 where xxx regexp('is a test of some long text to '); select * from t1 where xxx regexp('is a test of some long text to ');
xxx xxx
this is a test of some long text to see what happens this is a test of some long text to see what happens
......
...@@ -1306,7 +1306,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1306,7 +1306,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2))) Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where 1
SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
f1 f2 f3 f1 f2 f1 f2 f3 f1 f2
......
...@@ -1317,7 +1317,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1317,7 +1317,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2))) Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where 1
SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2
WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2));
f1 f2 f3 f1 f2 f1 f2 f3 f1 f2
......
...@@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; ...@@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0
DROP TABLE t1; DROP TABLE t1;
SELECT * FROM mysql.time_zone SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
...@@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00
1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8)
SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) SELECT * FROM t1 INNER JOIN t2 ON ( c = a )
WHERE 1 IS NULL OR b < 33 AND b = c; WHERE 1 IS NULL OR b < 33 AND b = c;
a b c a b c
...@@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6))
INSERT INTO t1 VALUES (3,1,6); INSERT INTO t1 VALUES (3,1,6);
SELECT * FROM t1, t2 SELECT * FROM t1, t2
WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
......
...@@ -5136,7 +5136,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; ...@@ -5136,7 +5136,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0
DROP TABLE t1; DROP TABLE t1;
SELECT * FROM mysql.time_zone SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
...@@ -5159,7 +5159,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5159,7 +5159,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00
1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8)
SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) SELECT * FROM t1 INNER JOIN t2 ON ( c = a )
WHERE 1 IS NULL OR b < 33 AND b = c; WHERE 1 IS NULL OR b < 33 AND b = c;
a b c a b c
...@@ -5283,7 +5283,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5283,7 +5283,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6))
INSERT INTO t1 VALUES (3,1,6); INSERT INTO t1 VALUES (3,1,6);
SELECT * FROM t1, t2 SELECT * FROM t1, t2
WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
......
...@@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; ...@@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0
DROP TABLE t1; DROP TABLE t1;
SELECT * FROM mysql.time_zone SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
...@@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00
1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index
Warnings: Warnings:
Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8)
SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) SELECT * FROM t1 INNER JOIN t2 ON ( c = a )
WHERE 1 IS NULL OR b < 33 AND b = c; WHERE 1 IS NULL OR b < 33 AND b = c;
a b c a b c
...@@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6))
INSERT INTO t1 VALUES (3,1,6); INSERT INTO t1 VALUES (3,1,6);
SELECT * FROM t1, t2 SELECT * FROM t1, t2
WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL );
......
...@@ -5693,7 +5693,7 @@ FROM t1 AS sq4_alias1 ...@@ -5693,7 +5693,7 @@ FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
sq4_alias1.col_varchar_key = @var3; sq4_alias1.col_varchar_key = @var3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found
SELECT @var3:=12, sq4_alias1.* SELECT @var3:=12, sq4_alias1.*
FROM t1 AS sq4_alias1 FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
......
...@@ -46,7 +46,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -46,7 +46,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ('2007-04-25 18:30:22' = 0) Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where 0
select * from t1 select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null)); where id in (select id from t1 as x1 where (t1.cur_date is null));
id cur_date id cur_date
...@@ -57,7 +57,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -57,7 +57,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ('2007-04-25' = 0) Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where 0
select * from t2 select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null)); where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date id cur_date
......
...@@ -5692,7 +5692,7 @@ FROM t1 AS sq4_alias1 ...@@ -5692,7 +5692,7 @@ FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
sq4_alias1.col_varchar_key = @var3; sq4_alias1.col_varchar_key = @var3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found
SELECT @var3:=12, sq4_alias1.* SELECT @var3:=12, sq4_alias1.*
FROM t1 AS sq4_alias1 FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
......
...@@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1 ...@@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
sq4_alias1.col_varchar_key = @var3; sq4_alias1.col_varchar_key = @var3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found
SELECT @var3:=12, sq4_alias1.* SELECT @var3:=12, sq4_alias1.*
FROM t1 AS sq4_alias1 FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
......
...@@ -5699,7 +5699,7 @@ FROM t1 AS sq4_alias1 ...@@ -5699,7 +5699,7 @@ FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
sq4_alias1.col_varchar_key = @var3; sq4_alias1.col_varchar_key = @var3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found
SELECT @var3:=12, sq4_alias1.* SELECT @var3:=12, sq4_alias1.*
FROM t1 AS sq4_alias1 FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
......
...@@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1 ...@@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
sq4_alias1.col_varchar_key = @var3; sq4_alias1.col_varchar_key = @var3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found
SELECT @var3:=12, sq4_alias1.* SELECT @var3:=12, sq4_alias1.*
FROM t1 AS sq4_alias1 FROM t1 AS sq4_alias1
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
......
...@@ -519,7 +519,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -519,7 +519,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ('2007-04-25 18:30:22' = 0) Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where 0
select * from t1 select * from t1
where id in (select id from t1 as x1 where (t1.cur_date is null)); where id in (select id from t1 as x1 where (t1.cur_date is null));
id cur_date id cur_date
...@@ -530,7 +530,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -530,7 +530,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ('2007-04-25' = 0) Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where 0
select * from t2 select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null)); where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date id cur_date
......
...@@ -4300,7 +4300,7 @@ WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%'); ...@@ -4300,7 +4300,7 @@ WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%');
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
Warnings: Warnings:
Note 1003 select 'r' AS `f4` from `test`.`t1` where (20 <> 0) Note 1003 select 'r' AS `f4` from `test`.`t1` where 1
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
# #
......
...@@ -3528,6 +3528,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -3528,6 +3528,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
join->impossible_where= false; join->impossible_where= false;
if (conds && const_count) if (conds && const_count)
{ {
conds->update_used_tables();
conds= remove_eq_conds(join->thd, conds, &join->cond_value); conds= remove_eq_conds(join->thd, conds, &join->cond_value);
join->select_lex->where= conds; join->select_lex->where= conds;
if (join->cond_value == Item::COND_FALSE) if (join->cond_value == Item::COND_FALSE)
......
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