~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/delete.result

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
`i2` int NOT NULL default '0',
50
50
PRIMARY KEY  (`i`)
51
51
);
 
52
DELETE FROM t1 USING t1 WHERE post='1';
 
53
ERROR 42S22: Unknown column 'post' in 'where clause'
52
54
drop table t1;
53
 
CREATE TEMPORARY TABLE t1 (
 
55
CREATE TABLE t1 (
54
56
bool     char(0) default NULL,
55
 
not_null varchar(20) NOT NULL default '',
 
57
not_null varchar(20) binary NOT NULL default '',
56
58
misc     integer not null,
57
59
PRIMARY KEY  (not_null)
58
60
) ENGINE=MyISAM;
76
78
count(*)
77
79
0
78
80
drop table t1;
 
81
create table t1 (a int not null auto_increment primary key, b char(32));
 
82
insert into t1 (b) values ('apple'), ('apple');
 
83
select * from t1;
 
84
a       b
 
85
1       apple
 
86
2       apple
 
87
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
 
88
select * from t1;
 
89
a       b
 
90
1       apple
 
91
drop table t1;
79
92
create table t11 (a int NOT NULL, b int, primary key (a));
80
93
create table t12 (a int NOT NULL, b int, primary key (a));
81
94
create table t2 (a int NOT NULL, b int, primary key (a));
97
110
1       21
98
111
2       12
99
112
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
107
 
0       11
108
 
2       12
109
 
33      10
110
 
select * from t11;
111
 
a       b
112
 
0       10
113
 
1       11
114
 
2       12
115
 
select * from t12;
116
 
a       b
117
 
0       11
118
 
2       12
119
 
33      10
 
113
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
 
114
ERROR 21000: Subquery returns more than 1 row
 
115
select * from t11;
 
116
a       b
 
117
0       10
 
118
1       11
 
119
2       12
 
120
select * from t12;
 
121
a       b
 
122
0       11
 
123
2       12
 
124
33      10
 
125
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
 
126
Warnings:
 
127
Error   1242    Subquery returns more than 1 row
 
128
select * from t11;
 
129
a       b
 
130
0       10
 
131
1       11
 
132
select * from t12;
 
133
a       b
 
134
0       11
 
135
33      10
 
136
insert into t11 values (2, 12);
120
137
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
121
138
ERROR 21000: Subquery returns more than 1 row
122
139
select * from t11;
135
152
drop table t11, t12, t2;
136
153
create table t1 (a int, b int, unique key (a), key (b));
137
154
insert into t1 values (3, 3), (7, 7);
138
 
delete from t1 where a = 3;
 
155
delete t1 from t1 where a = 3;
139
156
check table t1;
140
157
Table   Op      Msg_type        Msg_text
141
158
test.t1 check   status  OK
152
169
0
153
170
2
154
171
DROP TABLE t1;
 
172
create table t1 (a int);
 
173
delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
 
174
delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
 
175
drop table t1;
155
176
create table t1(f1 int primary key);
156
177
insert into t1 values (4),(3),(1),(2);
157
178
delete from t1 where (@a:= f1) order by f1 limit 1;
169
190
DELETE FROM t1 ORDER BY date ASC LIMIT 1;
170
191
drop table t1;
171
192
End of 4.1 tests
 
193
CREATE TABLE t1 (a int not null,b int not null);
 
194
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
 
195
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
 
196
insert into t1 values (1,1),(2,1),(1,3);
 
197
insert into t2 values (1,1),(2,2),(3,3);
 
198
insert into t3 values (1,1),(2,1),(1,3);
 
199
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
 
200
a       b       a       b       a       b
 
201
1       1       1       1       1       1
 
202
2       1       2       2       2       1
 
203
1       3       1       1       1       3
 
204
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
 
205
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
206
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       
 
207
1       SIMPLE  t2      ref     PRIMARY PRIMARY 4       test.t1.a       1       Using index
 
208
1       SIMPLE  t3      eq_ref  PRIMARY PRIMARY 8       test.t2.b,test.t1.b     1       Using index
 
209
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
 
210
select * from t3;
 
211
a       b
 
212
drop table t1,t2,t3;
172
213
CREATE TABLE t1 (a INT);
173
214
INSERT INTO t1 VALUES (1);
174
215
DELETE FROM t1 ORDER BY x;
194
235
a INT
195
236
);
196
237
INSERT INTO db2.t1 (a) SELECT * FROM t2;
 
238
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
 
239
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
 
240
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
 
241
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
 
242
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
 
