Details

    • Type: Bug
    • Status: Stalled
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 10.0.4
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:

      Description

      This is a MySQL bug, but as you know I prefer not to give lots of my personal data to Oracle.

      As far as I can tell, error 1758 seems to have not a SQLSTATE:

      MariaDB [(none)]> \W
      Show warnings enabled.
      MariaDB [(none)]> GET DIAGNOSTICS CONDITION 0 @a = MYSQL_ERRNO;
      Query OK, 0 rows affected, 1 warning (0.10 sec)
      
      Error (Code 1758): Invalid condition number
      

      From the documentation, SQLSTATE should be '35000':
      http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html

      This causes some trivial problems:

      • DECLARE HANDLER FOR '35000' doesnt handle it
      • Same for SQLEXCEPTION and other classes
      • mysqld reports it as a warning, not an error (see above)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              elenst Elena Stepanova added a comment - - edited

              Hi Federico,

              Could you please help me understand how your example shows that there is no SQLSTATE for 1758? From what I see, it's there all right:

              MariaDB [test]> \W
              Show warnings enabled.
              MariaDB [test]> GET DIAGNOSTICS CONDITION 0 @a = MYSQL_ERRNO ;
              Query OK, 0 rows affected, 1 warning (0.00 sec)
              
              Error (Code 1758): Invalid condition number
              MariaDB [test]> GET DIAGNOSTICS CONDITION 1 @a = MYSQL_ERRNO, @b = RETURNED_SQLSTATE ;
              Query OK, 0 rows affected (0.00 sec)
              
              MariaDB [test]> SELECT @a, @b;
              +------+-------+
              | @a   | @b    |
              +------+-------+
              | 1758 | 35000 |
              +------+-------+
              1 row in set (0.00 sec)
              

              Reporting it as a warning rather than an error is apparently intentional, at least it's documented (http://dev.mysql.com/doc/refman/5.6/en/get-diagnostics.html):
              "A warning occurs if the condition number is not in the range from 1 to the number of condition areas that have information. In this case, the warning is added to the diagnostics area without clearing it."

              The fact that it's not handled by a handler is another story. I'd think it's not because of the SQLSTATE, it looks like the warning somehow gets lost (suppressed?) if it happens inside a procedure:

              MariaDB [test]> drop procedure if exists p;
              Query OK, 0 rows affected (0.01 sec)
              
              MariaDB [test]> delimiter ||
              MariaDB [test]> create procedure p()
                  -> begin
                  -> GET DIAGNOSTICS CONDITION 0 @a = MYSQL_ERRNO ;
                  -> end ||
              Query OK, 0 rows affected (0.01 sec)
              
              MariaDB [test]> delimiter ;
              MariaDB [test]> 
              MariaDB [test]> call p();
              Query OK, 0 rows affected (0.01 sec)
              
              MariaDB [test]> 
              

              (no warning caused by the procedure call).

              I'm not quite sure if it's a bug or not (haven't found it in the documentation yet), if you think it is, we might try to create a bug report at Oracle and see what they say.

              Show
              elenst Elena Stepanova added a comment - - edited Hi Federico, Could you please help me understand how your example shows that there is no SQLSTATE for 1758? From what I see, it's there all right: MariaDB [test]> \W Show warnings enabled. MariaDB [test]> GET DIAGNOSTICS CONDITION 0 @a = MYSQL_ERRNO ; Query OK, 0 rows affected, 1 warning (0.00 sec) Error (Code 1758): Invalid condition number MariaDB [test]> GET DIAGNOSTICS CONDITION 1 @a = MYSQL_ERRNO, @b = RETURNED_SQLSTATE ; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> SELECT @a, @b; +------+-------+ | @a | @b | +------+-------+ | 1758 | 35000 | +------+-------+ 1 row in set (0.00 sec) Reporting it as a warning rather than an error is apparently intentional, at least it's documented ( http://dev.mysql.com/doc/refman/5.6/en/get-diagnostics.html): "A warning occurs if the condition number is not in the range from 1 to the number of condition areas that have information. In this case, the warning is added to the diagnostics area without clearing it." The fact that it's not handled by a handler is another story. I'd think it's not because of the SQLSTATE, it looks like the warning somehow gets lost (suppressed?) if it happens inside a procedure: MariaDB [test]> drop procedure if exists p; Query OK, 0 rows affected (0.01 sec) MariaDB [test]> delimiter || MariaDB [test]> create procedure p() -> begin -> GET DIAGNOSTICS CONDITION 0 @a = MYSQL_ERRNO ; -> end || Query OK, 0 rows affected (0.01 sec) MariaDB [test]> delimiter ; MariaDB [test]> MariaDB [test]> call p(); Query OK, 0 rows affected (0.01 sec) MariaDB [test]> (no warning caused by the procedure call). I'm not quite sure if it's a bug or not (haven't found it in the documentation yet), if you think it is, we might try to create a bug report at Oracle and see what they say.
              Hide
              f_razzoli Federico Razzoli added a comment -

              My hypotesys (no SQLSTATE) seems to be wrong, but what I find strange is that:

              • The client doesn't display an SQLSTATE (only error code)
              • While it's reported as a warning, SHOW WARNINGS tells it's an error (see Level column). (As far as I understand, only '01...' SQLSTATEs indicate a warning?)
              • About the HANDLER, you seem to be totally right, but I don't know of other errors which are suppressed inside stored procedures

              These facts surprised me, so I wanted to report that (in my opinion) there is something strange. If it isn't a bug, or you think it's totally unimportant, please ignore this report.

              Show
              f_razzoli Federico Razzoli added a comment - My hypotesys (no SQLSTATE) seems to be wrong, but what I find strange is that: The client doesn't display an SQLSTATE (only error code) While it's reported as a warning, SHOW WARNINGS tells it's an error (see Level column). (As far as I understand, only '01...' SQLSTATEs indicate a warning?) About the HANDLER, you seem to be totally right, but I don't know of other errors which are suppressed inside stored procedures These facts surprised me, so I wanted to report that (in my opinion) there is something strange. If it isn't a bug, or you think it's totally unimportant, please ignore this report.
              Hide
              elenst Elena Stepanova added a comment -

              Hi Federico,

              Sorry for the delay.
              Not displaying an SQLSTATE is usual for warnings:

              MariaDB [test]> drop table if exists nonexisting;
              Query OK, 0 rows affected, 1 warning (0.01 sec)

              Note (Code 1051): Unknown table 'test.nonexisting'

              The warning of Level error does look weird, I asked for Serg's consult on this. If he reckons it to be a bug, we'll file it at MySQL and see what they say, and will proceed from there.

              Show
              elenst Elena Stepanova added a comment - Hi Federico, Sorry for the delay. Not displaying an SQLSTATE is usual for warnings: MariaDB [test] > drop table if exists nonexisting; Query OK, 0 rows affected, 1 warning (0.01 sec) Note (Code 1051): Unknown table 'test.nonexisting' The warning of Level error does look weird, I asked for Serg's consult on this. If he reckons it to be a bug, we'll file it at MySQL and see what they say, and will proceed from there.
              Hide
              elenst Elena Stepanova added a comment -
              Show
              elenst Elena Stepanova added a comment - Filed as http://bugs.mysql.com/bug.php?id=70358
              Hide
              f_razzoli Federico Razzoli added a comment -

              My conclusion that it doesn't have an SQLSTATE was wrong. The problem was that I couldn't handle that error in any way.

              Here's the story of how I discovered this bug. I wrote a procedure to copy the diagnostics area into a table. There is no easy way to do this, so I loop through the conditions and used MYSQL_ERRNO, etc, to compose a prepared statement INSERT. In the initial version, I thought I could exit from the loop when this warning occurs (DECLARE HANDLER ... LEAVE `this_loop`), but this never happened.

              The workaround was easy. So... I guess it's up to you decide if this is a bug.

              Show
              f_razzoli Federico Razzoli added a comment - My conclusion that it doesn't have an SQLSTATE was wrong. The problem was that I couldn't handle that error in any way. Here's the story of how I discovered this bug. I wrote a procedure to copy the diagnostics area into a table. There is no easy way to do this, so I loop through the conditions and used MYSQL_ERRNO, etc, to compose a prepared statement INSERT. In the initial version, I thought I could exit from the loop when this warning occurs (DECLARE HANDLER ... LEAVE `this_loop`), but this never happened. The workaround was easy. So... I guess it's up to you decide if this is a bug.
              Hide
              f_razzoli Federico Razzoli added a comment -

              Curiously, I've noted that this warning is written in the SQL_ERROR_LOG. But other warnings I tried are not logged.

              Show
              f_razzoli Federico Razzoli added a comment - Curiously, I've noted that this warning is written in the SQL_ERROR_LOG. But other warnings I tried are not logged.

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  f_razzoli Federico Razzoli
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated: