diff options
author | malff/marcsql@weblab.(none) <> | 2006-12-11 16:59:02 -0700 |
---|---|---|
committer | malff/marcsql@weblab.(none) <> | 2006-12-11 16:59:02 -0700 |
commit | 506c2a722fd2078c2005df71b52145633454559c (patch) | |
tree | f3d26b05138f6f861bb6c7ec0b9975d59d37deeb /mysql-test/t/sp_stress_case.test | |
parent | ce5a3fcca888bc9233f908da878710d3b81c8a70 (diff) | |
download | mariadb-git-506c2a722fd2078c2005df71b52145633454559c.tar.gz |
Bug#19194 (Right recursion in parser for CASE causes excessive stack usage,
limitation)
Bug#24854 (Mixing Searched Case with Simple Case inside Stored Procedure
crashes Mysqld)
Implemented code review (19194) comments
Diffstat (limited to 'mysql-test/t/sp_stress_case.test')
-rw-r--r-- | mysql-test/t/sp_stress_case.test | 105 |
1 files changed, 82 insertions, 23 deletions
diff --git a/mysql-test/t/sp_stress_case.test b/mysql-test/t/sp_stress_case.test index ef9c31b6dcf..5b278802e26 100644 --- a/mysql-test/t/sp_stress_case.test +++ b/mysql-test/t/sp_stress_case.test @@ -1,35 +1,94 @@ - -# The production code tested is not platform specific, -# but /bin/sh is needed to run the test case. - ---source include/not_windows.inc - # # Bug#19194 (Right recursion in parser for CASE causes excessive stack # usage, limitation) # +# This test takes some time (8 min) in debug builds +# It's provided as a separate file so that the next line can be uncommented +# later if needed: +# -- source include/big_test.inc + --disable_warnings -DROP PROCEDURE IF EXISTS bug_19194_a; -DROP PROCEDURE IF EXISTS bug_19194_b; +DROP PROCEDURE IF EXISTS proc_19194_codegen; +DROP PROCEDURE IF EXISTS bug_19194_simple; +DROP PROCEDURE IF EXISTS bug_19194_searched; --enable_warnings ---exec $MYSQL_TEST_DIR/t/sp_stress_case.sh | $MYSQL_TEST 2>&1 +delimiter |; + +CREATE PROCEDURE proc_19194_codegen( + IN proc_name VARCHAR(50), + IN count INTEGER, + IN simple INTEGER, + OUT body MEDIUMTEXT) +BEGIN + DECLARE code MEDIUMTEXT; + DECLARE i INT DEFAULT 1; + + SET code = concat("CREATE PROCEDURE ", proc_name, "(i INT)\n"); + SET code = concat(code, "BEGIN\n"); + SET code = concat(code, " DECLARE str CHAR(10);\n"); + + IF (simple) + THEN + SET code = concat(code, " CASE i\n"); + ELSE + SET code = concat(code, " CASE\n"); + END IF; + + WHILE (i <= count) + DO + IF (simple) + THEN + SET code = concat(code, " WHEN ", i, " THEN SET str=\"", i, "\";\n"); + ELSE + SET code = concat(code, " WHEN i=", i, " THEN SET str=\"", i, "\";\n"); + END IF; + + SET i = i + 1; + END WHILE; + + SET code = concat(code, " ELSE SET str=\"unknown\";\n"); + SET code = concat(code, " END CASE;\n"); + SET code = concat(code, " SELECT str;\n"); + + SET code = concat(code, "END\n"); + + SET body = code; +END| + +delimiter ;| + +set @body=""; +call proc_19194_codegen("test_simple", 10, 1, @body); +select @body; +call proc_19194_codegen("test_searched", 10, 0, @body); +select @body; + +--disable_query_log +call proc_19194_codegen("bug_19194_simple", 5000, 1, @body); +let $proc_body = `select @body`; +eval $proc_body; +call proc_19194_codegen("bug_19194_searched", 5000, 1, @body); +let $proc_body = `select @body`; +eval $proc_body; +--enable_query_log -CALL bug_19194_a(1); -CALL bug_19194_a(2); -CALL bug_19194_a(1000); -CALL bug_19194_a(4998); -CALL bug_19194_a(4999); -CALL bug_19194_a(9999); +CALL bug_19194_simple(1); +CALL bug_19194_simple(2); +CALL bug_19194_simple(1000); +CALL bug_19194_simple(4998); +CALL bug_19194_simple(4999); +CALL bug_19194_simple(9999); -CALL bug_19194_b(1); -CALL bug_19194_b(2); -CALL bug_19194_b(1000); -CALL bug_19194_b(4998); -CALL bug_19194_b(4999); -CALL bug_19194_b(9999); +CALL bug_19194_searched(1); +CALL bug_19194_searched(2); +CALL bug_19194_searched(1000); +CALL bug_19194_searched(4998); +CALL bug_19194_searched(4999); +CALL bug_19194_searched(9999); -DROP PROCEDURE bug_19194_a; -DROP PROCEDURE bug_19194_b; +DROP PROCEDURE proc_19194_codegen; +DROP PROCEDURE bug_19194_simple; +DROP PROCEDURE bug_19194_searched; |