d406a9c9c0e3dfebc3305802de0d4da4e871a69c mysql-5.7.20/mysql-test/r/partition_innodb.result | 25 +++++++++++++- mysql-5.7.20/mysql-test/t/partition_innodb.test | 38 +++++++++++++++++++++- mysql-5.7.20/sql/partitioning/partition_handler.cc | 20 +++++++----- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/mysql-5.7.20/mysql-test/r/partition_innodb.result b/mysql-5.7.20/mysql-test/r/partition_innodb.result index 4ba70ee..2a29b40 100644 --- a/mysql-5.7.20/mysql-test/r/partition_innodb.result +++ b/mysql-5.7.20/mysql-test/r/partition_innodb.result @@ -1264,4 +1264,27 @@ partition_id=1; begin; update test12 set grade=0,date=now() where age=20 and partition_id=1; -drop table test12; \ No newline at end of file +drop table test12; + +Bug #87253 INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK + + +CREATE TABLE `t2` ( +`id` int(11) NOT NULL, +`dt` datetime NOT NULL, +`data` varchar(10) DEFAULT NULL, +PRIMARY KEY (`id`,`dt`), +KEY `idx_dt` (`dt`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (to_days(dt)) +(PARTITION p20170218 VALUES LESS THAN (736744) ENGINE = InnoDB, +PARTITION p20170219 VALUES LESS THAN (736745) ENGINE = InnoDB, +PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */; +insert into t2 values (1, now(), '1'); +insert into t2 values (2, now(), '2'); +insert into t2 values (3, now(), '3'); +begin; +update t2 set data = '12' where id = 1; +begin; +update t2 set data = '21' where id = 2; +drop table t2; diff --git a/mysql-5.7.20/mysql-test/t/partition_innodb.test b/mysql-5.7.20/mysql-test/t/partition_innodb.test index 1a322e3..1367750 100644 --- a/mysql-5.7.20/mysql-test/t/partition_innodb.test +++ b/mysql-5.7.20/mysql-test/t/partition_innodb.test @@ -1244,4 +1244,40 @@ partition_id=1; --disconnect con2 --connection default -drop table test12; \ No newline at end of file +drop table test12; + + +--echo +--echo Bug #87253 INNODB PARTITION TABLE HAS UNEXPECTED ROW LOCK +--echo +--echo + +--connect (con1,localhost,root,,) + +--connection default + +CREATE TABLE `t2` ( + `id` int(11) NOT NULL, + `dt` datetime NOT NULL, + `data` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`,`dt`), + KEY `idx_dt` (`dt`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (to_days(dt)) +(PARTITION p20170218 VALUES LESS THAN (736744) ENGINE = InnoDB, + PARTITION p20170219 VALUES LESS THAN (736745) ENGINE = InnoDB, + PARTITION pMax VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */; + +insert into t2 values (1, now(), '1'); +insert into t2 values (2, now(), '2'); +insert into t2 values (3, now(), '3'); + +begin;update t2 set data = '12' where id = 1; + +--connection con1 +begin;update t2 set data = '21' where id = 2; + +--disconnect con1 + +--connection default +drop table t2; \ No newline at end of file diff --git a/mysql-5.7.20/sql/partitioning/partition_handler.cc b/mysql-5.7.20/sql/partitioning/partition_handler.cc index 2c2f0e7..117e9c3 100644 --- a/mysql-5.7.20/sql/partitioning/partition_handler.cc +++ b/mysql-5.7.20/sql/partitioning/partition_handler.cc @@ -3523,20 +3523,24 @@ int Partition_helper::handle_ordered_next(uchar *buf, bool is_next_same) else read_buf= rec_buf; - - if (m_index_scan_type == PARTITION_READ_RANGE) + if (is_next_same) + { + error= index_next_same_in_part(part_id, + read_buf, + m_start_key.key, + m_start_key.length); + } + else if (m_index_scan_type == PARTITION_READ_RANGE) { error= read_range_next_in_part(part_id, read_buf == m_table->record[0] ? NULL : read_buf); } - else if (!is_next_same) - error= index_next_in_part(part_id, read_buf); else - error= index_next_same_in_part(part_id, - read_buf, - m_start_key.key, - m_start_key.length); + { + error= index_next_in_part(part_id, read_buf); + } + if (error) { if (error == HA_ERR_END_OF_FILE)