mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Moving LP BUG#794005 to 5.3 + fixing INSERT of multi-table view.
This commit is contained in:
@@ -103,7 +103,8 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
|
||||
*/
|
||||
|
||||
bool check_view_single_update(List<Item> &fields, List<Item> *values,
|
||||
TABLE_LIST *view, table_map *map)
|
||||
TABLE_LIST *view, table_map *map,
|
||||
bool insert)
|
||||
{
|
||||
/* it is join view => we need to find the table for update */
|
||||
List_iterator_fast<Item> it(fields);
|
||||
@@ -140,6 +141,14 @@ bool check_view_single_update(List<Item> &fields, List<Item> *values,
|
||||
*/
|
||||
tbl->table->insert_values= view->table->insert_values;
|
||||
view->table= tbl->table;
|
||||
if (!tbl->single_table_updatable())
|
||||
{
|
||||
if (insert)
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias, "INSERT");
|
||||
else
|
||||
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias, "UPDATE");
|
||||
return TRUE;
|
||||
}
|
||||
*map= tables;
|
||||
|
||||
return FALSE;
|
||||
@@ -184,7 +193,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
{
|
||||
TABLE *table= table_list->table;
|
||||
|
||||
if (!table_list->updatable)
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
return -1;
|
||||
@@ -260,7 +269,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
||||
if (check_view_single_update(fields,
|
||||
fields_and_values_from_different_maps ?
|
||||
(List<Item>*) 0 : &values,
|
||||
table_list, map))
|
||||
table_list, map, true))
|
||||
return -1;
|
||||
table= table_list->table;
|
||||
}
|
||||
@@ -347,7 +356,7 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
|
||||
if (insert_table_list->is_view() &&
|
||||
insert_table_list->is_merged_derived() &&
|
||||
check_view_single_update(update_fields, &update_values,
|
||||
insert_table_list, map))
|
||||
insert_table_list, map, false))
|
||||
return -1;
|
||||
|
||||
if (table->timestamp_field)
|
||||
@@ -1159,7 +1168,7 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
|
||||
bool insert_into_view= (table_list->view != 0);
|
||||
DBUG_ENTER("mysql_prepare_insert_check_table");
|
||||
|
||||
if (!table_list->updatable)
|
||||
if (!table_list->single_table_updatable())
|
||||
{
|
||||
my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
|
||||
DBUG_RETURN(TRUE);
|
||||
|
Reference in New Issue
Block a user