diff options
author | Guilhem Bichot <guilhem@mysql.com> | 2008-11-21 15:21:50 +0100 |
---|---|---|
committer | Guilhem Bichot <guilhem@mysql.com> | 2008-11-21 15:21:50 +0100 |
commit | 33b194c36ec28528fd349dd17412848de2f1171c (patch) | |
tree | 68cba4897925b9395dd0bfe53b5b95a777d78637 /sql/sql_update.cc | |
parent | 8d96bcda72df224f7a656cbcc1535a027bada75f (diff) | |
parent | 1d521f6c20881997c9162bd11cadcbc77d20520b (diff) | |
download | mariadb-git-33b194c36ec28528fd349dd17412848de2f1171c.tar.gz |
Merge of 5.1-main into 5.1-maria. There were no changes to storage/myisam, or mysql-test/t/*myisam*.
However there were three new tests mysql-test/suite/parts/t/partition*myisam.test, of which I make here
copies for Maria.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index dbbc0e58d8a..7d7b08f964a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1039,7 +1039,7 @@ reopen_tables: correct order of statements. Otherwise, we use a TL_READ lock to improve performance. */ - tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ; + tl->lock_type= read_lock_type_for_table(thd, table); tl->updating= 0; /* Update TABLE::lock_type accordingly. */ if (!tl->placeholder() && !using_lock_tables) @@ -1076,11 +1076,14 @@ reopen_tables: } /* now lock and fill tables */ - if (lock_tables(thd, table_list, table_count, &need_reopen)) + if (!thd->stmt_arena->is_stmt_prepare() && + lock_tables(thd, table_list, table_count, &need_reopen)) { if (!need_reopen) DBUG_RETURN(TRUE); + DBUG_PRINT("info", ("lock_tables failed, reopening")); + /* We have to reopen tables since some of them were altered or dropped during lock_tables() or something was done with their triggers. @@ -1096,6 +1099,34 @@ reopen_tables: for (TABLE_LIST *tbl= table_list; tbl; tbl= tbl->next_global) tbl->cleanup_items(); + /* + To not to hog memory (as a result of the + unit->reinit_exec_mechanism() call below): + */ + lex->unit.cleanup(); + + for (SELECT_LEX *sl= lex->all_selects_list; + sl; + sl= sl->next_select_in_list()) + { + SELECT_LEX_UNIT *unit= sl->master_unit(); + unit->reinit_exec_mechanism(); // reset unit->prepared flags + /* + Reset 'clean' flag back to force normal execution of + unit->cleanup() in Prepared_statement::cleanup_stmt() + (call to lex->unit.cleanup() above sets this flag to TRUE). + */ + unit->unclean(); + } + + /* + Also we need to cleanup Natural_join_column::table_field items. + To not to traverse a join tree we will cleanup whole + thd->free_list (in PS execution mode that list may not contain + items from 'fields' list, so the cleanup above is necessary to. + */ + cleanup_items(thd->free_list); + close_tables_for_reopen(thd, &table_list); goto reopen_tables; } |