Below is the list of changes that have just been committed into a local
5.0 repository of marcsql. When marcsql 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@stripped, 2007-01-10 09:05:04-07:00, malff@weblab.(none) +3 -0
Bug#25411 (trigger code truncated)
Before this change, when a trigger code ends with the following characters:
- '*'
- ';'
- '/'
- whitespace
the trigger code would be truncated by the parser, and later saved in the
trigger .TRG file.
In particluar, the following statement, which is syntaxically correct
(it refers to an unknown table NEW, in a select from dual)
INSERT INTO T2 SELECT NEW.*;
whould be saved as :
INSERT INTO T2 SELECT NEW.
As a result, reading the .TRG file when reloading the trigger later fails,
which prevents execution of any statements involving the table.
The reason for truncating trailing '*' '/' and ';' characters is related to
the use of the following syntax :
/*!50003 CREATE TRIGGER t1_bi BEFORE INSERT ON t1
FOR EACH ROW INSERT INTO t2 VALUES(NEW.c * 10) */;
which is used for dumps and replication.
Unders some circumpstances, this syntax can be altered to:
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
FOR EACH ROW INSERT INTO t2 VALUES(NEW.c * 10) */;
which create the need to clean up the closing comments, implemented by
the function skip_rear_comments().
With this fix, the function skip_rear_comments() has been changed to remove:
- trailing whitespace
- trailing ';' delimiters
- one trailing '*' '/' sequence
so that other combinations, like '*' ';' in this case, are not affected.
mysql-test/r/trigger.result@stripped, 2007-01-10 09:04:20-07:00, malff@weblab.(none) +20 -0
test for trigger code truncation
mysql-test/t/trigger.test@stripped, 2007-01-10 09:04:20-07:00, malff@weblab.(none) +36 -0
test for trigger code truncation
sql/sql_lex.cc@stripped, 2007-01-10 09:04:20-07:00, malff@weblab.(none) +26 -3
Remove only whitespace, ';' or '*/', not random combinations of '*' '/' ';'.
# 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: malff
# Host: weblab.(none)
# Root: /home/marcsql/TREE/mysql-5.0-25411
--- 1.207/sql/sql_lex.cc 2007-01-10 09:05:10 -07:00
+++ 1.208/sql/sql_lex.cc 2007-01-10 09:05:10 -07:00
@@ -1072,9 +1072,32 @@ int MYSQLlex(void *arg, void *yythd)
uchar *skip_rear_comments(uchar *begin, uchar *end)
{
- while (begin < end && (end[-1] <= ' ' || end[-1] == '*' ||
- end[-1] == '/' || end[-1] == ';'))
- end-= 1;
+ bool skipped;
+
+ do
+ {
+ skipped= false;
+
+ /* consume trailing white space */
+ while ( (begin < end)
+ && my_isspace(system_charset_info, end[-1]))
+ {
+ end--;
+ skipped= true;
+ }
+
+ /* consume trailing ';' */
+ if ( (begin < end) && end[-1] == ';')
+ {
+ end--;
+ skipped= true;
+ }
+ } while (skipped);
+
+ /* Chop off a trailing end comment marker */
+ if ((begin + 2 <= end) && (end[-2] == '*') && (end[-1] == '/'))
+ end-= 2;
+
return end;
}
--- 1.50/mysql-test/r/trigger.result 2007-01-10 09:05:10 -07:00
+++ 1.51/mysql-test/r/trigger.result 2007-01-10 09:05:10 -07:00
@@ -1278,4 +1278,24 @@ a b
2 b
3 c
drop table t1;
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (a int);
+create table t2 (a int);
+create trigger bug25411_trg after insert on t1
+for each row
+insert into t2 select new.*;
+select * from t1;
+a
+select * from t2;
+a
+insert into t1 values (1);
+ERROR 42S02: Unknown table 'new'
+insert into t2 values (1);
+select ACTION_STATEMENT from INFORMATION_SCHEMA.TRIGGERS
+where trigger_name="bug25411_trg";
+ACTION_STATEMENT
+insert into t2 select new.*
+drop table t1;
+drop table t2;
End of 5.0 tests
--- 1.56/mysql-test/t/trigger.test 2007-01-10 09:05:10 -07:00
+++ 1.57/mysql-test/t/trigger.test 2007-01-10 09:05:10 -07:00
@@ -1547,4 +1547,40 @@ select * from t1;
drop table t1;
+#
+# Bug#25411 (trigger code truncated)
+#
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+
+create table t1 (a int);
+
+create table t2 (a int);
+
+# "NEW.*" and "OLD.*" are not supported,
+# so this trigger _logic_ is boguous.
+# However, a bug choping the '*' off when writing
+# the .TRG file caused corruption on the _trigger_ itself,
+# affecting the table as a side effect.
+create trigger bug25411_trg after insert on t1
+for each row
+insert into t2 select new.*;
+
+select * from t1;
+select * from t2;
+
+--error ER_BAD_TABLE_ERROR
+insert into t1 values (1);
+
+insert into t2 values (1);
+
+select ACTION_STATEMENT from INFORMATION_SCHEMA.TRIGGERS
+where trigger_name="bug25411_trg";
+
+drop table t1;
+drop table t2;
+
--echo End of 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (malff:1.2322) BUG#25411 | marc.alff | 10 Jan |