Commit 3004dc7e authored by unknown's avatar unknown

An improvement of

ChangeSet
  1.1707 04/03/19 12:36:55 ram@gw.mysql.r18.ru +4 -0
  Fix for the bug #2976: NATURAL JOIN produces duplicate columns.

parent 6c937d71
......@@ -2290,16 +2290,20 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
DBUG_RETURN(-1);
#endif
Field **ptr=table->field,*field;
TABLE *natural_join_table;
thd->used_tables|=table->map;
if (table->outer_join ||
!tables->natural_join ||
tables->natural_join->table->outer_join)
natural_join_table= NULL;
else
natural_join_table= tables->natural_join->table;
while ((field = *ptr++))
{
/* Skip duplicate field names if NATURAL JOIN is used */
if (table->outer_join ||
!tables->natural_join ||
tables->natural_join->table->outer_join ||
!find_field_in_table(thd, tables->natural_join->table,
field->field_name, strlen(field->field_name),
0, 0))
if (!natural_join_table ||
!find_field_in_table(thd, natural_join_table, field->field_name,
strlen(field->field_name), 0, 0))
{
Item_field *item= new Item_field(field);
if (!found++)
......
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