summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2005-08-09 22:05:07 +0400
committerevgen@moonbone.local <>2005-08-09 22:05:07 +0400
commit2a025ffbebfbe7ee9cdf90ba5a1a317818c32fdb (patch)
treea1efb99bb6b73a6b8c883fc13864a3b8630767f3
parent083da3ecee010fc0deae65aba6d61da8cf8433d9 (diff)
downloadmariadb-git-2a025ffbebfbe7ee9cdf90ba5a1a317818c32fdb.tar.gz
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.
-rw-r--r--mysql-test/r/innodb.result8
-rw-r--r--mysql-test/t/innodb.test10
-rw-r--r--sql/ha_innodb.cc4
3 files changed, 20 insertions, 2 deletions
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 2bdec5125dd..e0b477ab543 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -2475,3 +2475,11 @@ SELECT GRADE FROM t1 WHERE GRADE= 151;
GRADE
151
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;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 05f47f36e42..0ec7faa8ade 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1394,3 +1394,13 @@ SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
SELECT GRADE FROM t1 WHERE GRADE= 151;
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;
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index d98222975c5..026bc0da13d 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -6852,8 +6852,8 @@ ha_innobase::cmp_ref(
return(result);
}
- ref1 += key_part->length;
- ref2 += key_part->length;
+ ref1 += key_part->store_length;
+ ref2 += key_part->store_length;
}
return(0);