~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2,t3,t11,t12;
396 by Brian Aker
Cleanup tiny and small int.
2
CREATE TABLE t1 (a int, b int);
1 by brian
clean slate
3
INSERT INTO t1 VALUES (1,1);
4
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
5
INSERT INTO t1 VALUES (1,3);
6
DELETE from t1 where a=1 limit 1;
7
DELETE LOW_PRIORITY from t1 where a=1;
8
INSERT INTO t1 VALUES (1,1);
9
DELETE from t1;
10
LOCK TABLE t1 write;
11
INSERT INTO t1 VALUES (1,2);
12
DELETE from t1;
13
UNLOCK TABLES;
14
INSERT INTO t1 VALUES (1,2);
15
SET AUTOCOMMIT=0;
16
DELETE from t1;
17
SET AUTOCOMMIT=1;
18
drop table t1;
19
create table t1 (
20
a bigint not null,
21
b bigint not null default 0,
22
c bigint not null default 0,
23
d bigint not null default 0,
24
e bigint not null default 0,
25
f bigint not null default 0,
26
g bigint not null default 0,
27
h bigint not null default 0,
28
i bigint not null default 0,
29
j bigint not null default 0,
30
primary key (a,b,c,d,e,f,g,h,i,j));
31
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
32
delete from t1 where a=26;
33
drop table t1;
34
create table t1 (
35
a bigint not null,
36
b bigint not null default 0,
37
c bigint not null default 0,
38
d bigint not null default 0,
39
e bigint not null default 0,
40
f bigint not null default 0,
41
g bigint not null default 0,
42
h bigint not null default 0,
43
i bigint not null default 0,
44
j bigint not null default 0,
45
primary key (a,b,c,d,e,f,g,h,i,j));
46
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
47
delete from t1 where a=27;
48
drop table t1;
49
CREATE TABLE `t1` (
223 by Brian Aker
Cleanup int() work.
50
`i` int NOT NULL default '0',
51
`i2` int NOT NULL default '0',
1 by brian
clean slate
52
PRIMARY KEY  (`i`)
53
);
54
DELETE FROM t1 USING t1 WHERE post='1';
55
ERROR 42S22: Unknown column 'post' in 'where clause'
56
drop table t1;
57
CREATE TABLE t1 (
58
bool     char(0) default NULL,
59
not_null varchar(20) binary NOT NULL default '',
60
misc     integer not null,
61
PRIMARY KEY  (not_null)
62
) ENGINE=MyISAM;
63
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
64
select * from t1 where misc > 5 and bool is null;
65
bool	not_null	misc
66
NULL	c	6
67
NULL	d	7
68
delete   from t1 where misc > 5 and bool is null;
69
select * from t1 where misc > 5 and bool is null;
70
bool	not_null	misc
71
select count(*) from t1;
72
count(*)
73
2
74
delete from t1 where 1 > 2;
75
select count(*) from t1;
76
count(*)
77
2
78
delete from t1 where 3 > 2;
79
select count(*) from t1;
80
count(*)
81
0
82
drop table t1;
83
create table t1 (a int not null auto_increment primary key, b char(32));
84
insert into t1 (b) values ('apple'), ('apple');
85
select * from t1;
86
a	b
87
1	apple
88
2	apple
89
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
90
select * from t1;
91
a	b
92
1	apple
93
drop table t1;
94
create table t11 (a int NOT NULL, b int, primary key (a));
95
create table t12 (a int NOT NULL, b int, primary key (a));
96
create table t2 (a int NOT NULL, b int, primary key (a));
97
insert into t11 values (0, 10),(1, 11),(2, 12);
98
insert into t12 values (33, 10),(0, 11),(2, 12);
99
insert into t2 values (1, 21),(2, 12),(3, 23);
100
select * from t11;
101
a	b
102
0	10
103
1	11
104
2	12
105
select * from t12;
106
a	b
201 by Brian Aker
Convert default engine to Innodb
107
0	11
108
2	12
1 by brian
clean slate
109
33	10
110
select * from t2;
111
a	b
112
1	21
113
2	12
114
3	23
115
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
116
ERROR 21000: Subquery returns more than 1 row
117
select * from t11;
118
a	b
119
0	10
120
1	11
121
2	12
122
select * from t12;
123
a	b
201 by Brian Aker
Convert default engine to Innodb
124
0	11
125
2	12
1 by brian
clean slate
126
33	10
127
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
128
Warnings:
129
Error	1242	Subquery returns more than 1 row
130
select * from t11;
131
a	b
132
0	10
133
1	11
134
select * from t12;
135
a	b
201 by Brian Aker
Convert default engine to Innodb
136
0	11
1 by brian
clean slate
137
33	10
138
insert into t11 values (2, 12);
139
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
140
ERROR 21000: Subquery returns more than 1 row
141
select * from t11;
142
a	b
143
0	10
144
1	11
145
2	12
146
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
147
Warnings:
148
Error	1242	Subquery returns more than 1 row
149
Error	1242	Subquery returns more than 1 row
150
select * from t11;
151
a	b
152
0	10
153
1	11
154
drop table t11, t12, t2;
155
create table t1 (a int, b int, unique key (a), key (b));
156
insert into t1 values (3, 3), (7, 7);
157
delete t1 from t1 where a = 3;
158
check table t1;
159
Table	Op	Msg_type	Msg_text
160
test.t1	check	status	OK
161
select * from t1;
162
a	b
163
7	7
164
drop table t1;
165
CREATE TABLE t1 ( a int PRIMARY KEY );
166
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
167
INSERT INTO t1 VALUES (0),(1),(2);
168
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
169
SELECT * FROM t1;
170
a
171
0
172
2
173
DROP TABLE t1;
174
create table t1 (a int);
175
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
176
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
177
drop table t1;
178
create table t1(f1 int primary key);
179
insert into t1 values (4),(3),(1),(2);
180
delete from t1 where (@a:= f1) order by f1 limit 1;
181
select @a;
182
@a
183
1
184
drop table t1;
185
CREATE TABLE t1 (
186
`date` date ,
187
`time` time ,
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
188
`seq` int NOT NULL auto_increment,
1 by brian
clean slate
189
PRIMARY KEY  (`seq`),
190
KEY `seq` (`seq`),
191
KEY `time` (`time`),
192
KEY `date` (`date`)
193
);
194
DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
195
drop table t1;
196
End of 4.1 tests
197
CREATE TABLE t1 (a int not null,b int not null);
198
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
199
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
200
insert into t1 values (1,1),(2,1),(1,3);
201
insert into t2 values (1,1),(2,2),(3,3);
202
insert into t3 values (1,1),(2,1),(1,3);
203
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
204
a	b	a	b	a	b
205
1	1	1	1	1	1
206
2	1	2	2	2	1
207
1	3	1	1	1	3
208
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
209
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
210
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
211
1	SIMPLE	t2	ref	PRIMARY	PRIMARY	4	test.t1.a	1	Using index
212
1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	8	test.t2.b,test.t1.b	1	Using index
213
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
214
select * from t3;
215
a	b
216
drop table t1,t2,t3;
217
create table t1(a date not null);
218
insert into t1 values (0);
219
select * from t1 where a is null;
220
a
221
0000-00-00
222
delete from t1 where a is null;
223
select count(*) from t1;
224
count(*)
225
0
226
drop table t1;
227
CREATE TABLE t1 (a INT);
228
INSERT INTO t1 VALUES (1);
229
DELETE FROM t1 ORDER BY x;
230
ERROR 42S22: Unknown column 'x' in 'order clause'
231
DELETE FROM t1 ORDER BY t2.x;
232
ERROR 42S22: Unknown column 't2.x' in 'order clause'
233
DELETE FROM t1 ORDER BY (SELECT x);
234
ERROR 42S22: Unknown column 'x' in 'field list'
235
DROP TABLE t1;
236
CREATE TABLE t1 (
237
a INT
238
);
239
CREATE TABLE t2 (
240
a INT
241
);
242
CREATE DATABASE db1;
243
CREATE TABLE db1.t1 (
244
a INT
245
);
246
INSERT INTO db1.t1 (a) SELECT * FROM t1;
247
CREATE DATABASE db2;
248
CREATE TABLE db2.t1 (
249
a INT
250
);
251
INSERT INTO db2.t1 (a) SELECT * FROM t2;
252
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
629.2.6 by Monty
Updated test output with new and improved error messages.
253
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'alias USING t1, t2 alias WHERE t1.a = alias.a' at line 1
1 by brian
clean slate
254
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
255
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
256
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
257
ERROR 42S02: Unknown table 't2' in MULTI DELETE
258
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
629.2.6 by Monty
Updated test output with new and improved error messages.
259
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
1 by brian
clean slate
260
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
261
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
262
ERROR 42S02: Unknown table 'alias' in MULTI DELETE
263
DELETE FROM t1 USING t1 WHERE a = 1;
264
SELECT * FROM t1;
265
a
266
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
629.2.6 by Monty
Updated test output with new and improved error messages.
267
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'alias USING t1 alias WHERE a = 2' at line 1
1 by brian
clean slate
268
SELECT * FROM t1;
269
a
270
DROP TABLE t1, t2;
271
DROP DATABASE db1;
272
DROP DATABASE db2;
273
End of 5.0 tests
274
DROP DATABASE IF EXISTS db1;
275
DROP DATABASE IF EXISTS db2;
276
DROP DATABASE IF EXISTS db3;
277
DROP DATABASE IF EXISTS db4;
278
DROP TABLE IF EXISTS t1, t2;
279
USE test;
280
CREATE DATABASE db1;
281
CREATE DATABASE db2;
282
CREATE TABLE db1.t1 (a INT, b INT);
283
INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3);
284
CREATE TABLE db1.t2 AS SELECT * FROM db1.t1;
285
CREATE TABLE db2.t1 AS SELECT * FROM db1.t2;
286
CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
287
CREATE TABLE t1 AS SELECT * FROM db2.t2;
288
CREATE TABLE t2 AS SELECT * FROM t1;
289
CREATE DATABASE db3;
290
USE db3;
291
DROP DATABASE db3;
292
SELECT * FROM t1;
293
ERROR 3D000: No database selected
294
DELETE a1,a2 FROM db1.t1, db2.t2;
295
ERROR 3D000: No database selected
296
DELETE a1,a2 FROM db1.t1, db2.t2;
297
ERROR 3D000: No database selected
298
DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
299
ERROR 3D000: No database selected
300
DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
301
ERROR 3D000: No database selected
302
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
303
ERROR 3D000: No database selected
304
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
305
ERROR 3D000: No database selected
306
DELETE FROM a1,a2 USING db1.t1, db2.t2;
307
ERROR 3D000: No database selected
308
DELETE FROM a1,a2 USING db1.t1, db2.t2;
309
ERROR 3D000: No database selected
310
DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
311
ERROR 3D000: No database selected
312
DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
313
ERROR 3D000: No database selected
314
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
315
ERROR 3D000: No database selected
316
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
317
ERROR 3D000: No database selected
318
DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
319
ERROR 3D000: No database selected
320
DELETE a1 FROM db1.a1, db2.t2 AS a1;
321
ERROR 3D000: No database selected
322
DELETE a1 FROM a1, db1.t1 AS a1;
323
ERROR 3D000: No database selected
324
DELETE t1 FROM db1.t1, db2.t1 AS a1;
325
ERROR 3D000: No database selected
326
DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
327
ERROR 3D000: No database selected
328
DELETE t1 FROM db1.t1, db2.t1;
329
ERROR 3D000: No database selected
330
USE test;
331
DELETE a1,a2 FROM db1.t1, db2.t2;
332
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
333
DELETE a1,a2 FROM db1.t1, db2.t2;
334
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
335
DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
336
ERROR 42S02: Unknown table 'a2' in MULTI DELETE
337
DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
338
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
339
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
340
ERROR 42S02: Table 'db3.t1' doesn't exist
341
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
342
ERROR 42S02: Table 'db3.t1' doesn't exist
343
DELETE FROM a1,a2 USING db1.t1, db2.t2;
344
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
345
DELETE FROM a1,a2 USING db1.t1, db2.t2;
346
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
347
DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
348
ERROR 42S02: Unknown table 'a2' in MULTI DELETE
349
DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
350
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
351
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
352
ERROR 42S02: Table 'db3.t1' doesn't exist
353
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
354
ERROR 42S02: Table 'db3.t1' doesn't exist
355
DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
356
ERROR 42000: Not unique table/alias: 'a1'
357
DELETE a1 FROM db1.a1, db2.t2 AS a1;
358
ERROR 42S02: Table 'db1.a1' doesn't exist
359
DELETE a1 FROM a1, db1.t1 AS a1;
360
ERROR 42000: Not unique table/alias: 'a1'
361
DELETE t1 FROM db1.t1, db2.t1 AS a1;
362
ERROR 42S02: Unknown table 't1' in MULTI DELETE
363
DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
364
ERROR 42S02: Unknown table 't1' in MULTI DELETE
365
DELETE t1 FROM db1.t1, db2.t1;
366
ERROR 42S02: Unknown table 't1' in MULTI DELETE
367
DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a;
368
SELECT ROW_COUNT();
369
ROW_COUNT()
370
1
371
DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2;
372
SELECT ROW_COUNT();
373
ROW_COUNT()
374
2
375
DROP DATABASE db1;
376
DROP DATABASE db2;
377
DROP TABLE t1, t2;