~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1;
2
drop table if exists t2;
3
SET SQL_WARNINGS=1;
1063.9.3 by Brian Aker
Partial fix for tests for tmp
4
create TEMPORARY table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
1 by brian
clean slate
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;
1273.19.12 by Brian Aker
Enabled more tests.
15
show table status like "t1";
1320.1.18 by Brian Aker
Overhaul of SHOW TABLE STATUS.
16
Session	Schema	Name	Type	Engine	Version	Rows	Avg_row_length	Table_size	Auto_increment
17
#	test	t1	TEMPORARY	MyISAM	#	#	#	#	#
1 by brian
clean slate
18
replace t1 values (3,1);
19
ALTER TABLE t1 add c int;
20
replace t1 values (3,3,3);
21
insert into t1 values (NULL,7,7);
22
update t1 set a=8,b=b+1,c=c+1 where a=7;
23
insert into t1 values (NULL,9,9);
24
select * from t1;
25
a	b	c
26
1	1	NULL
27
3	3	3
28
5	5	NULL
29
8	8	8
30
9	9	9
31
drop table t1;
32
create table t1 (
642.1.71 by Lee
merge with latest from the trunk
33
skey int NOT NULL auto_increment PRIMARY KEY,
1 by brian
clean slate
34
sval char(20)
35
);
36
insert into t1 values (NULL, "hello");
37
insert into t1 values (NULL, "hey");
38
select * from t1;
39
skey	sval
40
1	hello
41
2	hey
42
select _rowid,t1._rowid,skey,sval from t1;
43
_rowid	_rowid	skey	sval
44
1	1	1	hello
45
2	2	2	hey
46
drop table t1;
47
create table t1 (a int not null primary key auto_increment);
48
insert into t1 values (0);
49
update t1 set a=0;
50
select * from t1;
51
a
52
0
53
check table t1;
54
Table	Op	Msg_type	Msg_text
55
test.t1	check	status	OK
56
drop table t1;
57
create table t1 (a int not null auto_increment primary key);
58
insert into t1 values (NULL);
59
insert into t1 values (-1);
60
select last_insert_id();
61
last_insert_id()
62
1
63
insert into t1 values (NULL);
64
select * from t1;
65
a
66
-1
67
1
68
2
69
drop table t1;
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
70
create temporary table t1 (a int not null auto_increment primary key) /*!40102 engine=MEMORY */;
1 by brian
clean slate
71
insert into t1 values (NULL);
72
insert into t1 values (-1);
73
select last_insert_id();
74
last_insert_id()
75
1
76
insert into t1 values (NULL);
77
select * from t1;
78
a
79
1
80
-1
81
2
82
drop table t1;
642.1.71 by Lee
merge with latest from the trunk
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));
1 by brian
clean slate
95
insert into t1 values (NULL, 10);
96
select last_insert_id();
97
last_insert_id()
98
1
99
insert into t1 values (NULL, 15);
100
select last_insert_id();
101
last_insert_id()
102
2
103
insert into t1 values (NULL, 10);
104
ERROR 23000: Duplicate entry '10' for key 'b'
105
select last_insert_id();
106
last_insert_id()
107
2
108
drop table t1;
109
create table t1(a int auto_increment,b int null,primary key(a));
110
insert into t1(a,b)values(NULL,1);
111
insert into t1(a,b)values(200,2);
112
insert into t1(a,b)values(0,3);
113
insert into t1(b)values(4);
114
insert into t1(b)values(5);
115
insert into t1(b)values(6);
116
insert into t1(b)values(7);
117
select * from t1 order by b;
118
a	b
119
1	1
120
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
121
0	3
122
201	4
123
202	5
124
203	6
125
204	7
642.1.71 by Lee
merge with latest from the trunk
126
alter table t1 modify b int;
1 by brian
clean slate
127
select * from t1 order by b;
128
a	b
129
1	1
130
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
131
0	3
132
201	4
133
202	5
134
203	6
135
204	7
1 by brian
clean slate
136
create table t2 (a int);
137
insert t2 values (1),(2);
138
alter table t2 add b int auto_increment primary key;
139
select * from t2;
140
a	b
141
1	1
142
2	2
143
drop table t2;
144
delete from t1 where a=0;
145
update t1 set a=0 where b=5;
146
select * from t1 order by b;
147
a	b
148
1	1
149
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
150
201	4
1 by brian
clean slate
151
0	5
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
152
203	6
153
204	7
1 by brian
clean slate
154
delete from t1 where a=0;
155
update t1 set a=NULL where b=6;
156
ERROR 23000: Column 'a' cannot be null
157
update t1 set a=300 where b=7;
158
insert into t1(a,b)values(NULL,8);
159
insert into t1(a,b)values(400,9);
160
insert into t1(a,b)values(0,10);
161
insert into t1(b)values(11);
162
insert into t1(b)values(12);
163
insert into t1(b)values(13);
164
insert into t1(b)values(14);
165
select * from t1 order by b;
166
a	b
167
1	1
168
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
169
201	4
170
203	6
1 by brian
clean slate
171
300	7
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
172
205	8
1 by brian
clean slate
173
400	9
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
174
0	10
175
401	11
176
402	12
177
403	13
178
404	14
1 by brian
clean slate
179
delete from t1 where a=0;
180
update t1 set a=0 where b=12;
181
select * from t1 order by b;
182
a	b
183
1	1
184
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
185
201	4
186
203	6
1 by brian
clean slate
187
300	7
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
188
205	8
1 by brian
clean slate
189
400	9
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
190
401	11
1 by brian
clean slate
191
0	12
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
192
403	13
193
404	14
1 by brian
clean slate
194
delete from t1 where a=0;
195
update t1 set a=NULL where b=13;
196
ERROR 23000: Column 'a' cannot be null
197
update t1 set a=500 where b=14;
198
select * from t1 order by b;
199
a	b
200
1	1
201
200	2
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
202
201	4
203
203	6
1 by brian
clean slate
204
300	7
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
205
205	8
1 by brian
clean slate
206
400	9
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
207
401	11
208
403	13
1 by brian
clean slate
209
500	14
210
drop table t1;
211
create table t1 (a bigint);
212
insert into t1 values (1), (2), (3), (NULL), (NULL);
213
alter table t1 modify a bigint not null auto_increment primary key;
214
select * from t1;
215
a
216
1
217
2
218
3
219
4
220
5
221
drop table t1;
222
create table t1 (a bigint);
223
insert into t1 values (1), (2), (3), (0), (0);
224
alter table t1 modify a bigint not null auto_increment primary key;
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
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
1 by brian
clean slate
243
drop table t1;
244
create table t1 (a int auto_increment primary key , b int null);
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
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
1 by brian
clean slate
251
alter table t1 modify b varchar(255);
252
insert into t1 values (0,4);
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
253
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
1 by brian
clean slate
254
select * from t1;
255
a	b
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
256
0	1
257
1	2
258
2	3
1 by brian
clean slate
259
drop table t1;
260
CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10)));
261
INSERT INTO t1 (b) VALUES ('aaaa');
262
CHECK TABLE t1;
263
Table	Op	Msg_type	Msg_text
264
test.t1	check	status	OK
265
INSERT INTO t1 (b) VALUES ('');
266
CHECK TABLE t1;
267
Table	Op	Msg_type	Msg_text
268
test.t1	check	status	OK
269
INSERT INTO t1 (b) VALUES ('bbbb');
270
CHECK TABLE t1;
271
Table	Op	Msg_type	Msg_text
272
test.t1	check	status	OK
273
DROP TABLE IF EXISTS t1;
642.1.71 by Lee
merge with latest from the trunk
274
CREATE TABLE t1 (
1 by brian
clean slate
275
t1_name VARCHAR(255) DEFAULT NULL,
642.1.71 by Lee
merge with latest from the trunk
276
t1_id INT not null AUTO_INCREMENT,
1 by brian
clean slate
277
KEY (t1_name),
278
PRIMARY KEY (t1_id)
279
) AUTO_INCREMENT = 1000;
642.1.71 by Lee
merge with latest from the trunk
280
Warnings:
281
Warning	1071	Specified key was too long; max key length is 767 bytes
1 by brian
clean slate
282
INSERT INTO t1 (t1_name) VALUES('MySQL');
283
INSERT INTO t1 (t1_name) VALUES('MySQL');
284
INSERT INTO t1 (t1_name) VALUES('MySQL');
285
SELECT * from t1;
286
t1_name	t1_id
287
MySQL	1000
288
MySQL	1001
289
MySQL	1002
290
SHOW CREATE TABLE `t1`;
291
Table	Create Table
292
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
293
  `t1_name` varchar(255) DEFAULT NULL,
