Commit 28eaef79 authored by unknown's avatar unknown

A fix for a bug in fix_fields in case like this:

select .. UNION select some_column;

This is exhibited in sub-selects and derived tables.

parent fddbc989
......@@ -123,3 +123,5 @@ SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
select * from (select 1 as a) b left join (select 2 as a) c using(a);
a a
1 NULL
SELECT * FROM (SELECT 1 UNION SELECT a) b;
Unknown column 'a' in 'field list'
......@@ -43,3 +43,5 @@ explain select count(*) from t1 as tt1, (select * from t1) as tt2;
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
select * from (select 1 as a) b left join (select 2 as a) c using(a);
--error 1054
SELECT * FROM (SELECT 1 UNION SELECT a) b;
......@@ -1735,6 +1735,14 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
bool allow_rowid= tables && !tables->next; // Only one table
for (; tables ; tables=tables->next)
{
if (!tables->table)
{
if (report_error)
my_printf_error(ER_BAD_FIELD_ERROR,ER(ER_BAD_FIELD_ERROR),MYF(0),
item->full_name(),thd->where);
return (Field*) not_found_field;
}
Field *field=find_field_in_table(thd,tables->table,name,length,
grant_option &&
!thd->master_access, allow_rowid);
......
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