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

164 lines
4.5 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 11:45:40 +01:00
"""
2022-01-18 20:45:21 +01:00
ID: issue-361
2022-01-18 11:45:40 +01:00
ISSUE: 361
TITLE: Error "no current record for fetch operation" on view select
DESCRIPTION:
NOTES:
[24.01.2019] Added separate code for running on FB 4.0+.
UDF usage is deprecated in FB 4+, see: ".../doc/README.incompatibilities.3to4.txt".
Functions div, frac, dow, sdow, getExactTimestampUTC and isLeapYear got safe
replacement in UDR library "udf_compat", see it in folder: ../plugins/udr/
2022-01-18 20:45:21 +01:00
JIRA: CORE-37
FBTEST: bugs.core_0037
2022-01-18 11:45:40 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 11:45:40 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-18 11:45:40 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
test_script_1 = """
set bail on;
recreate view v1 as select 1 k from rdb$database;
recreate view v2 as select 1 k from rdb$database;
commit;
set term ^;
execute block as
begin
execute statement 'drop function udf_frac';
2022-01-18 11:45:40 +01:00
when any do
begin end
end
^
set term ;^
commit;
declare external function udf_frac
double precision
returns double precision by value
entry_point 'IB_UDF_frac' module_name 'ib_udf';
commit;
recreate table t1
(
t1f1 integer not null primary key,
t1f2 varchar(30)
);
recreate table t2
(
t2f1 integer not null primary key,
t2f2 integer not null,
t2f3 varchar(30)
);
create index t2f2_ndx on t2(t2f2);
recreate view v1 as select * from t1 where udf_frac( mod(t1f1,100) / 100.000) > 0.03;
recreate view v2 as select * from t2 where udf_frac( mod(t2f1,100) / 100.000) > 0.03;
insert into t1(t1f1, t1f2) values (1, '1');
insert into t1(t1f1, t1f2) values (2, '2');
insert into t1(t1f1, t1f2) values (3, '3');
insert into t1(t1f1, t1f2) values (104, '104');
insert into t1(t1f1, t1f2) values (105, '205');
insert into t1(t1f1, t1f2) values (106, '106');
insert into t2(t2f1, t2f2, t2f3) values (1, 1, '1');
insert into t2(t2f1, t2f2, t2f3) values (2, 2, '2');
insert into t2(t2f1, t2f2, t2f3) values (3, 3, '3');
insert into t2(t2f1, t2f2, t2f3) values (104, 104, '104');
insert into t2(t2f1, t2f2, t2f3) values (105, 105, '105');
insert into t2(t2f1, t2f2, t2f3) values (106, 106, '106');
set count on;
select x.*, y.*, udf_frac( mod(t2f1,100) / 100.000)
from v1 x, v2 y
2022-01-18 11:45:40 +01:00
where x.t1f1 = y.t2f2
and udf_frac( mod(t2f1,100) / 100.000) < 0.03
;
"""
2022-01-18 11:45:40 +01:00
act_1 = isql_act('db', test_script_1)
2022-01-18 11:45:40 +01:00
expected_stdout = """
Records affected: 0
"""
2022-01-18 11:45:40 +01:00
@pytest.mark.version('>=3,<4.0')
def test_1(act_1: Action):
2022-01-18 11:45:40 +01:00
act_1.expected_stdout = expected_stdout
act_1.execute()
assert act_1.clean_stdout == act_1.clean_expected_stdout
# version: 4.0
test_script_2 = """
set bail on;
2021-04-26 20:07:00 +02:00
-- See declaration sample in plugins\\udr\\UdfBackwardCompatibility.sql:
create function UDR40_frac (
val double precision
) returns double precision
external name 'udf_compat!UC_frac'
engine udr;
recreate view v1 as select 1 k from rdb$database;
recreate view v2 as select 1 k from rdb$database;
commit;
recreate table t1
(
t1f1 integer not null primary key,
t1f2 varchar(30)
);
recreate table t2
(
t2f1 integer not null primary key,
t2f2 integer not null,
t2f3 varchar(30)
);
create index t2f2_ndx on t2(t2f2);
recreate view v1 as select * from t1 where UDR40_frac( mod(t1f1,100) / 100.000) > 0.03;
recreate view v2 as select * from t2 where UDR40_frac( mod(t2f1,100) / 100.000) > 0.03;
insert into t1(t1f1, t1f2) values (1, '1');
insert into t1(t1f1, t1f2) values (2, '2');
insert into t1(t1f1, t1f2) values (3, '3');
insert into t1(t1f1, t1f2) values (104, '104');
insert into t1(t1f1, t1f2) values (105, '205');
insert into t1(t1f1, t1f2) values (106, '106');
insert into t2(t2f1, t2f2, t2f3) values (1, 1, '1');
insert into t2(t2f1, t2f2, t2f3) values (2, 2, '2');
insert into t2(t2f1, t2f2, t2f3) values (3, 3, '3');
insert into t2(t2f1, t2f2, t2f3) values (104, 104, '104');
insert into t2(t2f1, t2f2, t2f3) values (105, 105, '105');
insert into t2(t2f1, t2f2, t2f3) values (106, 106, '106');
set count on;
select x.*, y.*, UDR40_frac( mod(t2f1,100) / 100.000)
from v1 x, v2 y
2022-01-18 11:45:40 +01:00
where x.t1f1 = y.t2f2
2021-04-26 20:07:00 +02:00
and UDR40_frac( mod(t2f1,100) / 100.000) < 0.03
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 11:45:40 +01:00
act_2 = isql_act('db', test_script_2)
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
def test_2(act_2: Action):
2022-01-18 11:45:40 +01:00
act_2.expected_stdout = expected_stdout
act_2.execute()
assert act_2.clean_stdout == act_2.clean_expected_stdout
2021-04-26 20:07:00 +02:00