diff options
Diffstat (limited to 'mysql-test/r/insert_update.result')
-rw-r--r-- | mysql-test/r/insert_update.result | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index fed66ed47a7..704cf444681 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -336,3 +336,74 @@ 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; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT PRIMARY KEY, +c1 INT NOT NULL, +cnt INT DEFAULT 1 +); +INSERT INTO t1 (id,c1) VALUES (1,10); +SELECT * FROM t1; +id c1 cnt +1 10 1 +CREATE TABLE t2 (id INT, c1 INT); +INSERT INTO t2 VALUES (1,NULL), (2,2); +INSERT INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL; +ERROR 23000: Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 10 1 +INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Error 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 2 +INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2 +ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +Warnings: +Warning 1048 Column 'c1' cannot be null +Error 1048 Column 'c1' cannot be null +SELECT * FROM t1; +id c1 cnt +1 0 3 +2 2 1 +DROP TABLE t1; +create table t1(f1 int primary key, +f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP); +insert into t1(f1) values(1); +select @stamp1:=f2 from t1; +@stamp1:=f2 +# +insert into t1(f1) values(1) on duplicate key update f1=1; +select @stamp2:=f2 from t1; +@stamp2:=f2 +# +select if( @stamp1 = @stamp2, "correct", "wrong"); +if( @stamp1 = @stamp2, "correct", "wrong") +correct +drop table t1; |