summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-08-29 17:01:46 +0200
committerunknown <ingo@mysql.com>2005-08-29 17:01:46 +0200
commit6318e449e3e196d5e4ee0db73d63eac5ebd94195 (patch)
treee4d229201c8689829b922b13ecfa4646c36fa844 /sql/sql_delete.cc
parent0f7161b050d398971495bbe1b674684665162753 (diff)
downloadmariadb-git-6318e449e3e196d5e4ee0db73d63eac5ebd94195.tar.gz
Bug#11816 - Truncate table doesn't work with temporary innodb tables
Handle temporary tables like permanent tables: If the storage engine cannot truncate, delete instead. mysql-test/r/innodb.result: Bug#11816 - Truncate table doesn't work with temporary innodb tables The test result. mysql-test/t/innodb.test: Bug#11816 - Truncate table doesn't work with temporary innodb tables The test case. sql/sql_delete.cc: Bug#11816 - Truncate table doesn't work with temporary innodb tables Handle temporary tables like permanent tables: If the storage engine cannot truncate, delete instead. Replaced a numeric literal by its symbolic name.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 0752105bcae..7248adf6993 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -617,6 +617,8 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
TABLE *table= *table_ptr;
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
db_type table_type=table->db_type;
+ if (!ha_supports_generate(table_type))
+ goto trunc_by_del;
strmov(path,table->path);
*table_ptr= table->next; // Unlink table from list
close_temporary(table,0);
@@ -635,7 +637,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
(void) sprintf(path,"%s/%s/%s%s",mysql_data_home,table_list->db,
table_list->real_name,reg_ext);
- fn_format(path,path,"","",4);
+ fn_format(path, path, "", "", MY_UNPACK_FILENAME);
if (!dont_send_ok)
{
@@ -647,18 +649,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
DBUG_RETURN(-1);
}
if (!ha_supports_generate(table_type))
- {
- /* Probably InnoDB table */
- ulong save_options= thd->options;
- table_list->lock_type= TL_WRITE;
- thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
- ha_enable_transaction(thd, FALSE);
- error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
- HA_POS_ERROR, 0);
- ha_enable_transaction(thd, TRUE);
- thd->options= save_options;
- DBUG_RETURN(error);
- }
+ goto trunc_by_del;
if (lock_and_wait_for_table_name(thd, table_list))
DBUG_RETURN(-1);
}
@@ -693,4 +684,16 @@ end:
VOID(pthread_mutex_unlock(&LOCK_open));
}
DBUG_RETURN(error ? -1 : 0);
+
+ trunc_by_del:
+ /* Probably InnoDB table */
+ ulong save_options= thd->options;
+ table_list->lock_type= TL_WRITE;
+ thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT);
+ ha_enable_transaction(thd, FALSE);
+ error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
+ HA_POS_ERROR, 0);
+ ha_enable_transaction(thd, TRUE);
+ thd->options= save_options;
+ DBUG_RETURN(error);
}