mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
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
This commit is contained in:
@ -261,52 +261,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.
|
||||
|
||||
@ -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
|
||||
|
Reference in New Issue
Block a user