summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/rpl/r/rpl_create_drop_trigger.result
blob: e1474d8854e47bdd1f7b7f1f08f4337734bb6ff2 (plain)
1
2
3
4
5
6
7
8
9
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
include/master-slave.inc
[connection master]
# Part 1 - initial creation
connection master;
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1 (val INT);
CREATE TRIGGER val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val + 1;
SET @sum=0;
INSERT INTO t1 VALUES (10), (20), (30);
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Master FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Master
SET @sum = @sum + NEW.val + 1
connection slave;
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Slave FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Slave
SET @sum = @sum + NEW.val + 1
# Part 2 - CREATE IF NOT EXISTS (on a existing trigger)
connection master;
CREATE TRIGGER IF NOT EXISTS val_sum AFTER INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val + 2;
Warnings:
Note	1359	Trigger 'db1.val_sum' already exists
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Master FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Master
SET @sum = @sum + NEW.val + 1
connection slave;
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Slave FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Slave
SET @sum = @sum + NEW.val + 1
# Part 3 - CREATE OR REPLACE (on a existing trigger)
connection master;
CREATE OR REPLACE TRIGGER val_sum BEFORE INSERT ON t1 FOR EACH ROW SET @sum = @sum + NEW.val + 3;
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Master FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Master
SET @sum = @sum + NEW.val + 3
connection slave;
SELECT ACTION_STATEMENT AS ACTION_STATEMENT_Slave FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME='val_sum';
ACTION_STATEMENT_Slave
SET @sum = @sum + NEW.val + 3
# Clearing up
connection master;
DROP TRIGGER val_sum;
DROP TABLE t1;
DROP TRIGGER IF EXISTS val_sum;
Warnings:
Note	1360	Trigger does not exist
DROP TRIGGER random_trigger;
ERROR HY000: Trigger does not exist
DROP DATABASE db1;
DROP TRIGGER IF EXISTS val_sum;
ERROR 3D000: No database selected
# Syncing slave with master
connection slave;
DROP TRIGGER val_sum;
ERROR HY000: Trigger does not exist
include/rpl_end.inc