rpl_trigger.result 19.5 KB
Newer Older
1 2 3 4 5 6
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
jmiller@mysql.com's avatar
jmiller@mysql.com committed
7 8 9
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
create table t2 (a int auto_increment, primary key (a), b int);
create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null);
create trigger t1 before insert on t1 for each row
begin
insert into t3 values (NULL, "t1", new.a, new.b, rand());
end|
create trigger t2 after insert on t2 for each row
begin
insert into t3 values (NULL, "t2", new.a, new.b, rand());
end|
insert into t3 values(100,"log",0,0,0);
SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
insert into t1 values(1,1,rand()),(NULL,2,rand());
insert into t2 (b) values(last_insert_id());
insert into t2 values(3,0),(NULL,0);
insert into t2 values(NULL,0),(500,0);
select a,b, truncate(rand_value,4) from t1;
a	b	truncate(rand_value,4)
1	1	0.4320
2	2	0.3055
select * from t2;
a	b
1	2
3	0
4	0
5	0
500	0
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
a	name	old_a	old_b	truncate(rand_value,4)
100	log	0	0	0.0000
101	t1	1	1	0.3203
102	t1	0	2	0.5666
103	t2	1	2	0.9164
104	t2	3	0	0.8826
105	t2	4	0	0.6635
106	t2	5	0	0.6699
107	t2	500	0	0.3593

--- On slave --
select a,b, truncate(rand_value,4) from t1;
a	b	truncate(rand_value,4)
1	1	0.4320
2	2	0.3055
select * from t2;
a	b
1	2
3	0
4	0
5	0
500	0
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
a	name	old_a	old_b	truncate(rand_value,4)
100	log	0	0	0.0000
101	t1	1	1	0.3203
102	t1	0	2	0.5666
103	t2	1	2	0.9164
104	t2	3	0	0.8826
105	t2	4	0	0.6635
106	t2	5	0	0.6699
107	t2	500	0	0.3593
drop table t1,t2,t3;
select get_lock("bug12480",2);
get_lock("bug12480",2)
1
create table t1 (a datetime,b  datetime, c datetime);
drop function if exists bug12480;
create function bug12480() returns datetime
begin
set @a=get_lock("bug12480",2);
return now();
end|
create trigger t1_first before insert on t1
for each row begin
set @a=get_lock("bug12480",2);
set new.b= now();
set new.c= bug12480();
end
|
insert into t1 set a = now();
select a=b && a=c from t1;
a=b && a=c
1
93
SELECT routine_name, definer
94 95
FROM information_schema.routines
WHERE routine_name = 'bug12480';
96 97 98
routine_name	definer
bug12480	root@localhost
SELECT trigger_name, definer
99 100
FROM information_schema.triggers
WHERE trigger_name = 't1_first';
101 102
trigger_name	definer
t1_first	root@localhost
103 104

