Below is the list of changes that have just been committed into a local
5.0 repository of dlenev. When dlenev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2104 06/03/04 16:55:06 dlenev@stripped +4 -0
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).
sql/sql_yacc.yy
1.456 06/03/04 16:55:00 dlenev@stripped +2 -2
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.
sql/sql_trigger.cc
1.44 06/03/04 16:54:59 dlenev@stripped +1 -0
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.
mysql-test/t/trigger.test
1.37 06/03/04 16:54:59 dlenev@stripped +9 -5
Added test for bug #17866 "Problem with renaming table with triggers with fully
qualified subject table".
mysql-test/r/trigger.result
1.32 06/03/04 16:54:59 dlenev@stripped +18 -12
Added test for bug #17866 "Problem with renaming table with triggers with fully
qualified subject table".
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: dlenev
# Host: brandersnatch.site
# Root: /home/dlenev/src/mysql-5.0-bg17866-2
--- 1.455/sql/sql_yacc.yy 2006-03-03 20:49:15 +03:00
+++ 1.456/sql/sql_yacc.yy 2006-03-04 16:55:00 +03:00
@@ -9127,7 +9127,7 @@
trigger_tail:
TRIGGER_SYM remember_name sp_name trg_action_time trg_event
- ON remember_name table_ident remember_end FOR_SYM EACH_SYM ROW_SYM
+ ON remember_name table_ident FOR_SYM remember_name EACH_SYM ROW_SYM
{
LEX *lex= Lex;
sp_head *sp;
@@ -9145,7 +9145,7 @@
lex->trigger_definition_begin= $2;
lex->ident.str= $7;
- lex->ident.length= $9 - $7;
+ lex->ident.length= $10 - $7;
sp->m_type= TYPE_ENUM_TRIGGER;
lex->sphead= sp;
--- 1.31/mysql-test/r/trigger.result 2006-02-26 20:25:16 +03:00
+++ 1.32/mysql-test/r/trigger.result 2006-03-04 16:54:59 +03:00
@@ -787,46 +787,52 @@
ERROR 3D000: No database selected
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;
-@a
-101
+select @a, @b;
+@a @b
+101 101
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
trigger_schema trigger_name event_object_schema event_object_table action_statement
test t1_bi test t1 set @a:=new.id
+test t1_ai test t1 set @b:=new.id
rename table t1 to t2;
insert into t2 values (102);
-select @a;
-@a
-102
+select @a, @b;
+@a @b
+102 102
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
trigger_schema trigger_name event_object_schema event_object_table action_statement
test t1_bi test t2 set @a:=new.id
+test t1_ai test t2 set @b:=new.id
alter table t2 rename to t3;
insert into t3 values (103);
-select @a;
-@a
-103
+select @a, @b;
+@a @b
+103 103
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
trigger_schema trigger_name event_object_schema event_object_table action_statement
test t1_bi test t3 set @a:=new.id
+test t1_ai test t3 set @b:=new.id
alter table t3 rename to t4, add column val int default 0;
insert into t4 values (104, 1);
-select @a;
-@a
-104
+select @a, @b;
+@a @b
+104 104
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
trigger_schema trigger_name event_object_schema event_object_table action_statement
test t1_bi test t4 set @a:=new.id
+test t1_ai test t4 set @b:=new.id
drop trigger t1_bi;
+drop trigger t1_ai;
drop table t4;
create database mysqltest;
use mysqltest;
--- 1.36/mysql-test/t/trigger.test 2006-02-27 20:32:23 +03:00
+++ 1.37/mysql-test/t/trigger.test 2006-03-04 16:54:59 +03:00
@@ -960,38 +960,42 @@
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;
--- 1.43/sql/sql_trigger.cc 2006-02-26 16:32:52 +03:00
+++ 1.44/sql/sql_trigger.cc 2006-03-04 16:54:59 +03:00
@@ -1217,6 +1217,7 @@
buff.append(def->str, before_on_len);
buff.append(STRING_WITH_LEN("ON "));
append_identifier(thd, &buff, new_table_name->str, new_table_name->length);
+ buff.append(STRING_WITH_LEN(" "));
on_q_table_name_len= buff.length() - before_on_len;
buff.append(on_table_name->str + on_table_name->length,
def->length - (before_on_len + on_table_name->length));
| Thread |
|---|
| • bk commit into 5.0 tree (dlenev:1.2104) BUG#13525 | dlenev | 4 Mar |