~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/auto_increment.result

Renamed more stuff to drizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1;
2
2
drop table if exists t2;
3
3
SET SQL_WARNINGS=1;
4
 
create TEMPORARY table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
 
4
create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
5
5
insert into t1 values (1,1),(NULL,3),(NULL,4);
6
6
delete from t1 where a=4;
7
7
insert into t1 values (NULL,5),(NULL,6);
12
12
5       5
13
13
6       6
14
14
delete from t1 where a=6;
15
 
show table status like "t1";
16
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
17
 
#       test    t1      TEMPORARY       MyISAM  #       #       #       #       #
18
15
replace t1 values (3,1);
19
16
ALTER TABLE t1 add c int;
20
17
replace t1 values (3,3,3);
30
27
9       9       9
31
28
drop table t1;
32
29
create table t1 (
33
 
skey int NOT NULL auto_increment PRIMARY KEY,
 
30
skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
34
31
sval char(20)
35
32
);
36
33
insert into t1 values (NULL, "hello");
44
41
1       1       1       hello
45
42
2       2       2       hey
46
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;
47
99
create table t1 (a int not null primary key auto_increment);
48
100
insert into t1 values (0);
49
101
update t1 set a=0;
52
104
0
53
105
check table t1;
54
106
Table   Op      Msg_type        Msg_text
 
107
test.t1 check   warning Found row where the auto_increment column has the value 0
55
108
test.t1 check   status  OK
56
109
drop table t1;
57
110
create table t1 (a int not null auto_increment primary key);
67
120
1
68
121
2
69
122
drop table t1;
70
 
create temporary table t1 (a int not null auto_increment primary key) /*!40102 engine=MEMORY */;
 
123
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
71
124
insert into t1 values (NULL);
72
125
insert into t1 values (-1);
73
126
select last_insert_id();
80
133
-1
81
134
2
82
135
drop table t1;
83
 
create table t1 (i int not null auto_increment, key (i));
84
 
insert into t1 set i = 254;
85
 
insert into t1 set i = null;
86
 
select last_insert_id();
87
 
last_insert_id()
88
 
255
89
 
insert into t1 set i = null;
90
 
select last_insert_id();
91
 
last_insert_id()
92
 
256
93
 
drop table t1;
94
 
create table t1 (i int not null auto_increment primary key, b int, unique (b));
 
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));
95
172
insert into t1 values (NULL, 10);
96
173
select last_insert_id();
97
174
last_insert_id()
107
184
2
108
185
drop table t1;
109
186
create table t1(a int auto_increment,b int null,primary key(a));
 
187
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
110
188
insert into t1(a,b)values(NULL,1);
111
189
insert into t1(a,b)values(200,2);
112
190
insert into t1(a,b)values(0,3);
123
201
202     5
124
202
203     6
125
203
204     7
126
 
alter table t1 modify b int;
 
204
alter table t1 modify b mediumint;
127
205
select * from t1 order by b;
128
206
a       b
129
207
1       1
155
233
update t1 set a=NULL where b=6;
156
234
ERROR 23000: Column 'a' cannot be null
157
235
update t1 set a=300 where b=7;
 
236
SET SQL_MODE='';
158
237
insert into t1(a,b)values(NULL,8);
159
238
insert into t1(a,b)values(400,9);
160
239
insert into t1(a,b)values(0,10);
171
250
300     7
172
251
301     8
173
252
400     9
174
 
0       10
175
 
401     11
176
 
402     12
177
 
403     13
178
 
404     14
 
253
401     10
 
254
402     11
 
255
403     12
 
256
404     13
 
257
405     14
179
258
delete from t1 where a=0;
180
259
update t1 set a=0 where b=12;
181
260
select * from t1 order by b;
187
266
300     7
188
267
301     8
189
268
400     9
190
 
401     11
 
269
401     10
 
270
402     11
191
271
0       12
192
 
403     13
193
 
404     14
 
272
404     13
 
273
405     14
194
274
delete from t1 where a=0;
195
275
update t1 set a=NULL where b=13;
196
276
ERROR 23000: Column 'a' cannot be null
204
284
300     7
205
285
301     8
206
286
400     9
207
 
401     11
208
 
403     13
 
287
401     10
 
288
402     11
 
289
404     13
209
290
500     14
210
291
drop table t1;
211
292
create table t1 (a bigint);
222
303
create table t1 (a bigint);
223
304
insert into t1 values (1), (2), (3), (0), (0);
224
305
alter table t1 modify a bigint not null auto_increment primary key;
225
 
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
226
306
select * from t1;
227
307
a
228
308
1
229
309
2
230
310
3
231
 
0
232
 
0
 
311
4
 
312
5
233
313
drop table t1;
234
314
create table t1 (a bigint);
235
315
insert into t1 values (0), (1), (2), (3);
 
316
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
236
317
alter table t1 modify a bigint not null auto_increment primary key;
 
318
set sql_mode= '';
237
319
select * from t1;
238
320
a
239
321
0
242
324
3
243
325
drop table t1;
244
326
create table t1 (a int auto_increment primary key , b int null);
 
327
set sql_mode=NO_AUTO_VALUE_ON_ZERO;
245
328
insert into t1 values (0,1),(1,2),(2,3);
246
329
select * from t1;
247
330
a       b
248
331
0       1
249
332
1       2
250
333
2       3
 
334
set sql_mode= '';
251
335
alter table t1 modify b varchar(255);
252
336
insert into t1 values (0,4);
253
 
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
254
337
select * from t1;
255
338
a       b
256
339
0       1
257
340
1       2
258
341
2       3
 
342
3       4
259
343
drop table t1;
260
344
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
261
345
INSERT INTO t1 (b) VALUES ('aaaa');
271
355
Table   Op      Msg_type        Msg_text
272
356
test.t1 check   status  OK
273
357
DROP TABLE IF EXISTS t1;
274
 
CREATE TABLE t1 (
 
358
CREATE TABLE `t1` (
275
359
t1_name VARCHAR(255) DEFAULT NULL,
276
 
t1_id INT not null AUTO_INCREMENT,
 
360
t1_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
277
361
KEY (t1_name),
278
362
PRIMARY KEY (t1_id)
279
363
) AUTO_INCREMENT = 1000;
288
372
SHOW CREATE TABLE `t1`;
289
373
Table   Create Table
290
374
t1      CREATE TABLE `t1` (
291
 
  `t1_name` VARCHAR(255) COLLATE utf8_general_ci DEFAULT NULL,
292
 
  `t1_id` INT NOT NULL AUTO_INCREMENT,
 
375
  `t1_name` varchar(255) DEFAULT NULL,
 
376
  `t1_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
293
377
  PRIMARY KEY (`t1_id`),
294
378
  KEY `t1_name` (`t1_name`)
295
 
) ENGINE=InnoDB COLLATE = utf8_general_ci AUTO_INCREMENT=1000
 
379
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
296
380
DROP TABLE `t1`;
297
381
create table t1(a int not null auto_increment primary key);
298
382
create table t2(a int not null auto_increment primary key, t1a int);
317
401
9       3
318
402
drop table t1, t2;
319
403
End of 4.1 tests
320
 
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
 
404
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
321
405
insert into t1 (b) values (1);
322
406
replace into t1 (b) values (2), (1), (3);
323
407
select * from t1;
324
408
a       b
 
409
3       1
325
410
2       2
326
 
3       1
327
411
4       3
328
412
truncate table t1;
329
413
insert into t1 (b) values (1);
332
416
replace into t1 (b) values (3);
333
417
select * from t1;
334
418
a       b
 
419
3       1
335
420
2       2
336
 
3       1
337
421
4       3
338
422
drop table t1;
339
423
create table t1 (rowid int not null auto_increment, val int not null,primary
347
431
3       1
348
432
4       2
349
433
drop table t1;
350
 
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
 
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));
351
444
INSERT INTO t1 VALUES(0, 0);
352
445
INSERT INTO t1 VALUES(1, 1);
353
 
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
354
 
INSERT INTO t1 VALUES(0,0);
355
 
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
 
446
ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
 
447
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
356
448
DROP TABLE t1;
357
449
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
358
450
insert into t1 values(null,1,1,now());