Loading mysql-test/r/subselect2.result +12 −0 Original line number Diff line number Diff line Loading @@ -132,3 +132,15 @@ id select_type table type possible_keys key key_len ref rows Extra 5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where 6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 func 1 Using index; Using where drop table t1, t2, t3, t4; CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t2 VALUES (1); CREATE TABLE t3 (a int(10), b int(10), c int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t3 VALUES (1,2,1); SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a and t2.a='1' AND t1.a=t3.b) > 0; a 2 DROP TABLE t1,t2,t3; mysql-test/t/subselect2.test +18 −0 Original line number Diff line number Diff line Loading @@ -150,3 +150,21 @@ EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JO drop table t1, t2, t3, t4; # End of 4.1 tests # # Bug #20792: Incorrect results from aggregate subquery # CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t2 VALUES (1); CREATE TABLE t3 (a int(10), b int(10), c int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t3 VALUES (1,2,1); SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a and t2.a='1' AND t1.a=t3.b) > 0; DROP TABLE t1,t2,t3; sql/item.h +1 −1 Original line number Diff line number Diff line Loading @@ -752,7 +752,7 @@ class Item { virtual bool find_item_in_field_list_processor(byte *arg) { return 0; } virtual bool change_context_processor(byte *context) { return 0; } virtual bool reset_query_id_processor(byte *query_id) { return 0; } virtual bool func_type_checker_processor(byte *arg) { return 0; } virtual bool is_expensive_processor(byte *arg) { return 0; } virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; } Loading sql/item_func.cc +2 −2 Original line number Diff line number Diff line Loading @@ -399,9 +399,9 @@ Field *Item_func::tmp_table_field(TABLE *t_arg) } bool Item_func::func_type_checker_processor(byte *arg) bool Item_func::is_expensive_processor(byte *arg) { return *((Functype*)arg) == functype(); return is_expensive(); } Loading sql/item_func.h +4 −1 Original line number Diff line number Diff line Loading @@ -189,7 +189,8 @@ class Item_func :public Item_result_field Item *transform(Item_transformer transformer, byte *arg); void traverse_cond(Cond_traverser traverser, void * arg, traverse_order order); bool func_type_checker_processor(byte *arg); bool is_expensive_processor(byte *arg); virtual bool is_expensive() { return 0; } }; Loading Loading @@ -947,6 +948,7 @@ class Item_udf_func :public Item_func void cleanup(); Item_result result_type () const { return udf.result_type(); } table_map not_null_tables() const { return 0; } bool is_expensive() { return 1; } }; Loading Loading @@ -1475,6 +1477,7 @@ class Item_func_sp :public Item_func virtual enum Functype functype() const { return FUNC_SP; } bool fix_fields(THD *thd, Item **ref); bool is_expensive() { return 1; } }; Loading Loading
mysql-test/r/subselect2.result +12 −0 Original line number Diff line number Diff line Loading @@ -132,3 +132,15 @@ id select_type table type possible_keys key key_len ref rows Extra 5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where 6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 func 1 Using index; Using where drop table t1, t2, t3, t4; CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t2 VALUES (1); CREATE TABLE t3 (a int(10), b int(10), c int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t3 VALUES (1,2,1); SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a and t2.a='1' AND t1.a=t3.b) > 0; a 2 DROP TABLE t1,t2,t3;
mysql-test/t/subselect2.test +18 −0 Original line number Diff line number Diff line Loading @@ -150,3 +150,21 @@ EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JO drop table t1, t2, t3, t4; # End of 4.1 tests # # Bug #20792: Incorrect results from aggregate subquery # CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t2 VALUES (1); CREATE TABLE t3 (a int(10), b int(10), c int(10), PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t3 VALUES (1,2,1); SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a and t2.a='1' AND t1.a=t3.b) > 0; DROP TABLE t1,t2,t3;
sql/item.h +1 −1 Original line number Diff line number Diff line Loading @@ -752,7 +752,7 @@ class Item { virtual bool find_item_in_field_list_processor(byte *arg) { return 0; } virtual bool change_context_processor(byte *context) { return 0; } virtual bool reset_query_id_processor(byte *query_id) { return 0; } virtual bool func_type_checker_processor(byte *arg) { return 0; } virtual bool is_expensive_processor(byte *arg) { return 0; } virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; } Loading
sql/item_func.cc +2 −2 Original line number Diff line number Diff line Loading @@ -399,9 +399,9 @@ Field *Item_func::tmp_table_field(TABLE *t_arg) } bool Item_func::func_type_checker_processor(byte *arg) bool Item_func::is_expensive_processor(byte *arg) { return *((Functype*)arg) == functype(); return is_expensive(); } Loading
sql/item_func.h +4 −1 Original line number Diff line number Diff line Loading @@ -189,7 +189,8 @@ class Item_func :public Item_result_field Item *transform(Item_transformer transformer, byte *arg); void traverse_cond(Cond_traverser traverser, void * arg, traverse_order order); bool func_type_checker_processor(byte *arg); bool is_expensive_processor(byte *arg); virtual bool is_expensive() { return 0; } }; Loading Loading @@ -947,6 +948,7 @@ class Item_udf_func :public Item_func void cleanup(); Item_result result_type () const { return udf.result_type(); } table_map not_null_tables() const { return 0; } bool is_expensive() { return 1; } }; Loading Loading @@ -1475,6 +1477,7 @@ class Item_func_sp :public Item_func virtual enum Functype functype() const { return FUNC_SP; } bool fix_fields(THD *thd, Item **ref); bool is_expensive() { return 1; } }; Loading