From 976f0a391c9d20982d495cd01ab6e8f701d915fd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Feb 2007 00:46:03 +0300 Subject: Bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. INSERT ... ON DUPLICATE KEY UPDATE reports that a record was updated when the duplicate key occurs even if the record wasn't actually changed because the update values are the same as those in the record. Now the compare_record() function is used to check whether the record was changed and the update of a record reported only if the record differs from the original one. sql/sql_update.cc: Bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. The compare_record() function was changed to non-static one. sql/sql_insert.cc: Bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. Now the compare_record() function is used to check whether the record was changed and the update of a record reported only if the record differs from the original one. sql/mysql_priv.h: Bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. Added the prototype of the compare_record() function. mysql-test/t/insert_select.test: Added a test case for bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. mysql-test/r/insert_select.result: Added a test case for bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were updated. --- mysql-test/t/insert_select.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mysql-test/t/insert_select.test') diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 404d67390ab..6302d5f1dae 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -265,4 +265,17 @@ INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1; DROP DATABASE bug21774_1; DROP DATABASE bug21774_2; +USE test; +# +# Bug#19978: INSERT .. ON DUPLICATE erroneously reports some records were +# updated. +# +create table t1(f1 int primary key, f2 int); +--enable_info +insert into t1 values (1,1); +insert into t1 values (1,1) on duplicate key update f2=1; +insert into t1 values (1,1) on duplicate key update f2=2; +--disable_info +select * from t1; +drop table t1; -- cgit v1.2.1 From dd6feec4f40e89ae7d830b0a15d009ea2e66759e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Feb 2007 22:25:09 +0300 Subject: Bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT when no rows were inserted. The select_insert::send_eof() function now resets LAST_INSERT_ID variable if no rows were inserted. mysql-test/t/insert_select.test: Added a test case for bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT when no rows were inserted. mysql-test/r/insert_select.result: Added a test case for bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT when no rows were inserted. sql/sql_insert.cc: Bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT when no rows were inserted.The select_insert::send_eof() function now resets LAST_INSERT_ID variable if no rows were inserted. --- mysql-test/t/insert_select.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mysql-test/t/insert_select.test') diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 6302d5f1dae..5c60fc8e1f0 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -279,3 +279,16 @@ insert into t1 values (1,1) on duplicate key update f2=2; --disable_info select * from t1; drop table t1; + +# +# Bug#23170: LAST_INSERT_ID isn't reset to 0 in INSERT .. SELECT if no rows +# were inserted. +# +create table t1(f1 int primary key auto_increment, f2 int unique); +insert into t1(f2) values(1); +select @@identity; +insert ignore t1(f2) values(1); +select @@identity; +insert ignore t1(f2) select 1; +select @@identity; +drop table t1; -- cgit v1.2.1