Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Not a Bug
-
Affects Version/s: 10.0.8
-
Fix Version/s: N/A
-
Component/s: Data Definition - Procedure
-
Labels:None
Description
In the following example error 1370 is ok, but I'm trying to handle it, and this seems to be impossible.
MariaDB [test]> CREATE USER u2;
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> DELIMITER ||
MariaDB [test]> CREATE DEFINER = u2 PROCEDURE p()
-> SQL SECURITY DEFINER
-> BEGIN
-> DECLARE EXIT HANDLER
-> FOR 1370
-> SELECT 1370 AS `ERROR`;
-> DECLARE EXIT HANDLER
-> FOR SQLSTATE '42000'
-> SELECT '42000' AS `ERROR`;
-> SHOW PROCESSLIST;
-> SELECT 'OK';
-> END;
-> ||
Query OK, 0 rows affected (0.03 sec)
MariaDB [test]> DELIMITER ;
MariaDB [test]> CALL p();
ERROR 1370 (42000): execute command denied to user 'u2'@'%' for routine 'test.p'
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
It doesn't look like a problem with the error.
The procedure has the default SQL SECURITY value (DEFINER), so the definer must have the EXECUTE privilege, which it doesn't. It's the execution of the whole procedure that is denied, so how can the handler work?
If we modify the test case this way, it works:
MariaDB [test]> CREATE USER u2@localhost; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> GRANT EXECUTE ON PROCEDURE test.p TO u2@localhost; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> delimiter || MariaDB [test]> CREATE DEFINER = u2@localhost PROCEDURE p() -> SQL SECURITY DEFINER -> BEGIN -> DECLARE EXIT HANDLER -> FOR 1370 -> SELECT 1370 AS `ERROR`; -> DECLARE EXIT HANDLER -> FOR SQLSTATE '42000' -> SELECT '42000' AS `ERROR`; -> SELECT * FROM mysql.user; -> SELECT 'OK'; -> END || Query OK, 0 rows affected (0.15 sec) MariaDB [test]> delimiter ;