Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-04 19:30:39+05:00, gshchepa@stripped +3 -0
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 free of this problem. 4.1 was not affected too.
The value of last updated record AUTO_INCREMENT field was used to calculate
next_insert_id (even if it was insertion of NULL into that field).
handler::adjust_next_insert_id_after_explicit_value() function is fixed.
mysql-test/r/insert_update.result@stripped, 2007-05-04 18:23:10+05:00, gshchepa@stripped +22
-0
Added test case for bug #27954.
mysql-test/t/insert_update.test@stripped, 2007-05-04 18:22:51+05:00, gshchepa@stripped +17
-0
Added test case for bug #27954.
sql/handler.cc@stripped, 2007-05-04 19:19:51+05:00, gshchepa@stripped +2 -1
Fixed bug #27954.
The value of last updated record AUTO_INCREMENT field was used to calculate
next_insert_id (even if it was insertion of NULL into that field).
handler::adjust_next_insert_id_after_explicit_value() function is fixed.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gshchepa
# Host: gleb.loc
# Root: /home/uchum/work/bk/mysql-5.0-opt-27954
--- 1.232/sql/handler.cc 2007-04-12 14:46:06 +05:00
+++ 1.233/sql/handler.cc 2007-05-04 19:19:51 +05:00
@@ -1486,7 +1486,8 @@ void handler::adjust_next_insert_id_afte
THD::next_insert_id to be greater than the explicit value.
*/
THD *thd= table->in_use;
- if (thd->clear_next_insert_id && (nr >= thd->next_insert_id))
+ if ((thd->next_insert_id > 0) &&
+ thd->clear_next_insert_id && (nr >= thd->next_insert_id))
{
if (thd->variables.auto_increment_increment != 1)
nr= next_insert_id(nr, &thd->variables);
--- 1.24/mysql-test/r/insert_update.result 2007-03-30 19:11:59 +05:00
+++ 1.25/mysql-test/r/insert_update.result 2007-05-04 18:23:10 +05:00
@@ -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;
--- 1.24/mysql-test/t/insert_update.test 2007-03-30 19:12:01 +05:00
+++ 1.25/mysql-test/t/insert_update.test 2007-05-04 18:22:51 +05:00
@@ -247,3 +247,20 @@ REPLACE INTO t1 VALUES (0,"test1",null);
SELECT id, f1 FROM t1;
DROP TABLE t1;
SET SQL_MODE='';
+
+#
+# Bug#27954: multi-row INSERT ... ON DUPLICATE with duplicated
+# row at the first place into table with AUTO_INCREMENT and
+# additional UNIQUE key.
+#
+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;
+INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z')
+ ON DUPLICATE KEY UPDATE cnt=cnt+1;
+SELECT * FROM t1;
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (gshchepa:1.2469) BUG#27954 | gshchepa | 4 May |