Fixed bug mdev-5160.
The used_tables attribute must be recalculated for the HAVING condition if the condition is applied to the rows read from a temporary table.
This commit is contained in:
parent
3a75900b91
commit
e0d9a25690
@ -637,3 +637,15 @@ Note 1003 select min(`test`.`t1`.`f10`) AS `field1` from `test`.`t1` where <expr
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# Bug mdev-5160: two-way join with HAVING over the second table
|
||||
#
|
||||
CREATE TABLE t1 (c1 varchar(6)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('s'), ('t'), ('a'), ('x');
|
||||
CREATE TABLE t2 (c2 varchar(6)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('a'), ('x');
|
||||
SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
|
||||
c1 c2
|
||||
x x
|
||||
DROP TABLE t1,t2;
|
||||
End of 10.0 tests
|
||||
|
@ -657,3 +657,19 @@ set optimizer_switch=@save_optimizer_switch;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo End of 5.2 tests
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-5160: two-way join with HAVING over the second table
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c1 varchar(6)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('s'), ('t'), ('a'), ('x');
|
||||
|
||||
CREATE TABLE t2 (c2 varchar(6)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('a'), ('x');
|
||||
|
||||
SELECT * FROM t1 JOIN t2 ON c1 = c2 HAVING c2 > 'a' ORDER BY c2 LIMIT 1;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo End of 10.0 tests
|
||||
|
@ -2912,6 +2912,7 @@ void JOIN::exec_inner()
|
||||
JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables];
|
||||
table_map used_tables= (curr_join->const_table_map |
|
||||
curr_table->table->map);
|
||||
curr_join->tmp_having->update_used_tables();
|
||||
|
||||
Item* sort_table_cond= make_cond_for_table(thd, curr_join->tmp_having,
|
||||
used_tables,
|
||||
|
Loading…
x
Reference in New Issue
Block a user