mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
merge with 4.0 to get last fixes to last merge
This commit is contained in:
@ -1303,7 +1303,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
thd->proc_info="init";
|
||||
table_name=table_list->real_name;
|
||||
db=table_list->db;
|
||||
if (!new_db)
|
||||
if (!new_db || !strcmp(new_db,db))
|
||||
new_db=db;
|
||||
used_fields=create_info->used_fields;
|
||||
|
||||
@ -1357,10 +1357,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
/* In some simple cases we need not to recreate the table */
|
||||
|
||||
thd->proc_info="setup";
|
||||
if (simple_alter)
|
||||
if (simple_alter && !table->tmp_table)
|
||||
{
|
||||
error=0;
|
||||
if (new_name != table_name)
|
||||
if (new_name != table_name || new_db != db)
|
||||
{
|
||||
thd->proc_info="rename";
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
@ -1383,15 +1383,15 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
}
|
||||
if (!error)
|
||||
{
|
||||
switch (keys_onoff)
|
||||
{
|
||||
case LEAVE_AS_IS: break;
|
||||
case ENABLE:
|
||||
error=table->file->activate_all_index(thd);
|
||||
break;
|
||||
case DISABLE:
|
||||
table->file->deactivate_non_unique_index(HA_POS_ERROR);
|
||||
break;
|
||||
switch (keys_onoff) {
|
||||
case LEAVE_AS_IS:
|
||||
break;
|
||||
case ENABLE:
|
||||
error=table->file->activate_all_index(thd);
|
||||
break;
|
||||
case DISABLE:
|
||||
table->file->deactivate_non_unique_index(HA_POS_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!error)
|
||||
@ -1797,7 +1797,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
thd->proc_info="rename result table";
|
||||
sprintf(old_name,"%s2-%lx-%lx", tmp_file_prefix, current_pid,
|
||||
thd->thread_id);
|
||||
if (new_name != table_name)
|
||||
if (new_name != table_name || new_db != db)
|
||||
{
|
||||
if (!access(new_name_buff,F_OK))
|
||||
{
|
||||
@ -1815,7 +1815,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
{
|
||||
/*
|
||||
Win32 and InnoDB can't drop a table that is in use, so we must
|
||||
close all the original table at before doing the rename
|
||||
close the original table at before doing the rename
|
||||
*/
|
||||
table_name=thd->strdup(table_name); // must be saved
|
||||
if (close_cached_table(thd,table))
|
||||
|
Reference in New Issue
Block a user