Skip to content

Commit 57b13a6

Browse files
author
Chaithra Gopalareddy
committed
Bug#35710183: mysql server 8.1.0 crashed at Item_ident::walk
While trying to clone a Item_ref object during condition pushdown, Item_ref::print does not print the underlying expression since it is an alias. However, in this case the underlying expression is a user variable, which results in a mismatch for the number of fields present in the original expression and the cloned expression (parser creates a field object for the alias in the cloned expression while the original expression has none). In case of condition pushdown, we always want the original expression to be printed instead of the alias. So the solution is to skip the code path which has special handling for aliases. Also, removed a (!const_item()) check which was added for a similar case but for a constant expression. Change-Id: I3b390915dbc7618175fd1b65e06af73eb0a9f6ef
1 parent 6b51573 commit 57b13a6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mysql-test/r/derived.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4051,7 +4051,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
40514051
1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL
40524052
Warnings:
40534053
Note 1249 Select 3 was reduced during optimization
4054-
Note 1003 /* select#1 */ select 1 AS `alias1`,1 AS `alias2` from dual
4054+
Note 1003 /* select#1 */ select 1 AS `alias1`,`alias1` AS `alias2` from dual
40554055
SELECT *
40564056
FROM (SELECT (1) alias1,
40574057
(SELECT alias1) alias2
@@ -4079,7 +4079,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
40794079
1 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL
40804080
Warnings:
40814081
Note 1249 Select 3 was reduced during optimization
4082-
Note 1003 /* select#1 */ select 1 AS `alias2` from dual
4082+
Note 1003 /* select#1 */ select `alias1` AS `alias2` from dual
40834083
SELECT alias2
40844084
FROM (SELECT (1) alias1,
40854085
(SELECT alias1) alias2

sql/item.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8372,7 +8372,7 @@ void Item_ref::print(const THD *thd, String *str,
83728372
if (m_ref_item == nullptr) // Unresolved reference: print reference
83738373
return Item_ident::print(thd, str, query_type);
83748374

8375-
if (!const_item() && m_alias_of_expr &&
8375+
if (!thd->lex->reparse_derived_table_condition && m_alias_of_expr &&
83768376
ref_item()->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF &&
83778377
table_name == nullptr && item_name.ptr()) {
83788378
Simple_cstring str1 = ref_item()->real_item()->item_name;

0 commit comments

Comments
 (0)