From d1e4c5d13e581eedfb817cbd61c900facd3f25ce Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Wed, 27 Dec 2017 15:25:40 +0300 Subject: [PATCH] MDEV-14748 Assertion in ha_myisammrg::attach_children() [fixes #434] --- .../suite/versioning/r/partition.result | 21 +++++++++++++----- mysql-test/suite/versioning/t/partition.test | 22 ++++++++++++++----- sql/partition_info.cc | 4 ++++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index ae83b412646..8bf9bc79183 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -345,7 +345,7 @@ partition by system_time interval 1 day ( partition p1 history, partition pc current); create or replace table t2 (f int); -create trigger tr before insert on t2 +create or replace trigger tr before insert on t2 for each row select table_rows from information_schema.tables where table_name = 't1' into @a; insert into t2 values (1); @@ -355,7 +355,7 @@ partition by system_time interval 1 week ( partition p1 history, partition pn current); create or replace table t2 (f int); -create trigger tr before insert on t2 +create or replace trigger tr before insert on t2 for each row select count(*) from t1 into @a; insert into t2 values (1); # MDEV-14741 Assertion `(trx)->start_file == 0' failed in row_truncate_table_for_mysql() @@ -366,11 +366,22 @@ partition pn current); set autocommit= off; truncate table t1; set autocommit= on; -MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES +# MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES create or replace table t1 (x int) with system versioning; lock table t1 write; alter table t1 partition by system_time interval 1 week ( partition p1 history, partition pn current); -drop table t1; -drop table t2; +unlock tables; +# MDEV-14748 Assertion in ha_myisammrg::attach_children() +create or replace table t1 (x int) engine=myisam with system versioning +partition by system_time interval 1 month (partition p1 history, partition pn current); +create or replace table t2 (x int) engine=myisam; +create or replace table t3 (x int) engine=merge union=(t2); +create or replace table t4 (x int) engine=myisam; +create or replace trigger tr after insert on t4 for each row insert into t2 +( select x from t3 ) union ( select x from t1 ); +insert into t4 values (1); +# Test cleanup +drop database test; +create database test; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index fa99428badc..570b1f44d58 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -290,7 +290,7 @@ partition by system_time interval 1 day ( partition p1 history, partition pc current); create or replace table t2 (f int); -create trigger tr before insert on t2 +create or replace trigger tr before insert on t2 for each row select table_rows from information_schema.tables where table_name = 't1' into @a; insert into t2 values (1); @@ -301,7 +301,7 @@ partition by system_time interval 1 week ( partition p1 history, partition pn current); create or replace table t2 (f int); -create trigger tr before insert on t2 +create or replace trigger tr before insert on t2 for each row select count(*) from t1 into @a; insert into t2 values (1); @@ -314,14 +314,24 @@ set autocommit= off; truncate table t1; set autocommit= on; ---echo MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES +--echo # MDEV-14747 ALTER PARTITION BY SYSTEM_TIME after LOCK TABLES create or replace table t1 (x int) with system versioning; lock table t1 write; alter table t1 partition by system_time interval 1 week ( partition p1 history, partition pn current); +unlock tables; -drop table t1; -drop table t2; +--echo # MDEV-14748 Assertion in ha_myisammrg::attach_children() +create or replace table t1 (x int) engine=myisam with system versioning + partition by system_time interval 1 month (partition p1 history, partition pn current); +create or replace table t2 (x int) engine=myisam; +create or replace table t3 (x int) engine=merge union=(t2); +create or replace table t4 (x int) engine=myisam; +create or replace trigger tr after insert on t4 for each row insert into t2 + ( select x from t3 ) union ( select x from t1 ); +insert into t4 values (1); --- source suite/versioning/common_finish.inc +--echo # Test cleanup +drop database test; +create database test; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 72d98c89791..e1e83db7b31 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1038,6 +1038,7 @@ class Table_locker thr_lock_type saved_type; MYSQL_LOCK *saved_lock; enum_locked_tables_mode saved_mode; + TABLE_LIST **saved_query_tables_own_last; TABLE_LIST table_list; bool locked; @@ -1048,6 +1049,7 @@ public: saved_type(table.reginfo.lock_type), saved_lock(_thd->lock), saved_mode(_thd->locked_tables_mode), + saved_query_tables_own_last(_thd->lex->query_tables_own_last), table_list(_table, lock_type), locked(false) { @@ -1064,6 +1066,7 @@ public: } thd->lock= NULL; thd->locked_tables_mode= LTM_NONE; + thd->lex->query_tables_own_last= NULL; bool res= lock_tables(thd, &table_list, 1, 0); locked= !res; return res; @@ -1075,6 +1078,7 @@ public: table.reginfo.lock_type= saved_type; thd->lock= saved_lock; thd->locked_tables_mode= saved_mode; + thd->lex->query_tables_own_last= saved_query_tables_own_last; if (locked && !thd->in_sub_stmt) { ha_commit_trans(thd, false);