diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-06-20 11:34:24 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-06-20 15:47:44 +0200 |
commit | ce6a63ec41160ef6b7c0110d3f40aea79b8f3129 (patch) | |
tree | 4be27ef7152fd4f557bb09ad8943893f2d62ea1c /sql/sql_truncate.cc | |
parent | cc5b3998b6767523792f7e4ec8c9a100db2d06ce (diff) | |
download | mariadb-git-ce6a63ec41160ef6b7c0110d3f40aea79b8f3129.tar.gz |
MDEV-4260 Don't create frm files for temporary tables
* Don't write frm for tmp tables
* pass frm image down to open_table_uncached, when possible
* don't use truncate-by-recreate for temp tables - cannot recreate
without frm, and delete_all_rows is faster anyway
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r-- | sql/sql_truncate.cc | 68 |
1 files changed, 1 insertions, 67 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index fe2ea02a8e2..e98679b1d51 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -262,52 +262,6 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, /* - Close and recreate a temporary table. In case of success, - write truncate statement into the binary log if in statement - mode. - - @param thd Thread context. - @param table The temporary table. - - @retval FALSE Success. - @retval TRUE Error. -*/ - -static bool recreate_temporary_table(THD *thd, TABLE *table) -{ - bool error= TRUE; - TABLE_SHARE *share= table->s; - handlerton *table_type= table->s->db_type(); - TABLE *new_table; - DBUG_ENTER("recreate_temporary_table"); - - table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); - - /* Don't free share. */ - close_temporary_table(thd, table, FALSE, FALSE); - - dd_recreate_table(thd, share->db.str, share->table_name.str, - share->normalized_path.str); - - if ((new_table= open_table_uncached(thd, table_type, share->path.str, - share->db.str, - share->table_name.str, true, true))) - { - error= FALSE; - thd->thread_specific_used= TRUE; - new_table->s->table_creation_was_logged= share->table_creation_was_logged; - } - else - rm_temporary_table(table_type, share->path.str); - - free_table_share(share); - my_free(table); - - DBUG_RETURN(error); -} - - -/* Handle locking a base table for truncate. @param[in] thd Thread context. @@ -441,30 +395,10 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) /* If it is a temporary table, no need to take locks. */ if (is_temporary_table(table_ref)) { - TABLE *tmp_table= table_ref->table; - /* In RBR, the statement is not binlogged if the table is temporary. */ binlog_stmt= !thd->is_current_stmt_binlog_format_row(); - /* Note that a temporary table cannot be partitioned. */ - if (ha_check_storage_engine_flag(tmp_table->s->db_type(), - HTON_CAN_RECREATE)) - { - if ((error= recreate_temporary_table(thd, tmp_table))) - binlog_stmt= FALSE; /* No need to binlog failed truncate-by-recreate. */ - - DBUG_ASSERT(! thd->transaction.stmt.modified_non_trans_table); - } - else - { - /* - The engine does not support truncate-by-recreate. Open the - table and invoke the handler truncate. In such a manner this - can in fact open several tables if it's a temporary MyISAMMRG - table. - */ - error= handler_truncate(thd, table_ref, TRUE); - } + error= handler_truncate(thd, table_ref, TRUE); /* No need to invalidate the query cache, queries with temporary |