Here is example of the bug during conversion Item_ref to Item_field
CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(0,0);
CREATE TABLE t2 (c int); insert into t2 values (1),(2);
prepare stmt1 from "select sum(a),(select sum(c) from t2 having table1.b) as sub from t1 as table1";
execute stmt1;
drop table t1,t2;
Here is example of the bug during conversion Item_ref to Item_field
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(0,0);
CREATE TABLE t2 (c int);
insert into t2 values (1),(2);
prepare stmt1 from "select sum(a),(select sum(c) from t2 having table1.b) as sub
from t1 as table1";
execute stmt1;
drop table t1,t2;