2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
|
|
|
ID: issue-512
|
|
|
|
ISSUE: 512
|
|
|
|
TITLE: DB crashes if trigger BU deletes own row
|
|
|
|
DESCRIPTION:
|
|
|
|
NOTES:
|
|
|
|
Ortiginal test:
|
|
|
|
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_28.script
|
|
|
|
JIRA: CORE-185
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_0185
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
create table test (id integer not null);
|
|
|
|
commit;
|
|
|
|
set term ^ ;
|
|
|
|
create trigger test_bu for test active before update position 0 as
|
|
|
|
begin
|
|
|
|
delete from test where id=old.id;
|
2022-01-18 20:45:21 +01:00
|
|
|
end
|
2021-04-26 20:07:00 +02:00
|
|
|
^
|
|
|
|
set term ; ^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
insert into test values (1);
|
|
|
|
insert into test values (2);
|
|
|
|
insert into test values (3);
|
|
|
|
insert into test values (4);
|
|
|
|
insert into test values (5);
|
|
|
|
insert into test values (6);
|
|
|
|
commit;
|
|
|
|
|
|
|
|
update test set id=-1 where id=1;
|
|
|
|
rollback;
|
|
|
|
set list on;
|
|
|
|
select count(*) from test;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
COUNT 6
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2022-01-18 20:45:21 +01:00
|
|
|
expected_stderr = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Statement failed, SQLSTATE = 22000
|
|
|
|
no current record for fetch operation
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
@pytest.mark.version('>=3')
|
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.expected_stderr = expected_stderr
|
|
|
|
act.execute()
|
|
|
|
assert (act.clean_stderr == act.clean_expected_stderr and
|
|
|
|
act.clean_stdout == act.clean_expected_stdout)
|
2021-04-26 20:07:00 +02:00
|
|
|
|