mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-13354: Server crashes in find_field_in_tables upon PS with window function and subquery
When creating an Item_direct_view_ref we were setting the Name_resolution_context based on TABLE_LIST::view member variable. However, for derived tables this member is NULL. To not set a wrong context, if TABLE_LIST::view is empty, use THD::lex instead.
This commit is contained in:
@@ -3262,3 +3262,14 @@ is_not_null_lead_order
|
|||||||
1
|
1
|
||||||
0
|
0
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
#
|
||||||
|
# MDEV-13354: Server crashes in find_field_in_tables upon PS with window function and subquery
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (i INT, a char);
|
||||||
|
INSERT INTO t1 VALUES (1, 'a'),(2, 'b');
|
||||||
|
PREPARE stmt FROM "SELECT row_number() over (partition by i order by i), i FROM (SELECT * from t1) as sq";
|
||||||
|
EXECUTE stmt;
|
||||||
|
row_number() over (partition by i order by i) i
|
||||||
|
1 1
|
||||||
|
1 2
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -2025,3 +2025,14 @@ FROM t1
|
|||||||
ORDER BY a;
|
ORDER BY a;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-13354: Server crashes in find_field_in_tables upon PS with window function and subquery
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (i INT, a char);
|
||||||
|
INSERT INTO t1 VALUES (1, 'a'),(2, 'b');
|
||||||
|
PREPARE stmt FROM "SELECT row_number() over (partition by i order by i), i FROM (SELECT * from t1) as sq";
|
||||||
|
EXECUTE stmt;
|
||||||
|
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -5766,9 +5766,10 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
|
|||||||
{
|
{
|
||||||
DBUG_RETURN(field);
|
DBUG_RETURN(field);
|
||||||
}
|
}
|
||||||
|
Name_resolution_context *context= view->view ? &view->view->select_lex.context :
|
||||||
|
&thd->lex->select_lex.context;
|
||||||
Item *item= (new (thd->mem_root)
|
Item *item= (new (thd->mem_root)
|
||||||
Item_direct_view_ref(thd, &view->view->select_lex.context,
|
Item_direct_view_ref(thd, context, field_ref, view->alias,
|
||||||
field_ref, view->alias,
|
|
||||||
name, view));
|
name, view));
|
||||||
/*
|
/*
|
||||||
Force creation of nullable item for the result tmp table for outer joined
|
Force creation of nullable item for the result tmp table for outer joined
|
||||||
|
Reference in New Issue
Block a user