diff options
author | Monty <monty@mariadb.org> | 2016-10-02 15:35:08 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2016-10-05 01:11:07 +0300 |
commit | 8be53a389c8eebed337057fa366b7c4506ba16b1 (patch) | |
tree | abd36c95a598f1d6e5537e94fd7de034715ce299 /mysql-test/suite/rpl/r/rpl_trigger.result | |
parent | 0bae1957dd124f8382ae6af1de0e2168fc200bfb (diff) | |
download | mariadb-git-8be53a389c8eebed337057fa366b7c4506ba16b1.tar.gz |
MDEV-6112 multiple triggers per table
This is similar to MysQL Worklog 3253, but with
a different implementation. The disk format and
SQL syntax is identical with MySQL 5.7.
Fetures supported:
- "Any" ammount of any trigger
- Supports FOLLOWS and PRECEDES to be
able to put triggers in a certain execution order.
Implementation details:
- Class Trigger added to hold information about a trigger.
Before this trigger information was stored in a set of lists in
Table_triggers_list and in Table_triggers_list::bodies
- Each Trigger has a next field that poinst to the next Trigger with the
same action and time.
- When accessing a trigger, we now always access all linked triggers
- The list are now only used to load and save trigger files.
- MySQL trigger test case (trigger_wl3253) added and we execute these
identically.
- Even more gracefully handling of wrong trigger files than before. This
is useful if a trigger file uses functions or syntax not provided by
the server.
- Each trigger now has a "Created" field that shows when the trigger was
created, with 2 decimals.
Other comments:
- Many of the changes in test files was done because of the new "Created"
field in the trigger file. This shows up in SHOW ... TRIGGER and when
using information_schema.trigger.
- Don't check if all memory is released if on uses --gdb; This is needed
to be able to get a list from safemalloc of not freed memory while
debugging.
- Added option to trim_whitespace() to know how many prefix characters
was skipped.
- Changed a few ulonglong sql_mode to sql_mode_t, to find some wrong usage
of sql_mode.
Diffstat (limited to 'mysql-test/suite/rpl/r/rpl_trigger.result')
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_trigger.result | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result index 729d31fb001..dcf0c70ffc4 100644 --- a/mysql-test/suite/rpl/r/rpl_trigger.result +++ b/mysql-test/suite/rpl/r/rpl_trigger.result @@ -972,7 +972,7 @@ t1 t2 SHOW TRIGGERS; 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 +trg1 INSERT t1 INSERT INTO t2 VALUES(CURRENT_USER()) AFTER # latin1 latin1_swedish_ci latin1_swedish_ci SELECT * FROM t1; c 1 @@ -1115,4 +1115,47 @@ Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Gtid # # GTID #-#-# slave-bin.000001 # Query # # use `test`; drop trigger if exists notexistent connection master; +create table t1 (a int primary key, b int); +create trigger tr3 +before insert on t1 +for each row set NEW.b := (NEW.b+1)*4; +create trigger tr1 +before insert on t1 +for each row precedes tr3 set NEW.b := (NEW.b+1)*2; +create trigger tr2 +before insert on t1 +for each row follows tr1 set NEW.b := (NEW.b+1)*3; +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr1 INSERT t1 set NEW.b := (NEW.b+1)*2 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +tr2 INSERT t1 set NEW.b := (NEW.b+1)*3 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +tr3 INSERT t1 set NEW.b := (NEW.b+1)*4 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +insert into t1 values (1,1); +select * from t1; +a b +1 64 +connection slave; +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr1 INSERT t1 set NEW.b := (NEW.b+1)*2 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +tr2 INSERT t1 set NEW.b := (NEW.b+1)*3 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +tr3 INSERT t1 set NEW.b := (NEW.b+1)*4 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +select * from t1; +a b +1 64 +connection master; +drop table t1; +CREATE TABLE t1 (i INT); +CREATE OR REPLACE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET @a=1; +CREATE OR REPLACE TRIGGER tr BEFORE DELETE ON t1 FOR EACH ROW PRECEDES non_existing_trigger SET @a=2; +ERROR HY000: Referenced trigger 'non_existing_trigger' for the given action time and event type does not exist +SHOW TRIGGERS; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr INSERT t1 SET @a=1 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +connection slave; +SHOW TRIGGERS; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +tr INSERT t1 SET @a=1 BEFORE # NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci +connection master; +drop table t1; include/rpl_end.inc |