~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Test of update statement that uses many tables.
3
#
4
5
source include/have_log_bin.inc;
6
7
--disable_warnings
8
drop table if exists t1,t2,t3;
9
drop database if exists mysqltest;
10
drop view if exists v1;
11
--error 0,1141,1147
12
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
13
--error 0,1141,1147
14
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
15
delete from mysql.user where user=_binary'mysqltest_1';
16
--enable_warnings
17
18
create table t1(id1 int not null auto_increment primary key, t char(12));
19
create table t2(id2 int not null, t char(12));
20
create table t3(id3 int not null, t char(12), index(id3));
21
disable_query_log;
22
let $1 = 100;
23
while ($1)
24
 {
25
  let $2 = 5;
26
  eval insert into t1(t) values ('$1'); 
27
  while ($2)
28
   {
29
     eval insert into t2(id2,t) values ($1,'$2'); 
30
     let $3 = 10;
31
     while ($3)
32
     {
33
       eval insert into t3(id3,t) values ($1,'$2'); 
34
       dec $3;
35
     }
36
     dec $2; 
37
   }
38
  dec $1;
39
 }
40
enable_query_log;
41
42
select count(*) from t1 where id1 > 95;
43
select count(*) from t2 where id2 > 95;
44
select count(*) from t3 where id3 > 95;
45
46
update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where  t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 90;
47
select count(*) from t1 where t = "aaa";
48
select count(*) from t1 where id1 > 90;
49
select count(*) from t2 where t = "bbb";
50
select count(*) from t2 where id2 > 90;
51
select count(*) from t3 where t = "cc";
52
select count(*) from t3 where id3 > 90;
53
delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
54
55
check table t1, t2, t3;
56
57
select count(*) from t1 where id1 > 95;
58
select count(*) from t2 where id2 > 95;
59
select count(*) from t3 where id3 > 95;
60
61
delete t1, t2, t3  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 5;
62
select count(*) from t1 where id1 > 5;
63
select count(*) from t2 where id2 > 5;
64
select count(*) from t3 where id3 > 5;
65
66
delete from t1, t2, t3  using t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 0;
67
68
# These queries will force a scan of the table
69
select count(*) from t1 where id1;
70
select count(*) from t2 where id2;
71
select count(*) from t3 where id3;
72
drop table t1,t2,t3;
73
74
create table t1(id1 int not null  primary key, t varchar(100)) pack_keys = 1;
75
create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1;
76
disable_query_log;
77
let $1 = 1000;
78
while ($1)
79
 {
80
  let $2 = 5;
81
  eval insert into t1 values ($1,'aaaaaaaaaaaaaaaaaaaa'); 
82
  while ($2)
83
   {
84
     eval insert into t2(id2,t) values ($1,'bbbbbbbbbbbbbbbbb'); 
85
     dec $2; 
86
   }
87
  dec $1;
88
 }
89
enable_query_log;
90
delete t1  from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500;
91
drop table t1,t2;
92
93
CREATE TABLE t1 (
94
  id int(11) NOT NULL default '0',
95
  name varchar(10) default NULL,
96
  PRIMARY KEY  (id)
97
) ENGINE=MyISAM;
98
INSERT INTO t1 VALUES (1,'aaa'),(2,'aaa'),(3,'aaa');
99
CREATE TABLE t2 (
100
  id int(11) NOT NULL default '0',
101
  name varchar(10) default NULL,
102
  PRIMARY KEY  (id)
103
) ENGINE=MyISAM;
104
INSERT INTO t2 VALUES (2,'bbb'),(3,'bbb'),(4,'bbb');
105
CREATE TABLE t3 (
106
  id int(11) NOT NULL default '0',
107
  mydate datetime default NULL,
108
  PRIMARY KEY  (id)
109
) ENGINE=MyISAM;
110
INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22
111
00:00:00'),(7,'2002-07-22 00:00:00');
112
delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id;
113
select * from t3;
114
DROP TABLE t1,t2,t3;
115
116
CREATE TABLE IF NOT EXISTS `t1` (
117
  `id` int(11) NOT NULL auto_increment,
118
  `tst` text,
119
  `tst1` text,
120
  PRIMARY KEY  (`id`)
121
) ENGINE=MyISAM;
122
123
CREATE TABLE IF NOT EXISTS `t2` (
124
  `ID` int(11) NOT NULL auto_increment,
125
  `ParId` int(11) default NULL,
126
  `tst` text,
127
  `tst1` text,
128
  PRIMARY KEY  (`ID`),
129
  KEY `IX_ParId_t2` (`ParId`),
130
  FOREIGN KEY (`ParId`) REFERENCES `t1` (`id`)
131
) ENGINE=MyISAM;
132
133
INSERT INTO t1(tst,tst1) VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE");
134
135
INSERT INTO t2(ParId) VALUES(1), (2), (3);
136
137
select * from t2;
138
139
UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id;
140
141
select * from t2;
142
drop table t1, t2 ;
143
144
create table t1 (n numeric(10));
145
create table t2 (n numeric(10));
146
insert into t2 values (1),(2),(4),(8),(16),(32);
147
select * from t2 left outer join t1  using (n);
148
delete  t1,t2 from t2 left outer join t1  using (n);
149
select * from t2 left outer join t1  using (n);
150
drop table t1,t2 ;
151
152
#
153
# Test with locking
154
#
155
156
create table t1 (n int(10) not null primary key, d int(10));
157
create table t2 (n int(10) not null primary key, d int(10));
158
insert into t1 values(1,1);
159
insert into t2 values(1,10),(2,20);
160
LOCK TABLES t1 write, t2 read;
161
--error 1099
162
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
163
--error 1099
164
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
165
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
166
unlock tables;
167
LOCK TABLES t1 write, t2 write;
168
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
169
select * from t1;
170
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
171
select * from t1;
172
select * from t2;
173
unlock tables;
174
drop table t1,t2;
175
176
#
177
# Test safe updates and timestamps
178
#
179
set sql_safe_updates=1;
180
create table t1 (n int(10), d int(10));
181
create table t2 (n int(10), d int(10));
182
insert into t1 values(1,1);
183
insert into t2 values(1,10),(2,20);
184
--error 1175
185
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
186
set sql_safe_updates=0;
187
drop table t1,t2;
188
set timestamp=1038401397;
189
create table t1 (n int(10) not null primary key, d int(10), t timestamp);
190
create table t2 (n int(10) not null primary key, d int(10), t timestamp);
191
insert into t1 values(1,1,NULL);
192
insert into t2 values(1,10,NULL),(2,20,NULL);
193
set timestamp=1038000000;
194
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
195
select n,d,unix_timestamp(t) from t1;
196
select n,d,unix_timestamp(t) from t2;
197
--error 1064
198
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
199
drop table t1,t2;
200
set timestamp=0;
201
set sql_safe_updates=0;
202
create table t1 (n int(10) not null primary key, d int(10));
203
create table t2 (n int(10) not null primary key, d int(10));
204
insert into t1 values(1,1), (3,3);
205
insert into t2 values(1,10),(2,20);
206
UPDATE t2 left outer join t1 on t1.n=t2.n  SET t1.d=t2.d;
207
select * from t1;
208
select * from t2;
209
drop table t1,t2;
210
create table t1 (n int(10), d int(10));
211
create table t2 (n int(10), d int(10));
212
insert into t1 values(1,1),(1,2);
213
insert into t2 values(1,10),(2,20);
214
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
215
select * from t1;
216
select * from t2;
217
drop table t1,t2;
218
create table t1 (n int(10), d int(10));
219
create table t2 (n int(10), d int(10));
220
insert into t1 values(1,1),(3,2);
221
insert into t2 values(1,10),(1,20);
222
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
223
select * from t1;
224
select * from t2;
225
UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n;
226
select * from t1;
227
select * from t2;
228
DELETE a, b  FROM t1 a,t2 b where a.n=b.n;
229
select * from t1;
230
select * from t2;
231
drop table t1,t2;
232
233
CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
234
INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,'');
235
CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
236
INSERT INTO t2 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a');
237
CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
238
INSERT INTO t3 VALUES (1,'jedan'),(2,'dva');
239
update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj;
240
update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj;
241
drop table t1,t2,t3;
242
243
#
244
# Test multi update with different join methods
245
#
246
247
CREATE TABLE t1 (a int not null primary key, b int not null, key (b));
248
CREATE TABLE t2 (a int not null primary key, b int not null, key (b));
249
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
250
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
251
252
# Full join, without key
253
update t1,t2 set t1.a=t1.a+100;
254
select * from t1;
255
256
# unique key
257
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
258
select * from t1;
259
260
# ref key
261
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
262
select * from t1;
263
264
# Range key (in t1)
265
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t2.a=t1.a-100;
266
select * from t1;
267
select * from t2;
268
269
# test for non-updating table which is also used in sub-select
270
271
update t1,t2 set t1.b=t2.b, t1.a=t2.a where t1.a=t2.a and not exists (select * from t2 where t2.a > 10);
272
273
drop table t1,t2;
274
CREATE TABLE t3 (  KEY1 varchar(50) NOT NULL default '',  PARAM_CORR_DISTANCE_RUSH double default NULL,  PARAM_CORR_DISTANCE_GEM double default NULL,  PARAM_AVG_TARE double default NULL,  PARAM_AVG_NB_DAYS double default NULL,  PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL,  PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL,  PARAM_SCENARIO_COSTS varchar(50) default NULL,  PARAM_DEFAULT_WAGON_COST double default NULL,  tmp int(11) default NULL,  PRIMARY KEY  (KEY1)) ENGINE=MyISAM;
275
INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);
276
create table t1 (A varchar(1));
277
insert into t1 values  ("A") ,("B"),("C"),("D");
278
create table t2(Z varchar(15));
279
insert into t2(Z)  select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d;
280
update t2,t3 set Z =param_scenario_costs;
281
drop table t1,t2,t3;
282
create table t1 (a int, b int);
283
create table t2 (a int, b int);
284
insert into t1 values (1,1),(2,1),(3,1);
285
insert into t2 values (1,1), (3,1);
286
update t1 left join t2  on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL;
287
select t1.a, t1.b,t2.a, t2.b from t1 left join t2  on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL;
288
drop table t1,t2;
289
290
#
291
# Test reuse of same table
292
#
293
294
create table t1 (a int not null auto_increment primary key, b int not null);
295
insert into t1 (b) values (1),(2),(3),(4);
296
update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a;
297
select * from t1;
298
drop table t1;
299
300
# Test multi-update and multi-delete with impossible where
301
302
create table t1(id1 smallint(5), field char(5));
303
create table t2(id2 smallint(5), field char(5));
304
305
insert into t1 values (1, 'a'), (2, 'aa');
306
insert into t2 values (1, 'b'), (2, 'bb');
307
308
select * from t1;
309
select * from t2;
310
311
update t2 inner join t1 on t1.id1=t2.id2
312
  set t2.field=t1.field
