6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_4386_test.py

149 lines
4.0 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4708
ISSUE: 4708
TITLE: Report more details for "object in use" errors
DESCRIPTION:
NOTES:
[22.11.2021] pcisar
This test requires READ_COMMITTED_NO_RECORD_VERSION transaction to work, which
requires ReadConsistency disabled in FB 4. However, it does not work as expected
because all drop commands pass without exception even with ReadConsistency disabled.
The same happens under 3.0.8 (no errors raised).
JIRA: CORE-4386
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-23 20:41:55 +01:00
from firebird.qa import *
2021-12-10 19:50:31 +01:00
from firebird.driver import tpb, Isolation
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory()
2021-11-26 19:20:43 +01:00
2022-01-23 20:41:55 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2021-12-22 20:23:11 +01:00
ddl_script = """
set bail on;
create or alter procedure sp_worker as begin end;
create or alter procedure sp_test as begin end;
create or alter view v_test as select 1 x from rdb$database;
commit;
recreate table test1(id int,x int);
recreate table test2(id int,x int);
commit;
create index test1_id on test1(id);
commit;
create descending index test2_id_x_desc on test2(id,x);
commit;
create or alter view v_test as select id,x from test1 where id between 15 and 30;
commit;
set term ^;
create or alter procedure sp_worker(a_id int) returns(x int) as
begin
for
execute statement ('select v.x from v_test v where v.id = ? and exists(select * from test2 b where b.id = v.id)') (:a_id)
into x
do
suspend;
end
^
create or alter procedure sp_test(a_id int) returns(x int) as
begin
for
execute statement ('select x from sp_worker(?)') (:a_id)
into x
do
suspend;
end
^
set term ;^
commit;
insert into test1 values(11,111);
insert into test1 values(21,222);
insert into test1 values(31,333);
insert into test1 values(41,444);
commit;
insert into test2 select * from test1;
commit;
"""
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object PROCEDURE "SP_TEST" is in use
335544345
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object PROCEDURE "SP_WORKER" is in use
335544345
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object VIEW "V_TEST" is in use
335544345
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object TABLE "TEST2" is in use
335544345
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object INDEX "TEST1_ID" is in use
335544345
Error while commiting transaction:
- SQLCODE: -901
- lock conflict on no wait transaction
- unsuccessful metadata update
- object INDEX "TEST2_ID_X_DESC" is in use
335544345
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
@pytest.mark.skip("FIXME: see notes")
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.6')
2022-01-23 20:41:55 +01:00
def test_1(act: Action, capsys):
act.isql(switches=[], input=ddl_script)
2021-11-26 19:20:43 +01:00
#
2021-12-10 19:50:31 +01:00
custom_tpb = tpb(isolation=Isolation.READ_COMMITTED_NO_RECORD_VERSION, lock_timeout=0)
2022-01-23 20:41:55 +01:00
with act.db.connect() as con:
2021-11-26 19:20:43 +01:00
cur1 = con.cursor()
cur1.execute('select x from sp_test(21)').fetchall()
drop_commands = ['drop procedure sp_test',
'drop procedure sp_worker',
'drop view v_test',
'drop table test2',
'drop index test1_id',
'drop index test2_id_x_desc']
for cmd in drop_commands:
2022-01-23 20:41:55 +01:00
with act.db.connect() as con2:
2021-12-10 19:50:31 +01:00
tx = con2.transaction_manager(custom_tpb)
2021-11-26 19:20:43 +01:00
tx.begin()
cur2 = tx.cursor()
try:
cur2.execute(cmd)
except Exception as exc:
print(exc)
#
2022-01-23 20:41:55 +01:00
act.reset()
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout