summaryrefslogtreecommitdiff
path: root/mysql-test/r/insert_update.result
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-05-08 00:24:25 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-05-08 00:24:25 +0500
commit35659a285d3bf1c18798cd2819c18d3d6fca8e55 (patch)
tree87b2e5da90d760cfa0520e274d66d96828f5bef1 /mysql-test/r/insert_update.result
parent5352b41d29bf3a0ca37d64acfa61527a4944812d (diff)
downloadmariadb-git-35659a285d3bf1c18798cd2819c18d3d6fca8e55.tar.gz
Fixed bug #27954.
This bug affects multi-row INSERT ... ON DUPLICATE into table with PRIMARY KEY of AUTO_INCREMENT field and some additional UNIQUE indices. If the first row in multi-row INSERT contains duplicated values of UNIQUE indices, then following rows of multi-row INSERT (with either duplicated or unique key field values) may me applied to _arbitrary_ records of table as updates. This bug was introduced in 5.0. Related code was widely rewritten in 5.1, and 5.1 is already free of this problem. 4.1 was not affected too. When updating the row during INSERT ON DUPLICATE KEY UPDATE, we called restore_auto_increment(), which set next_insert_id back to 0, but we forgot to set clear_next_insert_id back to 0. restore_auto_increment() function has been fixed. sql/sql_class.h: Fixed bug #27954. Added commentary for THD::clear_next_insert_id variable. sql/handler.cc: Fixed bug #27954. When updating the row during INSERT ON DUPLICATE KEY UPDATE, we called restore_auto_increment(), which set next_insert_id back to 0, but we forgot to set clear_next_insert_id back to 0. restore_auto_increment() function has been fixed. mysql-test/t/insert_update.test: Added test case for bug #27954. mysql-test/r/insert_update.result: Added test case for bug #27954.
Diffstat (limited to 'mysql-test/r/insert_update.result')
-rw-r--r--mysql-test/r/insert_update.result22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index fd70fcb9084..4a3e87d9d48 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -336,3 +336,25 @@ id f1
0 test1
DROP TABLE t1;
SET SQL_MODE='';
+CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+c1 CHAR(1) UNIQUE KEY,
+cnt INT DEFAULT 1
+);
+INSERT INTO t1 (c1) VALUES ('A'), ('B'), ('C');
+SELECT * FROM t1;
+id c1 cnt
+1 A 1
+2 B 1
+3 C 1
+INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
+ON DUPLICATE KEY UPDATE cnt=cnt+1;
+SELECT * FROM t1;
+id c1 cnt
+1 A 2
+2 B 1
+3 C 1
+4 X 1
+5 Y 1
+6 Z 1
+DROP TABLE t1;