6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_4870_test.py

95 lines
2.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5166
ISSUE: 5166
TITLE: Incorrect number of affected rows for UPDATE against VIEW created WITH CHECK OPTION
DESCRIPTION:
JIRA: CORE-4870
FBTEST: bugs.core_4870
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
-- Checked on LI-V3.0.0.32008, build after commiting rev. http://sourceforge.net/p/firebird/code/62140
create or alter view v_test3 as select 1 id from rdb$database;
create or alter view v_test2 as select 1 id from rdb$database;
create or alter view v_test1 as select 1 id from rdb$database;
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
recreate table test(id int primary key, x int);
commit;
insert into test values(1, 100);
insert into test values(2, 200);
insert into test values(3, 300);
insert into test values(4, 400);
insert into test values(5, 500);
insert into test values(6, 600);
commit;
2022-01-24 20:27:02 +01:00
recreate view v_test1 as select * from test where mod(id, 3)=0;
recreate view v_test2 as select * from test where mod(id, 3)=0 with check option;
recreate view v_test3 as select * from v_test2 where mod(id, 3)=0 with check option;
2021-04-26 20:07:00 +02:00
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set count on;
update v_test1 set x = -x where mod(id,3) = 0;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
update v_test2 set x = -x where mod(id,3) = 0;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
update v_test3 set x = -x where mod(id,3) = 0;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
merge into v_test1 t using( select id, x from test ) s on t.id = s.id
when matched then update set x = -s.x
when not matched then insert(id, x) values( -3 * s.id, -s.x )
;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
merge into v_test2 t using( select id, x from test ) s on t.id = s.id
when matched then update set x = -s.x
when not matched then insert(id, x) values( -3 * s.id, -s.x )
;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
merge into v_test3 t using( select id, x from test ) s on t.id = s.id
when matched then update set x = -s.x
when not matched then insert(id, x) values( -3 * s.id, -s.x )
;
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
insert into v_test1(id, x) values( 9, 900);
insert into v_test2(id, x) values(12, 1200);
insert into v_test3(id, x) values(15, 1500);
rollback;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set count off;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Records affected: 2
Records affected: 2
Records affected: 2
Records affected: 6
Records affected: 6
Records affected: 6
Records affected: 1
Records affected: 1
Records affected: 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +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