mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
b2f8005094
****** 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.
143 lines
3.4 KiB
Text
143 lines
3.4 KiB
Text
SET @start_global_value = @@global.max_error_count;
|
|
SELECT @start_global_value;
|
|
@start_global_value
|
|
64
|
|
SET @start_session_value = @@session.max_error_count;
|
|
SELECT @start_session_value;
|
|
@start_session_value
|
|
64
|
|
drop database if exists demo;
|
|
create database demo;
|
|
use demo;
|
|
create procedure proc_1()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_1';
|
|
call proc_2();
|
|
end
|
|
$$
|
|
create procedure proc_2()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_2';
|
|
call proc_3();
|
|
end
|
|
$$
|
|
create procedure proc_3()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_3';
|
|
call proc_4();
|
|
end
|
|
$$
|
|
create procedure proc_4()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_4';
|
|
call proc_5();
|
|
end
|
|
$$
|
|
create procedure proc_5()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_5';
|
|
call proc_6();
|
|
end
|
|
$$
|
|
create procedure proc_6()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_6';
|
|
call proc_7();
|
|
end
|
|
$$
|
|
create procedure proc_7()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_7';
|
|
call proc_8();
|
|
end
|
|
$$
|
|
create procedure proc_8()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_8';
|
|
call proc_9();
|
|
end
|
|
$$
|
|
create procedure proc_9()
|
|
begin
|
|
declare exit handler for sqlexception
|
|
resignal sqlstate '45000' set message_text='Oops in proc_9';
|
|
## Do something that fails, to see how errors are reported
|
|
drop table oops_it_is_not_here;
|
|
end
|
|
$$
|
|
call proc_1();
|
|
ERROR 45000: Oops in proc_1
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'oops_it_is_not_here'
|
|
Error 1644 Oops in proc_9
|
|
Error 1644 Oops in proc_8
|
|
Error 1644 Oops in proc_7
|
|
Error 1644 Oops in proc_6
|
|
Error 1644 Oops in proc_5
|
|
Error 1644 Oops in proc_4
|
|
Error 1644 Oops in proc_3
|
|
Error 1644 Oops in proc_2
|
|
Error 1644 Oops in proc_1
|
|
SET @@session.max_error_count = 5;
|
|
SELECT @@session.max_error_count;
|
|
@@session.max_error_count
|
|
5
|
|
call proc_1();
|
|
ERROR 45000: Oops in proc_1
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'oops_it_is_not_here'
|
|
Error 1644 Oops in proc_9
|
|
Error 1644 Oops in proc_8
|
|
Error 1644 Oops in proc_7
|
|
Error 1644 Oops in proc_6
|
|
SET @@session.max_error_count = 7;
|
|
SELECT @@session.max_error_count;
|
|
@@session.max_error_count
|
|
7
|
|
call proc_1();
|
|
ERROR 45000: Oops in proc_1
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'oops_it_is_not_here'
|
|
Error 1644 Oops in proc_9
|
|
Error 1644 Oops in proc_8
|
|
Error 1644 Oops in proc_7
|
|
Error 1644 Oops in proc_6
|
|
Error 1644 Oops in proc_5
|
|
Error 1644 Oops in proc_4
|
|
SET @@session.max_error_count = 9;
|
|
SELECT @@session.max_error_count;
|
|
@@session.max_error_count
|
|
9
|
|
call proc_1();
|
|
ERROR 45000: Oops in proc_1
|
|
show warnings;
|
|
Level Code Message
|
|
Error 1051 Unknown table 'oops_it_is_not_here'
|
|
Error 1644 Oops in proc_9
|
|
Error 1644 Oops in proc_8
|
|
Error 1644 Oops in proc_7
|
|
Error 1644 Oops in proc_6
|
|
Error 1644 Oops in proc_5
|
|
Error 1644 Oops in proc_4
|
|
Error 1644 Oops in proc_3
|
|
Error 1644 Oops in proc_2
|
|
drop database demo;
|
|
SET @@global.max_error_count = @start_global_value;
|
|
SELECT @@global.max_error_count;
|
|
@@global.max_error_count
|
|
64
|
|
SET @@session.max_error_count = @start_session_value;
|
|
SELECT @@session.max_error_count;
|
|
@@session.max_error_count
|
|
64
|