[MDEV-9726] Output parameter is not assigned when rising SIGNAL (Class >= '02' (exception)) Created: 2016-03-14  Updated: 2016-03-19

Status: Confirmed
Project: MariaDB Server
Component/s: Data Definition - Procedure
Affects Version/s: 10.1.12, 5.5, 10.0, 10.1
Fix Version/s: 10.1

Type: Bug Priority: Minor
Reporter: William Chiquito Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: upstream
Environment:

Ubuntu 15.10 (64 bits)



 Description   

MariaDB [test]> SELECT VERSION();
+-------------------+
| VERSION()         |
+-------------------+
| 10.1.12-MariaDB-1 |
+-------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> DROP PROCEDURE IF EXISTS `sp_bug`;
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
MariaDB [test]> DELIMITER //
 
MariaDB [test]> CREATE PROCEDURE `sp_bug`(OUT `out_parameter` INT UNSIGNED)
    -> BEGIN
    ->     DECLARE EXIT HANDLER FOR SQLEXCEPTION
    ->     BEGIN
    ->         SET `out_parameter` := 2;
    ->         SELECT `out_parameter`;        
    ->         RESIGNAL;
    ->     END;
    ->     SET `out_parameter` := 1;
    ->     SELECT `out_parameter`;
    ->     SIGNAL SQLSTATE '45000' SET
    ->         MYSQL_ERRNO = 2,
    ->         MESSAGE_TEXT = 'Too long';
    -> END//
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> DELIMITER ;
 
MariaDB [test]> SET @`out_parameter` := NULL;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> CALL `sp_bug`(@`out_parameter`);
+-----------------+
| `out_parameter` |
+-----------------+
|               1 |
+-----------------+
1 row in set (0.00 sec)
 
+-----------------+
| `out_parameter` |
+-----------------+
|               2 |
+-----------------+
1 row in set (0.00 sec)
 
ERROR 2 (45000): Too long
 
MariaDB [test]> SHOW WARNINGS;
+-------+------+----------+
| Level | Code | Message  |
+-------+------+----------+
| Error |    2 | Too long |
+-------+------+----------+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT @`out_parameter`;
+------------------+
| @`out_parameter` |
+------------------+
| NULL             |
+------------------+
1 row in set (0.00 sec)



 Comments   
Comment by Elena Stepanova [ 2016-03-19 ]

Apparently, it's not as much "when rising a signal", as "when doing resignal".
Reproducible on MariaDB 5.5, 10.0, 10.1, and on MySQL 5.5, 5.6, 5.7.

I don't know whether it's a bug, it surely looks like one, at least I cannot find anything in resignal documentation that would explain this behavior; it only says that RESIGNAL restores the last diagnostics area, but it doesn't explain what happens to the out parameter here (even if it were a part of diagnostics area, I suppose it should have been returned as 1, not as NULL).

Assigning to serg for an expert opinion.

wchiquito, did you also report it to MySQL (at bugs.mysql.com)? We normally do so when an upstream bug is filed, and we can file it on your behalf if you so prefer, but more often than not it's done by the original reporter – it's easier for the reporter to track further progress this way.

Comment by William Chiquito [ 2016-03-19 ]

Elena Stepanova, I also reported it to MySQL: Bug #80732 Output parameter is not assigned when rising SIGNAL. Thanks.

Generated at Thu Feb 08 07:36:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.