[Commits] Rev 4350: MDEV-6985: MariaDB crashes on stored procedure call in file:///home/bell/maria/bzr/work-maria-5.5-MDEV-6985/

sanja at askmonty.org sanja at askmonty.org
Mon Nov 17 15:27:04 EET 2014


At file:///home/bell/maria/bzr/work-maria-5.5-MDEV-6985/

------------------------------------------------------------
revno: 4350
revision-id: sanja at askmonty.org-20141117132635-gf281ipiomifw1oc
parent: psergey at askmonty.org-20141113111559-cuhsyfhor141qo6a
committer: sanja at askmonty.org
branch nick: work-maria-5.5-MDEV-6985
timestamp: Mon 2014-11-17 14:26:35 +0100
message:
  MDEV-6985: MariaDB crashes on stored procedure call
  
  Item_ident fixed to allow double cleanup().
-------------- next part --------------
=== added file 'mysql-test/r/sp-innodb.result'
--- a/mysql-test/r/sp-innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/sp-innodb.result	2014-11-17 13:26:35 +0000
@@ -0,0 +1,32 @@
+drop table if exists t1,t2;
+drop procedure if exists p1;
+#
+#MDEV-6985: MariaDB crashes on stored procedure call
+#
+CREATE TABLE `t1` (
+`ID` int(11) NOT NULL,
+PRIMARY KEY (`ID`)
+) ENGINE=InnoDB;
+CREATE TABLE `t2` (
+`ID` int(11) NOT NULL,
+`DATE` datetime DEFAULT NULL,
+PRIMARY KEY (`ID`)
+) ENGINE=InnoDB;
+CREATE PROCEDURE `p1`()
+BEGIN
+DECLARE _mySelect CURSOR FOR 
+SELECT DISTINCT t1.ID
+FROM t1  
+LEFT JOIN t2 AS t2 ON 
+t2.ID = t1.ID
+AND t2.DATE = (
+SELECT MAX(T3.DATE) FROM t2 AS T3 WHERE T3.ID = t2.ID AND T3.DATE<=NOW()
+)
+WHERE t1.ID = 1;
+OPEN _mySelect;
+CLOSE _mySelect;
+END ;;
+CALL p1();
+CALL p1();
+drop procedure p1;
+drop table t1,t2;

=== added file 'mysql-test/t/sp-innodb.test'
--- a/mysql-test/t/sp-innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/sp-innodb.test	2014-11-17 13:26:35 +0000
@@ -0,0 +1,45 @@
+
+--source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1,t2;
+drop procedure if exists p1;
+--enable_warnings
+
+--echo #
+--echo #MDEV-6985: MariaDB crashes on stored procedure call
+--echo #
+CREATE TABLE `t1` (
+  `ID` int(11) NOT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB;
+
+CREATE TABLE `t2` (
+  `ID` int(11) NOT NULL,
+  `DATE` datetime DEFAULT NULL,
+  PRIMARY KEY (`ID`)
+) ENGINE=InnoDB;
+
+--delimiter ;;
+
+CREATE PROCEDURE `p1`()
+BEGIN
+  DECLARE _mySelect CURSOR FOR 
+	SELECT DISTINCT t1.ID
+	FROM t1  
+		LEFT JOIN t2 AS t2 ON 
+			t2.ID = t1.ID
+			AND t2.DATE = (
+				SELECT MAX(T3.DATE) FROM t2 AS T3 WHERE T3.ID = t2.ID AND T3.DATE<=NOW()
+			)
+	WHERE t1.ID = 1;
+  OPEN _mySelect;
+  CLOSE _mySelect;
+END ;;
+--delimiter ;
+
+CALL p1();
+CALL p1();
+
+drop procedure p1;
+drop table t1,t2;

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2014-10-06 17:53:55 +0000
+++ b/sql/item.cc	2014-11-17 13:26:35 +0000
@@ -862,12 +862,20 @@ void Item_ident::cleanup()
 		       field_name ? field_name : "(null)",
                        orig_field_name ? orig_field_name : "(null)"));
 #endif
+  bool was_fixed= fixed;
   Item::cleanup();
   db_name= orig_db_name; 
   table_name= orig_table_name;
   field_name= orig_field_name;
   /* Store if this Item was depended */
-  can_be_depended= test(depended_from);
+  if (was_fixed)
+  {
+    /*
+      We can trust that depended_from set correctly only if this item
+      was fixed
+    */
+    can_be_depended= test(depended_from);
+  }
   DBUG_VOID_RETURN;
 }
 



More information about the commits mailing list