Bug #69865 Wrong default MESSAGE_TEXT values for SIGNALs are listed in the manual
Submitted: 29 Jul 2013 12:19 Modified: 5 Aug 2013 14:58
Reporter: Valeriy Kravchuk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[29 Jul 2013 12:19] Valeriy Kravchuk
Description:
This documentation request is based on report from my Facebook friend who is not happy with the amount of personal information Oracle requests to set up SSO login account for bugs database.

http://dev.mysql.com/doc/refman/5.6/en/signal.html#signal-condition-information-items lists wrong default MESSAGE_TEXT:

"A SIGNAL statement always specifies an SQLSTATE value, either directly, or indirectly by referring to a named condition defined with an SQLSTATE value. The first two characters of an SQLSTATE value are its class, and the class determines the default value for the condition information items:

    Class = '00' (success)

    Illegal. SQLSTATE values that begin with '00' indicate success and are not valid for SIGNAL.

    Class = '01' (warning)

    MESSAGE_TEXT = 'Unhandled user-defined warning';
    MYSQL_ERRNO = ER_SIGNAL_WARN

    Class = '02' (not found)

    MESSAGE_TEXT = 'Unhandled user-defined not found';
    MYSQL_ERRNO = ER_SIGNAL_NOT_FOUND

    Class > '02' (exception)

    MESSAGE_TEXT = 'Unhandled user-defined exception';
    MYSQL_ERRNO = ER_SIGNAL_EXCEPTION"

In all cases the word "condition" is missing (see "How to repeat"). For example, default error message for warnings is 'Unhandled user-defined warning condition'.

Side note: ER_SIGNAL_WARN, ER_SIGNAL_NOT_FOUND and ER_SIGNAL_EXCEPTION constants are not accessible from SQL so probably it makes sense to say that they are respectively 1642, 1643 and 1644.

How to repeat:
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -proot -P3314 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 5.6.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE TABLE t (s1 INT);
Query OK, 0 rows affected (4.30 sec)

mysql> delimiter //
mysql> CREATE FUNCTION f () RETURNS INT
    -> BEGIN
    ->   SIGNAL SQLSTATE '99999';
    ->   RETURN 5;
    -> END//
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> INSERT INTO t VALUES (f());
ERROR 1644 (99999): Unhandled user-defined exception condition
mysql> delimiter //
mysql> CREATE FUNCTION f2 () RETURNS INT
    -> BEGIN
    ->   SIGNAL SQLSTATE '02001' SET MYSQL_ERRNO = ER_SIGNAL_NOT_FOUND;
    ->   RETURN 4;
    -> END//
Query OK, 0 rows affected (0.10 sec)

mysql> INSERT INTO t VALUES (f2());//
ERROR 1054 (42S22): Unknown column 'ER_SIGNAL_NOT_FOUND' in 'field list'
mysql> drop function f2;//
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE FUNCTION f2 () RETURNS INT
    -> BEGIN
    ->   SIGNAL SQLSTATE '02001' SET MYSQL_ERRNO = 1643;
    ->   RETURN 4;
    -> END//
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;
mysql> INSERT INTO t VALUES (f2());
ERROR 1643 (02001): Unhandled user-defined not found condition

Suggested fix:
Show real default MESSAGE_TEXT in the manual and mention MYSQL_ERRNO numbers maybe.
[31 Jul 2013 17:31] MySQL Verification Team
Hello Valeriy,

Thank you for the bug report. 
Verified as described.

Thanks,
Umesh
[5 Aug 2013 14:58] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Added missing words.
Instead of writing out the MYSQL_ERRNO numbers, I'll make the symbols links into
http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html
where all information for the error in question is given.