37
37
# Test auto_increment on sub key
39
#Drizzle does not support auto_increment on sub key.
40
#create table t1 (a char(10) not null, b int not null auto_increment, primary key(b));
41
#insert into t1 values ("a",1),("b",2),("a",2),("c",1);
42
#insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
43
#insert into t1 (a) values ("a"),("b"),("c"),("d");
44
#insert into t1 (a) values ('k'),('d');
45
#insert into t1 (a) values ("a");
46
#insert into t1 values ("d",last_insert_id());
50
#create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ordid), index(ord,ordid));
51
#insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
55
#create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid));
56
#insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
60
#create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid, id));
61
#create table t2 (sid char(20), id int(2));
62
#insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
63
#insert into t1 select * from t2;
39
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
40
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
41
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
42
insert into t1 (a) values ("a"),("b"),("c"),("d");
43
insert into t1 (a) values ('k'),('d');
44
insert into t1 (a) values ("a");
45
insert into t1 values ("d",last_insert_id());
49
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ordid), index(ord,ordid));
50
insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
54
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid));
55
insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
59
create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid, id));
60
create table t2 (sid char(20), id int(2));
61
insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
62
insert into t1 select * from t2;
68
67
# Test of auto_increment columns when they are set to 0
179
190
# We still should be able to preserve zero in NO_AUTO_VALUE_ON_ZERO mode
180
#create table t1 (a bigint);
181
#insert into t1 values (0), (1), (2), (3);
183
#sql_mode not supported
184
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
186
# Bug314567 - ALTER TABLE causes auto_increment resequencing,
187
# resulting in duplicate entry since sql_mode=NO_AUTO_VALUE_ON_ZERO
190
#alter table t1 modify a bigint not null auto_increment primary key;
191
create table t1 (a bigint);
192
insert into t1 values (0), (1), (2), (3);
193
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
194
alter table t1 modify a bigint not null auto_increment primary key;
195
199
# It also sensible to preserve zeroes if we are converting auto_increment
196
200
# column to auto_increment column (or not touching it at all, which is more
197
201
# common case probably)
198
202
create table t1 (a int auto_increment primary key , b int null);
199
#sql_mode is not supported.
200
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
201
#insert into t1 values (0,1),(1,2),(2,3);
203
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
204
insert into t1 values (0,1),(1,2),(2,3);
204
207
alter table t1 modify b varchar(255);
205
208
insert into t1 values (0,4);
206
209
select * from t1;
285
288
# Test that update changes internal auto-increment value
288
#create table t1 (a int not null auto_increment primary key, val int);
289
#insert into t1 (val) values (1);
290
#update t1 set a=2 where a=1;
291
#insert into t1 (val) values (1);
291
create table t1 (a int not null auto_increment primary key, val int);
292
insert into t1 (val) values (1);
293
update t1 set a=2 where a=1;
294
insert into t1 (val) values (1);
296
299
# Test key duplications with auto-increment in ALTER TABLE
299
#changed syntax of int(11) to int.
300
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
302
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
301
303
INSERT INTO t1 VALUES(0, 0);
302
304
INSERT INTO t1 VALUES(1, 1);
303
305
--error ER_DUP_ENTRY
304
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
306
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
307
309
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: