diff options
author | unknown <holyfoot/hf@hfmain.(none)> | 2007-03-09 16:51:32 +0400 |
---|---|---|
committer | unknown <holyfoot/hf@hfmain.(none)> | 2007-03-09 16:51:32 +0400 |
commit | 209802eb79f69afd20b8e21db3b86ff6d9d933ea (patch) | |
tree | 21132a2634a78e6b5d8c1aa06b42bae2e2ec4aa0 | |
parent | d5f3bc14c0f06e4774c61d95ebee0bd4e70cf869 (diff) | |
parent | e68df7a1ab28e92647705adae6eb1d8d7e1bf6ce (diff) | |
download | mariadb-git-209802eb79f69afd20b8e21db3b86ff6d9d933ea.tar.gz |
Merge mysql.com:/home/hf/work/mrg/mysql-5.0-opt
into mysql.com:/home/hf/work/mrg/mysql-5.1-opt
mysql-test/r/union.result:
Auto merged
mysql-test/t/union.test:
Auto merged
sql/item.cc:
Auto merged
-rw-r--r-- | mysql-test/r/union.result | 11 | ||||
-rw-r--r-- | mysql-test/t/union.test | 13 | ||||
-rw-r--r-- | sql/item.cc | 7 |
3 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 9805b788a73..2a465364045 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1426,4 +1426,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 diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 2bdf8420d6d..cc93fbd715a 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -900,4 +900,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 diff --git a/sql/item.cc b/sql/item.cc index f2ec94bb92e..19f5c215274 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3475,7 +3475,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) |