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

130 lines
3.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-27 20:08:36 +01:00
"""
ID: issue-6584
ISSUE: 6584
TITLE: Rolled back transaction produces unexpected results leading to duplicate values in PRIMARY KEY field
DESCRIPTION:
JIRA: CORE-6343
FBTEST: bugs.core_6343
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
create or alter procedure sp_test as begin end;
create global temporary table gtt_table (
id integer not null
) on commit delete rows;
create table test (
id integer not null primary key
);
set term ^;
create or alter procedure sp_test returns ( id1 integer)
as
declare variable v integer;
begin
insert into gtt_table values(1);
insert into gtt_table values(2);
insert into gtt_table values(3);
for
select id from gtt_table
into :id1 do
begin
insert into test (id) values (:id1);
-- NOTE: it is mandatory to make "unnecessary" query to rdb$database
-- in order to reproduce bug. Do not replace it with "pure PSQL".
for
select 1 from rdb$database into :v
2022-01-27 20:08:36 +01:00
do
2021-04-26 20:07:00 +02:00
if (:id1=3) then
id1 = 1/0; -- do NOT suppress this exception otherwise bug will not shown
suspend;
delete from test;
end
end
^
set term ;^
commit;
-----------------------------------
set heading off;
-- Iteration #1
select * from sp_test;
rollback;
select * from test;
-- Iteration #2
select * from sp_test;
rollback;
select * from test;
-- Iteration #3
select * from sp_test;
rollback;
select * from test;
-- Iteration #4
select * from sp_test;
rollback;
select * from test;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
act = isql_act('db', test_script, substitutions=[('line:.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stdout = """
1
2
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
1
2
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
1
2
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
1
2
2021-12-22 20:23:11 +01:00
"""
2022-01-27 20:08:36 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 22012
arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
-At procedure 'SP_TEST'
Statement failed, SQLSTATE = 22012
arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
-At procedure 'SP_TEST'
Statement failed, SQLSTATE = 22012
arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
-At procedure 'SP_TEST'
Statement failed, SQLSTATE = 22012
arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
-At procedure 'SP_TEST'
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.6')
2022-01-27 20:08:36 +01:00
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)