diff options
author | unknown <ram@gw.mysql.r18.ru> | 2004-06-22 14:48:29 +0500 |
---|---|---|
committer | unknown <ram@gw.mysql.r18.ru> | 2004-06-22 14:48:29 +0500 |
commit | 5e7260ab4fccead72ea03fcfc55de9f17fb0b5aa (patch) | |
tree | 36532eeacfa72a177f65dae129bd2c90c0aaa771 | |
parent | 3da21e1c3e7ba6e5b45bbd196c3bb02513bcc04f (diff) | |
parent | 8000e4134c4b72225dfdb68896ff1cec01842c24 (diff) | |
download | mariadb-git-5e7260ab4fccead72ea03fcfc55de9f17fb0b5aa.tar.gz |
after merge fix
sql/item.h:
Auto merged
-rw-r--r-- | mysql-test/r/subselect.result | 9 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 12 | ||||
-rw-r--r-- | sql/item.h | 5 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 3286ddceb0b..7571dfffc41 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1831,6 +1831,15 @@ Warnings: Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1 Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a)) drop table t1; +CREATE TABLE t1 (t1_a int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (t2_a int, t2_b int, PRIMARY KEY (t2_a, t2_b)); +INSERT INTO t2 VALUES (1, 1), (1, 2); +SELECT * FROM t1, t2 table2 WHERE t1_a = 1 AND table2.t2_a = 1 +HAVING table2.t2_b = (SELECT MAX(t2_b) FROM t2 WHERE t2_a = table2.t2_a); +t1_a t2_a t2_b +1 1 2 +DROP TABLE t1, t2; CREATE TABLE t1 (id int(11) default NULL,name varchar(10) default NULL); INSERT INTO t1 VALUES (1,'Tim'),(2,'Rebecca'),(3,NULL); CREATE TABLE t2 (id int(11) default NULL, pet varchar(10) default NULL); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index d68e519e460..930f339e26c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1169,6 +1169,18 @@ explain extended select * from t1 up where exists (select * from t1 where t1.a=u drop table t1; # +# Bug #4102: subselect in HAVING +# + +CREATE TABLE t1 (t1_a int); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (t2_a int, t2_b int, PRIMARY KEY (t2_a, t2_b)); +INSERT INTO t2 VALUES (1, 1), (1, 2); +SELECT * FROM t1, t2 table2 WHERE t1_a = 1 AND table2.t2_a = 1 + HAVING table2.t2_b = (SELECT MAX(t2_b) FROM t2 WHERE t2_a = table2.t2_a); +DROP TABLE t1, t2; + +# # Test problem with NULL and derived tables (Bug #4097) # diff --git a/sql/item.h b/sql/item.h index 52a44a65526..fe8c2cb0df1 100644 --- a/sql/item.h +++ b/sql/item.h @@ -822,7 +822,10 @@ public: void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); } enum Item_result result_type () const { return (*ref)->result_type(); } enum_field_types field_type() const { return (*ref)->field_type(); } - table_map used_tables() const { return (*ref)->used_tables(); } + table_map used_tables() const + { + return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); + } void set_result_field(Field *field) { result_field= field; } bool is_result_field() { return 1; } void save_in_result_field(bool no_conversions) |