From 53643152296f007eb698d44f067016889b4d8470 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 30 Jul 2014 13:27:52 +0300 Subject: Fix for MDEV-6493: Assertion `table->file->stats.records > 0 || error' failure, or 'Invalid write' valgrind warnings, or crash on scenario with Aria table, view, LOCK TABLES This bug only happens in case of paritioned tables used in LOCK TABLES and implicit_commit() was called (as part of trying to execute a CREATE TABLE withing lock tables) The problem was that Aria could not move the tables from one transaction to the new one, as thd->open_tables contained a partitioned tables and not an Aria table. Fix: - Store a list of all open tables that are part of a share in share->open_tables - In maria::implict_commit() use transaction->used_tables & share->open_tables to find out which tables was part of the current transaction instead of using thd->open_tables, which may contain partitioned tables. mysql-test/suite/maria/maria_partition.result: Added test case mysql-test/suite/maria/maria_partition.test: Added test case storage/maria/ha_maria.cc: Use trn->used tables and share->open_tables to find out which tables was part of the current transaction instead of using thd->open_tables. storage/maria/ma_close.c: Remove closed table from share->open_list storage/maria/ma_open.c: Add table to share->open_list storage/maria/ma_state.c: Added comment storage/maria/maria_def.h: Added share->open_list, a list of all tables that is using this share. --- storage/maria/ma_close.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'storage/maria/ma_close.c') diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index c355f1f1def..547c4445177 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -75,7 +75,8 @@ int maria_close(register MARIA_HA *info) info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); } flag= !--share->reopen; - maria_open_list=list_delete(maria_open_list,&info->open_list); + maria_open_list= list_delete(maria_open_list, &info->open_list); + share->open_list= list_delete(share->open_list, &info->share_list); my_free(info->rec_buff); (*share->end)(info); @@ -86,6 +87,7 @@ int maria_close(register MARIA_HA *info) /* Check that we don't have any dangling pointers from the transaction */ DBUG_ASSERT(share->in_trans == 0); + DBUG_ASSERT(share->open_list == 0); if (share->kfile.file >= 0) { -- cgit v1.2.1