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

Local routine MEDIUMBLOB variable overwritten while asigning value to another MEDIUMBLOB variable using SELECT INTO

Details

    Description

      Using SELECT INTO local routine variable, value is assigned to two distinct variables.

      Test cast to reproduce issue;

      Two tables with one row with different values


      CREATE TABLE `test`.`A`(  
        `idA` BIGINT NOT NULL AUTO_INCREMENT,
        `messageA` MEDIUMBLOB,
        PRIMARY KEY (`idA`)
      );
       
      CREATE TABLE `test`.`B`(  
        `idB` BIGINT NOT NULL AUTO_INCREMENT,
        `messageB` MEDIUMBLOB,
        PRIMARY KEY (`idB`)
      );
       
      INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
      INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));
      
      


      Stored procedure:


      DELIMITER $$
       
      CREATE PROCEDURE `procC`()
      BEGIN
      	DECLARE pA MEDIUMBLOB;
      	DECLARE pB MEDIUMBLOB;
      	
      	SElect messageA
      	into pA 
      	FROM A;
      	
      	SELECT messageB
      	into pB
      	from B;
      	
      	select UNCOMPRESS(pA), UNCOMPRESS(pB);
          END$$
       
      DELIMITER ;
      
      

      Calling procedure:

      CALL procC();
      
      


      Expected result:

      messageA, messageB
      

      Result:

      messageB, messageB
      

      Attachments

        Activity

          ljubomir.djokic Ljubomir Đokić created issue -
          ljubomir.djokic Ljubomir Đokić made changes -
          Field Original Value New Value
          Description Using SELECT INTO local routine variable, value is assigned to two distinct variables.

          Test cast to reproduce issue;

          Two tables with one row with different values

          {{
          CREATE TABLE `test`.`A`(
            `idA` BIGINT NOT NULL AUTO_INCREMENT,
            `messageA` MEDIUMBLOB,
            PRIMARY KEY (`idA`)
          );

          CREATE TABLE `test`.`B`(
            `idB` BIGINT NOT NULL AUTO_INCREMENT,
            `messageB` MEDIUMBLOB,
            PRIMARY KEY (`idB`)
          );

          INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
          INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));
          }}

          Stored procedure:
          {{
          DELIMITER $$

          CREATE PROCEDURE `procC`()
          BEGIN
          DECLARE pA MEDIUMBLOB;
          DECLARE pB MEDIUMBLOB;

          SElect messageA
          into pA
          FROM A;

          SELECT messageB
          into pB
          from B;

          select UNCOMPRESS(pA), UNCOMPRESS(pB);
              END$$

          DELIMITER ;
          }}

          Calling procedure:
          {{CALL procC();}}

          Expected result:
          {{messageA, messageB}}

          Result:
          {{messageB, messageB}}
          Using SELECT INTO local routine variable, value is assigned to two distinct variables.

          Test cast to reproduce issue;

          Two tables with one row with different values

          {{CREATE TABLE `test`.`A`(
            `idA` BIGINT NOT NULL AUTO_INCREMENT,
            `messageA` MEDIUMBLOB,
            PRIMARY KEY (`idA`)
          );

          CREATE TABLE `test`.`B`(
            `idB` BIGINT NOT NULL AUTO_INCREMENT,
            `messageB` MEDIUMBLOB,
            PRIMARY KEY (`idB`)
          );

          INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
          INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));}}

          Stored procedure:
          {{
          DELIMITER $$

          CREATE PROCEDURE `procC`()
          BEGIN
          DECLARE pA MEDIUMBLOB;
          DECLARE pB MEDIUMBLOB;

          SElect messageA
          into pA
          FROM A;

          SELECT messageB
          into pB
          from B;

          select UNCOMPRESS(pA), UNCOMPRESS(pB);
              END$$

          DELIMITER ;
          }}

          Calling procedure:
          {{CALL procC();}}

          Expected result:
          {{messageA, messageB}}

          Result:
          {{messageB, messageB}}
          ljubomir.djokic Ljubomir Đokić made changes -
          Description Using SELECT INTO local routine variable, value is assigned to two distinct variables.

          Test cast to reproduce issue;

          Two tables with one row with different values

          {{CREATE TABLE `test`.`A`(
            `idA` BIGINT NOT NULL AUTO_INCREMENT,
            `messageA` MEDIUMBLOB,
            PRIMARY KEY (`idA`)
          );

          CREATE TABLE `test`.`B`(
            `idB` BIGINT NOT NULL AUTO_INCREMENT,
            `messageB` MEDIUMBLOB,
            PRIMARY KEY (`idB`)
          );

          INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
          INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));}}

          Stored procedure:
          {{
          DELIMITER $$

          CREATE PROCEDURE `procC`()
          BEGIN
          DECLARE pA MEDIUMBLOB;
          DECLARE pB MEDIUMBLOB;

          SElect messageA
          into pA
          FROM A;

          SELECT messageB
          into pB
          from B;

          select UNCOMPRESS(pA), UNCOMPRESS(pB);
              END$$

          DELIMITER ;
          }}

          Calling procedure:
          {{CALL procC();}}

          Expected result:
          {{messageA, messageB}}

          Result:
          {{messageB, messageB}}
          Using SELECT INTO local routine variable, value is assigned to two distinct variables.

          Test cast to reproduce issue;

          Two tables with one row with different values

          {color:#707070}
          {code:java}
          CREATE TABLE `test`.`A`(
            `idA` BIGINT NOT NULL AUTO_INCREMENT,
            `messageA` MEDIUMBLOB,
            PRIMARY KEY (`idA`)
          );

          CREATE TABLE `test`.`B`(
            `idB` BIGINT NOT NULL AUTO_INCREMENT,
            `messageB` MEDIUMBLOB,
            PRIMARY KEY (`idB`)
          );

          INSERT INTO A(messageA) VALUES (COMPRESS('messageA'));
          INSERT INTO B(messageB) VALUES (COMPRESS('messageB'));

          {code}
          {color}
          Stored procedure:

          {color:#707070}
          {code:java}
          DELIMITER $$

          CREATE PROCEDURE `procC`()
          BEGIN
          DECLARE pA MEDIUMBLOB;
          DECLARE pB MEDIUMBLOB;

          SElect messageA
          into pA
          FROM A;

          SELECT messageB
          into pB
          from B;

          select UNCOMPRESS(pA), UNCOMPRESS(pB);
              END$$

          DELIMITER ;

          {code}
          {color}

          Calling procedure:
          {color:#707070}
          {code:java}
          CALL procC();

          {code}
          {color}
          Expected result:

          {code:java}
          messageA, messageB
          {code}


          Result:

          {code:java}
          messageB, messageB
          {code}
          serg Sergei Golubchik made changes -
          Component/s Data Definition - Procedure [ 10119 ]
          Component/s Scripts & Clients [ 11002 ]
          elenst Elena Stepanova made changes -
          Fix Version/s 5.5.48 [ 21000 ]
          Labels assignment blob mediumblob subroutine variable assignment blob mediumblob subroutine upstream variable
          elenst Elena Stepanova made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 75953 ] MariaDB v4 [ 150505 ]

          People

            Unassigned Unassigned
            ljubomir.djokic Ljubomir Đokić
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.