diff options
-rw-r--r-- | mysql-test/r/partition_explicit_prune.result | 19 | ||||
-rw-r--r-- | mysql-test/t/partition_explicit_prune.test | 19 | ||||
-rw-r--r-- | sql/ha_partition.cc | 9 |
3 files changed, 45 insertions, 2 deletions
diff --git a/mysql-test/r/partition_explicit_prune.result b/mysql-test/r/partition_explicit_prune.result index 3ca1e688e8f..c8ab243c34c 100644 --- a/mysql-test/r/partition_explicit_prune.result +++ b/mysql-test/r/partition_explicit_prune.result @@ -1870,3 +1870,22 @@ CREATE TABLE t2 LIKE t1 PARTITION (p0, p2); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PARTITION (p0, p2)' at line 1 DROP TABLE t1; SET @@default_storage_engine = @old_default_storage_engine; +# +# MDEV-14815 - Server crash or AddressSanitizer errors or valgrind warnings in thr_lock / has_old_lock upon FLUSH TABLES +# +CREATE TABLE t1 (i INT) ENGINE=MEMORY PARTITION BY RANGE (i) (PARTITION p0 VALUES LESS THAN (4), PARTITION pm VALUES LESS THAN MAXVALUE); +CREATE TABLE t2 (i INT) ENGINE=MEMORY; +LOCK TABLE t1 WRITE, t2 WRITE; +SELECT * FROM t1 PARTITION (p0); +i +FLUSH TABLES; +SELECT * FROM t1 PARTITION (p0); +i +ALTER TABLE t1 TRUNCATE PARTITION p0; +SELECT * FROM t1 PARTITION (p0); +i +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +SELECT * FROM t1 PARTITION (p0); +i +UNLOCK TABLES; +DROP TABLE t1, t2; diff --git a/mysql-test/t/partition_explicit_prune.test b/mysql-test/t/partition_explicit_prune.test index 68b829fbcc3..b8b6e480ce9 100644 --- a/mysql-test/t/partition_explicit_prune.test +++ b/mysql-test/t/partition_explicit_prune.test @@ -858,3 +858,22 @@ CREATE TABLE t2 LIKE t1 PARTITION (p0, p2); DROP TABLE t1; SET @@default_storage_engine = @old_default_storage_engine; + + +--echo # +--echo # MDEV-14815 - Server crash or AddressSanitizer errors or valgrind warnings in thr_lock / has_old_lock upon FLUSH TABLES +--echo # +CREATE TABLE t1 (i INT) ENGINE=MEMORY PARTITION BY RANGE (i) (PARTITION p0 VALUES LESS THAN (4), PARTITION pm VALUES LESS THAN MAXVALUE); +CREATE TABLE t2 (i INT) ENGINE=MEMORY; +LOCK TABLE t1 WRITE, t2 WRITE; +SELECT * FROM t1 PARTITION (p0); +FLUSH TABLES; +SELECT * FROM t1 PARTITION (p0); +ALTER TABLE t1 TRUNCATE PARTITION p0; +SELECT * FROM t1 PARTITION (p0); +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +SELECT * FROM t1 PARTITION (p0); +UNLOCK TABLES; + +# Cleanup +DROP TABLE t1, t2; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0488ebfb60f..02de92aa17f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3907,9 +3907,14 @@ THR_LOCK_DATA **ha_partition::store_lock(THD *thd, } else { - for (i= bitmap_get_first_set(&(m_part_info->lock_partitions)); + MY_BITMAP *used_partitions= lock_type == TL_UNLOCK || + lock_type == TL_IGNORE ? + &m_locked_partitions : + &m_part_info->lock_partitions; + + for (i= bitmap_get_first_set(used_partitions); i < m_tot_parts; - i= bitmap_get_next_set(&m_part_info->lock_partitions, i)) + i= bitmap_get_next_set(used_partitions, i)) { DBUG_PRINT("info", ("store lock %d iteration", i)); to= m_file[i]->store_lock(thd, to, lock_type); |