313
  where 0=1;
314
update t2, t1 set t2.field=t1.field
315
  where t1.id1=t2.id2 and 0=1;
316
317
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2
318
  where 0=1;
319
delete t1, t2 from t2,t1 
320
  where t1.id1=t2.id2 and 0=1;
321
322
drop table t1,t2;
323
324
#
325
# Test for bug #1820.
326
#
327
328
create table t1 ( a int not null, b int not null) ;
329
--disable_query_log
330
insert into t1 values (1,1),(2,2),(3,3),(4,4);
331
let $1=19;
332
set @d=4;
333
while ($1)
334
{
335
  eval insert into t1 select a+@d,b+@d from t1;
336
  eval set @d=@d*2;
337
  dec $1;
338
}
339
340
--enable_query_log
341
alter table t1 add index i1(a);
342
delete from t1 where a > 2000000;
343
create table t2 like t1;
344
insert into t2 select * from t1;
345
346
select 't2 rows before small delete', count(*) from t1;
347
delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2;
348
select 't2 rows after small delete', count(*) from t2;
349
select 't1 rows after small delete', count(*) from t1;
350
351
## Try deleting many rows 
352
353
delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000;
354
select 't2 rows after big delete', count(*) from t2;
355
select 't1 rows after big delete', count(*) from t1;
356
357
drop table t1,t2;
358
359
#
360
# Test alias (this is not correct in 4.0)
361
#
362
363
CREATE TABLE t1 ( a int );
364
CREATE TABLE t2 ( a int );
365
DELETE t1 FROM t1, t2 AS t3;
366
DELETE t4 FROM t1, t1 AS t4;
367
DELETE t3 FROM t1 AS t3, t1 AS t4;
368
--error 1109
369
DELETE t1 FROM t1 AS t3, t2 AS t4;
370
INSERT INTO t1 values (1),(2);
371
INSERT INTO t2 values (1),(2);
372
DELETE t1 FROM t1 AS t2, t2 AS t1 where t1.a=t2.a and t1.a=1;
373
SELECT * from t1;
374
SELECT * from t2;
375
DELETE t2 FROM t1 AS t2, t2 AS t1 where t1.a=t2.a and t1.a=2;
376
SELECT * from t1;
377
SELECT * from t2;
378
DROP TABLE t1,t2;
379
380
#
381
# Test update with const tables
382
#
383
create table `t1` (`p_id` int(10) unsigned NOT NULL auto_increment, `p_code` varchar(20) NOT NULL default '', `p_active` tinyint(1) unsigned NOT NULL default '1', PRIMARY KEY (`p_id`) );
384
create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(10) unsigned NOT NULL default '0', `c2_note` text NOT NULL, `c2_active` tinyint(1) unsigned NOT NULL default '1', PRIMARY KEY (`c2_id`), KEY `c2_p_id` (`c2_p_id`) );
385
insert into t1 values (0,'A01-Comp',1);
386
insert into t1 values (0,'B01-Comp',1);
387
insert into t2 values (0,1,'A Note',1);
388
update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2; 
389
select * from t1;
390
select * from t2;
391
drop table t1, t2;
392
393
#
394
# privilege check for multiupdate with other tables
395
#
396
397
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
398
connection root;
399
--disable_warnings
400
create database mysqltest;
401
--enable_warnings
402
create table mysqltest.t1 (a int, b int, primary key (a));
403
create table mysqltest.t2 (a int, b int, primary key (a));
404
create table mysqltest.t3 (a int, b int, primary key (a));
405
grant select on mysqltest.* to mysqltest_1@localhost;
406
grant update on mysqltest.t1 to mysqltest_1@localhost;
407
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
408
connection user1;
409
update t1, t2 set t1.b=1 where t1.a=t2.a;
410
update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a;
411
connection root;
412
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
413
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
414
delete from mysql.user where user=_binary'mysqltest_1';
415
drop database mysqltest;
416
417
#
418
# multi delete wrong table check
419
#
420
create table t1 (a int, primary key (a));
421
create table t2 (a int, primary key (a));
422
create table t3 (a int, primary key (a));
423
-- error 1109
424
delete t1,t3 from t1,t2 where t1.a=t2.a and t2.a=(select t3.a from t3 where t1.a=t3.a);
425
drop table t1, t2, t3;
426
427
#
428
# multi* unique updating table check
429
#
430
create table t1 (col1 int); 
431
create table t2 (col1 int);
432
-- error 1093
433
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
434
-- error 1093
435
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
436
drop table t1,t2;
437
438
# Test for BUG#5837 - delete with outer join and const tables
439
--disable_warnings
440
create table t1 (
441
  aclid bigint not null primary key, 
442
  status tinyint(1) not null 
443
) engine = innodb;
444
445
create table t2 (
446
  refid bigint not null primary key, 
447
  aclid bigint, index idx_acl(aclid) 
448
) engine = innodb;
449
--enable_warnings
450
insert into t2 values(1,null);
451
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
452
drop table t1, t2;
453
454
#
455
# Bug#19225: unchecked error leads to server crash
456
#
457
create table t1(a int);
458
create table t2(a int);
459
--error 1093
460
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
461
drop table t1, t2;
462
# End of 4.1 tests
463
464
#
465
# Test for bug #1980.
466
#
467
--disable_warnings
468
create table t1 ( c char(8) not null ) engine=innodb;
469
--enable_warnings
470
471
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
472
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
473
474
alter table t1 add b char(8) not null;
475
alter table t1 add a char(8) not null;
476
alter table t1 add primary key (a,b,c);
477
update t1 set a=c, b=c;
478
479
create table t2 like t1;
480
insert into t2 select * from t1;
481
482
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
483
484
drop table t1,t2;
485
486
--disable_warnings
487
create table t1 ( c char(8) not null ) engine=innodb;
488
--enable_warnings
489
490
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
491
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
492
493
alter table t1 add b char(8) not null;
494
alter table t1 add a char(8) not null;
495
alter table t1 add primary key (a,b,c);
496
update t1 set a=c, b=c;
497
498
create table t2 like t1;
499
insert into t2 select * from t1;
500
501
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
502
503
drop table t1,t2;
504
505
#
506
# Test alter table and a concurrent multi update
507
# (This will force update to reopen tables)
508
#
509
510
create table t1 (a int, b int);
511
insert into t1 values (1, 2), (2, 3), (3, 4);
512
create table t2 (a int);
513
insert into t2 values (10), (20), (30);
514
create view v1 as select a as b, a/10 as a from t2;
515
516
connect (locker,localhost,root,,test);
517
connection locker;
518
lock table t1 write;
519
520
connect (changer,localhost,root,,test);
521
connection changer;
522
send alter table t1 add column c int default 100 after a;
523
524
connect (updater,localhost,root,,test);
525
connection updater;
526
sleep 2;
527
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
528
529
connection locker;
530
sleep 2;
531
unlock tables;
532
533
connection changer;
534
reap;
535
536
connection updater;
537
reap;
538
select * from t1;
539
select * from t2;
540
drop view v1;
541
drop table t1, t2;
542
543
#
544
# Test multi updates and deletes using primary key and without.
545
#
546
create table t1 (i1 int, i2 int, i3 int);
547
create table t2 (id int, c1 varchar(20), c2 varchar(20));
548
insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2);
549
insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test");
550
select * from t1 order by i1;
551
select * from t2;
552
update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id;
553
select * from t1 order by i1;
554
select * from t2 order by id;
555
delete t1.*,t2.* from t1,t2 where t1.i2=t2.id;
556
select * from t1 order by i1;
557
select * from t2 order by id;
558
drop table t1, t2;
559
create table t1 (i1 int auto_increment not null, i2 int, i3 int, primary key (i1));
560
create table t2 (id int auto_increment not null, c1 varchar(20), c2 varchar(20), primary key(id));
561
insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2);
562
insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test");
563
select * from t1 order by i1;
564
select * from t2 order by id;
565
update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id;
566
select * from t1 order by i1;
567
select * from t2 order by id;
568
delete t1.*,t2.* from t1,t2 where t1.i2=t2.id;
569
select * from t1 order by i1;
570
select * from t2 order by id;
571
drop table t1, t2;
572
573
#
574
# Bug#27716  	multi-update did partially and has not binlogged
575
#
576
CREATE TABLE `t1` (
577
  `a` int(11) NOT NULL auto_increment,
578
  `b` int(11) default NULL,
579
  PRIMARY KEY  (`a`)
580
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
581
582
CREATE TABLE `t2` (
583
  `a` int(11) NOT NULL auto_increment,
584
  `b` int(11) default NULL,
585
  PRIMARY KEY  (`a`)
586
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
587
588
# as the test is about to see erroed queries in binlog
589
set @sav_binlog_format=  @@session.binlog_format;
590
set @@session.binlog_format= mixed;
591
592
593
# A. testing multi_update::send_error() effective update
594
insert into t1 values (1,1),(2,2);
595
insert into t2 values (1,1),(4,4);
596
reset master;
597
error ER_DUP_ENTRY;
598
UPDATE t2,t1 SET t2.a=t1.a+2;
599
# check
600
select * from t2 /* must be (3,1), (4,4) */;
601
show master status /* there must be the UPDATE query event */;
602
603
# B. testing multi_update::send_error() ineffective update 
604
# (as there is a policy described at mysql_update() still go to binlog) 
605
delete from t1;
606
delete from t2;
607
insert into t1 values (1,2),(3,4),(4,4);
608
insert into t2 values (1,2),(3,4),(4,4);
609
reset master;
610
error ER_DUP_ENTRY;
611
UPDATE t2,t1  SET t2.a=t2.b where t2.a=t1.a;
612
show master status /* there must be the UPDATE query event */;
613
614
# cleanup bug#27716
615
drop table t1, t2;
616
set @@session.binlog_format= @sav_binlog_format;
617
618
#
619
# Bug #29136  	erred multi-delete on trans table does not rollback 
620
#
621
622
# prepare
623
--disable_warnings
624
drop table if exists t1, t2, t3;
625
--enable_warnings
626
CREATE TABLE t1 (a int, PRIMARY KEY (a));
627
CREATE TABLE t2 (a int, PRIMARY KEY (a));
628
CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM;
629
create trigger trg_del_t3 before  delete on t3 for each row insert into t1 values (1);
630
631
insert into t2 values (1),(2);
632
insert into t3 values (1),(2);
633
reset master;
634
635
# exec cases B, A - see innodb.test
636
637
# B. send_eof() and send_error() afterward
638
639
--error ER_DUP_ENTRY
640
delete t3.* from t2,t3 where t2.a=t3.a;
641
642
# check
643
select count(*) from t1 /* must be 1 */;
644
select count(*) from t3 /* must be 1 */;
645
646
# cleanup bug#29136
647
drop table t1, t2, t3;
648
649
#
650
# Add further tests from here
651
#
652
653
654
--echo end of tests