summaryrefslogtreecommitdiff
path: root/mysql-test/r/insert_update.result
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-03-15 23:21:29 +0300
committerunknown <evgen@moonbone.local>2007-03-15 23:21:29 +0300
commit542f18a31ab261c0b36ffddf6372e8c1e3de4294 (patch)
tree7fa5760ca5855723a89f7a63d38ef6f33a6162cf /mysql-test/r/insert_update.result
parented80fe2dfb68b30c6f41b5e0beae1be4394e63cf (diff)
downloadmariadb-git-542f18a31ab261c0b36ffddf6372e8c1e3de4294.tar.gz
Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed. The LAST_INSERT_ID() is reset to 0 if no rows were inserted or changed. This is the case when an INSERT ... ON DUPLICATE KEY UPDATE updates a row with the same values as the row contains. Now the LAST_INSERT_ID() values is reset to 0 only if there were no rows successfully inserted or touched. The new 'touched' field is added to the COPY_INFO structure. It holds the number of rows that were touched no matter whether they were actually changed or not. sql/sql_class.h: Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were touched but not actually changed. The new 'touched' field is added to the COPY_INFO structure. It holds the number of rows that were touched no matter whether they were actually changed or not. mysql-test/r/insert_update.result: Added a test case for the bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were touched but not actually changed. mysql-test/t/insert_update.test: Added a test case for the bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were touched but not actually changed. sql/sql_insert.cc: Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were touched but not actually changed. Now the LAST_INSERT_ID() values is reset to 0 only if there were no rows successfully inserted or touched.
Diffstat (limited to 'mysql-test/r/insert_update.result')
-rw-r--r--mysql-test/r/insert_update.result11
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index f658ff06624..b1dee844515 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -236,3 +236,14 @@ INSERT INTO t2 VALUES (1), (3);
INSERT INTO t1 SELECT 1, COUNT(*) FROM t2 ON DUPLICATE KEY UPDATE j= a;
ERROR 42S22: Unknown column 'a' in 'field list'
DROP TABLE t1,t2;
+CREATE TABLE t1 (f1 INT AUTO_INCREMENT PRIMARY KEY,
+f2 VARCHAR(5) NOT NULL UNIQUE);
+INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+INSERT t1 (f2) VALUES ('test') ON DUPLICATE KEY UPDATE f1 = LAST_INSERT_ID(f1);
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+DROP TABLE t1;