From bb6d674df91c6e7f6ea8bb68c916593d02b16ab6 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 8 Aug 2019 20:13:10 +0300 Subject: [PATCH] Fixed assertion Assertion `!table->pos_in_locked_tables' failed MDEV-19591 Assertion `!table->pos_in_locked_tables' failed in tc_release_table upon altering table into S3 under lock. The problem was that thd->open_tables->pos_in_locked_tables was not reset when alter table failed to reopen a locked table. --- mysql-test/suite/s3/alter.result | 19 +++++++++++++++++++ mysql-test/suite/s3/alter.test | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/mysql-test/suite/s3/alter.result b/mysql-test/suite/s3/alter.result index f8faa5d4eee..0764d661468 100644 --- a/mysql-test/suite/s3/alter.result +++ b/mysql-test/suite/s3/alter.result @@ -89,6 +89,25 @@ count(*) sum(a) sum(b) sum(c) sum(d) 10 55 155 NULL NULL drop table t1; # +# Test ALTER TABLE with locked table for S3 +# +create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10; +lock table t1 write; +alter table t1 add column c int, engine=s3; +ERROR HY000: Table 't1' is read only +unlock tables; +select count(*), sum(a), sum(b), sum(c) from t1; +count(*) sum(a) sum(b) sum(c) +10 55 155 NULL +lock table t1 write; +ERROR HY000: Table 't1' is read only +lock table t1 read; +select count(*), sum(a), sum(b), sum(c) from t1; +count(*) sum(a) sum(b) sum(c) +10 55 155 NULL +unlock tables; +drop table t1; +# # Test RENAME TABLE # create table t1 (a int, b int) engine=aria select seq as a, seq+10 as b from seq_1_to_10; diff --git a/mysql-test/suite/s3/alter.test b/mysql-test/suite/s3/alter.test index b14eb2cb52a..791d7750cb1 100644 --- a/mysql-test/suite/s3/alter.test +++ b/mysql-test/suite/s3/alter.test @@ -59,6 +59,23 @@ show create table t1; select count(*), sum(a), sum(b), sum(c), sum(d) from t1; drop table t1; +--echo # +--echo # Test ALTER TABLE with locked table for S3 +--echo # + +create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10; +lock table t1 write; +--error ER_OPEN_AS_READONLY +alter table t1 add column c int, engine=s3; +unlock tables; +select count(*), sum(a), sum(b), sum(c) from t1; +--error ER_OPEN_AS_READONLY +lock table t1 write; +lock table t1 read; +select count(*), sum(a), sum(b), sum(c) from t1; +unlock tables; +drop table t1; + --echo # --echo # Test RENAME TABLE --echo #