mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed BUG#11529: crash server after use stored procedure
Make sure to cleanup the items for a cursor query after each open, otherwise it's done too late, after the run-time mem_root is freed. mysql-test/r/sp.result: New test case for BUG#11529. mysql-test/t/sp.test: New test case for BUG#11529. sql/sp_head.cc: Add a back pointer from a sp_cursor to its cpush instruction, and use it to set the arena and cleanup the items for the cursor's query when opening it. sql/sp_rcontext.cc: Store pointer in sp_cursor to its cpush instruction. sql/sp_rcontext.h: Store pointer in sp_cursor to its cpush instruction.
This commit is contained in:
@ -3224,4 +3224,29 @@ bbbbb 2
|
||||
ccccc 3
|
||||
drop procedure bug10136|
|
||||
drop table t3|
|
||||
drop procedure if exists bug11529|
|
||||
create procedure bug11529()
|
||||
begin
|
||||
declare c cursor for select id, data from t1 where data in (10,13);
|
||||
open c;
|
||||
begin
|
||||
declare vid char(16);
|
||||
declare vdata int;
|
||||
declare exit handler for not found begin end;
|
||||
while true do
|
||||
fetch c into vid, vdata;
|
||||
end while;
|
||||
end;
|
||||
close c;
|
||||
end|
|
||||
insert into t1 values
|
||||
('Name1', 10),
|
||||
('Name2', 11),
|
||||
('Name3', 12),
|
||||
('Name4', 13),
|
||||
('Name5', 14)|
|
||||
call bug11529()|
|
||||
call bug11529()|
|
||||
delete from t1|
|
||||
drop procedure bug11529|
|
||||
drop table t1,t2;
|
||||
|
@ -3911,6 +3911,42 @@ call bug10136()|
|
||||
drop procedure bug10136|
|
||||
drop table t3|
|
||||
|
||||
#
|
||||
# BUG#11529: crash server after use stored procedure
|
||||
#
|
||||
--disable_warnings
|
||||
drop procedure if exists bug11529|
|
||||
--enable_warnings
|
||||
create procedure bug11529()
|
||||
begin
|
||||
declare c cursor for select id, data from t1 where data in (10,13);
|
||||
|
||||
open c;
|
||||
begin
|
||||
declare vid char(16);
|
||||
declare vdata int;
|
||||
declare exit handler for not found begin end;
|
||||
|
||||
while true do
|
||||
fetch c into vid, vdata;
|
||||
end while;
|
||||
end;
|
||||
close c;
|
||||
end|
|
||||
|
||||
insert into t1 values
|
||||
('Name1', 10),
|
||||
('Name2', 11),
|
||||
('Name3', 12),
|
||||
('Name4', 13),
|
||||
('Name5', 14)|
|
||||
|
||||
call bug11529()|
|
||||
call bug11529()|
|
||||
delete from t1|
|
||||
drop procedure bug11529|
|
||||
|
||||
|
||||
#
|
||||
# BUG#NNNN: New bug synopsis
|
||||
#
|
||||
@ -3921,7 +3957,7 @@ drop table t3|
|
||||
|
||||
|
||||
# Add bugs above this line. Use existing tables t1 and t2 when
|
||||
# practical, or create table t3, t3 etc temporarily (and drop them).
|
||||
# practical, or create table t3, t4 etc temporarily (and drop them).
|
||||
delimiter ;|
|
||||
drop table t1,t2;
|
||||
|
||||
|
Reference in New Issue
Block a user