37
37
# Test auto_increment on sub key
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;
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;
67
68
# Test of auto_increment columns when they are set to 0
190
179
# We still should be able to preserve zero in NO_AUTO_VALUE_ON_ZERO mode
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;
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;
199
195
# It also sensible to preserve zeroes if we are converting auto_increment
200
196
# column to auto_increment column (or not touching it at all, which is more
201
197
# common case probably)
202
198
create table t1 (a int auto_increment primary key , b int null);
203
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
204
insert into t1 values (0,1),(1,2),(2,3);
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);
207
204
alter table t1 modify b varchar(255);
208
205
insert into t1 values (0,4);
209
206
select * from t1;
288
285
# Test that update changes internal auto-increment value
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);
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);
299
296
# Test key duplications with auto-increment in ALTER TABLE
302
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
299
#changed syntax of int(11) to int.
300
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
303
301
INSERT INTO t1 VALUES(0, 0);
304
302
INSERT INTO t1 VALUES(1, 1);
305
303
--error ER_DUP_ENTRY
306
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
304
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
309
307
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: