diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2009-04-28 05:27:38 +0500 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2009-04-28 05:27:38 +0500 |
commit | 755d312e8456da751f432fd0e9c211dc4aeba131 (patch) | |
tree | f2c77af7f9404ada69bb2ec0c8133c1b334a62d5 | |
parent | 26cc84d947ca877f6f5e2551390ec8831e9f317b (diff) | |
parent | def04705986a9abad6927c0b52aaf63c136b546b (diff) | |
download | mariadb-git-755d312e8456da751f432fd0e9c211dc4aeba131.tar.gz |
manual merge 5.0-bugteam --> 5.1-bugteam
-rw-r--r-- | mysql-test/r/select.result | 13 | ||||
-rw-r--r-- | mysql-test/t/select.test | 14 | ||||
-rw-r--r-- | sql/item.cc | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 0771c7fb370..09c7d1b329d 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4373,6 +4373,19 @@ f3 f4 count 1 abc 1 1 def 2 drop table t1, t2, t3; +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2 +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 +DROP TABLE t1; End of 5.0 tests create table t1(a INT, KEY (a)); INSERT INTO t1 VALUES (1),(2),(3),(4),(5); diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 8981ddbe2e4..715bdf0e667 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3726,6 +3726,20 @@ cr.f4 = cr2.f4 GROUP BY a.f3, cr.f4; drop table t1, t2, t3; + + +# +# Bug #40925: Equality propagation takes non indexed attribute +# + +CREATE TABLE t1 (a INT KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); + +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; +EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; + +DROP TABLE t1; + --echo End of 5.0 tests # diff --git a/sql/item.cc b/sql/item.cc index 180ce4f4702..d1418b9a137 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4468,7 +4468,7 @@ Item *Item_field::replace_equal_field(uchar *arg) return const_item; } Item_field *subst= item_equal->get_first(); - if (subst && !field->eq(subst->field)) + if (subst && field->table != subst->field->table && !field->eq(subst->field)) return subst; } return this; |