Commit f1cc6dd4 authored by Igor Babaev's avatar Igor Babaev

Merge.

parents c7598614 81316aac
......@@ -1285,3 +1285,38 @@ a b a a b
1 1 1 1 1
1 1 1 1 1
drop table t1,t2,t3;
#
# BUG#729067/730466: unexpected 'Range checked for each record'
# for queries with OR in WHERE clause
#
CREATE TABLE t1 (f1 int, f2 int) ;
INSERT INTO t1 VALUES (4,0),(5,1);
CREATE TABLE t2 (f1 int, f2 int, KEY (f2)) ;
INSERT INTO t2 VALUES (5,7), (8,9);
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t2 ALL f2 NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
f1 f2 f1 f2
5 1 5 7
DROP TABLE t1,t2;
CREATE TABLE t1(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t1 VALUES (9,4), (10,9);
CREATE TABLE t2(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t2 VALUES (9,4), (10,9);
EXPLAIN
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where
1 PRIMARY t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
2 SUBQUERY t1 index NULL PRIMARY 4 NULL 2 Using index
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
f1 f2 f1 f2
9 4 10 9
DROP TABLE t1,t2;
......@@ -964,3 +964,36 @@ where t2.a=1 and t2.b=t1.a and t1.a=t3.b and t3.a=1;
drop table t1,t2,t3;
--echo #
--echo # BUG#729067/730466: unexpected 'Range checked for each record'
--echo # for queries with OR in WHERE clause
--echo #
CREATE TABLE t1 (f1 int, f2 int) ;
INSERT INTO t1 VALUES (4,0),(5,1);
CREATE TABLE t2 (f1 int, f2 int, KEY (f2)) ;
INSERT INTO t2 VALUES (5,7), (8,9);
EXPLAIN
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
SELECT * FROM t1 STRAIGHT_JOIN t2 ON t2.f1 = t1.f1
WHERE t1.f1<>0 OR t1.f2<>0 AND t1.f1 = t2.f2;
DROP TABLE t1,t2;
CREATE TABLE t1(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t1 VALUES (9,4), (10,9);
CREATE TABLE t2(f1 int PRIMARY KEY, f2 int) ;
INSERT INTO t2 VALUES (9,4), (10,9);
EXPLAIN
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1
WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9;
DROP TABLE t1,t2;
......@@ -5727,7 +5727,8 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
not_null_tables_cache|= tmp_table_map;
if (item->maybe_null)
maybe_null=1;
item->item_equal= this;
if (!item->item_equal)
item->item_equal= this;
}
fix_length_and_dec();
fixed= 1;
......
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