~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/auto_increment.result

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

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);
67
64
1
68
65
2
69
66
drop table t1;
70
 
create temporary table t1 (a int not null auto_increment primary key) /*!40102 engine=MEMORY */;
 
67
create table t1 (a int not null auto_increment primary key) /*!40102 engine=heap */;
71
68
insert into t1 values (NULL);
72
69
insert into t1 values (-1);
73
70
select last_insert_id();
118
115
a       b
119
116
1       1
120
117
200     2
121
 
0       3
122
 
201     4
123
 
202     5
124
 
203     6
125
 
204     7
 
118
201     3
 
119
202     4
 
120
203     5
 
121
204     6
 
122
205     7
126
123
alter table t1 modify b int;
127
124
select * from t1 order by b;
128
125
a       b
129
126
1       1
130
127
200     2
131
 
0       3
132
 
201     4
133
 
202     5
134
 
203     6
135
 
204     7
 
128
201     3
 
129
202     4
 
130
203     5
 
131
204     6
 
132
205     7
136
133
create table t2 (a int);
137
134
insert t2 values (1),(2);
138
135
alter table t2 add b int auto_increment primary key;
147
144
a       b
148
145
1       1
149
146
200     2
150
 
201     4
 
147
201     3
 
148
202     4
151
149
0       5
152
 
203     6
153
 
204     7
 
150
204     6
 
151
205     7
154
152
delete from t1 where a=0;
155
153
update t1 set a=NULL where b=6;
156
154
ERROR 23000: Column 'a' cannot be null
166
164
a       b
167
165
1       1
168
166
200     2
169
 
201     4
170
 
203     6
 
167
201     3
 
168
202     4
 
169
204     6
171
170
300     7
172
 
205     8
 
171
206     8
173
172
400     9
174
 
0       10
175
 
401     11
176
 
402     12
177
 
403     13
178
 
404     14
 
173
401     10
 
174
402     11
 
175
403     12
 
176
404     13
 
177
405     14
179
178
delete from t1 where a=0;
180
179
update t1 set a=0 where b=12;
181
180
select * from t1 order by b;
182
181
a       b
183
182
1       1
184
183
200     2
185
 
201     4
186
 
203     6
 
184
201     3
 
185
202     4
 
186
204     6
187
187
300     7
188
 
205     8
 
188
206     8
189
189
400     9
190
 
401     11
 
190
401     10
 
191
402     11
191
192
0       12
192
 
403     13
193
 
404     14
 
193
404     13
 
194
405     14
194
195
delete from t1 where a=0;
195
196
update t1 set a=NULL where b=13;
196
197
ERROR 23000: Column 'a' cannot be null
199
200
a       b
200
201
1       1
201
202
200     2
202
 
201     4
203
 
203     6
 
203
201     3
 
204
202     4
 
205
204     6
204
206
300     7
205
 
205     8
 
207
206     8
206
208
400     9
207
 
401     11
208
 
403     13
 
209
401     10
 
210
402     11
 
211
404     13
209
212
500     14
210
213
drop table t1;
211
214
create table t1 (a bigint);
222
225
create table t1 (a bigint);
223
226
insert into t1 values (1), (2), (3), (0), (0);
224
227
alter table t1 modify a bigint not null auto_increment primary key;
225
 
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '0' for key 'PRIMARY'
226
 
select * from t1;
227
 
a
228
 
1
229
 
2
230
 
3
231
 
0
232
 
0
233
 
drop table t1;
234
 
create table t1 (a bigint);
235
 
insert into t1 values (0), (1), (2), (3);
236
 
alter table t1 modify a bigint not null auto_increment primary key;
237
 
select * from t1;
238
 
a
239
 
0
240
 
1
241
 
2
242
 
3
 
228
select * from t1;
 
229
a
 
230
1
 
231
2
 
232
3
 
233
4
 
234
5
243
235
drop table t1;
244
236
create table t1 (a int auto_increment primary key , b int null);
245
 
insert into t1 values (0,1),(1,2),(2,3);
246
 
select * from t1;
247
 
a       b
248
 
0       1
249
 
1       2
250
 
2       3
251
237
alter table t1 modify b varchar(255);
252
238
insert into t1 values (0,4);
253
 
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
254
239
select * from t1;
255
240
a       b
256
 
0       1
257
 
1       2
258
 
2       3
 
241
1       4
259
242
drop table t1;
260
243
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
261
244
INSERT INTO t1 (b) VALUES ('aaaa');
293
276
  `t1_name` varchar(255) DEFAULT NULL,
294
277
  `t1_id` int NOT NULL AUTO_INCREMENT,
295
278
  PRIMARY KEY (`t1_id`),
296
 
  KEY `t1_name` (`t1_name`(191))
297
 
) ENGINE=InnoDB
 
279
  KEY `t1_name` (`t1_name`())
 
280
) ENGINE=InnoDB AUTO_INCREMENT=1003
298
281
DROP TABLE `t1`;
299
282
create table t1(a int not null auto_increment primary key);
300
283
create table t2(a int not null auto_increment primary key, t1a int);
353
336
INSERT INTO t1 VALUES(0, 0);
354
337
INSERT INTO t1 VALUES(1, 1);
355
338
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
356
 
INSERT INTO t1 VALUES(0,0);
357
 
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
 
339
ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'
358
340
DROP TABLE t1;
359
341
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
360
342
insert into t1 values(null,1,1,now());