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

109 lines
2.6 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-4334
ISSUE: 4334
TITLE: Error message "index unexpectedly deleted" in database trigger on commit transaction
DESCRIPTION:
JIRA: CORE-4002
"""
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
init_script = """
2021-04-26 20:07:00 +02:00
create or alter trigger trg_commit active on transaction commit position 999 as
begin
end;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter procedure test_gg as begin end;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate global temporary table g2(id int);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate global temporary table g1 (
id int primary key,
tt varchar(100) not null,
bb blob sub_type 1 segment size 80 not null
) on commit delete rows;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate global temporary table g2 (
id int primary key ,
id_g1 int not null references g1,
tt varchar(100) not null,
bb blob sub_type 1 segment size 80 not null
) on commit delete rows;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set term ^ ;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter procedure test_gg
as
declare i int = 0;
begin
in autonomous transaction do
while (i<100) do
begin
insert into g1 (id, tt, bb) values (:i, rand(), rand());
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
insert into g2 (id, id_g1, tt, bb) values (:i*1000+1, :i, rand(), rand());
insert into g2 (id, id_g1, tt, bb) values (:i*1000+2, :i, rand(), rand());
insert into g2 (id, id_g1, tt, bb) values (:i*1000+3, :i, rand(), rand());
insert into g2 (id, id_g1, tt, bb) values (:i*1000+4, :i, rand(), rand());
insert into g2 (id, id_g1, tt, bb) values (:i*1000+5, :i, rand(), rand());
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
i=i+1;
end
end^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
commit^
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
create or alter trigger trg_commit
active on transaction commit position 999
as
declare variable id integer;
declare variable tt varchar(100);
declare variable bb blob sub_type 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
declare variable id_g1 integer;
declare variable tt_2 varchar(100);
declare variable bb_2 blob sub_type 1;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
declare i int=0;
begin
for select id, tt, bb
from g1
order by id
into :id, :tt, :bb
do
begin
for select id_g1, tt, bb
from g2
where id_g1=:id
order by id
into :id_g1, :tt_2, :bb_2
do
begin
i=i+1;
end
end
end^
2022-01-23 20:41:55 +01:00
set term ;^
2021-04-26 20:07:00 +02:00
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(init=init_script)
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
execute procedure test_gg;
commit;
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
@pytest.mark.version('>=3')
def test_1(act: Action):
2022-01-25 22:55:48 +01:00
act.execute()