243
ERROR 42S02: Unknown table 't2' in MULTI DELETE
 
244
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
 
245
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
 
246
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
 
247
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
 
248
ERROR 42S02: Unknown table 'alias' in MULTI DELETE
 
249
DELETE FROM t1 USING t1 WHERE a = 1;
197
250
SELECT * FROM t1;
198
251
a
199
252
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
219
272
CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
220
273
CREATE TABLE t1 AS SELECT * FROM db2.t2;
221
274
CREATE TABLE t2 AS SELECT * FROM t1;
 
275
CREATE DATABASE db3;
 
276
USE db3;
 
277
DROP DATABASE db3;
 
278
SELECT * FROM t1;
 
279
ERROR 3D000: No database selected
 
280
DELETE a1,a2 FROM db1.t1, db2.t2;
 
281
ERROR 3D000: No database selected
 
282
DELETE a1,a2 FROM db1.t1, db2.t2;
 
283
ERROR 3D000: No database selected
 
284
DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
 
285
ERROR 3D000: No database selected
 
286
DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
 
287
ERROR 3D000: No database selected
 
288
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
 
289
ERROR 3D000: No database selected
 
290
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
 
291
ERROR 3D000: No database selected
 
292
DELETE FROM a1,a2 USING db1.t1, db2.t2;
 
293
ERROR 3D000: No database selected
 
294
DELETE FROM a1,a2 USING db1.t1, db2.t2;
 
295
ERROR 3D000: No database selected
 
296
DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
 
297
ERROR 3D000: No database selected
 
298
DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
 
299
ERROR 3D000: No database selected
 
300
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
 
301
ERROR 3D000: No database selected
 
302
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
 
303
ERROR 3D000: No database selected
 
304
DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
 
305
ERROR 3D000: No database selected
 
306
DELETE a1 FROM db1.a1, db2.t2 AS a1;
 
307
ERROR 3D000: No database selected
 
308
DELETE a1 FROM a1, db1.t1 AS a1;
 
309
ERROR 3D000: No database selected
 
310
DELETE t1 FROM db1.t1, db2.t1 AS a1;
 
311
ERROR 3D000: No database selected
 
312
DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
 
313
ERROR 3D000: No database selected
 
314
DELETE t1 FROM db1.t1, db2.t1;
 
315
ERROR 3D000: No database selected
 
316
USE test;
 
317
DELETE a1,a2 FROM db1.t1, db2.t2;
 
318
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
319
DELETE a1,a2 FROM db1.t1, db2.t2;
 
320
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
321
DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
 
322
ERROR 42S02: Unknown table 'a2' in MULTI DELETE
 
323
DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
 
324
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
325
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
 
326
ERROR 42S02: Table 'db3.t1' doesn't exist
 
327
DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
 
328
ERROR 42S02: Table 'db3.t1' doesn't exist
 
329
DELETE FROM a1,a2 USING db1.t1, db2.t2;
 
330
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
331
DELETE FROM a1,a2 USING db1.t1, db2.t2;
 
332
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
333
DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
 
334
ERROR 42S02: Unknown table 'a2' in MULTI DELETE
 
335
DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
 
336
ERROR 42S02: Unknown table 'a1' in MULTI DELETE
 
337
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
 
338
ERROR 42S02: Table 'db3.t1' doesn't exist
 
339
DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
 
340
ERROR 42S02: Table 'db3.t1' doesn't exist
 
341
DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
 
342
ERROR 42000: Not unique table/alias: 'a1'
 
343
DELETE a1 FROM db1.a1, db2.t2 AS a1;
 
344
ERROR 42S02: Table 'db1.a1' doesn't exist
 
345
DELETE a1 FROM a1, db1.t1 AS a1;
 
346
ERROR 42000: Not unique table/alias: 'a1'
 
347
DELETE t1 FROM db1.t1, db2.t1 AS a1;
 
348
ERROR 42S02: Unknown table 't1' in MULTI DELETE
 
349
DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
 
350
ERROR 42S02: Unknown table 't1' in MULTI DELETE
 
351
DELETE t1 FROM db1.t1, db2.t1;
 
352
ERROR 42S02: Unknown table 't1' in MULTI DELETE
 
353
DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a;
 
354
SELECT ROW_COUNT();
 
355
ROW_COUNT()
 
356
1
 
357
DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2;
 
358
SELECT ROW_COUNT();
 
359
ROW_COUNT()
 
360
2
222
361
DROP DATABASE db1;
223
362
DROP DATABASE db2;
224
363
DROP TABLE t1, t2;