2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
|
|
|
ID: issue-5653
|
|
|
|
ISSUE: 5653
|
|
|
|
TITLE: Allow subroutines to call others subroutines and themself recursively
|
|
|
|
DESCRIPTION:
|
|
|
|
We check not only ability of recursive calls but also max depth of them. It should be equal to 1000.
|
|
|
|
JIRA: CORE-5380
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5380
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set term ^;
|
|
|
|
create or alter function get_arithmetic_progression_total(n smallint) returns decfloat(34) as
|
|
|
|
declare function get_sub_total_recursively(n smallint) returns decfloat(34) as
|
|
|
|
begin
|
|
|
|
if (n = 1) then
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return n + get_sub_total_recursively(n - 1);
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
if (n <= 0) then
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return get_sub_total_recursively(n);
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set list on;
|
|
|
|
select get_arithmetic_progression_total(1001) as arithmetic_progression_total from rdb$database;
|
|
|
|
select get_arithmetic_progression_total(1002) as arithmetic_progression_total from rdb$database;
|
|
|
|
-- (a1 + an) * n / 2
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
act = isql_act('db', test_script, substitutions=[('line:\\s[0-9]+,', 'line: x'),
|
|
|
|
('col:\\s[0-9]+', 'col: y')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
ARITHMETIC_PROGRESSION_TOTAL 501501
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2022-01-25 22:55:48 +01:00
|
|
|
|
|
|
|
expected_stderr = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Statement failed, SQLSTATE = 54001
|
|
|
|
Too many concurrent executions of the same request
|
|
|
|
-At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY' line: 7, col: 13
|
|
|
|
At sub function 'GET_SUB_TOTAL_RECURSIVELY'...
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0')
|
2022-01-25 22:55:48 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.expected_stderr = expected_stderr
|
|
|
|
act.execute()
|
|
|
|
assert (act.clean_stderr == act.clean_expected_stderr and
|
|
|
|
act.clean_stdout == act.clean_expected_stdout)
|
2021-04-26 20:07:00 +02:00
|
|
|
|