| 1 |
connection node_2; |
| 2 |
connection node_1; |
| 3 |
CREATE TABLE IF NOT EXISTS t1 (id int(10) not null primary key) engine=innodb; |
| 4 |
CREATE OR REPLACE TRIGGER tr1 |
| 5 |
BEFORE INSERT ON t1 FOR EACH ROW |
| 6 |
BEGIN |
| 7 |
SET NEW.id = 100; |
| 8 |
END| |
| 9 |
INSERT INTO t1 VALUES (1); |
| 10 |
SELECT * from t1; |
| 11 |
id |
| 12 |
100 |
| 13 |
CREATE OR REPLACE TRIGGER tr1 |
| 14 |
BEFORE INSERT ON t1 FOR EACH ROW |
| 15 |
BEGIN |
| 16 |
SET NEW.id = 200; |
| 17 |
END| |
| 18 |
connection node_2; |
| 19 |
SET SESSION wsrep_sync_wait=15; |
| 20 |
SELECT * FROM t1; |
| 21 |
id |
| 22 |
100 |
| 23 |
INSERT INTO t1 values (2); |
| 24 |
SELECT * FROM t1; |
| 25 |
id |
| 26 |
100 |
| 27 |
200 |
| 28 |
connection node_1; |
| 29 |
SELECT * FROM t1; |
| 30 |
id |
| 31 |
100 |
| 32 |
200 |
| 33 |
DROP TRIGGER tr1; |
| 34 |
DROP TABLE t1; |
| 35 |
connection node_1; |
| 36 |
CREATE TABLE t1(id int not null auto_increment, value int not null, primary key (id)) engine=innodb; |
| 37 |
CREATE TABLE t2(id int not null auto_increment, tbl varchar(64) not null, action varchar(64) not null, primary key (id)); |
| 38 |
create trigger log_insert after insert on t1 |
| 39 |
for each row begin |
| 40 |
insert into t2(tbl, action) values ('t1', 'INSERT'); |
| 41 |
end| |
| 42 |
insert into t1(value) values (1); |
| 43 |
insert into t1(value) values (2); |
| 44 |
connection node_2; |
| 45 |
set session wsrep_sync_wait=15; |
| 46 |
insert into t1(value) values (3); |
| 47 |
insert into t1(value) values (4); |
| 48 |
select tbl, action from t2; |
| 49 |
tbl action |
| 50 |
t1 INSERT |
| 51 |
t1 INSERT |
| 52 |
t1 INSERT |
| 53 |
t1 INSERT |
| 54 |
connection node_1; |
| 55 |
drop trigger if exists log_insert; |
| 56 |
insert into t1(value) values (5); |
| 57 |
select tbl, action from t2; |
| 58 |
tbl action |
| 59 |
t1 INSERT |
| 60 |
t1 INSERT |
| 61 |
t1 INSERT |
| 62 |
t1 INSERT |
| 63 |
connection node_2; |
| 64 |
insert into t1(value) values (6); |
| 65 |
select tbl, action from t2; |
| 66 |
tbl action |
| 67 |
t1 INSERT |
| 68 |
t1 INSERT |
| 69 |
t1 INSERT |
| 70 |
t1 INSERT |
| 71 |
connection node_1; |
| 72 |
select tbl, action from t2; |
| 73 |
tbl action |
| 74 |
t1 INSERT |
| 75 |
t1 INSERT |
| 76 |
t1 INSERT |
| 77 |
t1 INSERT |
| 78 |
drop table t1, t2; |