Commit fffe1e84 authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

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