Loading mysql-test/r/union.result +11 −0 Original line number Diff line number Diff line Loading @@ -1370,4 +1370,15 @@ select _utf8'12' union select _latin1'12345'; 12 12 12345 CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (3),(1),(2),(4),(1); SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test; a 1 2 3 4 SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; ERROR 42S22: Unknown column 'c' in 'order clause' DROP TABLE t1; End of 5.0 tests mysql-test/t/union.test +13 −0 Original line number Diff line number Diff line Loading @@ -855,4 +855,17 @@ drop table t1, t2; # select _utf8'12' union select _latin1'12345'; # # Bug #26661: UNION with ORDER BY undefined column in FROM list # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (3),(1),(2),(4),(1); SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test; --error 1054 SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; DROP TABLE t1; --echo End of 5.0 tests sql/item.cc +6 −1 Original line number Diff line number Diff line Loading @@ -3441,7 +3441,12 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) */ Name_resolution_context *last_checked_context= context; Item **ref= (Item **) not_found_item; Name_resolution_context *outer_context= context->outer_context; SELECT_LEX *current_sel= (SELECT_LEX *) thd->lex->current_select; Name_resolution_context *outer_context= 0; /* Currently derived tables cannot be correlated */ if (current_sel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE) outer_context= context->outer_context; for (; outer_context; outer_context= outer_context->outer_context) Loading Loading
mysql-test/r/union.result +11 −0 Original line number Diff line number Diff line Loading @@ -1370,4 +1370,15 @@ select _utf8'12' union select _latin1'12345'; 12 12 12345 CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (3),(1),(2),(4),(1); SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test; a 1 2 3 4 SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; ERROR 42S22: Unknown column 'c' in 'order clause' DROP TABLE t1; End of 5.0 tests
mysql-test/t/union.test +13 −0 Original line number Diff line number Diff line Loading @@ -855,4 +855,17 @@ drop table t1, t2; # select _utf8'12' union select _latin1'12345'; # # Bug #26661: UNION with ORDER BY undefined column in FROM list # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (3),(1),(2),(4),(1); SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a) AS test; --error 1054 SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test; DROP TABLE t1; --echo End of 5.0 tests
sql/item.cc +6 −1 Original line number Diff line number Diff line Loading @@ -3441,7 +3441,12 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) */ Name_resolution_context *last_checked_context= context; Item **ref= (Item **) not_found_item; Name_resolution_context *outer_context= context->outer_context; SELECT_LEX *current_sel= (SELECT_LEX *) thd->lex->current_select; Name_resolution_context *outer_context= 0; /* Currently derived tables cannot be correlated */ if (current_sel->master_unit()->first_select()->linkage != DERIVED_TABLE_TYPE) outer_context= context->outer_context; for (; outer_context; outer_context= outer_context->outer_context) Loading