2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID : issue - 5058
ISSUE : 5058
TITLE : Bugcheck 167 ( invalid SEND request ) while working with GTT from several attachments ( using EXECUTE STATEMENT . . . ON EXTERNAL and different roles )
DESCRIPTION :
JIRA : CORE - 4754
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-24 20:27:02 +01:00
from firebird . qa import *
2021-12-10 19:50:31 +01:00
from firebird . driver import tpb , Isolation , TraAccessMode , DatabaseError
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate global temporary table gtt_session ( x int , y int ) on commit preserve rows ;
commit ;
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory ( init = init_script )
2021-11-26 19:20:43 +01:00
2022-01-24 20:27:02 +01:00
act = python_act ( ' db ' )
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-11-26 19:20:43 +01:00
Error - 1 :
lock conflict on no wait transaction
- unsuccessful metadata update
- object TABLE " GTT_SESSION " is in use
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
@pytest.mark.version ( ' >=3 ' )
def test_1 ( act : Action , capsys ) :
2021-12-10 19:50:31 +01:00
custom_tpb = tpb ( isolation = Isolation . READ_COMMITTED_RECORD_VERSION ,
access_mode = TraAccessMode . WRITE , lock_timeout = 0 )
2022-01-24 20:27:02 +01:00
with act . db . connect ( ) as con1 :
2021-11-26 19:20:43 +01:00
tx1a = con1 . transaction_manager ( custom_tpb )
cur1a = tx1a . cursor ( )
tx1b = con1 . transaction_manager ( custom_tpb )
cur1b = tx1b . cursor ( )
try :
cur1a . execute ( " insert into gtt_session select rand()*10, rand()*10 from rdb$types " )
cur1b . execute ( " create index gtt_session_x_y on gtt_session computed by (x+y) " )
tx1b . commit ( ) # WI-V2.5.6.27013 issues here: lock conflict on no wait transaction unsuccessful metadata update object TABLE "GTT_SESSION" is in use -901 335544345
tx1a . commit ( )
except DatabaseError as e :
print ( ' Error-1: ' )
msg = e . args [ 0 ]
print ( msg )
#
if not msg . split ( ) :
# 2.5.5: control should NOT pass here at all!
2022-01-24 20:27:02 +01:00
with act . db . connect ( ) as con2 :
2021-11-26 19:20:43 +01:00
try :
tx2a = con2 . transaction_manager ( )
cur2a = tx2a . cursor ( )
cur2a . execute ( " insert into gtt_session select rand()*11, rand()*11 from rdb$types " )
except DatabaseError as e :
print ( ' Error-2: ' )
print ( e . args [ 0 ] )
#
2022-01-24 20:27:02 +01:00
act . expected_stdout = expected_stdout
act . stdout = capsys . readouterr ( ) . out
assert act . clean_stdout == act . clean_expected_stdout