summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2006-10-13 08:57:15 -0400
committerunknown <cmiller@zippy.cornsilk.net>2006-10-13 08:57:15 -0400
commitaff965c3b1a6564cdc448b9a1101d02f6050bf59 (patch)
treec9ceeb2739c4460d63cb38192bb4bd37e35b8dec /sql/sql_table.cc
parenta28a9c278638974ce0173eb5329f5946d209bd33 (diff)
parent25393e391be033a1f32b11f4ea1405f427930725 (diff)
downloadmariadb-git-aff965c3b1a6564cdc448b9a1101d02f6050bf59.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into zippy.cornsilk.net:/home/cmiller/work/mysql/bug14262/my50-bug14262 BitKeeper/deleted/.del-collapsed: 'Auto converge rename' BitKeeper/etc/collapsed: 'Auto converge' sql/sp.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_db.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_trigger.cc: Auto merged sql/sql_view.h: Auto merged vio/viosocket.c: Auto merged sql/sql_parse.cc: Manual merge sql/sql_view.cc: Manual merge
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1c5be098ae0..39e58e4f8e8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3173,6 +3173,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
/* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */
if (alter_info->tablespace_op != NO_TABLESPACE_OP)
+ /* Conditionally writes to binlog. */
DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list,
alter_info->tablespace_op));
if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
@@ -3254,10 +3255,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
!table->s->tmp_table) // no need to touch frm
{
error=0;
+ VOID(pthread_mutex_lock(&LOCK_open));
if (new_name != table_name || new_db != db)
{
thd->proc_info="rename";
- VOID(pthread_mutex_lock(&LOCK_open));
/* Then do a 'simple' rename of the table */
error=0;
if (!access(new_name_buff,F_OK))
@@ -3279,7 +3280,6 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
error= -1;
}
}
- VOID(pthread_mutex_unlock(&LOCK_open));
}
if (!error)
@@ -3288,16 +3288,12 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
case LEAVE_AS_IS:
break;
case ENABLE:
- VOID(pthread_mutex_lock(&LOCK_open));
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
- VOID(pthread_mutex_unlock(&LOCK_open));
error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
/* COND_refresh will be signaled in close_thread_tables() */
break;
case DISABLE:
- VOID(pthread_mutex_lock(&LOCK_open));
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
- VOID(pthread_mutex_unlock(&LOCK_open));
error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
/* COND_refresh will be signaled in close_thread_tables() */
break;
@@ -3327,6 +3323,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
table->file->print_error(error, MYF(0));
error= -1;
}
+ VOID(pthread_mutex_unlock(&LOCK_open));
table_list->table=0; // For query cache
query_cache_invalidate3(thd, table_list, 0);
DBUG_RETURN(error);
@@ -3773,6 +3770,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_free((gptr) new_table,MYF(0));
goto err;
}
+ /*
+ Writing to the binlog does not need to be synchronized for temporary tables,
+ which are thread-specific.
+ */
if (mysql_bin_log.is_open())
{
thd->clear_error();
@@ -3955,7 +3956,7 @@ end_temporary:
thd->some_tables_deleted=0;
DBUG_RETURN(FALSE);
- err:
+err:
DBUG_RETURN(TRUE);
}