diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-04-26 14:02:37 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-04-26 14:02:37 +0200 |
commit | 2ce52790ffc72c4a4d3670ebf67c6655450620f2 (patch) | |
tree | 4be382f34905809f0a19e87574e2b07b91f5cb7c /sql/sql_update.cc | |
parent | caa9023c9ed101acbcf6b9bd821a09daeb8271ee (diff) | |
parent | 757daa4174ed1b8786d0307852f79885dd08ea89 (diff) | |
download | mariadb-git-2ce52790ffc72c4a4d3670ebf67c6655450620f2.tar.gz |
Merge branch '5.5' into 10.1
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 78aa059f64f..721e1ed908c 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1384,6 +1384,9 @@ int mysql_multi_update_prepare(THD *thd) List<Item> *fields= &lex->select_lex.item_list; table_map tables_for_update; bool update_view= 0; + DML_prelocking_strategy prelocking_strategy; + bool has_prelocking_list= thd->lex->requires_prelocking(); + /* if this multi-update was converted from usual update, here is table counter else junk will be assigned here, but then replaced with real @@ -1404,10 +1407,10 @@ int mysql_multi_update_prepare(THD *thd) keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE and global read lock. */ - if ((original_multiupdate && - open_tables(thd, &table_list, &table_count, - (thd->stmt_arena->is_stmt_prepare() ? - MYSQL_OPEN_FORCE_SHARED_MDL : 0))) || + if ((original_multiupdate && open_tables(thd, &table_list, &table_count, + thd->stmt_arena->is_stmt_prepare() + ? MYSQL_OPEN_FORCE_SHARED_MDL : 0, + &prelocking_strategy)) || mysql_handle_derived(lex, DT_INIT)) DBUG_RETURN(TRUE); /* @@ -1454,6 +1457,9 @@ int mysql_multi_update_prepare(THD *thd) if (unsafe_key_update(lex->select_lex.leaf_tables, tables_for_update)) DBUG_RETURN(true); + TABLE_LIST **new_tables= lex->query_tables_last; + DBUG_ASSERT(*new_tables== NULL); + /* Setup timestamp handling and locking mode */ @@ -1479,6 +1485,11 @@ int mysql_multi_update_prepare(THD *thd) If table will be updated we should not downgrade lock for it and leave it as is. */ + tl->updating= 1; + if (tl->belong_to_view) + tl->belong_to_view->updating= 1; + if (extend_table_list(thd, tl, &prelocking_strategy, has_prelocking_list)) + DBUG_RETURN(TRUE); } else { @@ -1501,7 +1512,6 @@ int mysql_multi_update_prepare(THD *thd) tl->lock_type= lock_type; else tl->set_lock_type(thd, lock_type); - tl->updating= 0; } } @@ -1510,6 +1520,20 @@ int mysql_multi_update_prepare(THD *thd) Note that unlike in the above loop we need to iterate here not only through all leaf tables but also through all view hierarchy. */ + + uint addon_table_count= 0; + if (*new_tables) + { + Sroutine_hash_entry **new_routines= thd->lex->sroutines_list.next; + DBUG_ASSERT(*new_routines == NULL); + if (open_tables(thd, thd->lex->create_info, new_tables, + &addon_table_count, new_routines, + thd->stmt_arena->is_stmt_prepare() + ? MYSQL_OPEN_FORCE_SHARED_MDL : 0, + &prelocking_strategy)) + DBUG_RETURN(TRUE); + } + for (tl= table_list; tl; tl= tl->next_local) { bool not_used= false; @@ -1538,7 +1562,7 @@ int mysql_multi_update_prepare(THD *thd) /* now lock and fill tables */ if (!thd->stmt_arena->is_stmt_prepare() && - lock_tables(thd, table_list, table_count, 0)) + lock_tables(thd, table_list, table_count + addon_table_count, 0)) { DBUG_RETURN(TRUE); } |