Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.2.13, 10.3.5
-
Windows x64 and CENTOS 7.4
-
10.2.14
Description
https://mariadb.com/kb/en/library/mariadb-10213-call-procedure-param-last_insert_id/
Before the update MariaDB 10.2.13 I was able to call a procedure inside the other passing as argument LAST_INSERT_ID (), now of the error in MariaDB, after the update I have to assign the LAST_INSERT_ID () in a variable before calling the procedure
Before MariaDB 10.2.13
in procedure1
CALL procedure2 (LAST_INSERT_ID ());
|
After MariaDB 10.2.13
in procedure1
SET id = LAST_INSERT_ID (); |
CALL procedure2 (id);
|
Run CALL procedure1 ();
SET FOREIGN_KEY_CHECKS=0; |
-- ----------------------------
|
-- Table structure for `table`
|
-- ----------------------------
|
DROP TABLE IF EXISTS `table`; |
CREATE TABLE `table` ( |
`id` int(11) NOT NULL AUTO_INCREMENT, |
`name` varchar(20) DEFAULT NULL, |
PRIMARY KEY (`id`) |
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; |
-- ----------------------------
|
-- Procedure definition for `procedure1`
|
-- ----------------------------
|
DROP PROCEDURE IF EXISTS `procedure1`; |
DELIMITER ;;
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure1`() |
MAIN:BEGIN |
DECLARE id INT(11) DEFAULT NULL; |
|
 |
DECLARE EXIT HANDLER FOR SQLEXCEPTION |
BEGIN |
GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
|
SELECT @text AS message; |
ROLLBACK; |
END; |
 |
START TRANSACTION; |
 |
INSERT INTO `table` (name) VALUES ('Elvis'); |
 |
SET id = LAST_INSERT_ID(); |
 |
CALL procedure2(LAST_INSERT_ID());
|
|
SELECT 'Add' AS message; |
 |
COMMIT; |
END
|
;;
|
DELIMITER ;
|
-- ----------------------------
|
-- Procedure definition for `procedure2`
|
-- ----------------------------
|
DROP PROCEDURE IF EXISTS `procedure2`; |
DELIMITER ;;
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `procedure2`(IN id int(11)) |
BEGIN
|
#Routine body goes here...
|
 |
END
|
;;
|
DELIMITER ;
|
Attachments
Issue Links
- duplicates
-
MDEV-15545 crash 11 during evaluating an expression
- Closed
- relates to
-
MDEV-15449 Signal 11 using LAST_INSERT_ID() as parameter in stored procedure
- Closed
-
MDEV-15870 Using aggregate and window function in unexpected places can crash the server
- Closed