Commit 669258ab authored by Konstantin Osipov's avatar Konstantin Osipov

Backport of:

----------------------------------------------------------
revno: 2630.4.36
committer: Konstantin Osipov <konstantin@mysql.com>
branch nick: mysql-6.0-3726
timestamp: Wed 2008-06-25 17:03:37 +0400
message:
  As per discussion with Serg and Dmitri, remove the code
  that is trying to emulate LOCK TABLES when locking tables for prelocking.
  This code was worked around by the engines, and has no effect.
  We may still have to do something to ensure that statement-based
  replication is consistent in MVCC engines, or other engines
  that downgrade table level locks, but this will have to be done
  somehow differently.
parent 416a6263
...@@ -1335,7 +1335,6 @@ void close_thread_tables(THD *thd, ...@@ -1335,7 +1335,6 @@ void close_thread_tables(THD *thd,
bool skip_mdl) bool skip_mdl)
{ {
TABLE *table; TABLE *table;
bool clear_table_lock_option= FALSE;
DBUG_ENTER("close_thread_tables"); DBUG_ENTER("close_thread_tables");
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
...@@ -1428,7 +1427,6 @@ void close_thread_tables(THD *thd, ...@@ -1428,7 +1427,6 @@ void close_thread_tables(THD *thd,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
thd->locked_tables_mode= LTM_NONE; thd->locked_tables_mode= LTM_NONE;
clear_table_lock_option= TRUE;
/* /*
Note that we are leaving prelocked mode so we don't need Note that we are leaving prelocked mode so we don't need
...@@ -1467,10 +1465,6 @@ void close_thread_tables(THD *thd, ...@@ -1467,10 +1465,6 @@ void close_thread_tables(THD *thd,
{ {
mdl_remove_all_locks(&thd->mdl_context); mdl_remove_all_locks(&thd->mdl_context);
} }
if (clear_table_lock_option)
thd->options&= ~OPTION_TABLE_LOCK;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -4842,8 +4836,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, ...@@ -4842,8 +4836,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count,
/* We have to emulate LOCK TABLES if we are statement needs prelocking. */ /* We have to emulate LOCK TABLES if we are statement needs prelocking. */
if (thd->lex->requires_prelocking()) if (thd->lex->requires_prelocking())
{ {
thd->in_lock_tables=1;
thd->options|= OPTION_TABLE_LOCK;
/* /*
A query that modifies autoinc column in sub-statement can make the A query that modifies autoinc column in sub-statement can make the
master and slave inconsistent. master and slave inconsistent.
...@@ -4863,14 +4855,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, ...@@ -4863,14 +4855,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count,
if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
flags, need_reopen))) flags, need_reopen)))
{
if (thd->lex->requires_prelocking())
{
thd->options&= ~(OPTION_TABLE_LOCK);
thd->in_lock_tables=0;
}
DBUG_RETURN(-1); DBUG_RETURN(-1);
}
if (thd->lex->requires_prelocking() && if (thd->lex->requires_prelocking() &&
thd->lex->sql_command != SQLCOM_LOCK_TABLES) thd->lex->sql_command != SQLCOM_LOCK_TABLES)
...@@ -4880,10 +4865,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, ...@@ -4880,10 +4865,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count,
We just have done implicit LOCK TABLES, and now we have We just have done implicit LOCK TABLES, and now we have
to emulate first open_and_lock_tables() after it. to emulate first open_and_lock_tables() after it.
*/
thd->in_lock_tables= 0;
/*
When open_and_lock_tables() is called for a single table out of When open_and_lock_tables() is called for a single table out of
a table list, the 'next_global' chain is temporarily broken. We a table list, the 'next_global' chain is temporarily broken. We
may not find 'first_not_own' before the end of the "list". may not find 'first_not_own' before the end of the "list".
...@@ -4906,7 +4887,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, ...@@ -4906,7 +4887,6 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count,
*/ */
mysql_unlock_tables(thd, thd->lock); mysql_unlock_tables(thd, thd->lock);
thd->lock= 0; thd->lock= 0;
thd->options&= ~(OPTION_TABLE_LOCK);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment