mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fixed BUG#9856: Stored procedures: crash if handler for sqlexception, not found.
mysql-test/r/sp.result: Added test case for BUG#6129. mysql-test/t/sp.test: Added test case for BUG#6129. sql/sp_pcontext.h: Only need one handler counter. sql/sql_yacc.yy: Count handlers correctly.
This commit is contained in:
@@ -2862,4 +2862,22 @@ call bug6129(@@sql_mode)|
|
|||||||
@@sql_mode = mode
|
@@sql_mode = mode
|
||||||
0
|
0
|
||||||
drop procedure bug6129|
|
drop procedure bug6129|
|
||||||
|
drop procedure if exists bug9856|
|
||||||
|
create procedure bug9856()
|
||||||
|
begin
|
||||||
|
declare v int;
|
||||||
|
declare c cursor for select data from t1;
|
||||||
|
declare exit handler for sqlexception, not found select '16';
|
||||||
|
open c;
|
||||||
|
fetch c into v;
|
||||||
|
select v;
|
||||||
|
end|
|
||||||
|
delete from t1|
|
||||||
|
call bug9856()|
|
||||||
|
16
|
||||||
|
16
|
||||||
|
call bug9856()|
|
||||||
|
16
|
||||||
|
16
|
||||||
|
drop procedure bug9856|
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
@@ -3514,6 +3514,29 @@ call bug6129(@@sql_mode)|
|
|||||||
drop procedure bug6129|
|
drop procedure bug6129|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#9856: Stored procedures: crash if handler for sqlexception, not found
|
||||||
|
#
|
||||||
|
--disable_warnings
|
||||||
|
drop procedure if exists bug9856|
|
||||||
|
--enable_warnings
|
||||||
|
create procedure bug9856()
|
||||||
|
begin
|
||||||
|
declare v int;
|
||||||
|
declare c cursor for select data from t1;
|
||||||
|
declare exit handler for sqlexception, not found select '16';
|
||||||
|
|
||||||
|
open c;
|
||||||
|
fetch c into v;
|
||||||
|
select v;
|
||||||
|
end|
|
||||||
|
|
||||||
|
delete from t1|
|
||||||
|
call bug9856()|
|
||||||
|
call bug9856()|
|
||||||
|
drop procedure bug9856|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# BUG#NNNN: New bug synopsis
|
# BUG#NNNN: New bug synopsis
|
||||||
#
|
#
|
||||||
|
@@ -235,12 +235,6 @@ class sp_pcontext : public Sql_alloc
|
|||||||
// Handlers
|
// Handlers
|
||||||
//
|
//
|
||||||
|
|
||||||
inline void
|
|
||||||
add_handler()
|
|
||||||
{
|
|
||||||
m_handlers+= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
push_handler(sp_cond_type_t *cond)
|
push_handler(sp_cond_type_t *cond)
|
||||||
{
|
{
|
||||||
@@ -257,7 +251,7 @@ class sp_pcontext : public Sql_alloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
push_handlers(uint n)
|
add_handlers(uint n)
|
||||||
{
|
{
|
||||||
m_handlers+= n;
|
m_handlers+= n;
|
||||||
}
|
}
|
||||||
|
@@ -1681,7 +1681,6 @@ sp_decl:
|
|||||||
|
|
||||||
sp->add_instr(i);
|
sp->add_instr(i);
|
||||||
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
|
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
|
||||||
ctx->add_handler();
|
|
||||||
sp->m_in_handler= TRUE;
|
sp->m_in_handler= TRUE;
|
||||||
}
|
}
|
||||||
sp_hcond_list sp_proc_stmt
|
sp_hcond_list sp_proc_stmt
|
||||||
@@ -1709,6 +1708,7 @@ sp_decl:
|
|||||||
sp->m_in_handler= FALSE;
|
sp->m_in_handler= FALSE;
|
||||||
$$.vars= $$.conds= $$.curs= 0;
|
$$.vars= $$.conds= $$.curs= 0;
|
||||||
$$.hndlrs= $6;
|
$$.hndlrs= $6;
|
||||||
|
ctx->add_handlers($6);
|
||||||
}
|
}
|
||||||
| DECLARE_SYM ident CURSOR_SYM FOR_SYM sp_cursor_stmt
|
| DECLARE_SYM ident CURSOR_SYM FOR_SYM sp_cursor_stmt
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user