| 1695 | */ |
| 1696 | |
| 1697 | static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, |
| 1698 | List<Item> &fields, |
| 1699 | bool select_insert) |
| 1700 | { |
| 1701 | bool insert_into_view= (table_list->view != 0); |
| 1702 | DBUG_ENTER("mysql_prepare_insert_check_table"); |
| 1703 | |
| 1704 | if (!table_list->single_table_updatable()) |
| 1705 | { |
| 1706 | my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias.str, "INSERT"); |
| 1707 | DBUG_RETURN(TRUE); |
| 1708 | } |
| 1709 | /* |
| 1710 | first table in list is the one we'll INSERT into, requires INSERT_ACL. |
| 1711 | all others require SELECT_ACL only. the ACL requirement below is for |
| 1712 | new leaves only anyway (view-constituents), so check for SELECT rather |
| 1713 | than INSERT. |
| 1714 | */ |
| 1715 | |
| 1716 | if (setup_tables_and_check_access(thd, |
| 1717 | &thd->lex->first_select_lex()->context, |
| 1718 | &thd->lex->first_select_lex()-> |
| 1719 | top_join_list, |
| 1720 | table_list, |
| 1721 | thd->lex->first_select_lex()->leaf_tables, |
| 1722 | select_insert, INSERT_ACL, SELECT_ACL, |
| 1723 | true)) |
| 1724 | DBUG_RETURN(TRUE); |
| 1725 | |
| 1726 | if (insert_into_view && !fields.elements) |
| 1727 | { |
| 1728 | thd->lex->empty_field_list_on_rset= 1; |
| 1729 | if (!thd->lex->first_select_lex()->leaf_tables.head()->table || |
| 1730 | table_list->is_multitable()) |
| 1731 | { |
| 1732 | my_error(ER_VIEW_NO_INSERT_FIELD_LIST, MYF(0), |
| 1733 | table_list->view_db.str, table_list->view_name.str); |
| 1734 | DBUG_RETURN(TRUE); |
| 1735 | } |
| 1736 | DBUG_RETURN(insert_view_fields(thd, &fields, table_list)); |
| 1737 | } |
| 1738 | |
| 1739 | if (table_list->table->check_sequence_privileges(thd)) |
| 1740 | DBUG_RETURN(TRUE); |
| 1741 | |
| 1742 | DBUG_RETURN(FALSE); |
| 1743 | } |
| 1744 | |
| 1745 | |
| 1746 | /* |
no test coverage detected