~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/auto_increment.result

  • Committer: Brian Aker
  • Date: 2009-01-08 22:47:46 UTC
  • mfrom: (642.1.77 drizzle-clean-code)
  • Revision ID: brian@tangent.org-20090108224746-b6l8m91ougralsh9
MergeĀ fromĀ Lee.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
9       9       9
28
28
drop table t1;
29
29
create table t1 (
30
 
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
 
30
skey int NOT NULL auto_increment PRIMARY KEY,
31
31
sval char(20)
32
32
);
33
33
insert into t1 values (NULL, "hello");
41
41
1       1       1       hello
42
42
2       2       2       hey
43
43
drop table t1;
44
 
create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
45
 
insert into t1 values ("a",1),("b",2),("a",2),("c",1);
46
 
insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
47
 
insert into t1 (a) values ("a"),("b"),("c"),("d");
48
 
insert into t1 (a) values ('k'),('d');
49
 
insert into t1 (a) values ("a");
50
 
insert into t1 values ("d",last_insert_id());
51
 
select * from t1;
52
 
a       b
53
 
a       1
54
 
a       2
55
 
a       3
56
 
a       4
57
 
a       5
58
 
b       2
59
 
b       3
60
 
b       4
61
 
c       1
62
 
c       2
63
 
c       3
64
 
d       1
65
 
d       2
66
 
d       5
67
 
e       1
68
 
k       1
69
 
drop table t1;
70
 
create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ordid), index(ord,ordid));
71
 
insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
72
 
select * from t1;
73
 
ordid   ord
74
 
1       sdj
75
 
2       sdj
76
 
drop table t1;
77
 
create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid));
78
 
insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
79
 
select * from t1;
80
 
ordid   ord
81
 
1       abc
82
 
2       abc
83
 
3       abc
84
 
1       sdj
85
 
2       sdj
86
 
3       sdj
87
 
1       zzz
88
 
drop table t1;
89
 
create table t1 (sid char(5), id int(2) NOT NULL auto_increment, key(sid,  id));
90
 
create table t2 (sid char(20), id int(2));
91
 
insert into t2 values ('skr',NULL),('skr',NULL),('test',NULL);
92
 
insert into t1 select * from t2;
93
 
select * from t1;
94
 
sid     id
95
 
skr     1
96
 
skr     2
97
 
test    1
98
 
drop table t1,t2;
99
44
create table t1 (a int not null primary key auto_increment);
100
45
insert into t1 values (0);
101
46
update t1 set a=0;
104
49
0
105
50
check table t1;
106
51
Table   Op      Msg_type        Msg_text
107
 
test.t1 check   warning Found row where the auto_increment column has the value 0
108
52
test.t1 check   status  OK
109
53
drop table t1;
110
54
create table t1 (a int not null auto_increment primary key);
133
77
-1
134
78
2
135
79
drop table t1;
136
 
create table t1 (i tinyint unsigned not null auto_increment primary key);
137
 
insert into t1 set i = 254;
138
 
insert into t1 set i = null;
139
 
select last_insert_id();
140
 
last_insert_id()
141
 
255
142
 
explain extended select last_insert_id();
143
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
144
 
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
145
 
Warnings:
146
 
Note    1003    select last_insert_id() AS `last_insert_id()`
147
 
insert into t1 set i = 254;
148
 
ERROR 23000: Duplicate entry '254' for key 'PRIMARY'
149
 
select last_insert_id();
150
 
last_insert_id()
151
 
255
152
 
insert into t1 set i = null;
153
 
ERROR 23000: Duplicate entry '255' for key 'PRIMARY'
154
 
select last_insert_id();
155
 
last_insert_id()
156
 
255
157
 
drop table t1;
158
 
create table t1 (i tinyint unsigned not null auto_increment, key (i));
159
 
insert into t1 set i = 254;
160
 
insert into t1 set i = null;
161
 
select last_insert_id();
162
 
last_insert_id()
163
 
255
164
 
insert into t1 set i = null;
165
 
Warnings:
166
 
Warning 1264    Out of range value for column 'i' at row 1
167
 
select last_insert_id();
168
 
last_insert_id()
169
 
255
170
 
drop table t1;
171
 
create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
 
80
create table t1 (i int not null auto_increment, key (i));
 
81
insert into t1 set i = 254;
 
82
insert into t1 set i = null;
 
83
select last_insert_id();
 
84
last_insert_id()
 
85
255
 
86
insert into t1 set i = null;
 
87
select last_insert_id();
 
88
last_insert_id()
 
89
256
 
90
drop table t1;
 
91
create table t1 (i int not null auto_increment primary key, b int, unique (b));
172
92
insert into t1 values (NULL, 10);
173
93
select last_insert_id();
174
94
last_insert_id()
184
104
2
185
105
drop table t1;
186
106
create table t1(a int auto_increment,b int null,primary key(a));
187
 
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
188
107
insert into t1(a,b)values(NULL,1);
189
108
insert into t1(a,b)values(200,2);
190
109
insert into t1(a,b)values(0,3);
196
115
a       b
197
116
1       1
198
117
200     2
199
 
0       3
200
 
201     4
201
 
202     5
202
 
203     6
203
 
204     7
204
 
alter table t1 modify b mediumint;
 
118
201     3
 
119
202     4
 
120
203     5
 
121
204     6
 
122
205     7
 
123
alter table t1 modify b int;
205
124
select * from t1 order by b;
206
125
a       b
207
126
1       1
208
127
200     2
209
 
0       3
210
 
201     4
211
 
202     5
212
 
203     6
213
 
204     7
 
128
201     3
 
129
202     4
 
130
203     5
 
131
204     6
 
