Skip to content

Commit

Permalink
Merge 10.4 into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Dec 21, 2023
2 parents cfaab61 + c712a53 commit a3dd7ea
Show file tree
Hide file tree
Showing 29 changed files with 416 additions and 489 deletions.
4 changes: 2 additions & 2 deletions include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,10 @@ extern void my_mutex_end(void);
by GCC 12.3.0, GCC 13.2.0, or clang 16.0.6
would fail ./mtr main.1st when the stack size is 5 MiB.
The minimum is more than 6 MiB for CMAKE_BUILD_TYPE=RelWithDebInfo and
more than 8 MiB for CMAKE_BUILD_TYPE=Debug.
more than 10 MiB for CMAKE_BUILD_TYPE=Debug.
Let us add some safety margin.
*/
# define DEFAULT_THREAD_STACK (10L<<20)
# define DEFAULT_THREAD_STACK (11L<<20)
# else
# define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
# endif
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/execution_constants.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# In embedded server we don't really have a control over stack usage
-- source include/not_embedded.inc
-- source include/not_asan.inc

#
# Bug#21476: Lost Database Connection During Query
Expand Down
101 changes: 101 additions & 0 deletions mysql-test/main/lotofstack.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
create function bug10100f(prm int) returns int
begin
if prm > 1 then
return prm * bug10100f(prm - 1);
end if;
return 1;
end|
set statement sql_mode = '' for
create procedure bug10100p(prm int, inout res int)
begin
set res = res * prm;
if prm > 1 then
call bug10100p(prm - 1, res);
end if;
end|
set statement sql_mode = '' for
create procedure bug10100t(prm int)
begin
declare res int;
set res = 1;
call bug10100p(prm, res);
select res;
end|
create table t3 (a int)|
insert into t3 values (0)|
create view v1 as select a from t3|
create procedure bug10100pt(level int, lim int)
begin
if level < lim then
update t3 set a=level;
FLUSH TABLES;
call bug10100pt(level+1, lim);
else
select * from t3;
end if;
end|
create procedure bug10100pv(level int, lim int)
begin
if level < lim then
update v1 set a=level;
FLUSH TABLES;
call bug10100pv(level+1, lim);
else
select * from v1;
end if;
end|
prepare stmt2 from "select * from t3;";
create procedure bug10100pd(level int, lim int)
begin
if level < lim then
select level;
prepare stmt1 from "update t3 set a=a+2";
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
deallocate prepare stmt1;
execute stmt2;
select * from t3;
call bug10100pd(level+1, lim);
else
execute stmt2;
end if;
end|
create procedure bug10100pc(level int, lim int)
begin
declare lv int;
declare c cursor for select a from t3;
open c;
if level < lim then
select level;
fetch c into lv;
select lv;
update t3 set a=level+lv;
FLUSH TABLES;
call bug10100pc(level+1, lim);
else
select * from t3;
end if;
close c;
end|
set @@max_sp_recursion_depth=255|
set @var=1|
call bug10100p(255, @var)|
call bug10100pt(1,255)|
call bug10100pv(1,255)|
call bug10100pd(1,255)|
call bug10100pc(1,255)|
set @@max_sp_recursion_depth=0|
deallocate prepare stmt2|
drop function bug10100f|
drop procedure bug10100p|
drop procedure bug10100t|
drop procedure bug10100pt|
drop procedure bug10100pv|
drop procedure bug10100pd|
drop procedure bug10100pc|
drop view v1|
drop table t3|
133 changes: 133 additions & 0 deletions mysql-test/main/lotofstack.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# For tests that need a lot of stack - they likely won't work under ASAN
#
source include/not_asan.inc;
source include/not_embedded.inc;

#
# Bug#10100 function (and stored procedure?) recursivity problem
#
# routines with simple recursion
delimiter |;
create function bug10100f(prm int) returns int
begin
if prm > 1 then
return prm * bug10100f(prm - 1);
end if;
return 1;
end|
set statement sql_mode = '' for
create procedure bug10100p(prm int, inout res int)
begin
set res = res * prm;
if prm > 1 then
call bug10100p(prm - 1, res);
end if;
end|
set statement sql_mode = '' for
create procedure bug10100t(prm int)
begin
declare res int;
set res = 1;
call bug10100p(prm, res);
select res;
end|

# a procedure which use tables and recursion
create table t3 (a int)|
insert into t3 values (0)|
create view v1 as select a from t3|
create procedure bug10100pt(level int, lim int)
begin
if level < lim then
update t3 set a=level;
FLUSH TABLES;
call bug10100pt(level+1, lim);
else
select * from t3;
end if;
end|
# view & recursion
create procedure bug10100pv(level int, lim int)
begin
if level < lim then
update v1 set a=level;
FLUSH TABLES;
call bug10100pv(level+1, lim);
else
select * from v1;
end if;
end|
# dynamic sql & recursion
prepare stmt2 from "select * from t3;";
create procedure bug10100pd(level int, lim int)
begin
if level < lim then
select level;
prepare stmt1 from "update t3 set a=a+2";
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
deallocate prepare stmt1;
execute stmt2;
select * from t3;
call bug10100pd(level+1, lim);
else
execute stmt2;
end if;
end|
# cursor & recursion
create procedure bug10100pc(level int, lim int)
begin
declare lv int;
declare c cursor for select a from t3;
open c;
if level < lim then
select level;
fetch c into lv;
select lv;
update t3 set a=level+lv;
FLUSH TABLES;
call bug10100pc(level+1, lim);
else
select * from t3;
end if;
close c;
end|

# end of the stack checking
set @@max_sp_recursion_depth=255|
set @var=1|
# disable log because error about stack overrun contains numbers which
# depend on a system
-- disable_ps_protocol
-- disable_result_log
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100p(255, @var)|
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100pt(1,255)|
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100pv(1,255)|
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100pd(1,255)|
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100pc(1,255)|
-- enable_result_log
-- enable_ps_protocol
set @@max_sp_recursion_depth=0|

deallocate prepare stmt2|

drop function bug10100f|
drop procedure bug10100p|
drop procedure bug10100t|
drop procedure bug10100pt|
drop procedure bug10100pv|
drop procedure bug10100pd|
drop procedure bug10100pc|
drop view v1|
drop table t3|
delimiter ;|
Loading

0 comments on commit a3dd7ea

Please sign in to comment.