IB: read lock on partitioned table read [closes #200]

Closes #204
This commit is contained in:
Eugene Kosov 2017-06-20 11:37:12 +03:00 committed by Aleksey Midenkov
parent ac5eb9771e
commit 2442a81eff
3 changed files with 27 additions and 0 deletions

View file

@ -230,6 +230,20 @@ partition by system_time limit 1 (
partition p0 versioning,
partition p1 versioning,
partition pn as of now);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`x` int(11) DEFAULT NULL,
`sys_trx_start` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW START,
`sys_trx_end` ${SYS_TRX_TYPE} GENERATED ALWAYS AS ROW END,
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=${INNODB_OR_MYISAM} DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
PARTITION BY SYSTEM_TIME LIMIT 1
(PARTITION p0 VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION p1 VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION pn AS OF NOW ENGINE = ${INNODB_OR_MYISAM})
alter table t1 drop partition non_existent;
ERROR HY000: Error in list of partitions to DROP
insert into t1 values (1), (2);
select * from t1 partition (pn);
x

View file

@ -145,6 +145,12 @@ partition by system_time limit 1 (
partition p1 versioning,
partition pn as of now);
--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE}
show create table t1;
--error ER_DROP_PARTITION_NON_EXISTENT
alter table t1 drop partition non_existent;
insert into t1 values (1), (2);
select * from t1 partition (pn);
delete from t1;

View file

@ -3059,7 +3059,14 @@ ha_innopart::part_recs_slow(void *_part_elem)
{
DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), part_id));
set_partition(part_id);
bool read_lock_needed = get_lock_type() == F_UNLCK;
if (read_lock_needed)
ha_external_lock(ha_thd(), F_RDLCK);
ha_rows n = ha_innobase::records_new();
if (read_lock_needed) {
ha_external_lock(ha_thd(), F_UNLCK);
ha_commit_one_phase(ha_thd(), false);
}
update_partition(part_id);
if (n == HA_POS_ERROR) {
return HA_POS_ERROR;