diff options
author | unknown <kostja@vajra.(none)> | 2007-05-16 09:52:01 +0400 |
---|---|---|
committer | unknown <kostja@vajra.(none)> | 2007-05-16 09:52:01 +0400 |
commit | 7e628372e9b21e0355b9b8145e12a0ca31e98260 (patch) | |
tree | c990b139823c3fe164a9109ccc0b8e3cdc26e02f /mysql-test/t/insert.test | |
parent | b763ff9a6b0d946a691559db6d69bd821783b8a9 (diff) | |
parent | 3395c53efcf07126fdf05ccd4ffdafb8ce319751 (diff) | |
download | mariadb-git-7e628372e9b21e0355b9b8145e12a0ca31e98260.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into vajra.(none):/opt/local/work/mysql-5.0-21483
sql/sp_head.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.h:
Auto merged
Diffstat (limited to 'mysql-test/t/insert.test')
-rw-r--r-- | mysql-test/t/insert.test | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 0a8e184ea5c..76177403bd0 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -216,3 +216,142 @@ select * from t1; drop view v1; drop table t1,t2; + +# +# BUG#21483: Server abort or deadlock on INSERT DELAYED with another +# implicit insert +# +# The solution is to downgrade INSERT DELAYED to normal INSERT if the +# statement uses functions and access tables or triggers, or is called +# from a function or a trigger. +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP FUNCTION IF EXISTS f1; +DROP FUNCTION IF EXISTS f2; +--enable_warnings + +CREATE TABLE t1 (i INT); +delimiter |; +CREATE FUNCTION f1() RETURNS INT +BEGIN + INSERT INTO t1 VALUES (1); + RETURN 1; +END | +CREATE FUNCTION f2() RETURNS INT +BEGIN + INSERT DELAYED INTO t1 VALUES (2); + RETURN 1; +END | +delimiter ;| + +SELECT f1(); +SELECT f2(); +INSERT INTO t1 VALUES (3); +INSERT DELAYED INTO t1 VALUES (4); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT INTO t1 VALUES (f1()); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT DELAYED INTO t1 VALUES (f1()); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT INTO t1 VALUES (f2()); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT DELAYED INTO t1 VALUES (f2()); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + INSERT INTO t1 VALUES (NEW.i); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT INTO t1 VALUES (1); + +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +INSERT DELAYED INTO t1 VALUES (1); + +SELECT * FROM t1; + +DROP FUNCTION f2; +DROP FUNCTION f1; +DROP TABLE t1; + +# +# BUG#20497: Trigger with INSERT DELAYED causes Error 1165 +# +# Fixed by the patch for Bug#21483 +# +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); + +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + INSERT DELAYED INTO t2 VALUES (NEW.i); + +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW + INSERT DELAYED INTO t2 VALUES (NEW.i); + +CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW + INSERT DELAYED INTO t2 VALUES (OLD.i); + +INSERT INTO t1 VALUES (1); +INSERT DELAYED INTO t1 VALUES (2); +SELECT * FROM t1; +UPDATE t1 SET i = 3 WHERE i = 1; +SELECT * FROM t1; +DELETE FROM t1 WHERE i = 3; +SELECT * FROM t1; +SELECT * FROM t2; + +DROP TABLE t1, t2; + +# +# BUG#21714: Wrong NEW.value and server abort on INSERT DELAYED to a +# table with a trigger +# +# Fixed by the patch for Bug#21483 +# +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 (i INT); +CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW + SET @a= NEW.i; + +SET @a= 0; +INSERT DELAYED INTO t1 VALUES (1); +SELECT @a; +INSERT DELAYED INTO t1 VALUES (2); +SELECT @a; + +DROP TABLE t1; + +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (i INT); + +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW + INSERT INTO t2 VALUES (NEW.i); + +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW + INSERT DELAYED INTO t2 VALUES (NEW.i); + +CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW + INSERT DELAYED INTO t2 VALUES (OLD.i); + +INSERT DELAYED INTO t1 VALUES (1); +SELECT * FROM t1; +UPDATE t1 SET i = 2 WHERE i = 1; +SELECT * FROM t1; +DELETE FROM t1 WHERE i = 2; +SELECT * FROM t1; +SELECT * FROM t2; + +DROP TABLE t1, t2; + +--echo End of 5.0 tests. + |