Commit 2442a81e authored by Eugene Kosov's avatar Eugene Kosov Committed by Aleksey Midenkov

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

Closes #204
parent ac5eb977
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
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