2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
|
|
|
ID: issue-939
|
|
|
|
ISSUE: 939
|
|
|
|
TITLE: Before triggers are firing after checks
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-583
|
|
|
|
"""
|
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
|
|
|
recreate table test1 (i int, constraint test1_chk check (i between 1 and 5));
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set term ^;
|
2022-01-18 20:45:21 +01:00
|
|
|
create trigger test1_bi for test1 active before insert position 0 as
|
2021-04-26 20:07:00 +02:00
|
|
|
begin
|
|
|
|
new.i=6;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
create trigger test1_bu for test1 active before update position 0 as
|
2021-04-26 20:07:00 +02:00
|
|
|
begin
|
|
|
|
new.i=7;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set count on;
|
|
|
|
insert into test1 values (2);
|
|
|
|
select * from test1;
|
|
|
|
update test1 set i=2 where i = 6;
|
|
|
|
select * from test1;
|
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, substitutions=[('-At trigger.*', '-At trigger')])
|
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
|
|
|
Records affected: 0
|
|
|
|
Records affected: 0
|
|
|
|
Records affected: 0
|
|
|
|
Records affected: 0
|
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 = 23000
|
|
|
|
Operation violates CHECK constraint TEST1_CHK on view or table TEST1
|
|
|
|
-At trigger 'CHECK_3'
|
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
|
|
|
|