summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2017-06-20 11:37:12 +0300
committerAleksey Midenkov <midenok@gmail.com>2017-06-22 18:37:49 +0300
commit2442a81eff012416883d401425e356f0c6e8afdd (patch)
tree6960e5305c3eb6cb5865499a71da0e7a0cd7086e
parentac5eb9771e4c07dc0442a44d863da6dafdf127e0 (diff)
downloadmariadb-git-2442a81eff012416883d401425e356f0c6e8afdd.tar.gz
IB: read lock on partitioned table read [closes #200]
Closes #204
-rw-r--r--mysql-test/suite/versioning/r/partition.result14
-rw-r--r--mysql-test/suite/versioning/t/partition.test6
-rw-r--r--storage/innobase/handler/ha_innopart.cc7
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result
index 2f203ba68ec..b76f01a340e 100644
--- a/mysql-test/suite/versioning/r/partition.result
+++ b/mysql-test/suite/versioning/r/partition.result
@@ -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
diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test
index 6dc7f56923b..ca998757515 100644
--- a/mysql-test/suite/versioning/t/partition.test
+++ b/mysql-test/suite/versioning/t/partition.test
@@ -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;
diff --git a/storage/innobase/handler/ha_innopart.cc b/storage/innobase/handler/ha_innopart.cc
index 38af9e44de9..35c77d1d5ec 100644
--- a/storage/innobase/handler/ha_innopart.cc
+++ b/storage/innobase/handler/ha_innopart.cc
@@ -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;