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

65 lines
2.5 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-6482
ISSUE: 6482
TITLE: DECFLOAT: subtraction Num1 - Num2 leads to "Decimal float overflow" if Num2
is specified in scientific notation and less than max double ( 1.7976931348623157e308 )
2022-01-27 20:08:36 +01:00
DESCRIPTION:
JIRA: CORE-6238
FBTEST: bugs.core_6238
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
-- All following statements raised before fix:
-- Statement failed, SQLSTATE = 22003
-- Decimal float overflow. The exponent of a result is greater than the magnitude allowed.
set list on;
select (d - 1e0) as result_01 from (select 9.999999999999999999999999999999998E+6144 d from rdb$database);
select (d - 1.79769313e308) as result_02 from (select 9.999999999999999999999999999999998E+6144 d from rdb$database);
select (d - cast( 1e0 as float) ) as result_03 from (select 9.999999999999999999999999999999998E+6144 d from rdb$database);
select (d + 1.79769313e-308 ) as result_04 from (select 9.999999999999999999999999999999998E+6144 d from rdb$database);
-- This EB was added only to check that no error will be while executing statements in it.
-- See letter to Alex, 31.01.2020 11:34, and his postfix for this ticket:
-- https://github.com/FirebirdSQL/firebird/commit/0ef5a1a1c1bf42021b378e1691aaccfd75a454b4
set term ^;
execute block as
declare dt date;
declare tm time;
declare ts timestamp;
begin
select current_date + cast(1 as numeric(19,0)) from rdb$database into dt;
select current_date + cast(1 as decfloat) from rdb$database into dt;
select current_time + cast(1 as numeric(19,0)) from rdb$database into tm;
select current_time + cast(1 as decfloat) from rdb$database into tm;
select current_timestamp + cast(1 as decfloat) from rdb$database into ts;
select current_timestamp + cast(1 as decfloat) from rdb$database into ts;
end
^
set term ;^
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)
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RESULT_01 9.999999999999999999999999999999998E+6144
RESULT_02 9.999999999999999999999999999999998E+6144
RESULT_03 9.999999999999999999999999999999998E+6144
RESULT_04 9.999999999999999999999999999999998E+6144
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-27 20:08:36 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout