mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
f68085c4e7
into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge BitKeeper/etc/ignore: auto-union BitKeeper/deleted/.del-im_options_set.result~59278f56be61d921: Auto merged BitKeeper/deleted/.del-mysqld.dsp~ffdbf2d234e23e56: Auto merged BitKeeper/deleted/.del-mysys.dsp~32695fee91189326: Auto merged BitKeeper/deleted/.del-im_options_set.imtest~b53d9d60e5684833: Auto merged BitKeeper/deleted/.del-im_options_unset.imtest~768eb186b51d0048: Auto merged BitKeeper/deleted/.del-im_options_unset.result~20a4790cd3c70a4f: Auto merged client/mysql.cc: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqlcheck.c: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged dbug/dbug.c: Auto merged extra/perror.c: Auto merged extra/yassl/src/yassl_imp.cpp: Auto merged extra/yassl/src/yassl_int.cpp: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged libmysql/libmysql.c: Auto merged mysql-test/r/cast.result: Auto merged mysql-test/r/date_formats.result: Auto merged mysql-test/r/federated.result: Auto merged mysql-test/r/func_compress.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/gis-rtree.result: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/r/im_daemon_life_cycle.result: Auto merged mysql-test/r/im_utils.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/mysqlcheck.result: Auto merged mysql-test/r/rpl_sp.result: Auto merged mysql-test/r/rpl_trigger.result: Auto merged mysql-test/r/sp-code.result: Auto merged mysql-test/r/sp-security.result: Auto merged mysql-test/r/strict.result: Auto merged mysql-test/r/type_blob.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/r/type_ranges.result: Auto merged mysql-test/r/udf.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/t/cast.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/func_group.test: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/im_life_cycle.imtest: Auto merged mysql-test/t/im_utils.imtest: Auto merged mysql-test/t/mysql.test: Auto merged mysql-test/t/mysqlbinlog.test: Auto merged mysql-test/t/mysqlcheck.test: Auto merged mysql-test/t/ps.test: Auto merged mysql-test/t/rpl_trigger.test: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/strict.test: Auto merged mysql-test/t/udf.test: Auto merged sql/field.cc: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_udf.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged sql-common/client.c: Auto merged sql-common/my_time.c: Auto merged sql/table.h: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged mysql-test/r/im_life_cycle.result: e use local mysql-test/r/ps.result: use local client/Makefile.am: Manual merge. client/mysqlimport.c: Manual merge. configure.in: Manual merge. mysql-test/mysql-test-run.pl: Manual merge. mysql-test/r/mysqldump.result: Manual merge. mysql-test/r/mysqltest.result: Manual merge. mysql-test/r/ndb_basic.result: Manual merge. mysql-test/r/rpl_view.result: Manual merge. mysql-test/r/show_check.result: Manual merge. mysql-test/r/sp-error.result: Manual merge. mysql-test/r/sp.result: Manual merge. mysql-test/r/union.result: Manual merge. mysql-test/t/mysqldump.test: Manual merge. mysql-test/t/mysqltest.test: Manual merge. mysql-test/t/ndb_basic.test: Manual merge. mysql-test/t/rpl_sp.test: Manual merge. mysql-test/t/rpl_view.test: Manual merge. mysql-test/t/show_check.test: Manual merge. mysql-test/t/sp-error.test: Manual merge. mysql-test/t/sp.test: Manual merge. sql/item_sum.cc: Manual merge. sql/mysql_priv.h: Manual merge. sql/sp_head.cc: Manual merge. sql/sql_db.cc: Manual merge. sql/sql_delete.cc: Manual merge. sql/sql_lex.h: Manual merge. sql/sql_show.cc: Manual merge. sql/sql_table.cc: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_yacc.yy: Manual merge. tests/mysql_client_test.c: Manual merge.
948 lines
18 KiB
Text
948 lines
18 KiB
Text
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;
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
DROP TABLE IF EXISTS t3;
|
|
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;
|
|
Warnings:
|
|
Note 1305 FUNCTION bug12480 does not exist
|
|
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
|
|
SELECT routine_name, definer
|
|
FROM information_schema.routines;
|
|
routine_name definer
|
|
bug12480 root@localhost
|
|
SELECT trigger_name, definer
|
|
FROM information_schema.triggers;
|
|
trigger_name definer
|
|
t1_first root@localhost
|
|
|
|
--- On slave --
|
|
SELECT routine_name, definer
|
|
FROM information_schema.routines;
|
|
routine_name definer
|
|
bug12480 root@localhost
|
|
SELECT trigger_name, definer
|
|
FROM information_schema.triggers;
|
|
trigger_name definer
|
|
t1_first root@localhost
|
|
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;
|
|
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;
|
|
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;
|
|
STOP SLAVE;
|
|
FLUSH LOGS;
|
|
RESET SLAVE;
|
|
START SLAVE;
|
|
SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
|
|
MASTER_POS_WAIT('master-bin.000001', 513) >= 0
|
|
1
|
|
SHOW TABLES LIKE 't_';
|
|
Tables_in_test (t_)
|
|
t1
|
|
t2
|
|
SHOW TRIGGERS;
|
|
Trigger Event Table Statement Timing Created sql_mode Definer
|
|
trg1 INSERT t1 INSERT INTO t2 VALUES(CURRENT_USER()) AFTER NULL
|
|
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;
|
|
SHOW TABLES LIKE 't_';
|
|
Tables_in_test (t_)
|
|
SHOW TRIGGERS;
|
|
Trigger Event Table Statement Timing Created sql_mode Definer
|
|
RESET MASTER;
|
|
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;
|