mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
MDEV-25629: Crash in get_sort_by_table() in subquery with order by having outer ref
In Item_field::fix_fields(): when the item was resolved to an Item_field in the SELECT's select_list, copy the Item_field's "depended_from" field. Failure to do so caused the item to have incorrect attributes: it pointed to a Field in an upper select but used_tables() didn't return OUTER_REF_TABLE_BIT.
This commit is contained in:
parent
af8d4a97e2
commit
e570f740cd
3 changed files with 25 additions and 0 deletions
|
@ -2783,3 +2783,13 @@ INSERT INTO t2 VALUES (3),(4);
|
|||
SELECT 1 IN (SELECT (SELECT a FROM t1) AS x FROM t2 GROUP BY x);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-25629: Crash in get_sort_by_table() in subquery with order by having outer ref
|
||||
#
|
||||
CREATE TABLE t1 (i1 int);
|
||||
insert into t1 values (1),(2);
|
||||
SELECT 1
|
||||
FROM (t1 JOIN t1 AS ref_t1 ON
|
||||
(t1.i1 > (SELECT ref_t1.i1 AS c0 FROM t1 b ORDER BY -c0)));
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -2282,3 +2282,17 @@ INSERT INTO t2 VALUES (3),(4); # Optional, fails either way
|
|||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT 1 IN (SELECT (SELECT a FROM t1) AS x FROM t2 GROUP BY x);
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-25629: Crash in get_sort_by_table() in subquery with order by having outer ref
|
||||
--echo #
|
||||
CREATE TABLE t1 (i1 int);
|
||||
insert into t1 values (1),(2);
|
||||
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT 1
|
||||
FROM (t1 JOIN t1 AS ref_t1 ON
|
||||
(t1.i1 > (SELECT ref_t1.i1 AS c0 FROM t1 b ORDER BY -c0)));
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
|
|
@ -5513,6 +5513,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
|
|||
*/
|
||||
set_max_sum_func_level(thd, select);
|
||||
set_field(new_field);
|
||||
depended_from= (*((Item_field**)res))->depended_from;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue