# At a local mysql-5.1-bugteam repository of davi
3379 Davi Arnaut 2010-03-09
Bug#51650: crash with user variables and triggers
The problem was that bits of the destructive equality propagation
optimization weren't being undone after the execution of a stored
program. Modifications to the parse tree that are based on transient
properties must be undone to enable the re-execution of stored
programs.
The solution is to cleanup any references to predicates generated
by the equality propagation during the execution of a stored program.
@ mysql-test/r/trigger.result
Add test case result for Bug#51650.
@ mysql-test/t/trigger.test
Add test case for Bug#51650.
@ sql/item.cc
Remove reference to a equality predicate.
modified:
mysql-test/r/trigger.result
mysql-test/t/trigger.test
sql/item.cc
=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result 2010-02-22 16:58:56 +0000
+++ b/mysql-test/r/trigger.result 2010-03-09 17:17:38 +0000
@@ -2087,4 +2087,28 @@ ERROR 42S02: Table 'test.a_nonextisting_
SELECT * FROM t2;
a b
DROP TABLE t1, t2;
+#
+# Bug#51650 crash with user variables and triggers
+#
+drop table if exists t1, t2;
+drop trigger if exists trg1;
+CREATE TABLE t1 (b VARCHAR(50) NOT NULL);
+CREATE TABLE t2 (a VARCHAR(10) NOT NULL DEFAULT '');
+CREATE TRIGGER trg1 AFTER INSERT ON t2
+FOR EACH ROW BEGIN
+SELECT 1 FROM t1 c WHERE
+(@bug51650 IS NULL OR @bug51650 != c.b) AND c.b = NEW.a LIMIT 1 INTO @foo;
+END//
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 VALUES();
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+INSERT IGNORE INTO t1 SET b = '777';
+INSERT IGNORE INTO t2 SET a = '111';
+Warnings:
+Warning 1329 No data - zero rows fetched, selected, or processed
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 SET a = '777';
+DROP TRIGGER trg1;
+DROP TABLE t1, t2;
End of 5.1 tests.
=== modified file 'mysql-test/t/trigger.test'
--- a/mysql-test/t/trigger.test 2010-02-22 16:58:56 +0000
+++ b/mysql-test/t/trigger.test 2010-03-09 17:17:38 +0000
@@ -2396,4 +2396,35 @@ SELECT * FROM t2;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug#51650 crash with user variables and triggers
+--echo #
+
+--disable_warnings
+drop table if exists t1, t2;
+drop trigger if exists trg1;
+--enable_warnings
+
+
+CREATE TABLE t1 (b VARCHAR(50) NOT NULL);
+CREATE TABLE t2 (a VARCHAR(10) NOT NULL DEFAULT '');
+
+delimiter //;
+CREATE TRIGGER trg1 AFTER INSERT ON t2
+FOR EACH ROW BEGIN
+ SELECT 1 FROM t1 c WHERE
+ (@bug51650 IS NULL OR @bug51650 != c.b) AND c.b = NEW.a LIMIT 1 INTO @foo;
+END//
+delimiter ;//
+
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 VALUES();
+INSERT IGNORE INTO t1 SET b = '777';
+INSERT IGNORE INTO t2 SET a = '111';
+SET @bug51650 = 1;
+INSERT IGNORE INTO t2 SET a = '777';
+
+DROP TRIGGER trg1;
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests.
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2010-02-26 13:40:01 +0000
+++ b/sql/item.cc 2010-03-09 17:17:38 +0000
@@ -4475,6 +4475,7 @@ void Item_field::cleanup()
I.e. we can drop 'field'.
*/
field= result_field= 0;
+ item_equal= NULL;
null_value= FALSE;
DBUG_VOID_RETURN;
}
Attachment: [text/bzr-bundle] bzr/davi.arnaut@sun.com-20100309171738-7ynpzzrbpij5vlf8.bundle