summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-03-16 00:20:20 +0300
committerKonstantin Osipov <kostja@sun.com>2010-03-16 00:20:20 +0300
commit09b7a0d11540495dd6fc9cf7ec0d2c81fd630f83 (patch)
tree3d24b829164a0567d0a3259fe6a86f4234031a42 /sql/sql_insert.cc
parenta45162d4e33152255132ec642ba7cfc60b5df1e1 (diff)
parent7116431a8a089e2f32d756073968951760d629cf (diff)
downloadmariadb-git-09b7a0d11540495dd6fc9cf7ec0d2c81fd630f83.tar.gz
A post-review fix for type-aware metadata locks.
DDL no longer aborts mysql_lock_tables(), and hence we no longer need to support need_reopen flag of this call. Remove the flag, and all the code in the server that was responsible for handling the case when it was set. This allowed to simplify: open_and_lock_tables_derived(), the delayed thread, multi-update. Rename MYSQL_LOCK_IGNORE_FLUSH to MYSQL_OPEN_IGNORE_FLUSH, since we now only support this flag in open_table(). Rename MYSQL_LOCK_PERF_SCHEMA to MYSQL_LOCK_LOG_TABLE, to avoid confusion. Move the wait for the global read lock for cases when we do updates in SELECT f1() or DO (UPDATE) to open_table() from mysql_lock_tables(). When waiting for the read lock, we could raise need_reopen flag, which is no longer present in mysql_lock_tables(). Since the block responsible for waiting for GRL was moved, MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK was renamed to MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK. mysql-test/r/mdl_sync.result: Update test results (see comments for mdl_sync.test). mysql-test/t/mdl_sync.test: Update tests: an abort mysql_lock_tables() called for an INSERT no longer auto-closes SQL HANDLERS, since it no longer leads to back-off and retry. sql/ha_ndbcluster_binlog.cc: Remove unused variables. sql/lock.cc: Remove support for need_reopen parameter of mysql_lock_tables(). Update comments. sql/log_event_old.cc: Remove the loop responsible for handling need_reopen out parameter of mysql_lock_tables(). sql/mysql_priv.h: Update open and lock tables flag names. sql/share/errmsg-utf8.txt: Add a new error message to report when thr_multi_lock() is aborted. sql/sql_base.cc: Update comments. Rename MYSQL_LOCK_IGNORE_FLUSH to MYSQL_OPEN_IGNORE_FLUSH. sql/sql_class.h: Remove unused code. sql/sql_db.cc: Remove an unused bit of code. sql/sql_handler.cc: For backward compatibility, we still want to back off and retry when a call to mysql_lock_tables() is aborted from within an SQL HANDLER. Write an internal error handler to support the case. sql/sql_insert.cc: Call mysql_lock_tables() no longer has need_reopen out parameter. Simplify the code by removing the crud that took care of it. MYSQL_LOCK_IGNORE_FLUSH is now only supported by open_tables(). sql/sql_show.cc: Rename MYSQL_LOCK_IGNORE_FLUSH to MYSQL_OPEN_IGNORE_FLUSH sql/sql_table.cc: Remove an unused parameter. sql/sql_update.cc: Remove the need_reopen loop from multi-update. We no also longer need to cleanup the parse tree in case when mysql_lock_tables() is aborted and thus an infinite source of multi-update bugs is gone. sql/tztime.cc: Rename MYSQL_LOCK_IGNORE_FLUSH to MYSQL_OPEN_IGNORE_FLUSH, since from now on this flag is only supported by open_table().
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc34
1 files changed, 6 insertions, 28 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 26fb4e4e4e4..7423dd9d292 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2396,7 +2396,8 @@ void kill_delayed_threads(void)
bool Delayed_insert::open_and_lock_table()
{
if (!(table= open_n_lock_single_table(&thd, &table_list,
- TL_WRITE_DELAYED, 0)))
+ TL_WRITE_DELAYED,
+ MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK)))
{
thd.fatal_error(); // Abort waiting inserts
return TRUE;
@@ -2557,7 +2558,6 @@ pthread_handler_t handle_delayed_insert(void *arg)
if (di->tables_in_use && ! thd->lock && !thd->killed)
{
- bool need_reopen;
/*
Request for new delayed insert.
Lock the table, but avoid to be blocked by a global read lock.
@@ -2568,30 +2568,10 @@ pthread_handler_t handle_delayed_insert(void *arg)
handler will close the table and finish when the outstanding
inserts are done.
*/
- if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1,
- MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK,
- &need_reopen)))
+ if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, 0)))
{
- if (need_reopen && !thd->killed)
- {
- /*
- We were waiting to obtain TL_WRITE_DELAYED (probably due to
- someone having or requesting TL_WRITE_ALLOW_READ) and got
- aborted. Try to reopen table and if it fails die.
- */
- TABLE_LIST *tl_ptr = &di->table_list;
- close_tables_for_reopen(thd, &tl_ptr, NULL);
- di->table= 0;
- if (di->open_and_lock_table())
- {
- thd->killed= THD::KILL_CONNECTION;
- }
- }
- else
- {
- /* Fatal error */
- thd->killed= THD::KILL_CONNECTION;
- }
+ /* Fatal error */
+ thd->killed= THD::KILL_CONNECTION;
}
mysql_cond_broadcast(&di->cond_client);
}
@@ -3542,7 +3522,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
List_iterator_fast<Item> it(*items);
Item *item;
Field *tmp_field;
- bool not_used;
DBUG_ENTER("create_table_from_items");
tmp_table.alias= 0;
@@ -3666,8 +3645,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
since it won't wait for the table lock (we have exclusive metadata lock on
the table) and thus can't get aborted.
*/
- if (! ((*lock)= mysql_lock_tables(thd, &table, 1,
- MYSQL_LOCK_IGNORE_FLUSH, &not_used)) ||
+ if (! ((*lock)= mysql_lock_tables(thd, &table, 1, 0)) ||
hooks->postlock(&table, 1))
{
if (*lock)