mirror of
https://github.com/MariaDB/server.git
synced 2025-08-30 11:22:14 +03:00
Fixed bug#19077: A nested materialized derived table is used before being populated.
The convert_constant_item() function converts constant items to ints on prepare phase to optimize execution speed. In this case it tries to evaluate subselect which contains a derived table and is contained in a derived table. All derived tables are filled only after all derived tables are prepared. So evaluation of subselect with derived table at the prepare phase will return a wrong result. A new flag with_subselect is added to the Item class. It indicates that expression which this item represents is a subselect or contains a subselect. It is set to 0 by default. It is set to 1 in the Item_subselect constructor for subselects. For Item_func and Item_cond derived classes it is set after fixing any argument in Item_func::fix_fields() and Item_cond::fix_fields accordingly. The convert_constant_item() function now doesn't convert a constant item if the with_subselect flag set in it.
This commit is contained in:
@@ -3177,3 +3177,9 @@ ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
|
||||
SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
|
||||
ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
|
||||
DROP TABLE t1;
|
||||
create table t1 (i int, j bigint);
|
||||
insert into t1 values (1, 2), (2, 2), (3, 2);
|
||||
select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3;
|
||||
min(i)
|
||||
1
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user