mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Auto-merge from mysql-trunk-bugfixing.
******
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.
This commit is contained in:
@@ -9325,6 +9325,8 @@ insert into t2 values (1);
|
||||
set @x = 3;
|
||||
END//
|
||||
CALL sp1();
|
||||
Warnings:
|
||||
Error 1136 Column count doesn't match value count at row 1
|
||||
DROP PROCEDURE sp1;
|
||||
DROP PROCEDURE IF EXISTS sp1;
|
||||
Warnings:
|
||||
@@ -13754,6 +13756,8 @@ END//
|
||||
CALL sp1();
|
||||
x y @x
|
||||
NULL a 3
|
||||
Warnings:
|
||||
Error 1305 PROCEDURE db_storedproc.nonsexist does not exist
|
||||
SELECT @v1, @v2;
|
||||
@v1 @v2
|
||||
4 a
|
||||
@@ -14938,6 +14942,8 @@ NULL NULL
|
||||
NULL NULL
|
||||
@x @y
|
||||
NULL NULL
|
||||
Warnings:
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
Testcase 4.2.63:
|
||||
@@ -15097,6 +15103,8 @@ END;
|
||||
fetch cur1 into newf1, newf2, newf4, newf3;
|
||||
END//
|
||||
CALL sp1();
|
||||
Warnings:
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
Testcase 4.2.70:
|
||||
@@ -22447,6 +22455,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22464,6 +22474,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1305 PROCEDURE db_storedproc.sp1 does not exist
|
||||
DROP PROCEDURE h1;
|
||||
|
||||
Testcase 4.11.3:
|
||||
@@ -22483,6 +22495,8 @@ CALL sp1 (1);
|
||||
set @x=0;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
SELECT @x, @x2;
|
||||
@x @x2
|
||||
1 1
|
||||
@@ -22501,6 +22515,8 @@ CALL sp1 (1);
|
||||
set @x=0;
|
||||
END//
|
||||
CALL h1 ();
|
||||
Warnings:
|
||||
Error 1305 PROCEDURE db_storedproc.sp1 does not exist
|
||||
SELECT @x, @x2;
|
||||
@x @x2
|
||||
1 1
|
||||
@@ -22525,6 +22541,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22547,6 +22565,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22569,6 +22589,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22586,6 +22608,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1305 PROCEDURE db_storedproc.sp1 does not exist
|
||||
DROP PROCEDURE h1;
|
||||
|
||||
Testcase 4.11.9:
|
||||
@@ -22605,6 +22629,8 @@ CALL sp1 (1);
|
||||
set @x=0;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
SELECT @x, @x2;
|
||||
@x @x2
|
||||
1 1
|
||||
@@ -22623,6 +22649,8 @@ CALL sp1 (1);
|
||||
set @x=0;
|
||||
END//
|
||||
CALL h1 ();
|
||||
Warnings:
|
||||
Error 1305 PROCEDURE db_storedproc.sp1 does not exist
|
||||
SELECT @x, @x2;
|
||||
@x @x2
|
||||
1 1
|
||||
@@ -22647,6 +22675,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22669,6 +22699,8 @@ END//
|
||||
CALL h1 ();
|
||||
@x @x2
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1318 Incorrect number of arguments for PROCEDURE db_storedproc.sp1; expected 2, got 1
|
||||
DROP PROCEDURE h1;
|
||||
DROP PROCEDURE sp1;
|
||||
|
||||
@@ -22704,6 +22736,8 @@ done
|
||||
1
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22777,6 +22811,8 @@ done
|
||||
0
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22814,6 +22850,8 @@ done
|
||||
0
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1329 No data - zero rows fetched, selected, or processed
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22844,6 +22882,8 @@ done
|
||||
0
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1328 Incorrect number of FETCH variables
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22874,6 +22914,8 @@ done
|
||||
0
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1328 Incorrect number of FETCH variables
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22904,6 +22946,8 @@ END//
|
||||
CALL h1();
|
||||
done
|
||||
0
|
||||
Warnings:
|
||||
Error 1328 Incorrect number of FETCH variables
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22934,6 +22978,8 @@ END//
|
||||
CALL h1();
|
||||
done
|
||||
0
|
||||
Warnings:
|
||||
Error 1328 Incorrect number of FETCH variables
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22964,6 +23010,8 @@ done
|
||||
0
|
||||
done
|
||||
1
|
||||
Warnings:
|
||||
Error 1325 Cursor is already open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -22995,6 +23043,8 @@ done
|
||||
0
|
||||
done @x
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1325 Cursor is already open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23025,6 +23075,8 @@ END//
|
||||
CALL h1();
|
||||
done
|
||||
0
|
||||
Warnings:
|
||||
Error 1325 Cursor is already open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23055,6 +23107,8 @@ END//
|
||||
CALL h1();
|
||||
done
|
||||
0
|
||||
Warnings:
|
||||
Error 1325 Cursor is already open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23082,6 +23136,8 @@ END//
|
||||
CALL h1();
|
||||
done @x
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1326 Cursor is not open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23109,6 +23165,8 @@ END//
|
||||
CALL h1();
|
||||
done @x
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1326 Cursor is not open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23134,6 +23192,8 @@ set @x=1;
|
||||
SELECT done, @x;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1326 Cursor is not open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23159,6 +23219,8 @@ set @x=1;
|
||||
SELECT done, @x;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1326 Cursor is not open
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
drop table IF EXISTS res_t1;
|
||||
drop table IF EXISTS res_t2;
|
||||
@@ -23189,6 +23251,8 @@ END//
|
||||
CALL h1();
|
||||
done @x
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1339 Case not found for CASE statement
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
drop table IF EXISTS res_t1;
|
||||
drop table IF EXISTS res_t2;
|
||||
@@ -23219,6 +23283,8 @@ END//
|
||||
CALL h1();
|
||||
done @x
|
||||
1 1
|
||||
Warnings:
|
||||
Error 1339 Case not found for CASE statement
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
drop table IF EXISTS res_t1;
|
||||
drop table IF EXISTS res_t2;
|
||||
@@ -23247,6 +23313,8 @@ set @x=1;
|
||||
SELECT done, @x;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1339 Case not found for CASE statement
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
drop table IF EXISTS res_t1;
|
||||
drop table IF EXISTS res_t2;
|
||||
@@ -23275,6 +23343,8 @@ set @x=1;
|
||||
SELECT done, @x;
|
||||
END//
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Error 1339 Case not found for CASE statement
|
||||
DROP PROCEDURE IF EXISTS h1;
|
||||
DROP TABLE IF EXISTS res_t1;
|
||||
DROP TABLE IF EXISTS res_t2;
|
||||
@@ -23423,6 +23493,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR);
|
||||
INSERT INTO res_t1 VALUES('a', 'b');
|
||||
INSERT INTO res_t1 VALUES('c', 'd');
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'w' at row 1
|
||||
Warning 1265 Data truncated for column 'x' at row 1
|
||||
SELECT @done, @x;
|
||||
@done @x
|
||||
1 1
|
||||
@@ -23445,6 +23518,9 @@ CREATE TABLE res_t1(w CHAR, x CHAR);
|
||||
INSERT INTO res_t1 VALUES('a', 'b');
|
||||
INSERT INTO res_t1 VALUES('c', 'd');
|
||||
CALL h1();
|
||||
Warnings:
|
||||
Warning 1265 Data truncated for column 'w' at row 1
|
||||
Warning 1265 Data truncated for column 'x' at row 1
|
||||
SELECT @done, @x;
|
||||
@done @x
|
||||
1 1
|
||||
|
||||
Reference in New Issue
Block a user