~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/auto_increment.test

  • Committer: Brian Aker
  • Date: 2009-02-05 10:38:55 UTC
  • Revision ID: brian@tangent.org-20090205103855-wajzccrbu7zbvmh4
Reworked some classes out of session.h
Also updated ignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#
37
37
# Test auto_increment on sub key
38
38
#
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());
46
 
select * from t1;
47
 
drop table t1;
48
 
 
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');
51
 
select * from t1;
52
 
drop table t1;
53
 
 
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');
56
 
select * from t1;
57
 
drop table t1;
58
 
 
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;
63
 
select * from t1;
64
 
drop table t1,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());
 
47
#select * from t1;
 
48
#drop table t1;
 
49
 
 
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');
 
52
#select * from t1;
 
53
#drop table t1;
 
54
 
 
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');
 
57
#select * from t1;
 
58
#drop table t1;
 
59
 
 
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;
 
64
#select * from t1;
 
65
#drop table t1,t2;
65
66
 
66
67
#
67
68
# Test of auto_increment columns when they are set to 0
93
94
insert into t1 values (NULL);
94
95
select * from t1;
95
96
drop table t1;
96
 
#
97
 
# last_insert_id() madness
98
 
#
99
 
create table t1 (i int not null auto_increment primary key);
100
 
insert into t1 set i = 254;
101
 
insert into t1 set i = null;
102
 
select last_insert_id();
103
 
explain extended select last_insert_id();
104
 
--error ER_DUP_ENTRY
105
 
insert into t1 set i = 254;
106
 
select last_insert_id();
107
 
--error ER_DUP_ENTRY
108
 
insert into t1 set i = null;
109
 
select last_insert_id();
110
 
drop table t1;
111
97
 
112
98
create table t1 (i int not null auto_increment, key (i));
113
99
insert into t1 set i = 254;
128
114
 
129
115
drop table t1;
130
116
 
 
117
#SQL_MODE was removed from Drizzle.
131
118
create table t1(a int auto_increment,b int null,primary key(a));
132
 
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
 
119
#SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
133
120
insert into t1(a,b)values(NULL,1);
134
121
insert into t1(a,b)values(200,2);
135
122
insert into t1(a,b)values(0,3);
138
125
insert into t1(b)values(6);
139
126
insert into t1(b)values(7);
140
127
select * from t1 order by b;
141
 
alter table t1 modify b mediumint;
 
128
#mediumint is not supported. changed to b int.
 
129
alter table t1 modify b int;
142
130
select * from t1 order by b;
143
131
create table t2 (a int);
144
132
insert t2 values (1),(2);
152
140
--error 1048
153
141
update t1 set a=NULL where b=6;
154
142
update t1 set a=300 where b=7;
155
 
SET SQL_MODE='';
 
143
#SQL_MODE var is not supported.
 
144
#SET SQL_MODE='';
156
145
insert into t1(a,b)values(NULL,8);
157
146
insert into t1(a,b)values(400,9);
158
147
insert into t1(a,b)values(0,10);
188
177
drop table t1;
189
178
 
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; 
195
 
set sql_mode= '';
196
 
select * from t1;
197
 
drop table t1;
 
180
#create table t1 (a bigint);
 
181
#insert into t1 values (0), (1), (2), (3);
 
182
 
 
183
#sql_mode not supported
 
184
#set sql_mode=NO_AUTO_VALUE_ON_ZERO;
 
185
 
 
186
# Bug314567 -  ALTER TABLE causes auto_increment resequencing,
 
187
# resulting in duplicate entry since sql_mode=NO_AUTO_VALUE_ON_ZERO
 
188
#is not supported.
 
189
 
 
190
#alter table t1 modify a bigint not null auto_increment primary key; 
 
191
#set sql_mode= '';
 
192
#select * from t1;
 
193
#drop table t1;
198
194
 
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);
205
 
select * from t1;
206
 
set sql_mode= '';
 
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);
 
202
#select * from t1;
 
203
#set sql_mode= '';
207
204
alter table t1 modify b varchar(255);
208
205
insert into t1 values (0,4);
209
206
select * from t1;
222
219
DROP TABLE IF EXISTS t1;
223
220
 
224
221
# BUG #19025:
225
 
 
226
 
CREATE TABLE `t1` (
 
222
#changed syntax of int(10) to int
 
223
CREATE TABLE t1 (
227
224
    t1_name VARCHAR(255) DEFAULT NULL,
228
 
    t1_id INT(10) NOT NULL AUTO_INCREMENT,
 
225
    t1_id INT not null AUTO_INCREMENT,
229
226
    KEY (t1_name),
230
227
    PRIMARY KEY (t1_id)
231
228
) AUTO_INCREMENT = 1000;
262
259
#
263
260
# Bug #11080 & #11005  Multi-row REPLACE fails on a duplicate key error
264
261
265
 
 
266
 
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
 
262
#changed syntax of int (11) to int
 
263
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
267
264
insert into t1 (b) values (1);
268
265
replace into t1 (b) values (2), (1), (3);
269
266
select * from t1;
286
283
 
287
284
#
288
285
# Test that update changes internal auto-increment value
289
 
#
 
286
# Bug 314570 
290
287
 
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);
295
 
select * from t1;
296
 
drop table t1;
 
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);
 
292
#select * from t1;
 
293
#drop table t1;
297
294
 
298
295
#
299
296
# Test key duplications with auto-increment in ALTER TABLE
300
297
# bug #14573
301
298
#
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;
307
305
DROP TABLE t1;
308
306
 
309
307
# Test of REPLACE when it does INSERT+DELETE and not UPDATE: