~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/pbxt/auto_increment.result

lp:drizzle + pbxt 1.1 + test results

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1;
 
2
drop table if exists t2;
 
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;
 
5
insert into t1 values (1,1),(NULL,3),(NULL,4);
 
6
delete from t1 where a=4;
 
7
insert into t1 values (NULL,5),(NULL,6);
 
8
select * from t1;
 
9
a       b
 
10
1       1
 
11
3       3
 
12
5       5
 
13
6       6
 
14
delete from t1 where a=6;
 
15
replace t1 values (3,1);
 
16
ALTER TABLE t1 add c int;
 
17
replace t1 values (3,3,3);
 
18
insert into t1 values (NULL,7,7);
 
19
update t1 set a=8,b=b+1,c=c+1 where a=7;
 
20
insert into t1 values (NULL,9,9);
 
21
select * from t1;
 
22
a       b       c
 
23
1       1       NULL
 
24
3       3       3
 
25
5       5       NULL
 
26
8       8       8
 
27
9       9       9
 
28
drop table t1;
 
29
create table t1 (
 
30
skey int NOT NULL auto_increment PRIMARY KEY,
 
31
sval char(20)
 
32
);
 
33
insert into t1 values (NULL, "hello");
 
34
insert into t1 values (NULL, "hey");
 
35
select * from t1;
 
36
skey    sval
 
37
1       hello
 
38
2       hey
 
39
select _rowid,t1._rowid,skey,sval from t1;
 
40
_rowid  _rowid  skey    sval
 
41
1       1       1       hello
 
42
2       2       2       hey
 
43
drop table t1;
 
44
create table t1 (a int not null primary key auto_increment);
 
45
insert into t1 values (0);
 
46
update t1 set a=0;
 
47
select * from t1;
 
48
a
 
49
0
 
50
check table t1;
 
51
Table   Op      Msg_type        Msg_text
 
52
test.t1 check   status  OK
 
53
drop table t1;
 
54
create table t1 (a int not null auto_increment primary key);
 
55
insert into t1 values (NULL);
 
56
insert into t1 values (-1);
 
57
select last_insert_id();
 
58
last_insert_id()
 
59
1
 
60
insert into t1 values (NULL);
 
61
select * from t1;
 
62
a
 
63
-1
 
64
1
 
65
2
 
66
drop table t1;
 
67
create temporary table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
 
68
insert into t1 values (NULL);
 
69
insert into t1 values (-1);
 
70
select last_insert_id();
 
71
last_insert_id()
 
72
1
 
73
insert into t1 values (NULL);
 
74
select * from t1;
 
75
a
 
76
1
 
77
-1
 
78
2
 
79
drop table t1;
 
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));
 
92
insert into t1 values (NULL, 10);
 
93
select last_insert_id();
 
94
last_insert_id()
 
95
1
 
96
insert into t1 values (NULL, 15);
 
97
select last_insert_id();
 
98
last_insert_id()
 
99
2
 
100
insert into t1 values (NULL, 10);
 
101
ERROR 23000: Duplicate entry '10' for key 'b'
 
102
select last_insert_id();
 
103
last_insert_id()
 
104
2
 
105
drop table t1;
 
106
create table t1(a int auto_increment,b int null,primary key(a));
 
107
insert into t1(a,b)values(NULL,1);
 
108
insert into t1(a,b)values(200,2);
 
109
insert into t1(a,b)values(0,3);
 
110
insert into t1(b)values(4);
 
111
insert into t1(b)values(5);
 
112
insert into t1(b)values(6);
 
113
insert into t1(b)values(7);
 
114
select * from t1 order by b;
 
115
a       b
 
116
1       1
 
117
200     2
 
118
0       3
 
119
201     4
 
120
202     5
 
121
203     6
 
122
204     7
 
123
alter table t1 modify b int;
 
124
select * from t1 order by b;
 
125
a       b
 
126
1       1
 
127
200     2
 
128
0       3
 
129
201     4
 
130
202     5
 
131
203     6
 
132
204     7
 
133
create table t2 (a int);
 
134
insert t2 values (1),(2);
 
135
alter table t2 add b int auto_increment primary key;
 
136
select * from t2;
 
137
a       b
 
138
1       1
 
139
2       2
 
140
drop table t2;
 
141
delete from t1 where a=0;
 
142
update t1 set a=0 where b=5;
 
143
select * from t1 order by b;
 
144
a       b
 
145
1       1
 
146
200     2
 
147
201     4
 
148
0       5
 
149
203     6
 
150
204     7
 
151
delete from t1 where a=0;
 
152
update t1 set a=NULL where b=6;
 
153
ERROR 23000: Column 'a' cannot be null
 
154
update t1 set a=300 where b=7;
 
155
insert into t1(a,b)values(NULL,8);
 
156
insert into t1(a,b)values(400,9);
 
157
insert into t1(a,b)values(0,10);
 
158
insert into t1(b)values(11);
 
159
insert into t1(b)values(12);
 
160
insert into t1(b)values(13);
 
161
insert into t1(b)values(14);
 
162
select * from t1 order by b;
 
163
a       b
 
164
1       1
 
165
200     2
 
166
201     4
 
167
203     6
 
168
300     7
 
169
301     8
 
170
400     9
 
171
0       10
 
172
401     11
 
173
402     12
 
174
403     13
 
175
404     14
 
176
delete from t1 where a=0;
 
177
update t1 set a=0 where b=12;
 
178
select * from t1 order by b;
 
179
a       b
 
180
1       1
 
181
200     2
 
182
201     4
 
183
203     6
 
184
300     7
 
185
301     8
 
186
400     9
 
187
401     11
 
188
0       12
 
189
403     13
 
190
404     14
 
191
delete from t1 where a=0;
 
192
update t1 set a=NULL where b=13;
 
193
ERROR 23000: Column 'a' cannot be null
 
194
update t1 set a=500 where b=14;
 
195
select * from t1 order by b;
 
196
a       b
 
197
1       1
 
198
200     2
 
199
201     4
 
200
203     6
 
201
300     7
 
202
301     8
 
203
400     9
 
204
401     11
 
205
403     13
 
206
500     14
 
207
drop table t1;
 
208
create table t1 (a bigint);
 
209
insert into t1 values (1), (2), (3), (NULL), (NULL);
 
210
alter table t1 modify a bigint not null auto_increment primary key;
 
211
select * from t1;
 
212
a
 
213
1
 
214
2
 
215
3
 
216
4
 
217
5
 
218
drop table t1;
 
219
create table t1 (a bigint);
 
220
insert into t1 values (1), (2), (3), (0), (0);
 
221
alter table t1 modify a bigint not null auto_increment primary key;
 
222
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '0' for key 'PRIMARY'
 
223
select * from t1;
 
224
a
 
225
1
 
226
2
 
227
3
 
228
0
 
229
0
 
230
drop table t1;
 
231
create table t1 (a bigint);
 
232
insert into t1 values (0), (1), (2), (3);
 
233
alter table t1 modify a bigint not null auto_increment primary key;
 
234
select * from t1;
 
235
a
 
236
0
 
237
1
 
238
2
 
239
3
 
240
drop table t1;
 
241
create table t1 (a int auto_increment primary key , b int null);
 
242
insert into t1 values (0,1),(1,2),(2,3);
 
243
select * from t1;
 
244
a       b
 
245
0       1
 
246
1       2
 
247
2       3
 
248
alter table t1 modify b varchar(255);
 
249
insert into t1 values (0,4);
 
250
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
 
251
select * from t1;
 
252
a       b
 
253
0       1
 
254
1       2
 
255
2       3
 
256
drop table t1;
 
257
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
 
258
INSERT INTO t1 (b) VALUES ('aaaa');
 
259
CHECK TABLE t1;
 
260
Table   Op      Msg_type        Msg_text
 
261
test.t1 check   status  OK
 
262
INSERT INTO t1 (b) VALUES ('');
 
263
CHECK TABLE t1;
 
264
Table   Op      Msg_type        Msg_text
 
265
test.t1 check   status  OK
 
266
INSERT INTO t1 (b) VALUES ('bbbb');
 
267
CHECK TABLE t1;
 
268
Table   Op      Msg_type        Msg_text
 
269
test.t1 check   status  OK
 
270
DROP TABLE IF EXISTS t1;
 
271
CREATE TABLE t1 (
 
272
t1_name VARCHAR(255) DEFAULT NULL,
 
273
t1_id INT not null AUTO_INCREMENT,
 
274
KEY (t1_name),
 
275
PRIMARY KEY (t1_id)
 
276
) AUTO_INCREMENT = 1000;
 
277
INSERT INTO t1 (t1_name) VALUES('MySQL');
 
278
INSERT INTO t1 (t1_name) VALUES('MySQL');
 
279
INSERT INTO t1 (t1_name) VALUES('MySQL');
 
280
SELECT * from t1;
 
281
t1_name t1_id
 
282
MySQL   1000
 
283
MySQL   1001
 
284
MySQL   1002
 
285
SHOW CREATE TABLE `t1`;
 
286
Table   Create Table
 
287
t1      CREATE TABLE `t1` (
 
288
  `t1_name` varchar(255) DEFAULT NULL,
 
289
  `t1_id` int NOT NULL AUTO_INCREMENT,
 
290
  PRIMARY KEY (`t1_id`),
 
291
  KEY `t1_name` (`t1_name`)
 
292
) ENGINE=PBXT
 
293
DROP TABLE `t1`;
 
294
create table t1(a int not null auto_increment primary key);
 
295
create table t2(a int not null auto_increment primary key, t1a int);
 
296
insert into t1 values(NULL);
 
297
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
 
298
insert into t1 values (NULL);
 
299
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
 
300
(NULL, LAST_INSERT_ID());
 
301
insert into t1 values (NULL);
 
302
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
 
303
(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
 
304
select * from t2;
 
305
a       t1a
 
306
1       1
 
307
2       1
 
308
3       2
 
309
4       2
 
310
5       2
 
311
6       3
 
312
7       3
 
313
8       3
 
314
9       3
 
315
drop table t1, t2;
 
316
End of 4.1 tests
 
317
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
 
318
insert into t1 (b) values (1);
 
319
replace into t1 (b) values (2), (1), (3);
 
320
select * from t1;
 
321
a       b
 
322
2       2
 
323
3       1
 
324
4       3
 
325
truncate table t1;
 
326
insert into t1 (b) values (1);
 
327
replace into t1 (b) values (2);
 
328
replace into t1 (b) values (1);
 
329
replace into t1 (b) values (3);
 
330
select * from t1;
 
331
a       b
 
332
2       2
 
333
3       1
 
334
4       3
 
335
drop table t1;
 
336
create table t1 (rowid int not null auto_increment, val int not null,primary
 
337
key (rowid), unique(val));
 
338
replace into t1 (val) values ('1'),('2');
 
339
replace into t1 (val) values ('1'),('2');
 
340
insert into t1 (val) values ('1'),('2');
 
341
ERROR 23000: Duplicate entry '1' for key 'val'
 
342
select * from t1;
 
343
rowid   val
 
344
3       1
 
345
4       2
 
346
drop table t1;
 
347
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
 
348
INSERT INTO t1 VALUES(0, 0);
 
349
INSERT INTO t1 VALUES(1, 1);
 
350
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
 
351
INSERT INTO t1 VALUES(0,0);
 
352
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
 
353
DROP TABLE t1;
 
354
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
 
355
insert into t1 values(null,1,1,now());
 
356
insert into t1 values(null,0,0,null);
 
357
replace into t1 values(null,1,0,null);
 
358
select last_insert_id();
 
359
last_insert_id()
 
360
3
 
361
drop table t1;