diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2019-07-16 19:40:38 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2019-08-11 12:32:08 +0300 |
commit | 98758b52b3a3b0ede3cb8f93bcada5e5af51254b (patch) | |
tree | f5f839c1099927689b2136da520a14eef844cce4 | |
parent | cdbac54df0bd857a053decd66b6067abf15a6801 (diff) | |
download | mariadb-git-98758b52b3a3b0ede3cb8f93bcada5e5af51254b.tar.gz |
MDEV-20068 History partition rotation is not done under LOCK TABLES
Wrong value F_WRLCK for thr_lock_type.
-rw-r--r-- | mysql-test/suite/versioning/r/partition.result | 12 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/partition.test | 11 | ||||
-rw-r--r-- | sql/ha_partition.cc | 17 |
3 files changed, 38 insertions, 2 deletions
diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index 588e6432c4a..da851791640 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -557,6 +557,18 @@ insert into t1 values (1), (2); explain select max(pk) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +# +# MDEV-20068 History partition rotation is not done under LOCK TABLES +# +create or replace table t1 (x int) with system versioning partition by system_time limit 1 +(partition p1 history, partition pn current); +lock tables t1 write; +insert into t1 values (0), (1), (2), (3); +delete from t1 where x < 3; +delete from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions +unlock tables; # 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 29e4c413f77..f602c49d7c1 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -518,6 +518,17 @@ explain select max(pk) from t1; set default_storage_engine= @saved_storage_engine; --enable_query_log +--echo # +--echo # MDEV-20068 History partition rotation is not done under LOCK TABLES +--echo # +create or replace table t1 (x int) with system versioning partition by system_time limit 1 +(partition p1 history, partition pn current); +lock tables t1 write; +insert into t1 values (0), (1), (2), (3); +delete from t1 where x < 3; +delete from t1; +unlock tables; + --echo # Test cleanup drop database test; create database test; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ce0f430147a..125669a403d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4093,8 +4093,21 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type) /* Add partition to be called in reset(). */ bitmap_set_bit(&m_partitions_to_reset, i); } - if (lock_type == F_WRLCK && m_part_info->part_expr) - m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0); + switch (lock_type) + { + case TL_WRITE_ALLOW_WRITE: + case TL_WRITE_CONCURRENT_INSERT: + case TL_WRITE_DELAYED: + case TL_WRITE_DEFAULT: + case TL_WRITE_LOW_PRIORITY: + case TL_WRITE: + case TL_WRITE_ONLY: + if (m_part_info->part_expr) + m_part_info->part_expr->walk(&Item::register_field_in_read_map, 1, 0); + if (m_part_info->part_type == VERSIONING_PARTITION) + m_part_info->vers_set_hist_part(thd); + default:; + } DBUG_RETURN(error); } |