From 69abd43703fcf68c4cf1056bf5bd56c690de5b4e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 10 Mar 2019 18:55:35 +0100 Subject: 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. --- storage/myisam/mi_extra.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'storage/myisam/mi_extra.c') diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 39b28d95759..dcb79a8dc3e 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -260,9 +260,11 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) break; case HA_EXTRA_PREPARE_FOR_DROP: /* Signals about intent to delete this table */ - //share->deleting= TRUE; + share->deleting= TRUE; share->global_changed= FALSE; /* force writing changed flag */ _mi_mark_file_changed(info); + if (share->temporary) + break; /* fall through */ case HA_EXTRA_PREPARE_FOR_RENAME: DBUG_ASSERT(!share->temporary); -- cgit v1.2.1