2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
|
|
|
ID: issue-2478
|
|
|
|
ISSUE: 2478
|
|
|
|
TITLE: Connection lost to database when used AUTONOMOUS TRANSACTION
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-2042
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_2042
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set term ^;
|
|
|
|
create or alter procedure test_caller_name
|
|
|
|
returns (
|
|
|
|
object_name char(31),
|
|
|
|
object_type smallint)
|
|
|
|
as
|
|
|
|
begin
|
|
|
|
end
|
|
|
|
^
|
|
|
|
create or alter procedure get_caller_name
|
|
|
|
returns (
|
|
|
|
object_name char(31),
|
|
|
|
object_type smallint)
|
|
|
|
as
|
|
|
|
declare variable tran_id integer;
|
|
|
|
begin
|
|
|
|
tran_id = current_transaction;
|
2022-01-21 18:49:26 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
in autonomous transaction do
|
|
|
|
begin
|
|
|
|
select cs.mon$object_name, cs.mon$object_type
|
|
|
|
from mon$call_stack cs, mon$statements st
|
|
|
|
where cs.mon$statement_id = st.mon$statement_id
|
|
|
|
and st.mon$transaction_id = :tran_id
|
|
|
|
and cs.mon$caller_id is null -- :: nb :: Added this condition because output differs in 3.0 vs 2.5!
|
|
|
|
order by cs.mon$call_id
|
|
|
|
rows 1
|
|
|
|
into :object_name, :object_type;
|
|
|
|
end
|
2022-01-21 18:49:26 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
suspend;
|
|
|
|
end
|
|
|
|
^
|
2022-01-21 18:49:26 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
create or alter procedure test_caller_name
|
|
|
|
returns (
|
|
|
|
object_name char(31),
|
|
|
|
object_type smallint)
|
|
|
|
as
|
|
|
|
begin
|
|
|
|
select object_name, object_type from get_caller_name
|
|
|
|
into :object_name, :object_type;
|
2022-01-21 18:49:26 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
suspend;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
select * from test_caller_name;
|
|
|
|
select * from test_caller_name;
|
|
|
|
select * from test_caller_name;
|
|
|
|
select * from test_caller_name;
|
|
|
|
select * from test_caller_name;
|
|
|
|
commit;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
expected_stdout = """
|
|
|
|
OBJECT_NAME TEST_CALLER_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
OBJECT_TYPE 5
|
2022-01-21 18:49:26 +01:00
|
|
|
OBJECT_NAME TEST_CALLER_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
OBJECT_TYPE 5
|
2022-01-21 18:49:26 +01:00
|
|
|
OBJECT_NAME TEST_CALLER_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
OBJECT_TYPE 5
|
2022-01-21 18:49:26 +01:00
|
|
|
OBJECT_NAME TEST_CALLER_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
OBJECT_TYPE 5
|
2022-01-21 18:49:26 +01:00
|
|
|
OBJECT_NAME TEST_CALLER_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
OBJECT_TYPE 5
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
|
|
|
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
|
|
|
|