132
205     7
214
133
create table t2 (a int);
215
134
insert t2 values (1),(2);
216
135
alter table t2 add b int auto_increment primary key;
225
144
a       b
226
145
1       1
227
146
200     2
228
 
201     4
 
147
201     3
 
148
202     4
229
149
0       5
230
 
203     6
231
 
204     7
 
150
204     6
 
151
205     7
232
152
delete from t1 where a=0;
233
153
update t1 set a=NULL where b=6;
234
154
ERROR 23000: Column 'a' cannot be null
235
155
update t1 set a=300 where b=7;
236
 
SET SQL_MODE='';
237
156
insert into t1(a,b)values(NULL,8);
238
157
insert into t1(a,b)values(400,9);
239
158
insert into t1(a,b)values(0,10);
245
164
a       b
246
165
1       1
247
166
200     2
248
 
201     4
249
 
203     6
 
167
201     3
 
168
202     4
 
169
204     6
250
170
300     7
251
 
301     8
 
171
206     8
252
172
400     9
253
173
401     10
254
174
402     11
261
181
a       b
262
182
1       1
263
183
200     2
264
 
201     4
265
 
203     6
 
184
201     3
 
185
202     4
 
186
204     6
266
187
300     7
267
 
301     8
 
188
206     8
268
189
400     9
269
190
401     10
270
191
402     11
279
200
a       b
280
201
1       1
281
202
200     2
282
 
201     4
283
 
203     6
 
203
201     3
 
204
202     4
 
205
204     6
284
206
300     7
285
 
301     8
 
207
206     8
286
208
400     9
287
209
401     10
288
210
402     11
311
233
4
312
234
5
313
235
drop table t1;
314
 
create table t1 (a bigint);
315
 
insert into t1 values (0), (1), (2), (3);
316
 
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
317
 
alter table t1 modify a bigint not null auto_increment primary key;
318
 
set sql_mode= '';
319
 
select * from t1;
320
 
a
321
 
0
322
 
1
323
 
2
324
 
3
325
 
drop table t1;
326
236
create table t1 (a int auto_increment primary key , b int null);
327
 
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
328
 
insert into t1 values (0,1),(1,2),(2,3);
329
 
select * from t1;
330
 
a       b
331
 
0       1
332
 
1       2
333
 
2       3
334
 
set sql_mode= '';
335
237
alter table t1 modify b varchar(255);
336
238
insert into t1 values (0,4);
337
239
select * from t1;
338
240
a       b
339
 
0       1
340
 
1       2
341
 
2       3
342
 
3       4
 
241
1       4
343
242
drop table t1;
344
243
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
345
244
INSERT INTO t1 (b) VALUES ('aaaa');
355
254
Table   Op      Msg_type        Msg_text
356
255
test.t1 check   status  OK
357
256
DROP TABLE IF EXISTS t1;
358
 
CREATE TABLE `t1` (
 
257
CREATE TABLE t1 (
359
258
t1_name VARCHAR(255) DEFAULT NULL,
360
 
t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 
259
t1_id INT not null AUTO_INCREMENT,
361
260
KEY (t1_name),
362
261
PRIMARY KEY (t1_id)
363
262
) AUTO_INCREMENT = 1000;
 
263
Warnings:
 
264
Warning 1071    Specified key was too long; max key length is 767 bytes
364
265
INSERT INTO t1 (t1_name) VALUES('MySQL');
365
266
INSERT INTO t1 (t1_name) VALUES('MySQL');
366
267
INSERT INTO t1 (t1_name) VALUES('MySQL');
372
273
SHOW CREATE TABLE `t1`;
373
274
Table   Create Table
374
275
t1      CREATE TABLE `t1` (
375
 
  `t1_name` varchar(255) DEFAULT NULL,
376
 
  `t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 
276
  `t1_name` varchar(255),
 
277
  `t1_id` int NOT NULL AUTO_INCREMENT,
377
278
  PRIMARY KEY (`t1_id`),
378
 
  KEY `t1_name` (`t1_name`)
379
 
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
 
279
  KEY `t1_name` (`t1_name`())
 
280
) ENGINE=InnoDB AUTO_INCREMENT=1003
380
281
DROP TABLE `t1`;
381
282
create table t1(a int not null auto_increment primary key);
382
283
create table t2(a int not null auto_increment primary key, t1a int);
401
302
9       3
402
303
drop table t1, t2;
403
304
End of 4.1 tests
404
 
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
 
305
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
405
306
insert into t1 (b) values (1);
406
307
replace into t1 (b) values (2), (1), (3);
407
308
select * from t1;
408
309
a       b
 
310
2       2
409
311
3       1
410
 
2       2
411
312
4       3
412
313
truncate table t1;
413
314
insert into t1 (b) values (1);
416
317
replace into t1 (b) values (3);
417
318
select * from t1;
418
319
a       b
 
320
2       2
419
321
3       1
420
 
2       2
421
322
4       3
422
323
drop table t1;
423
324
create table t1 (rowid int not null auto_increment, val int not null,primary
431
332
3       1
432
333
4       2
433
334
drop table t1;
434
 
create table t1 (a int not null auto_increment primary key, val int);
435
 
insert into t1 (val) values (1);
436
 
update t1 set a=2 where a=1;
437
 
insert into t1 (val) values (1);
438
 
select * from t1;
439
 
a       val
440
 
2       1
441
 
3       1
442
 
drop table t1;
443
 
CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
 
335
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
444
336
INSERT INTO t1 VALUES(0, 0);
445
337
INSERT INTO t1 VALUES(1, 1);
446
 
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
 
338
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
447
339
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
448
340
DROP TABLE t1;
449
341
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));