summaryrefslogtreecommitdiff
path: root/mysql-test/t/insert.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/insert.test')
-rw-r--r--mysql-test/t/insert.test38
1 files changed, 36 insertions, 2 deletions
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 0b5a12fa523..c58fb61ad30 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -9,8 +9,8 @@ drop table if exists t1,t2,t3;
create table t1 (a int not null);
insert into t1 values (1);
insert into t1 values (a+2);
-insert into t1 values (a+3);
-insert into t1 values (4),(a+5);
+insert into t1 values (a+3),(a+4);
+insert into t1 values (5),(a+6);
select * from t1;
drop table t1;
@@ -177,6 +177,32 @@ select count(*) from t2;
drop table t1,t2,t3;
#
+# Test different cases of duplicate fields
+#
+
+create table t1 (a int, b int);
+insert into t1 (a,b) values (a,b);
+insert into t1 SET a=1, b=a+1;
+insert into t1 (a,b) select 1,2;
+INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
+prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' ';
+--error 1110
+execute stmt1;
+--error 1110
+insert into t1 (a,b,b) values (1,1,1);
+--error 1136
+insert into t1 (a,a) values (1,1,1);
+--error 1110
+insert into t1 (a,a) values (1,1);
+--error 1110
+insert into t1 SET a=1,b=2,a=1;
+--error 1110
+insert into t1 (b,b) select 1,2;
+--error 1110
+INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
+drop table t1;
+
+#
# Test for values returned by ROW_COUNT() function
# (and thus for values returned by mysql_affected_rows())
# for various forms of INSERT
@@ -216,6 +242,14 @@ select * from t1;
drop view v1;
drop table t1,t2;
+# Test of INSERT IGNORE and re-using auto_increment values
+create table t1 (id int primary key auto_increment, data int, unique(data));
+insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
+insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
+insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
+select * from t1 order by id;
+
+drop table t1;
#
# BUG#21483: Server abort or deadlock on INSERT DELAYED with another