diff options
author | unknown <dlenev@mysql.com> | 2006-03-24 14:58:18 +0300 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2006-03-24 14:58:18 +0300 |
commit | a389ec0b1b7573fce04589ffc74f61787d2df22f (patch) | |
tree | 77e94372a9a9d94c408d2d5169ea1dd691186fcc /mysql-test/r/trigger-trans.result | |
parent | 4399da26b4f5f169c2264ad8bd3579f86f926522 (diff) | |
download | mariadb-git-a389ec0b1b7573fce04589ffc74f61787d2df22f.tar.gz |
Fix for bug #18153 "ALTER/OPTIMIZE/REPAIR on transactional tables corrupt
triggers".
Applying ALTER/OPTIMIZE/REPAIR TABLE statements to transactional table or to
table of any type on Windows caused disappearance of its triggers.
Bug was introduced in 5.0.19 by my fix for bug #13525 "Rename table does not
keep info of triggers" (see comment for sql_table.cc for more info).
.
mysql-test/r/trigger.result:
Added test-case covering handling of triggers when one does ALTER TABLE which
should move table to different database.
mysql-test/t/trigger.test:
Added test-case covering handling of triggers when one does ALTER TABLE which
should move table to different database.
sql/sql_table.cc:
mysql_alter_table():
Removal of strdup() which is no longer necessary allows us to preserve
nice assumption that "(new_db != db || new_table != table_name) indicates
that table will be renamed. So now we really can use this condition to
avoid updating trigger definitions when table is not renamed.
Note that we can't use (alter_info->flags & ALTER_RENAME) condition instead
since it can be also true when we do "ALTER TABLE t1 RENAME TO t1".
sql/sql_trigger.cc:
Table_triggers_list::change_table_name():
Mentioned assumption that subject table is not renamed to itself in method
description. Added DBUG_ASSERT() to catch wrong usage of this method.
mysql-test/r/trigger-trans.result:
New BitKeeper file ``mysql-test/r/trigger-trans.result''
mysql-test/t/trigger-trans.test:
New BitKeeper file ``mysql-test/t/trigger-trans.test''
Diffstat (limited to 'mysql-test/r/trigger-trans.result')
-rw-r--r-- | mysql-test/r/trigger-trans.result | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/mysql-test/r/trigger-trans.result b/mysql-test/r/trigger-trans.result new file mode 100644 index 00000000000..b56abf1f59a --- /dev/null +++ b/mysql-test/r/trigger-trans.result @@ -0,0 +1,84 @@ +drop table if exists t1; +create table t1 (a varchar(16), b int) engine=innodb; +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| +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'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 begin +set new.a := upper(new.a); +set new.b := new.b + 3; +end +insert into t1 values ('The Lion', 10); +select * from t1; +a b +THE LION 13 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +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'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 begin +set new.a := upper(new.a); +set new.b := new.b + 3; +end +insert into t1 values ('The Unicorn', 20); +select * from t1; +a b +THE LION 13 +THE UNICORN 23 +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'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 begin +set new.a := upper(new.a); +set new.b := new.b + 3; +end +insert into t1 values ('Alice', 30, 1); +select * from t1; +a b c +THE LION 13 0 +THE UNICORN 23 0 +ALICE 33 1 +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'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 begin +set new.a := upper(new.a); +set new.b := new.b + 3; +end +insert into t1 values ('The Crown', 40, 1); +select * from t1; +a b c +THE LION 13 0 +THE UNICORN 23 0 +ALICE 33 1 +THE CROWN 43 1 +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'; +trigger_schema trigger_name event_object_schema event_object_table action_statement +test t1_bi test t1 begin +set new.a := upper(new.a); +set new.b := new.b + 3; +end +insert into t1 values ('The Pie', 50, 1, 1); +select * from t1; +a b c d +THE LION 13 0 0 +THE UNICORN 23 0 0 +ALICE 33 1 0 +THE CROWN 43 1 0 +THE PIE 53 1 1 +drop table t1; |