Commit 98758b52 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-20068 History partition rotation is not done under LOCK TABLES

Wrong value F_WRLCK for thr_lock_type.
parent cdbac54d
......@@ -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;
......@@ -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;
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment