21
21
create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
22
insert into t1 values (NULL,"mysql");
23
insert into t1 values (NULL,"mysql ab");
24
insert into t1 values (NULL,"mysql a");
25
insert into t1 values (NULL,"r1manic");
26
insert into t1 values (NULL,"r1man");
22
insert into t1 values (0,"mysql");
23
insert into t1 values (0,"mysql ab");
24
insert into t1 values (0,"mysql a");
25
insert into t1 values (0,"r1manic");
26
insert into t1 values (0,"r1man");
30
30
# Test insert syntax
33
create table t1 (a int not null auto_increment, primary key (a), t timestamp null, c char(10) default "hello", i int);
34
insert into t1 values (default,default,default,default);
35
insert into t1 values (default,default,default,default);
36
--error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
37
insert into t1 values (4,0,"a",5);
38
insert into t1 values (default,default,default,default);
39
select a,t is not null,c,i from t1;
33
create table t1 (a int not null auto_increment, primary key (a), t timestamp, c char(10) default "hello", i int);
34
insert into t1 values (default,default,default,default), (default,default,default,default), (4,0,"a",5),(default,default,default,default);
35
select a,t>0,c,i from t1;
41
37
insert into t1 set a=default,t=default,c=default;
42
38
insert into t1 set a=default,t=default,c=default,i=default;
43
insert into t1 set a=4,t= NULL,c="a",i=5;
44
insert into t1 set a=5,t= NULL,c="a",i=null;
39
insert into t1 set a=4,t=0,c="a",i=5;
40
insert into t1 set a=5,t=0,c="a",i=null;
45
41
insert into t1 set a=default,t=default,c=default,i=default;
46
select a,t is not null,c,i from t1;
42
select a,t>0,c,i from t1;
46
# Test problem with bulk insert and auto_increment on second part keys
49
create table t1 (sid char(20), id int(2) NOT NULL auto_increment, key(sid, id));
50
insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
52
insert into t1 values ('rts',NULL),('rts',NULL),('test',NULL);
131
134
insert into t1 SET a=1, b=a+1;
132
135
insert into t1 (a,b) select 1,2;
133
136
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
134
--error ER_FIELD_SPECIFIED_TWICE
135
138
replace into t1 (a,a) select 100, 'hundred';
136
--error ER_FIELD_SPECIFIED_TWICE
137
140
insert into t1 (a,b,b) values (1,1,1);
138
--error ER_WRONG_VALUE_COUNT_ON_ROW
139
142
insert into t1 (a,a) values (1,1,1);
140
--error ER_FIELD_SPECIFIED_TWICE
141
144
insert into t1 (a,a) values (1,1);
142
--error ER_FIELD_SPECIFIED_TWICE
143
146
insert into t1 SET a=1,b=2,a=1;
144
--error ER_FIELD_SPECIFIED_TWICE
145
148
insert into t1 (b,b) select 1,2;
146
--error ER_FIELD_SPECIFIED_TWICE
147
150
INSERT INTO t1 (b,b) SELECT 0,0 ON DUPLICATE KEY UPDATE a = a + VALUES (a);
175
178
insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120);
176
179
insert ignore into t1 values(NULL,10),(NULL,20),(NULL,110),(NULL,120),(NULL,100),(NULL,90);
177
180
insert ignore into t1 values(NULL,130),(NULL,140),(500,110),(550,120),(450,100),(NULL,150);
178
# PBXT differs from InnoDB here. Main reason is that inserting
179
# 500 causes auto inc value to be set to 501, this is never
180
# undone because of possible concurrent inserts.
181
181
select * from t1 order by id;