Determine what tables could be updated in the multi-update For these tables we'll need to open triggers and continue prelocking until all is open. */
| 1669 | until all is open. |
| 1670 | */ |
| 1671 | bool Multiupdate_prelocking_strategy::handle_end(THD *thd) |
| 1672 | { |
| 1673 | DBUG_ENTER("Multiupdate_prelocking_strategy::handle_end"); |
| 1674 | if (done) |
| 1675 | DBUG_RETURN(0); |
| 1676 | |
| 1677 | LEX *lex= thd->lex; |
| 1678 | SELECT_LEX *select_lex= lex->first_select_lex(); |
| 1679 | TABLE_LIST *table_list= lex->query_tables, *tl; |
| 1680 | |
| 1681 | done= true; |
| 1682 | |
| 1683 | if (mysql_handle_derived(lex, DT_INIT) || |
| 1684 | mysql_handle_derived(lex, DT_MERGE_FOR_INSERT) || |
| 1685 | mysql_handle_derived(lex, DT_PREPARE)) |
| 1686 | DBUG_RETURN(1); |
| 1687 | |
| 1688 | if (table_list->has_period() && table_list->is_view_or_derived()) |
| 1689 | { |
| 1690 | my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str); |
| 1691 | DBUG_RETURN(TRUE); |
| 1692 | } |
| 1693 | |
| 1694 | /* |
| 1695 | setup_tables() need for VIEWs. JOIN::prepare() will call setup_tables() |
| 1696 | second time, but this call will do nothing (there are check for second |
| 1697 | call in setup_tables()). |
| 1698 | */ |
| 1699 | |
| 1700 | if (setup_tables_and_check_access(thd, &select_lex->context, |
| 1701 | &select_lex->top_join_list, table_list, select_lex->leaf_tables, |
| 1702 | false, UPDATE_ACL, SELECT_ACL, true)) |
| 1703 | DBUG_RETURN(1); |
| 1704 | |
| 1705 | if (table_list->has_period() && |
| 1706 | select_lex->period_setup_conds(thd, table_list)) |
| 1707 | DBUG_RETURN(true); |
| 1708 | |
| 1709 | List<Item> *fields= &lex->first_select_lex()->item_list; |
| 1710 | if (setup_fields_with_no_wrap(thd, Ref_ptr_array(), *fields, |
| 1711 | MARK_COLUMNS_WRITE, 0, 0, THD_WHERE::SET_LIST)) |
| 1712 | DBUG_RETURN(1); |
| 1713 | |
| 1714 | if (thd->lex->has_returning() && |
| 1715 | setup_returning_fields(thd, select_lex->get_table_list())) |
| 1716 | DBUG_RETURN(1); |
| 1717 | |
| 1718 | // Check if we have a view in the list ... |
| 1719 | for (tl= table_list; tl ; tl= tl->next_local) |
| 1720 | if (tl->view) |
| 1721 | break; |
| 1722 | // ... and pass this knowledge in check_fields call |
| 1723 | if (check_fields(thd, table_list, *fields, tl != NULL )) |
| 1724 | DBUG_RETURN(1); |
| 1725 | |
| 1726 | table_map tables_for_update= thd->table_map_for_update= get_table_map(fields); |
| 1727 | |
| 1728 | if (unsafe_key_update(select_lex->leaf_tables, tables_for_update)) |
no test coverage detected