--- On slave --
105
SELECT routine_name, definer
106 107
FROM information_schema.routines
WHERE routine_name = 'bug12480';
108
routine_name	definer
109
bug12480	root@localhost
110
SELECT trigger_name, definer
111 112
FROM information_schema.triggers
WHERE trigger_name = 't1_first';
113 114
trigger_name	definer
t1_first	root@localhost
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
select a=b && a=c from t1;
a=b && a=c
1
test
1
truncate table t1;
drop trigger t1_first;
insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now());
select a=b && a=c from t1;
a=b && a=c
1
1
1
drop function bug12480;
drop table t1;
130 131 132 133 134 135 136 137 138 139 140 141
create table t1 (i int);
create table t2 (i int);
create trigger tr1 before insert on t1 for each row
begin
insert into t2 values (1);
end|
create database other;
use other;
insert into test.t1 values (1);
use test;
drop table t1,t2;
drop database other;
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
test case for BUG#13227
-------------------
10
-------------------
drop table if exists t110;
drop table if exists t210,t310;
create table t110 (f1 int)  /* 2 replicate */;
insert into t110 values (-5);
insert into t110 values (-4);
insert into t110 values (-3);
insert into t110 values (-2);
insert into t110 values (-1);
select * from t110;
f1
-5
-4
-3
-2
-1
create trigger trg110 before update on t110 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t210 where f1=NEW.f1;
INSERT INTO t310 values (r);
end|
create table t210 (f1 int, f2 int) /* slave local */;
create table t310 (f3 int) /* slave local */;
insert into t210 values (5, 5*100);
insert into t210 values (4, 4*100);
insert into t210 values (3, 3*100);
insert into t210 values (2, 2*100);
insert into t210 values (1, 1*100);
select * from t210;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t110 SET f1=5 where f1=-5;
SELECT * from t110 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t310 /* must be f3 5*100 */;
f3
500
UPDATE t110 SET f1=5 where f1=-5;
UPDATE t110 SET f1=4 where f1=-4;
UPDATE t110 SET f1=3 where f1=-3;
UPDATE t110 SET f1=2 where f1=-2;
UPDATE t110 SET f1=1 where f1=-1;
SELECT * from t110 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t310 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg110;
drop table t210,t310;
drop table t110;
-------------------
9
-------------------
drop table if exists t19;
drop table if exists t29,t39;
create table t19 (f1 int)  /* 2 replicate */;
insert into t19 values (-5);
insert into t19 values (-4);
insert into t19 values (-3);
insert into t19 values (-2);
insert into t19 values (-1);
select * from t19;
f1
-5
-4
-3
-2
-1
create trigger trg19 before update on t19 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t29 where f1=NEW.f1;
INSERT INTO t39 values (r);
end|
create table t29 (f1 int, f2 int) /* slave local */;
create table t39 (f3 int) /* slave local */;
insert into t29 values (5, 5*100);
insert into t29 values (4, 4*100);
insert into t29 values (3, 3*100);
insert into t29 values (2, 2*100);
insert into t29 values (1, 1*100);
select * from t29;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t19 SET f1=5 where f1=-5;
SELECT * from t19 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t39 /* must be f3 5*100 */;
f3
500
UPDATE t19 SET f1=5 where f1=-5;
UPDATE t19 SET f1=4 where f1=-4;
UPDATE t19 SET f1=3 where f1=-3;
UPDATE t19 SET f1=2 where f1=-2;
UPDATE t19 SET f1=1 where f1=-1;
SELECT * from t19 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t39 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg19;
drop table t29,t39;
drop table t19;
-------------------
8
-------------------
drop table if exists t18;
drop table if exists t28,t38;
create table t18 (f1 int)  /* 2 replicate */;
insert into t18 values (-5);
insert into t18 values (-4);
insert into t18 values (-3);
insert into t18 values (-2);
insert into t18 values (-1);
select * from t18;
f1
-5
-4
-3
-2
-1
create trigger trg18 before update on t18 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t28 where f1=NEW.f1;
INSERT INTO t38 values (r);
end|
create table t28 (f1 int, f2 int) /* slave local */;
create table t38 (f3 int) /* slave local */;
insert into t28 values (5, 5*100);
insert into t28 values (4, 4*100);
insert into t28 values (3, 3*100);
insert into t28 values (2, 2*100);
insert into t28 values (1, 1*100);
select * from t28;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t18 SET f1=5 where f1=-5;
SELECT * from t18 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t38 /* must be f3 5*100 */;
f3
500
UPDATE t18 SET f1=5 where f1=-5;
UPDATE t18 SET f1=4 where f1=-4;
UPDATE t18 SET f1=3 where f1=-3;
UPDATE t18 SET f1=2 where f1=-2;
UPDATE t18 SET f1=1 where f1=-1;
SELECT * from t18 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t38 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg18;
drop table t28,t38;
drop table t18;
-------------------
7
-------------------
drop table if exists t17;
drop table if exists t27,t37;
create table t17 (f1 int)  /* 2 replicate */;
insert into t17 values (-5);
insert into t17 values (-4);
insert into t17 values (-3);
insert into t17 values (-2);
insert into t17 values (-1);
select * from t17;
f1
-5
-4
-3
-2
-1
create trigger trg17 before update on t17 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t27 where f1=NEW.f1;
INSERT INTO t37 values (r);
end|
create table t27 (f1 int, f2 int) /* slave local */;
create table t37 (f3 int) /* slave local */;
insert into t27 values (5, 5*100);
insert into t27 values (4, 4*100);
insert into t27 values (3, 3*100);
insert into t27 values (2, 2*100);
insert into t27 values (1, 1*100);
select * from t27;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t17 SET f1=5 where f1=-5;
SELECT * from t17 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t37 /* must be f3 5*100 */;
f3
500
UPDATE t17 SET f1=5 where f1=-5;
UPDATE t17 SET f1=4 where f1=-4;
UPDATE t17 SET f1=3 where f1=-3;
UPDATE t17 SET f1=2 where f1=-2;
UPDATE t17 SET f1=1 where f1=-1;
SELECT * from t17 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t37 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg17;
drop table t27,t37;
drop table t17;
-------------------
6
-------------------
drop table if exists t16;
drop table if exists t26,t36;
create table t16 (f1 int)  /* 2 replicate */;
insert into t16 values (-5);
insert into t16 values (-4);
insert into t16 values (-3);
insert into t16 values (-2);
insert into t16 values (-1);
select * from t16;
f1
-5
-4
-3
-2
-1
create trigger trg16 before update on t16 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t26 where f1=NEW.f1;
INSERT INTO t36 values (r);
end|
create table t26 (f1 int, f2 int) /* slave local */;
create table t36 (f3 int) /* slave local */;
insert into t26 values (5, 5*100);
insert into t26 values (4, 4*100);
insert into t26 values (3, 3*100);
insert into t26 values (2, 2*100);
insert into t26 values (1, 1*100);
select * from t26;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t16 SET f1=5 where f1=-5;
SELECT * from t16 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t36 /* must be f3 5*100 */;
f3
500
UPDATE t16 SET f1=5 where f1=-5;
UPDATE t16 SET f1=4 where f1=-4;
UPDATE t16 SET f1=3 where f1=-3;
UPDATE t16 SET f1=2 where f1=-2;
UPDATE t16 SET f1=1 where f1=-1;
SELECT * from t16 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t36 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg16;
drop table t26,t36;
drop table t16;
-------------------
5
-------------------
drop table if exists t15;
drop table if exists t25,t35;
create table t15 (f1 int)  /* 2 replicate */;
insert into t15 values (-5);
insert into t15 values (-4);
insert into t15 values (-3);
insert into t15 values (-2);
insert into t15 values (-1);
select * from t15;
f1
-5
-4
-3
-2
-1
create trigger trg15 before update on t15 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t25 where f1=NEW.f1;
INSERT INTO t35 values (r);
end|
create table t25 (f1 int, f2 int) /* slave local */;
create table t35 (f3 int) /* slave local */;
insert into t25 values (5, 5*100);
insert into t25 values (4, 4*100);
insert into t25 values (3, 3*100);
insert into t25 values (2, 2*100);
insert into t25 values (1, 1*100);
select * from t25;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t15 SET f1=5 where f1=-5;
SELECT * from t15 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t35 /* must be f3 5*100 */;
f3
500
UPDATE t15 SET f1=5 where f1=-5;
UPDATE t15 SET f1=4 where f1=-4;
UPDATE t15 SET f1=3 where f1=-3;
UPDATE t15 SET f1=2 where f1=-2;
UPDATE t15 SET f1=1 where f1=-1;
SELECT * from t15 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t35 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg15;
drop table t25,t35;
drop table t15;
-------------------
4
-------------------
drop table if exists t14;
drop table if exists t24,t34;
create table t14 (f1 int)  /* 2 replicate */;
insert into t14 values (-5);
insert into t14 values (-4);
insert into t14 values (-3);
insert into t14 values (-2);
insert into t14 values (-1);
select * from t14;
f1
-5
-4
-3
-2
-1
create trigger trg14 before update on t14 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t24 where f1=NEW.f1;
INSERT INTO t34 values (r);
end|
create table t24 (f1 int, f2 int) /* slave local */;
create table t34 (f3 int) /* slave local */;
insert into t24 values (5, 5*100);
insert into t24 values (4, 4*100);
insert into t24 values (3, 3*100);
insert into t24 values (2, 2*100);
insert into t24 values (1, 1*100);
select * from t24;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t14 SET f1=5 where f1=-5;
SELECT * from t14 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t34 /* must be f3 5*100 */;
f3
500
UPDATE t14 SET f1=5 where f1=-5;
UPDATE t14 SET f1=4 where f1=-4;
UPDATE t14 SET f1=3 where f1=-3;
UPDATE t14 SET f1=2 where f1=-2;
UPDATE t14 SET f1=1 where f1=-1;
SELECT * from t14 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t34 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg14;
drop table t24,t34;
drop table t14;
-------------------
3
-------------------
drop table if exists t13;
drop table if exists t23,t33;
create table t13 (f1 int)  /* 2 replicate */;
insert into t13 values (-5);
insert into t13 values (-4);
insert into t13 values (-3);
insert into t13 values (-2);
insert into t13 values (-1);
select * from t13;
f1
-5
-4
-3
-2
-1
create trigger trg13 before update on t13 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t23 where f1=NEW.f1;
INSERT INTO t33 values (r);
end|
create table t23 (f1 int, f2 int) /* slave local */;
create table t33 (f3 int) /* slave local */;
insert into t23 values (5, 5*100);
insert into t23 values (4, 4*100);
insert into t23 values (3, 3*100);
insert into t23 values (2, 2*100);
insert into t23 values (1, 1*100);
select * from t23;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t13 SET f1=5 where f1=-5;
SELECT * from t13 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t33 /* must be f3 5*100 */;
f3
500
UPDATE t13 SET f1=5 where f1=-5;
UPDATE t13 SET f1=4 where f1=-4;
UPDATE t13 SET f1=3 where f1=-3;
UPDATE t13 SET f1=2 where f1=-2;
UPDATE t13 SET f1=1 where f1=-1;
SELECT * from t13 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t33 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg13;
drop table t23,t33;
drop table t13;
-------------------
2
-------------------
drop table if exists t12;
drop table if exists t22,t32;
create table t12 (f1 int)  /* 2 replicate */;
insert into t12 values (-5);
insert into t12 values (-4);
insert into t12 values (-3);
insert into t12 values (-2);
insert into t12 values (-1);
select * from t12;
f1
-5
-4
-3
-2
-1
create trigger trg12 before update on t12 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t22 where f1=NEW.f1;
INSERT INTO t32 values (r);
end|
create table t22 (f1 int, f2 int) /* slave local */;
create table t32 (f3 int) /* slave local */;
insert into t22 values (5, 5*100);
insert into t22 values (4, 4*100);
insert into t22 values (3, 3*100);
insert into t22 values (2, 2*100);
insert into t22 values (1, 1*100);
select * from t22;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t12 SET f1=5 where f1=-5;
SELECT * from t12 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t32 /* must be f3 5*100 */;
f3
500
UPDATE t12 SET f1=5 where f1=-5;
UPDATE t12 SET f1=4 where f1=-4;
UPDATE t12 SET f1=3 where f1=-3;
UPDATE t12 SET f1=2 where f1=-2;
UPDATE t12 SET f1=1 where f1=-1;
SELECT * from t12 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t32 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg12;
drop table t22,t32;
drop table t12;
-------------------
1
-------------------
drop table if exists t11;
drop table if exists t21,t31;
create table t11 (f1 int)  /* 2 replicate */;
insert into t11 values (-5);
insert into t11 values (-4);
insert into t11 values (-3);
insert into t11 values (-2);
insert into t11 values (-1);
select * from t11;
f1
-5
-4
-3
-2
-1
create trigger trg11 before update on t11 /* slave local */
for each row
begin
DECLARE r integer;
SELECT f2 INTO r FROM t21 where f1=NEW.f1;
INSERT INTO t31 values (r);
end|
create table t21 (f1 int, f2 int) /* slave local */;
create table t31 (f3 int) /* slave local */;
insert into t21 values (5, 5*100);
insert into t21 values (4, 4*100);
insert into t21 values (3, 3*100);
insert into t21 values (2, 2*100);
insert into t21 values (1, 1*100);
select * from t21;
f1	f2
5	500
4	400
3	300
2	200
1	100
UPDATE t11 SET f1=5 where f1=-5;
SELECT * from t11 /* must be f1 5, 1 - 5 2 - 5 ... -1 */;
f1
5
-4
-3
-2
-1
SELECT * from t31 /* must be f3 5*100 */;
f3
500
UPDATE t11 SET f1=5 where f1=-5;
UPDATE t11 SET f1=4 where f1=-4;
UPDATE t11 SET f1=3 where f1=-3;
UPDATE t11 SET f1=2 where f1=-2;
UPDATE t11 SET f1=1 where f1=-1;
SELECT * from t11 /* must be f1 5 ... 1 */;
f1
5
4
3
2
1
SELECT * from t31 /* must be f3 5 * 100 ...  100 */;
f3
500
400
300
200
100
drop trigger trg11;
drop table t21,t31;
drop table t11;
863 864
STOP SLAVE;
FLUSH LOGS;
Serge Kozlov's avatar
Serge Kozlov committed
865 866 867
--> Stop master server
--> Start master server
--> Master binlog: Server ver: 5.0.16-debug-log, Binlog ver: 4
868 869 870 871 872
RESET SLAVE;
START SLAVE;
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
MASTER_POS_WAIT('master-bin.000001', 513) >= 0
1
873 874
SHOW TABLES LIKE 't_';
Tables_in_test (t_)
875 876 877
t1
t2
SHOW TRIGGERS;
878 879
Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
trg1	INSERT	t1	INSERT INTO t2 VALUES(CURRENT_USER())	AFTER	NULL			latin1	latin1_swedish_ci	latin1_swedish_ci
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
SELECT * FROM t1;
c
1
SELECT * FROM t2;
s
@
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
c
1
2
SELECT * FROM t2;
s
@
root@localhost
DROP TRIGGER trg1;
Warnings:
Warning	1454	No definer attribute for trigger 'test'.'trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
DROP TABLE t1;
DROP TABLE t2;
STOP SLAVE;
RESET SLAVE;
902 903
SHOW TABLES LIKE 't_';
Tables_in_test (t_)
904
SHOW TRIGGERS;
905
Trigger	Event	Table	Statement	Timing	Created	sql_mode	Definer	character_set_client	collation_connection	Database Collation
906
RESET MASTER;
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953
START SLAVE;

