summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger-trans.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/trigger-trans.test')
-rw-r--r--mysql-test/t/trigger-trans.test52
1 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test
new file mode 100644
index 00000000000..5c135d98878
--- /dev/null
+++ b/mysql-test/t/trigger-trans.test
@@ -0,0 +1,52 @@
+# Tests which involve triggers and transactions
+# (or just InnoDB storage engine)
+--source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+# Test for bug #18153 "OPTIMIZE/ALTER on transactional tables corrupt
+# triggers/triggers are lost".
+
+create table t1 (a varchar(16), b int) engine=innodb;
+delimiter |;
+create trigger t1_bi before insert on t1 for each row
+begin
+ set new.a := upper(new.a);
+ set new.b := new.b + 3;
+end|
+delimiter ;|
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+insert into t1 values ('The Lion', 10);
+select * from t1;
+optimize table t1;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+insert into t1 values ('The Unicorn', 20);
+select * from t1;
+alter table t1 add column c int default 0;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+insert into t1 values ('Alice', 30, 1);
+select * from t1;
+# Special tricky cases allowed by ALTER TABLE ... RENAME
+alter table t1 rename to t1;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+insert into t1 values ('The Crown', 40, 1);
+select * from t1;
+alter table t1 rename to t1, add column d int default 0;
+select trigger_schema, trigger_name, event_object_schema,
+ event_object_table, action_statement from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+insert into t1 values ('The Pie', 50, 1, 1);
+select * from t1;
+drop table t1;
+
+# End of 5.0 tests