summaryrefslogtreecommitdiff
path: root/mysql-test/t/insert_update.test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-06-12 01:41:23 +0400
committerunknown <evgen@moonbone.local>2007-06-12 01:41:23 +0400
commitccf393b67a9bcf52db91806f49c940ccd08545cc (patch)
treed6397e6bc275da4f6312afe4726409c25b52ca8d /mysql-test/t/insert_update.test
parent59d139eb293e1bcf72cf544e2b8dbe9216ee7acb (diff)
downloadmariadb-git-ccf393b67a9bcf52db91806f49c940ccd08545cc.tar.gz
Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't.
When the INSERT .. ON DUPLICATE KEY UPDATE has to update a matched row but the new data is the same as in the record then it returns as if no rows were inserted or updated. Nevertheless the row is silently updated. This leads to a situation when zero updated rows are reported in the case when data has actually been changed. Now the write_record function updates a row only if new data differs from that in the record. sql/sql_insert.cc: Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. Now the write_record function updates a row only if new data differs from that in the record. mysql-test/r/insert_update.result: Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't. mysql-test/t/insert_update.test: Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't.
Diffstat (limited to 'mysql-test/t/insert_update.test')
-rw-r--r--mysql-test/t/insert_update.test16
1 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index 725fbdb25d7..67108744ec6 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -290,3 +290,19 @@ INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it
+# shouldn't.
+#
+create table t1(f1 int primary key,
+ f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP);
+insert into t1(f1) values(1);
+--replace_column 1 #
+select @stamp1:=f2 from t1;
+--sleep 2
+insert into t1(f1) values(1) on duplicate key update f1=1;
+--replace_column 1 #
+select @stamp2:=f2 from t1;
+select if( @stamp1 = @stamp2, "correct", "wrong");
+drop table t1;