---> Test for BUG#20438

---> Preparing environment...
---> connection: master
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;

---> Synchronizing slave with master...

---> connection: master

---> Creating objects...
CREATE TABLE t1(c INT);
CREATE TABLE t2(c INT);
/*!50003 CREATE TRIGGER t1_bi BEFORE INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(NEW.c * 10) */;

---> Inserting value...
INSERT INTO t1 VALUES(1);

---> Checking on master...
SELECT * FROM t1;
c
1
SELECT * FROM t2;
c
10

---> Synchronizing slave with master...
---> connection: master

---> Checking on slave...
SELECT * FROM t1;
c
1
SELECT * FROM t2;
c
10

---> connection: master

---> Cleaning up...
DROP TABLE t1;
DROP TABLE t2;
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
drop table if exists t1;
create table t1(a int, b varchar(50));
drop trigger not_a_trigger;
ERROR HY000: Trigger does not exist
drop trigger if exists not_a_trigger;
Warnings:
Note	1360	Trigger does not exist
create trigger t1_bi before insert on t1
for each row set NEW.b := "In trigger t1_bi";
insert into t1 values (1, "a");
drop trigger if exists t1_bi;
insert into t1 values (2, "b");
drop trigger if exists t1_bi;
Warnings:
Note	1360	Trigger does not exist
insert into t1 values (3, "c");
select * from t1;
a	b
1	In trigger t1_bi
2	b
3	c
select * from t1;
a	b
1	In trigger t1_bi
2	b
3	c
drop table t1;
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 ( f int ) engine = innodb;
create table log ( r int ) engine = myisam;
create trigger tr
after insert on t1
for each row insert into log values ( new.f );
set autocommit = 0;
insert into t1 values ( 1 );
rollback;
Warnings:
Warning	1196	Some non-transactional changed tables couldn't be rolled back
Mats Kindahl's avatar
Mats Kindahl committed
997 998
Comparing tables master:test.t1 and slave:test.t1
Comparing tables master:test.log and slave:test.log
999
drop table t1, log;