summaryrefslogtreecommitdiff
path: root/sql/temporary_tables.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-03-10 18:55:35 +0100
committerSergei Golubchik <serg@mariadb.org>2019-03-12 09:51:42 +0100
commit69abd43703fcf68c4cf1056bf5bd56c690de5b4e (patch)
tree5a573a0a3c1105e7b96cebbf4a3fe130df36eaa8 /sql/temporary_tables.cc
parent7025a51a7b85376b2f01b1f32e737278e9aa659b (diff)
downloadmariadb-git-69abd43703fcf68c4cf1056bf5bd56c690de5b4e.tar.gz
MDEV-17070 Table corruption or Assertion `table->file->stats.records > 0 || error' or Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon actions on temporary table
This was caused by a combination of factors: * MyISAM/Aria temporary tables historically never saved the state to disk (MYI/MAI), because the state never needed to persist * certain ALTER TABLE operations modify the original TABLE structure and if they fail, the original table has to be reopened to revert all changes (m_needs_reopen=1) as a result, when ALTER fails and MyISAM/Aria temp table gets reopened, it reads the stale state from the disk. As a fix, MyISAM/Aria tables now *always* write the state to disk on close, *unless* HA_EXTRA_PREPARE_FOR_DROP was done first. And the server now always does HA_EXTRA_PREPARE_FOR_DROP before dropping a temporary table.
Diffstat (limited to 'sql/temporary_tables.cc')
-rw-r--r--sql/temporary_tables.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 29c9910f332..ed23dae06d2 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -491,6 +491,7 @@ bool THD::close_temporary_tables()
/* Traverse the table list. */
while ((table= share->all_tmp_tables.pop_front()))
{
+ table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
free_temporary_table(table);
}
}
@@ -579,9 +580,7 @@ bool THD::rename_temporary_table(TABLE *table,
@return false Table was dropped
true Error
*/
-bool THD::drop_temporary_table(TABLE *table,
- bool *is_trans,
- bool delete_table)
+bool THD::drop_temporary_table(TABLE *table, bool *is_trans, bool delete_table)
{
DBUG_ENTER("THD::drop_temporary_table");
@@ -624,7 +623,8 @@ bool THD::drop_temporary_table(TABLE *table,
parallel replication
*/
tab->in_use= this;
-
+ if (delete_table)
+ tab->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
free_temporary_table(tab);
}
@@ -1419,8 +1419,7 @@ bool THD::log_events_and_free_tmp_shares()
@return void
*/
-void THD::free_tmp_table_share(TMP_TABLE_SHARE *share,
- bool delete_table)
+void THD::free_tmp_table_share(TMP_TABLE_SHARE *share, bool delete_table)
{
DBUG_ENTER("THD::free_tmp_table_share");