summaryrefslogtreecommitdiff
path: root/mysql-test/r/trigger.result
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2006-03-29 14:53:00 +0400
committerunknown <dlenev@mysql.com>2006-03-29 14:53:00 +0400
commit297c18ada3b38fe1dd9f45a984bf973f10c35791 (patch)
tree6f6da109cd3a4c650e3a8bc44c60c6d773cefcd0 /mysql-test/r/trigger.result
parent24d83bbdc757c58a1b09bdbebf48ce2b333980c5 (diff)
downloadmariadb-git-297c18ada3b38fe1dd9f45a984bf973f10c35791.tar.gz
Proposed fix for bug #17764 "Trigger crashes MyISAM table"
A table with an on insert trigger was reported as crashed when the insert was processed with bulk insert mode on (handler::start_bulk_insert). The trigger was also selecting from the same table, and that caused the "crash". The same problem was present when an insert statement, which was processed in bulk mode, also used a stored function that was reading the same table. This fix disables bulk inserts if a statement uses functions or invokes triggers. Implementing more granular checks will require much more code and therefore can hardly be done in 5.0 mysql-test/r/trigger.result: Added test bug #17764 "Trigger crashes MyISAM table". mysql-test/t/trigger.test: Added test bug #17764 "Trigger crashes MyISAM table". sql/sql_insert.cc: We should not start bulk inserts for INSERT (or similar) statement if it uses functions or invokes triggers since they may access to the same table and therefore should not see its inconsistent state created by this optimization. sql/sql_load.cc: We should not start bulk inserts for INSERT (or similar) statement if it uses functions or invokes triggers since they may access to the same table and therefore should not see its inconsistent state created by this optimization.
Diffstat (limited to 'mysql-test/r/trigger.result')
-rw-r--r--mysql-test/r/trigger.result24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index c9a91758336..711399418ac 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -2,6 +2,7 @@ drop table if exists t1, t2, t3, t4;
drop view if exists v1;
drop database if exists mysqltest;
drop function if exists f1;
+drop function if exists f2;
drop procedure if exists p1;
create table t1 (i int);
create trigger trg before insert on t1 for each row set @a:=1;
@@ -897,3 +898,26 @@ create trigger t1_bi before insert on t1 for each row return 0;
ERROR 42000: RETURN is only allowed in a FUNCTION
insert into t1 values (1);
drop table t1;
+create table t1 (a varchar(64), b int);
+create table t2 like t1;
+create trigger t1_ai after insert on t1 for each row
+set @a:= (select max(a) from t1);
+insert into t1 (a) values
+("Twas"),("brillig"),("and"),("the"),("slithy"),("toves"),
+("Did"),("gyre"),("and"),("gimble"),("in"),("the"),("wabe");
+create trigger t2_ai after insert on t2 for each row
+set @a:= (select max(a) from t2);
+insert into t2 select * from t1;
+load data infile '../std_data_ln/words.dat' into table t1 (a);
+drop trigger t1_ai;
+drop trigger t2_ai;
+create function f1() returns int return (select max(b) from t1);
+insert into t1 values
+("All",f1()),("mimsy",f1()),("were",f1()),("the",f1()),("borogoves",f1()),
+("And",f1()),("the",f1()),("mome", f1()),("raths",f1()),("outgrabe",f1());
+create function f2() returns int return (select max(b) from t2);
+insert into t2 select a, f2() from t1;
+load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1();
+drop table t1;
+drop function f1;
+drop function f2;