diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 25de5ee4648..083acc8d5c9 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1617,7 +1617,7 @@ NULL UNION RESULT ALL NULL NULL NULL NULL NULL NULL Using filesort 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #-1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by <>((select `a` from `test`.`t2` where (`test`.`t2`.`b` = 12))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` union select `test`.`t1`.`a` AS `a` from `test`.`t1` order by <`a`>((select `a` from `test`.`t2` where (`test`.`t2`.`b` = 12))) # Should not crash SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY (SELECT a FROM t2 WHERE b = 12); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5af700b6917..0a2fd970f81 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7757,6 +7757,9 @@ bool st_select_lex_unit::add_fake_select_lex(THD *thd_arg) fake_select_lex->context.resolve_in_select_list= TRUE; fake_select_lex->context.select_lex= fake_select_lex; + fake_select_lex->nest_level_base= first_select()->nest_level_base; + fake_select_lex->nest_level=first_select()->nest_level; + if (!is_union()) { /*