| 7518 | */ |
| 7519 | |
| 7520 | static bool |
| 7521 | mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2, |
| 7522 | List<String> *using_fields, uint *found_using_fields) |
| 7523 | { |
| 7524 | Field_iterator_table_ref it_1, it_2; |
| 7525 | Natural_join_column *nj_col_1, *nj_col_2; |
| 7526 | Query_arena *arena, backup; |
| 7527 | bool result= TRUE; |
| 7528 | bool first_outer_loop= TRUE; |
| 7529 | Field *field_1; |
| 7530 | field_visibility_t field_1_invisible, field_2_invisible; |
| 7531 | /* |
| 7532 | Leaf table references to which new natural join columns are added |
| 7533 | if the leaves are != NULL. |
| 7534 | */ |
| 7535 | TABLE_LIST *leaf_1= (table_ref_1->nested_join && |
| 7536 | !table_ref_1->is_natural_join) ? |
| 7537 | NULL : table_ref_1; |
| 7538 | TABLE_LIST *leaf_2= (table_ref_2->nested_join && |
| 7539 | !table_ref_2->is_natural_join) ? |
| 7540 | NULL : table_ref_2; |
| 7541 | |
| 7542 | DBUG_ENTER("mark_common_columns"); |
| 7543 | DBUG_PRINT("info", ("operand_1: %s operand_2: %s", |
| 7544 | table_ref_1->alias.str, table_ref_2->alias.str)); |
| 7545 | |
| 7546 | *found_using_fields= 0; |
| 7547 | arena= thd->activate_stmt_arena_if_needed(&backup); |
| 7548 | |
| 7549 | for (it_1.set(table_ref_1); !it_1.end_of_fields(); it_1.next()) |
| 7550 | { |
| 7551 | bool found= FALSE; |
| 7552 | Lex_ident_column field_name_1; |
| 7553 | Field *field_2= 0; |
| 7554 | |
| 7555 | /* true if field_name_1 is a member of using_fields */ |
| 7556 | bool is_using_column_1; |
| 7557 | if (!(nj_col_1= it_1.get_or_create_column_ref(thd, leaf_1))) |
| 7558 | goto err; |
| 7559 | |
| 7560 | field_1= nj_col_1->field(); |
| 7561 | field_1_invisible= field_1 ? field_1->invisible : VISIBLE; |
| 7562 | |
| 7563 | if (field_1_invisible == INVISIBLE_FULL) |
| 7564 | continue; |
| 7565 | |
| 7566 | field_name_1= nj_col_1->name(); |
| 7567 | is_using_column_1= using_fields && |
| 7568 | test_if_string_in_list(field_name_1, using_fields); |
| 7569 | DBUG_PRINT ("info", ("field_name_1=%s.%s", |
| 7570 | nj_col_1->safe_table_name().str, |
| 7571 | field_name_1.str)); |
| 7572 | |
| 7573 | if (field_1_invisible && !is_using_column_1) |
| 7574 | continue; |
| 7575 | |
| 7576 | /* |
| 7577 | Find a field with the same name in table_ref_2. |
no test coverage detected