From 2de9fc6eacc9a17077b595cc03a1cfa5d23ed9c8 Mon Sep 17 00:00:00 2001
From: marko <Unknown>
Date: Mon, 5 Mar 2007 15:43:58 +0000
Subject: [PATCH] innodb.test, innodb.result: Add test case for Bug #26835. The
 bug could be reproduced as follows:

Define a table so that the first column of the clustered index is
a VARCHAR or a UTF-8 CHAR in a collation where sequences of bytes
of differing length are considered equivalent.

Insert and delete a record.  Before the delete-marked record is
purged, insert another record whose first column is of different
length but equivalent to the first record.  Under certain conditions,
the insertion can be incorrectly performed as update-in-place.

Likewise, an operation that could be done as update-in-place can
unnecessarily be performed as delete and insert, but that would not
cause corruption but merely degraded performance.
---
 mysql-test/innodb.result |  9 +++++++++
 mysql-test/innodb.test   | 12 ++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/mysql-test/innodb.result b/mysql-test/innodb.result
index c23415520f..c4e06c7de6 100644
--- a/mysql-test/innodb.result
+++ b/mysql-test/innodb.result
@@ -3480,3 +3480,12 @@ ALTER TABLE t2 MODIFY a INT NOT NULL;
 ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
 DELETE FROM t1;
 DROP TABLE t2,t1;
+CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
+DELETE FROM t1;
+INSERT INTO t1 VALUES ('DDD');
+SELECT * FROM t1;
+a
+DDD
+DROP TABLE t1;
diff --git a/mysql-test/innodb.test b/mysql-test/innodb.test
index 32ccebb52e..ae4e3596db 100644
--- a/mysql-test/innodb.test
+++ b/mysql-test/innodb.test
@@ -2530,6 +2530,18 @@ ALTER TABLE t2 MODIFY a INT NOT NULL;
 DELETE FROM t1;
 DROP TABLE t2,t1;
 
+#
+# Bug #26835: table corruption after delete+insert
+#
+
+CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
+DELETE FROM t1;
+INSERT INTO t1 VALUES ('DDD');
+SELECT * FROM t1;
+DROP TABLE t1;
+
 #######################################################################
 #                                                                     #
 # Please, DO NOT TOUCH this file as well as the innodb.result file.   #
-- 
2.30.9