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

79 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3353
ISSUE: 3353
TITLE: Invalid UPDATE OR INSERT usage may lead to successive "request depth exceeded. (Recursive definition?)" error
DESCRIPTION:
JIRA: CORE-2971
FBTEST: bugs.core_2971
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
-- This syntax works fine since 2.0.x:
recreate view v(x, y) as select 1 x, 2 y from rdb$database;
commit;
set term ^;
execute block as
begin
execute statement 'drop sequence g';
when any do begin end
end
^
set term ;^
commit;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
create sequence g;
recreate table t1 (n1 integer);
recreate table t2 (n2 integer);
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
recreate view v(x, y) as select t1.n1 as x, t2.n2 as y from t1, t2;
commit;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
execute block as
declare n int = 1000;
begin
while (n>0) do
begin
n = n - 1;
execute statement ('update or insert into v values ( '|| gen_id(g,1) ||', gen_id(g,1))');
-- ^
-- For this statement trace 2.5 and 3.0 shows:
-- ERROR AT JStatement::prepare
-- ...
-- 335544569 : Dynamic SQL Error
-- 336003101 : UPDATE OR INSERT without MATCHING could not be used with views based on more than one table
-- We have to suppress ONLY exception with gdscode = 335544569 and raise if its gdscode has any other value.
2022-01-21 18:49:26 +01:00
when any do
2021-04-26 20:07:00 +02:00
begin
if ( gdscode not in (335544569) ) then exception;
end
end
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
end
^
set term ;^
rollback;
set list on;
select gen_id(g, 0) curr_gen from rdb$database;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
CURR_GEN 1000
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3')
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