~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/delete.result

  • Committer: Jay Pipes
  • Date: 2009-08-05 19:17:08 UTC
  • mfrom: (1111 staging)
  • mto: (1115.3.12 captain)
  • mto: This revision was merged to the branch mainline in revision 1112.
  • Revision ID: jpipes@serialcoder-20090805191708-9mawjpke3fe3i7j6
Merge trunk

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'
54
52
drop table t1;
55
53
CREATE TEMPORARY TABLE t1 (
56
54
bool     char(0) default NULL,
78
76
count(*)
79
77
0
80
78
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;
92
79
create table t11 (a int NOT NULL, b int, primary key (a));
93
80
create table t12 (a int NOT NULL, b int, primary key (a));
94
81
create table t2 (a int NOT NULL, b int, primary key (a));
110
97
1       21
111
98
2       12
112
99
3       23
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);
 
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
137
120
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
138
121
ERROR 21000: Subquery returns more than 1 row
139
122
select * from t11;
152
135
drop table t11, t12, t2;
153
136
create table t1 (a int, b int, unique key (a), key (b));
154
137
insert into t1 values (3, 3), (7, 7);
155
 
delete t1 from t1 where a = 3;
 
138
delete from t1 where a = 3;
156
139
check table t1;
157
140
Table   Op      Msg_type        Msg_text
158
141
test.t1 check   status  OK
169
152
0
170
153
2
171
154
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;
176
155
create table t1(f1 int primary key);
177
156
insert into t1 values (4),(3),(1),(2);
178
157
delete from t1 where (@a:= f1) order by f1 limit 1;
190
169
DELETE FROM t1 ORDER BY date ASC LIMIT 1;
191
170
drop table t1;
192
171
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;
213
172
CREATE TABLE t1 (a INT);
214
173
INSERT INTO t1 VALUES (1);
215
174
DELETE FROM t1 ORDER BY x;
235
194
a INT
236
195
);
237
196
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;
250
197
SELECT * FROM t1;
251
198
a
252
199
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
272
219
CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
273
220
CREATE TABLE t1 AS SELECT * FROM db2.t2;
274
221
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
361
 
DROP DATABASE db1;
362
 
DROP DATABASE db2;
363
 
DROP TABLE t1, t2;