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_4561_test.py

74 lines
1.7 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-4878
ISSUE: 4878
TITLE: BUGCHECK(183) when use cursor with "order by ID+0" and "for update with lock"
DESCRIPTION:
JIRA: CORE-4561
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
-- Confirmed on WI-T3.0.0.31852 (CS/SC/SS):
-- Statement failed, SQLSTATE = XX000
-- internal Firebird consistency check (wrong record length (183), file: vio.cpp line: 1310)
-- Statement failed, SQLSTATE = XX000
-- internal Firebird consistency check (can't continue after bugcheck)
-- . . .
recreate table tm(id int);
commit;
insert into tm(id) values(1);
insert into tm(id) values(2); -- at least TWO records need to be added
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set list on;
set term ^;
execute block returns(deleted_count int) as
begin
deleted_count = 0;
for
select id
from tm
order by id+0 -- "+0" is mandatory for getting BCA
for update with lock -- and this also is mandatory
as cursor c
do begin
delete from tm where current of c;
deleted_count = deleted_count + 1;
end
suspend;
end^
set term ;^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set count on;
set echo on;
select * from tm;
rollback;
select * from tm;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
DELETED_COUNT 2
select * from tm;
Records affected: 0
rollback;
select * from tm;
ID 1
ID 2
Records affected: 2
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +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