some bug fixes related to derived tables

parent 408d7b2d
......@@ -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
......
......@@ -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);
......@@ -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))
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment