6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

Added/Updated tests\bugs\core_4386_test.py: Reimplemented, see notes.

This commit is contained in:
pavel-zotov 2024-08-22 21:50:18 +03:00
parent f5fc896942
commit d3e21985ab

View File

@ -21,8 +21,20 @@ NOTES:
See 'tx2.commit()' in the code. If we replace it with 'con2.commit()' then Tx2 will be
*silently* rolled back (!!despite that we issued con.commit() !!) and we will not get any
error messages. I'm not sure whether this correct or no.
Checked on 3.0.8.33535 (SS/CS), 4.0.1.2692 (SS/CS), 5.0.0.730
[22.08.2024] pzotov
* Changed DDL because of SubQueryConversion config parameter appearance.
We have to AVOID usage of queries which have plan that can be changed when firebird.conf has
SubQueryConversion = true. In that case some index can be excluded from plan and thus
it can be dropped on first iteration of 'for x_isol in tx_isol_lst' loop. This causes unexpected
error 'index not found' for subsequent checks.
* Added check for error message when we try to drop standalone function.
* Assert moved out to the point after loop in order to show whole result in case of some error
(rather than only one message block for some particular x_isol).
* Excluded check of FB 3.x (this version no more changed).
Checked on 6.0.0.442, 5.0.2.1479, 4.0.6.3142
"""
import pytest
@ -46,17 +58,24 @@ ddl_script = """
create index test1_id on test1(id);
commit;
create descending index test2_id_x_desc on test2(id,x);
create descending index test2_x on test2(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 function fn_worker(a_x int) returns int as
declare v_id int;
begin
execute statement ('select max(b.id) from test2 b where b.x >= ?') (:a_x) into v_id;
return v_id;
end
^
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)
execute statement ('select v.x from v_test v where v.id = ? and v.id >= fn_worker(v.x)') (:a_id)
into x
do
suspend;
@ -84,48 +103,18 @@ ddl_script = """
commit;
"""
expected_stdout = """
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_ID_X_DESC" is in use
(335544345, 335544351, 335544453)
"""
@pytest.mark.version('>=3.0.6')
@pytest.mark.version('>=4.0')
def test_1(act: Action, capsys):
act.isql(switches=[], input=ddl_script)
drop_commands = [ 'drop procedure sp_test',
'drop procedure sp_worker',
'drop function fn_worker',
'drop view v_test',
'drop table test2',
'drop index test1_id',
'drop index test2_id_x_desc']
'drop index test2_x'
]
tx_isol_lst = [ Isolation.READ_COMMITTED_NO_RECORD_VERSION,
Isolation.READ_COMMITTED_RECORD_VERSION,
@ -147,6 +136,7 @@ def test_1(act: Action, capsys):
for cmd in drop_commands:
with act.db.connect() as con2:
custom_tpb = tpb(isolation = x_isol, lock_timeout=0)
print(x_isol.name, cmd)
tx2 = con2.transaction_manager(custom_tpb)
tx2.begin()
cur2 = tx2.cursor()
@ -164,7 +154,218 @@ def test_1(act: Action, capsys):
print(e.__str__())
print(e.gds_codes)
act.expected_stdout = expected_stdout
act.expected_stdout = f"""
READ_COMMITTED_NO_RECORD_VERSION drop procedure sp_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop procedure sp_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop function fn_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object FUNCTION "FN_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop view v_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop table test2
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop index test1_id
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_NO_RECORD_VERSION drop index test2_x
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_X" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop procedure sp_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop procedure sp_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop function fn_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object FUNCTION "FN_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop view v_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop table test2
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop index test1_id
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_RECORD_VERSION drop index test2_x
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_X" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop procedure sp_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop procedure sp_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop function fn_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object FUNCTION "FN_WORKER" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop view v_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop table test2
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop index test1_id
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
SNAPSHOT drop index test2_x
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_X" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop procedure sp_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop procedure sp_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop function fn_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object FUNCTION "FN_WORKER" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop view v_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop table test2
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop index test1_id
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
SERIALIZABLE drop index test2_x
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_X" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop procedure sp_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop procedure sp_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object PROCEDURE "SP_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop function fn_worker
lock conflict on no wait transaction
-unsuccessful metadata update
-object FUNCTION "FN_WORKER" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop view v_test
lock conflict on no wait transaction
-unsuccessful metadata update
-object VIEW "V_TEST" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop table test2
lock conflict on no wait transaction
-unsuccessful metadata update
-object TABLE "TEST2" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop index test1_id
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST1_ID" is in use
(335544345, 335544351, 335544453)
READ_COMMITTED_READ_CONSISTENCY drop index test2_x
lock conflict on no wait transaction
-unsuccessful metadata update
-object INDEX "TEST2_X" is in use
(335544345, 335544351, 335544453)
"""
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout
act.reset()