6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_4929_test.py

90 lines
1.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5220
ISSUE: 5220
TITLE: Cannot compile source with "ELSE IF ( <expr> ) THEN" statement and commands
to manupulate explicit cursor inside
2022-01-24 20:27:02 +01:00
DESCRIPTION:
JIRA: CORE-4929
FBTEST: bugs.core_4929
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure sp_test(v smallint) returns(result int) as
begin
result = null;
suspend;
end
^
set term ;^
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
alter procedure sp_test(v smallint) returns(result int) as
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
declare c1 cursor for (
select 1 id from rdb$database
);
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
declare c2 cursor for (
select 2 id from rdb$database
);
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
begin
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
if ( v = 1 ) then open c1;
else
if ( :v = 2 ) then
open c2;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
while (1=1) do
begin
if ( v = 1 ) then fetch c1 into result;
else
if ( :v = 2 ) then
fetch c2 into result;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
if (row_count = 0) then leave;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
suspend;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
end
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
if ( v = 1 ) then close c1;
else
if ( :v = 2 ) then
close c2;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
end
^
set term ;^
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set list on;
select * from sp_test(1);
select * from sp_test(2);
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RESULT 1
RESULT 2
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00