mirror of
https://github.com/MariaDB/server.git
synced 2025-11-03 14:33:32 +03:00
******
This patch fixes the following bugs:
- Bug#5889: Exit handler for a warning doesn't hide the warning in
trigger
- Bug#9857: Stored procedures: handler for sqlwarning ignored
- Bug#23032: Handlers declared in a SP do not handle warnings generated
in sub-SP
- Bug#36185: Incorrect precedence for warning and exception handlers
The problem was in the way warnings/errors during stored routine execution
were handled. Prior to this patch the logic was as follows:
- when a warning/an error happens: if we're executing a stored routine,
and there is a handler for that warning/error, remember the handler,
ignore the warning/error and continue execution.
- after a stored routine instruction is executed: check for a remembered
handler and activate one (if any).
This logic caused several problems:
- if one instruction generates several warnings (errors) it's impossible
to choose the right handler -- a handler for the first generated
condition was chosen and remembered for activation.
- mess with handling conditions in scopes different from the current one.
- not putting generated warnings/errors into Warning Info (Diagnostic
Area) is against The Standard.
The patch changes the logic as follows:
- Diagnostic Area is cleared on the beginning of each statement that
either is able to generate warnings, or is able to work with tables.
- at the end of a stored routine instruction, Diagnostic Area is left
intact.
- Diagnostic Area is checked after each stored routine instruction. If
an instruction generates several condition, it's now possible to take a
look at all of them and determine an appropriate handler.
79 lines
1.9 KiB
Plaintext
79 lines
1.9 KiB
Plaintext
#
|
|
# Bug #47412: Valgrind warnings / user can read uninitalized memory
|
|
# using SP variables
|
|
#
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
CREATE PROCEDURE p3 ( arg1 VARCHAR(32) )
|
|
BEGIN
|
|
CALL p_not_exists ( );
|
|
END|
|
|
# should not return valgrind warnings
|
|
CALL p3 ( f2 () );
|
|
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
|
|
DROP SCHEMA testdb;
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
CREATE PROCEDURE p3 ( arg2 INTEGER )
|
|
BEGIN
|
|
CALL p_not_exists ( );
|
|
END|
|
|
# should not return valgrind warnings
|
|
CALL p3 ( f2 () );
|
|
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
|
|
DROP SCHEMA testdb;
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
# should not return valgrind warnings
|
|
SELECT f2 ();
|
|
f2 ()
|
|
NULL
|
|
Warnings:
|
|
Error 1305 FUNCTION testdb.f_not_exists does not exist
|
|
DROP SCHEMA testdb;
|
|
USE test;
|
|
#
|
|
# Bug#50423: Crash on second call of a procedure dropping a trigger
|
|
#
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
CREATE TABLE t1 (f1 INTEGER);
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
|
|
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
|
|
CALL p1 ();
|
|
CALL p1 ();
|
|
ERROR HY000: Trigger does not exist
|
|
DROP TABLE t1;
|
|
DROP PROCEDURE p1;
|
|
#
|
|
# Bug#50423: Crash on second call of a procedure dropping a trigger
|
|
#
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TRIGGER IF EXISTS tr1;
|
|
DROP PROCEDURE IF EXISTS p1;
|
|
CREATE TABLE t1 (f1 INTEGER);
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
|
|
CREATE PROCEDURE p1 () DROP TRIGGER tr1;
|
|
CALL p1 ();
|
|
CALL p1 ();
|
|
ERROR HY000: Trigger does not exist
|
|
DROP TABLE t1;
|
|
DROP PROCEDURE p1;
|
|
End of 5.1 tests
|