| 8763 | */ |
| 8764 | |
| 8765 | bool |
| 8766 | insert_fields(THD *thd, Name_resolution_context *context, |
| 8767 | const Lex_ident_db &db_name_arg, |
| 8768 | const Lex_ident_table &table_name, |
| 8769 | List_iterator<Item> *it, |
| 8770 | bool any_privileges, uint *hidden_bit_fields, |
| 8771 | bool returning_field) |
| 8772 | { |
| 8773 | Field_iterator_table_ref field_iterator; |
| 8774 | bool found; |
| 8775 | Lex_ident_db db_name= db_name_arg; |
| 8776 | IdentBuffer<SAFE_NAME_LEN> db_name_buff; |
| 8777 | DBUG_ENTER("insert_fields"); |
| 8778 | DBUG_PRINT("arena", ("stmt arena: %p",thd->stmt_arena)); |
| 8779 | |
| 8780 | if (db_name.str && lower_case_table_names) |
| 8781 | { |
| 8782 | /* |
| 8783 | convert database to lower case for comparison |
| 8784 | We can't do this in Item_field as this would change the |
| 8785 | 'name' of the item which may be used in the select list |
| 8786 | */ |
| 8787 | db_name= Lex_ident_db(db_name_buff.copy_casedn(db_name).to_lex_cstring()); |
| 8788 | } |
| 8789 | |
| 8790 | found= FALSE; |
| 8791 | |
| 8792 | /* |
| 8793 | If table names are qualified, then loop over all tables used in the query, |
| 8794 | else treat natural joins as leaves and do not iterate over their underlying |
| 8795 | tables. |
| 8796 | */ |
| 8797 | TABLE_LIST *first= context->first_name_resolution_table; |
| 8798 | TABLE_LIST *TABLE_LIST::* next= &TABLE_LIST::next_name_resolution_table; |
| 8799 | if (table_name.str && !returning_field) |
| 8800 | { |
| 8801 | first= context->table_list; |
| 8802 | next= &TABLE_LIST::next_local; |
| 8803 | } |
| 8804 | for (TABLE_LIST *tables= first; tables; tables= tables->*next) |
| 8805 | { |
| 8806 | Field *field; |
| 8807 | TABLE *table= tables->table; |
| 8808 | |
| 8809 | DBUG_ASSERT(tables->is_leaf_for_name_resolution()); |
| 8810 | |
| 8811 | if ((table_name.str && !table_name.streq(tables->alias)) || |
| 8812 | (db_name.str && strcmp(tables->db.str, db_name.str))) |
| 8813 | continue; |
| 8814 | |
| 8815 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
| 8816 | /* |
| 8817 | Ensure that we have access rights to all fields to be inserted |
| 8818 | the table 'tables'. Under some circumstances, this check may be skipped. |
| 8819 | |
| 8820 | The check is skipped in the following cases: |
| 8821 | |
| 8822 | - any_privileges is true |
no test coverage detected