From c115d1cee059ca49569642950802b650937690b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Nov 2002 10:58:49 +0200 Subject: [PATCH] fixed bug of subselect in derived tables mysql-test/r/subselect.result: test of subselect in derived table mysql-test/t/subselect.test: test of subselect in derived table --- mysql-test/r/subselect.result | 2 ++ mysql-test/t/subselect.test | 2 ++ sql/item.cc | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index ef4da19c826..5a8ff20aa33 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -30,6 +30,8 @@ Unknown column 'a' in 'field list' SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; a 1 +SELECT 1 FROM (SELECT (SELECT a)); +Unknown column 'a' in 'field list' drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; create table t1 (a int); create table t2 (a int, b int); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 6d4fc7de30b..00f3a4f6e44 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -13,6 +13,8 @@ SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1; -- error 1054 SELECT (SELECT 1), a; SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; +-- error 1054 +SELECT 1 FROM (SELECT (SELECT a)); drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; create table t1 (a int); create table t2 (a int, b int); diff --git a/sql/item.cc b/sql/item.cc index 13433990107..df42b9185cc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -472,7 +472,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) REPORT_EXCEPT_NOT_FOUND)) != (Item **)not_found_item) break; - + if (sl->linkage == DERIVED_TABLE_TYPE) + break; // do not look over derived table } if (!tmp) return -1; @@ -887,6 +888,8 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) if ((tmp= find_field_in_tables(thd, this, sl->get_table_list(), 0)) != not_found_field); + if (sl->linkage == DERIVED_TABLE_TYPE) + break; // do not look over derived table } if (!ref)