642.1.71 by Lee
merge with latest from the trunk
294
  `t1_id` int NOT NULL AUTO_INCREMENT,
1 by brian
clean slate
295
  PRIMARY KEY (`t1_id`),
1008.3.10 by Stewart Smith
fix test result now that I fixed SHOW CREATE TABLE
296
  KEY `t1_name` (`t1_name`(191))
1116.1.3 by Brian Aker
Small cleanup (behavior change to remove auto from output of show create
297
) ENGINE=InnoDB
1 by brian
clean slate
298
DROP TABLE `t1`;
299
create table t1(a int not null auto_increment primary key);
300
create table t2(a int not null auto_increment primary key, t1a int);
301
insert into t1 values(NULL);
302
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
303
insert into t1 values (NULL);
304
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
305
(NULL, LAST_INSERT_ID());
306
insert into t1 values (NULL);
307
insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
308
(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
309
select * from t2;
310
a	t1a
311
1	1
312
2	1
313
3	2
314
4	2
315
5	2
316
6	3
317
7	3
318
8	3
319
9	3
320
drop table t1, t2;
321
End of 4.1 tests
642.1.71 by Lee
merge with latest from the trunk
322
CREATE TABLE t1 ( `a` int NOT NULL auto_increment, `b` int default NULL,PRIMARY KEY  (`a`),UNIQUE KEY `b` (`b`));
1 by brian
clean slate
323
insert into t1 (b) values (1);
324
replace into t1 (b) values (2), (1), (3);
325
select * from t1;
326
a	b
642.1.71 by Lee
merge with latest from the trunk
327
2	2
1 by brian
clean slate
328
3	1
329
4	3
330
truncate table t1;
331
insert into t1 (b) values (1);
332
replace into t1 (b) values (2);
333
replace into t1 (b) values (1);
334
replace into t1 (b) values (3);
335
select * from t1;
336
a	b
642.1.71 by Lee
merge with latest from the trunk
337
2	2
1 by brian
clean slate
338
3	1
339
4	3
340
drop table t1;
341
create table t1 (rowid int not null auto_increment, val int not null,primary
342
key (rowid), unique(val));
343
replace into t1 (val) values ('1'),('2');
344
replace into t1 (val) values ('1'),('2');
345
insert into t1 (val) values ('1'),('2');
346
ERROR 23000: Duplicate entry '1' for key 'val'
347
select * from t1;
348
rowid	val
349
3	1
350
4	2
351
drop table t1;
642.1.71 by Lee
merge with latest from the trunk
352
CREATE TABLE t1 (t1 INT PRIMARY KEY, t2 INT);
1 by brian
clean slate
353
INSERT INTO t1 VALUES(0, 0);
354
INSERT INTO t1 VALUES(1, 1);
642.1.71 by Lee
merge with latest from the trunk
355
ALTER TABLE t1 CHANGE t1 t1 INT auto_increment;
1008.3.2 by Stewart Smith
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.
356
INSERT INTO t1 VALUES(0,0);
357
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
1 by brian
clean slate
358
DROP TABLE t1;
359
create table t1 (a int primary key auto_increment, b int, c int, d timestamp default current_timestamp, unique(b),unique(c));
360
insert into t1 values(null,1,1,now());
361
insert into t1 values(null,0,0,null);
362
replace into t1 values(null,1,0,null);
363
select last_insert_id();
364
last_insert_id()
365
3
366
drop table t1;