Commit 5dd2b9a3 authored by unknown's avatar unknown

Fix bug #12340 Wrong comparison in ha_innobase::cmp_ref()

When PRIMARY KEY is present ha_innobase::cmp_ref() uses it to compare refs.
After comparing part of key it moves pointers to compare next part.
For varchar parts pointers were moved only by length of parts, not including
bytes containig part length itself. This results in wrong comparision and
wrong number of deleted records.



sql/ha_innodb.cc:
  Fix bug #12340  ha_innobase::cmp_ref() moves pointers by wrong length.
mysql-test/t/innodb.test:
  Test case for bug #12340 ha_innobase::cmp_ref() moves pointers by wrong length.
mysql-test/r/innodb.result:
  Test case for bug #12340 ha_innobase::cmp_ref() moves pointers by wrong length.
parent 8a88fd69
...@@ -2475,3 +2475,11 @@ SELECT GRADE FROM t1 WHERE GRADE= 151; ...@@ -2475,3 +2475,11 @@ SELECT GRADE FROM t1 WHERE GRADE= 151;
GRADE GRADE
151 151
DROP TABLE t1; DROP TABLE t1;
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
insert into t2 values ('aa','cc');
insert into t1 values ('aa','bb'),('aa','cc');
delete t1 from t1,t2 where f1=f3 and f4='cc';
select * from t1;
f1 f2
drop table t1,t2;
...@@ -1394,3 +1394,13 @@ SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; ...@@ -1394,3 +1394,13 @@ SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
SELECT GRADE FROM t1 WHERE GRADE= 151; SELECT GRADE FROM t1 WHERE GRADE= 151;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #12340 multitable delete deletes only one record
#
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
insert into t2 values ('aa','cc');
insert into t1 values ('aa','bb'),('aa','cc');
delete t1 from t1,t2 where f1=f3 and f4='cc';
select * from t1;
drop table t1,t2;
...@@ -6852,8 +6852,8 @@ ha_innobase::cmp_ref( ...@@ -6852,8 +6852,8 @@ ha_innobase::cmp_ref(
return(result); return(result);
} }
ref1 += key_part->length; ref1 += key_part->store_length;
ref2 += key_part->length; ref2 += key_part->store_length;
} }
return(0); return(0);
......
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