summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger.test
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2006-03-04 16:55:06 +0300
committerunknown <dlenev@mysql.com>2006-03-04 16:55:06 +0300
commit350475fae41d31c37214705a54bdd93bb435a4f3 (patch)
treedb299ca84b23ab1fe9bd82d616d2c1de709c64ec /mysql-test/t/trigger.test
parent40f38a2d3e3bda4e0c09c44cb3fd2b3623cdd553 (diff)
downloadmariadb-git-350475fae41d31c37214705a54bdd93bb435a4f3.tar.gz
Fix for bug #17866 "Problem with renaming table with triggers with fully
qualified subject table" which was introduced during work on bug #13525 "Rename table does not keep info of triggers". The bug was caused by the fact that during reconstruction of CREATE TRIGGER statement stored in .TRG file which happened during RENAME TABLE we damaged trigger definition in case when it contained fully qualified name of subject table (see comment for sql_yacc.yy for more info). mysql-test/r/trigger.result: Added test for bug #17866 "Problem with renaming table with triggers with fully qualified subject table". mysql-test/t/trigger.test: Added test for bug #17866 "Problem with renaming table with triggers with fully qualified subject table". sql/sql_trigger.cc: Table_triggers_list::change_table_name_in_triggers(): Instead of trying to use pointer to the end of subject table identifier we use pointer to the beginning of FOR lexeme now, so during reconstruction of CREATE TRIGGER statement in this function we need to add extra space before part which begins with FOR to get nice trigger definition. sql/sql_yacc.yy: trigger_tail: In this rule we can't rely on using remember_end token after table_ident token, since value returned depends on whether table name is fully qualified or not. So instead of trying to get pointer to the end of table identifier we use pointer to the beginning of FOR lexeme.
Diffstat (limited to 'mysql-test/t/trigger.test')
-rw-r--r--mysql-test/t/trigger.test14
1 files changed, 9 insertions, 5 deletions
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 0ac57394c2f..1d68b519f1d 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -960,38 +960,42 @@ drop trigger t1_bi;
connection default;
#
-# Test for bug #13525 "Rename table does not keep info of triggers"
+# Tests for bug #13525 "Rename table does not keep info of triggers"
+# and bug #17866 "Problem with renaming table with triggers with fully
+# qualified subject table".
#
create table t1 (id int);
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
+create trigger t1_ai after insert on test.t1 for each row set @b:=new.id;
insert into t1 values (101);
-select @a;
+select @a, @b;
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
rename table t1 to t2;
# Trigger should work after rename
insert into t2 values (102);
-select @a;
+select @a, @b;
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
# Let us check that the same works for simple ALTER TABLE ... RENAME
alter table t2 rename to t3;
insert into t3 values (103);
-select @a;
+select @a, @b;
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
# And for more complex ALTER TABLE
alter table t3 rename to t4, add column val int default 0;
insert into t4 values (104, 1);
-select @a;
+select @a, @b;
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
# .TRN file should be updated with new table name
drop trigger t1_bi;
+drop trigger t1_ai;
drop table t4;
# Rename between different databases if triggers exist should fail
create database mysqltest;