diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-05-27 17:40:54 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2010-05-27 17:40:54 -0300 |
commit | 2d3e5019d451d5f6b88b3dfd549e88ba3e5dce92 (patch) | |
tree | 4e6ea173d93497d194e0298b20fc4abb785faee8 /sql/sql_truncate.cc | |
parent | 303fe45abf087f2ff68bb9db81af26151ed4ae7b (diff) | |
download | mariadb-git-2d3e5019d451d5f6b88b3dfd549e88ba3e5dce92.tar.gz |
Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
Post-merge fix: Retrieve handler statistics to workaround quirks
of the archive storage engine.
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r-- | sql/sql_truncate.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 47a98769d57..8fc04588aaa 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -52,6 +52,22 @@ delete_all_rows(THD *thd, TABLE *table) thd->clear_current_stmt_binlog_format_row(); /* + Update handler statistics (e.g. table->file->stats.records). + Might be used by the storage engine to aggregate information + necessary to allow deletion. Currently, this seems to be + meaningful only to the archive storage engine, which uses + the info method to set the number of records. Although + archive does not support deletion, it becomes necessary in + order to return a error if the table is not empty. + */ + error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); + if (error && error != HA_ERR_WRONG_COMMAND) + { + table->file->print_error(error, MYF(0)); + goto end; + } + + /* Attempt to delete all rows in the table. If it is unsupported, switch to row by row deletion. */ @@ -455,6 +471,11 @@ bool mysql_truncate_table(THD *thd, TABLE_LIST *table_ref) trans_rollback(thd); } + /* + A locked table ticket was upgraded to a exclusive lock. After the + the query has been written to the binary log, downgrade the lock + to a shared one. + */ if (mdl_ticket) mdl_ticket->downgrade_exclusive_lock(MDL_SHARED_NO_READ_WRITE); |