1
0
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:
Vicențiu Ciorbaru
2017-09-18 18:57:17 +03:00
parent 454b9b1bdc
commit a1e589be9b
3 changed files with 25 additions and 2 deletions

View File

@@ -3262,3 +3262,14 @@ is_not_null_lead_order
1
0
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;

View File

@@ -2025,3 +2025,14 @@ FROM t1
ORDER BY a;
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;

View File

@@ -5766,9 +5766,10 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
{
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_direct_view_ref(thd, &view->view->select_lex.context,
field_ref, view->alias,
Item_direct_view_ref(thd, context, field_ref, view->alias,
name, view));
/*
Force creation of nullable item for the result tmp table for outer joined