summaryrefslogtreecommitdiff
path: root/mysql-test/r/rpl_trigger.result
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2006-11-13 15:40:22 -0700
committerunknown <malff/marcsql@weblab.(none)>2006-11-13 15:40:22 -0700
commit541e9c9ac5ef31933beed881ea4171e2d7a38b97 (patch)
tree3f4f3f80ffa147506b1ce9e44eef713efeaefc3f /mysql-test/r/rpl_trigger.result
parent1031c460de5bd4b1014614e8871393eebd0a51bc (diff)
downloadmariadb-git-541e9c9ac5ef31933beed881ea4171e2d7a38b97.tar.gz
Bug#23703 (DROP TRIGGER needs an IF EXISTS)
This change set implements the DROP TRIGGER IF EXISTS functionality. This fix is considered a bug and not a feature, because without it, there is no known method to write a database creation script that can create a trigger without failing, when executed on a database that may or may not contain already a trigger of the same name. Implementing this functionality closes an orthogonality gap between triggers and stored procedures / stored functions (which do support the DROP IF EXISTS syntax). In sql_trigger.cc, in mysql_create_or_drop_trigger, the code has been reordered to: - perform the tests that do not depend on the file system (access()), - get the locks (wait_if_global_read_lock, LOCK_open) - call access() - perform the operation - write to the binlog - unlock (LOCK_open, start_waiting_global_read_lock) This is to ensure that all the code that depends on the presence of the trigger file is executed in the same critical section, and prevents race conditions similar to the case fixed by Bug 14262 : - thread 1 executes DROP TRIGGER IF EXISTS, access() returns a failure - thread 2 executes CREATE TRIGGER - thread 2 logs CREATE TRIGGER - thread 1 logs DROP TRIGGER IF EXISTS The patch itself is based on code contributed by the MySQL community, under the terms of the Contributor License Agreement (See Bug 18161). mysql-test/r/rpl_trigger.result: DROP TRIGGER IF EXISTS mysql-test/r/trigger.result: DROP TRIGGER IF EXISTS mysql-test/t/rpl_trigger.test: DROP TRIGGER IF EXISTS mysql-test/t/trigger.test: DROP TRIGGER IF EXISTS sql/sql_trigger.cc: DROP TRIGGER IF EXISTS sql/sql_yacc.yy: DROP TRIGGER IF EXISTS
Diffstat (limited to 'mysql-test/r/rpl_trigger.result')
-rw-r--r--mysql-test/r/rpl_trigger.result27
1 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/r/rpl_trigger.result b/mysql-test/r/rpl_trigger.result
index 3c740bf8e64..f8573eec75f 100644
--- a/mysql-test/r/rpl_trigger.result
+++ b/mysql-test/r/rpl_trigger.result
@@ -941,3 +941,30 @@ c
---> Cleaning up...
DROP TABLE t1;
DROP TABLE t2;
+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;