MySQL Continue Handler Problems inside a Function I am in process of writing a simple MySQL function that looks up a value in a table and returns it. In case there is not value found it returns null. However, even with a continue handler defined I still end up with a warning "No data - zero rows fetched, selected, or processed". My code is below, what am I doing wrong? I really want to get rid of this warning :)

DROP FUNCTION IF EXISTS `getCompanySetting`;
DELIMITER |

CREATE FUNCTION `getCompanySetting`(setting_company_id INT, setting_name VARCHAR(255))
    RETURNS TEXT
BEGIN
    DECLARE setting_value TEXT DEFAULT NULL;
    DECLARE CONTINUE HANDLER FOR SQLWARNING BEGIN END;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET setting_value = NULL;

    SELECT
        value
    FROM company_settings
    WHERE
        company_id = `setting_company_id`
        AND
        name       = `setting_name`
    INTO setting_value;

    RETURN setting_value;
END|

DELIMITER ;

mysql&gt; SELECT getCompanySetting(24, 'observers_active');
+-------------------------------------------+
| getCompanySetting(24, 'observers_active') |
+-------------------------------------------+
| NULL                                      |
+-------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql&gt; show warnings;
+---------+------+-----------------------------------------------------+
| Level   | Code | Message                                             |
+---------+------+-----------------------------------------------------+
| Warning | 1329 | No data - zero rows fetched, selected, or processed |
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)


Update: MySQL Version 5.5.25
Before  MySQL 5.6.3, if a statement that generates a warning or error causes a condition handler to be invoked, the handler may not clear the diagnostic area. This might lead to the appearance that the handler was not invoked.

I have explained this kind of behavior and the solution in this post:

Event Scheduler: No data - zero rows fetched, selected, or processed