Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15328

MariaDB 10.2.13 Crashes upon CALL PROCEDURE PARAM LAST_INSERT_ID ()

    XMLWordPrintable

Details

    • 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

          Activity

            People

              sanja Oleksandr Byelkin
              elvisdosreis Elvis P dos Reis
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.