#
# MDEV-34391 Path resolution
# Path embedding with recursive routines
#
CREATE DATABASE test2;
CREATE FUNCTION test2.func2(val INT, t TEXT) RETURNS TEXT
BEGIN
SET val:= val - 1;
IF val = 0 THEN
RETURN CONCAT(t, CAST(val AS CHAR(4)));
END IF;
RETURN func2(val, CONCAT(t, CAST(val AS CHAR(4))));
END;
/
CREATE PROCEDURE test2.proc2(val INT, t TEXT)
BEGIN
SET val:= val - 1;
IF val = 0 THEN
SELECT CONCAT(t, CAST(val AS CHAR(4)));
ELSE
CALL proc2(val, CONCAT(t, CAST(val AS CHAR(4))));
END IF;
END;
/
SET PATH 'test2'/
CREATE FUNCTION ff() RETURNS TEXT
BEGIN
RETURN func2(5, '');
END;
/
CREATE PROCEDURE pp()
BEGIN
CALL proc2(5, '');
END;
/
SET PATH 'CURRENT_SCHEMA';
SELECT ff();
ERROR HY000: Recursive stored functions and triggers are not allowed
SELECT ff();
ERROR HY000: Recursive stored functions and triggers are not allowed
CALL pp();
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine proc2
CALL pp();
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine proc2
SET max_sp_recursion_depth=10;
CALL pp();
CONCAT(t, CAST(val AS CHAR(4)))
43210
CALL pp();
CONCAT(t, CAST(val AS CHAR(4)))
43210
SET max_sp_recursion_depth=0;
DROP FUNCTION ff;
DROP PROCEDURE pp;
SET PATH 'test';
CREATE FUNCTION test2.f(t TEXT) RETURNS TEXT
RETURN f(CONCAT(t, ' >> test2.f'));
CREATE FUNCTION f(t TEXT) RETURNS TEXT
RETURN CONCAT(t, ' >> test.f');
SELECT test2.f('*');
test2.f('*')
* >> test2.f >> test.f
DROP DATABASE test2;
DROP FUNCTION f;
#
# MDEV-38483 UBSAN: SIGSEGV in Sp_handler::db_load_routine | Sp_handler::db_find_routine
#
set path 'test';
create procedure p() call p(sleep(1));
call p();
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine p
drop procedure p;
set path 'current_schema';
