diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2002-11-11 17:45:23 +0200 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2002-11-11 17:45:23 +0200 |
commit | 736e3c3c17a251af2732ca63cd9688398f99e414 (patch) | |
tree | beead16295a85df39e9090666939cf6488d83e8f | |
parent | 9134db473dabee4483d141ecbcbb8269bbc55cd1 (diff) | |
download | mariadb-git-736e3c3c17a251af2732ca63cd9688398f99e414.tar.gz |
some bug fixes related to derived tables
-rw-r--r-- | mysql-test/r/derived.result | 13 | ||||
-rw-r--r-- | mysql-test/t/derived.test | 10 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 |
4 files changed, 31 insertions, 6 deletions
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index d3fbd557156..b99664835a2 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -17,6 +17,19 @@ select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3 a y 3 3 3 3 +SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1); +Unknown column 'a' in 'having clause' +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1; +Column: 'a' in having clause is ambiguous +SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2; +a a +1 2 +SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1; +a a +SELECT 1 FROM (SELECT 1) WHERE a=2; +Unknown column 'a' in 'where clause' +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); +Unknown column 'a' in 'having clause' drop table if exists t1.t2,t3; select * from (select 1); 1 diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 87910c29706..6f32cfa0390 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -8,6 +8,16 @@ select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3. CREATE TABLE t3 (a int not null, b char (10) not null); insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y; +--error 1054 +SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1); +--error 1052 +SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1; +SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2; +SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1; +--error 1054 +SELECT 1 FROM (SELECT 1) WHERE a=2; +--error 1054 +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); drop table if exists t1.t2,t3; select * from (select 1); select a from (select 1 as a); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 77253d49ed0..fd6c2c48020 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1748,7 +1748,9 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length, } else { - Field **ptr=table->field; + Field **ptr; + if (!(ptr=table->field)) + return (Field *)0; while ((field = *ptr++)) { if (!my_strcasecmp(system_charset_info, field->field_name, name)) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e30773984fb..758c2c405e6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1332,11 +1332,6 @@ mysql_execute_command(THD *thd) TODO: make derived tables processing 'inside' SELECT processing. TODO: solve problem with depended derived tables in subselects */ - if ((lex->select_lex.next_select_in_list() && - lex->unit.create_total_list(thd, lex, &tables)) || - (table_rules_on && tables && thd->slave_thread && - !tables_ok(thd,tables))) - DBUG_VOID_RETURN; if (lex->derived_tables) { for (TABLE_LIST *cursor= tables; @@ -1351,6 +1346,11 @@ mysql_execute_command(THD *thd) DBUG_VOID_RETURN; } } + if ((lex->select_lex.next_select_in_list() && + lex->unit.create_total_list(thd, lex, &tables)) || + (table_rules_on && tables && thd->slave_thread && + !tables_ok(thd,tables))) + DBUG_VOID_RETURN; thread_safe_increment(com_stat[lex->sql_command],&LOCK_status); switch (lex->sql_command) { |