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

78 lines
2.2 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-4571
ISSUE: 4571
TITLE: Delete "where current of" cursor fails for tables with newly added fields
DESCRIPTION: Scenario has been taken from attachment to this ticket
JIRA: CORE-4247
"""
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 table test_table (id integer not null, desc varchar(10));
alter table test_table add constraint pk_test_table primary key (id);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
insert into test_table (id, desc) values (1, 'a');
insert into test_table (id, desc) values (2, 'b');
insert into test_table (id, desc) values (3, 'c');
insert into test_table (id, desc) values (4, 'd');
insert into test_table (id, desc) values (5, 'e');
insert into test_table (id, desc) values (6, 'f');
insert into test_table (id, desc) values (7, 'g');
insert into test_table (id, desc) values (8, 'h');
insert into test_table (id, desc) values (9, 'i');
insert into test_table (id, desc) values (10, 'k');
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
alter table test_table add seqno integer;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- without this update - everything works
update test_table set seqno=id where id>=5;
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
set term ^ ;
create or alter procedure test_cursor
as
declare variable id integer;
declare variable desc varchar(10);
declare variable seqno integer;
begin
for
select id, desc, seqno from test_table
order by seqno -- if seqno values are unique - it works. With "order by id" works
into
:id, :desc, :seqno
as cursor data_cursor
do begin
delete from test_table where current of data_cursor; -- this fails !!!
-- with dummy suspend stored procedure works even it does not require to return any results
--suspend;
end
end^
set term ; ^
2022-01-23 20:41:55 +01:00
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_cursor;
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):
try:
act.execute()
except ExecutionError as e:
pytest.fail("Test script execution failed", pytrace=False)