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

86 lines
3.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-22 21:59:15 +01:00
"""
ID: issue-3903
ISSUE: 3903
TITLE: Floating-point negative zero doesn't match positive zero in the index
DESCRIPTION:
JIRA: CORE-3547
FBTEST: bugs.core_3547
NOTES:
[09.02.2022] pcisar
Specific stdout is required on Windows for v3 up to 3.0.8 due to small difference
It's possible that this problem would be fixed in 3.0.9.
[20.09.2022] pzotov
Added substitution in order to stop comparison after 15th digit ("COL = 0.000000000000000").
We have to ensure that one can not insert duplicate (-0e0). It is enough to show concrete
value of problematic key with accuracy 15 digits.
Checked on 3.0.8.33535, 4.0.1.2692, 5.0.0.730 - both Linux and Windows
2022-01-22 21:59:15 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table t_float_no_pk (col float);
commit;
insert into t_float_no_pk (col) values (0e0);
insert into t_float_no_pk (col) values (-0e0);
commit;
2021-11-09 11:01:26 +01:00
2021-04-26 20:07:00 +02:00
recreate table t1_double_as_pk (col double precision, constraint t1_double_pk primary key(col) using index t1_double_pk);
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
select count(*) "where id = 0" from rdb$relations where rdb$relation_id = 0;
select count(*) "where id = 0e0" from rdb$relations where rdb$relation_id = 0e0;
select count(*) "where id = (1e0 - 1e0)" from rdb$relations where rdb$relation_id = (1e0 - 1e0);
select count(*) "where id = -0e0" from rdb$relations where rdb$relation_id = -0e0;
select count(*) "where id = -(1e0 - 1e0)" from rdb$relations where rdb$relation_id = -(1e0 - 1e0);
select count(*) "where 0e0 = -0e0" from rdb$database where 0e0 = -0e0;
2021-11-09 11:01:26 +01:00
2021-04-26 20:07:00 +02:00
insert into t1_double_as_pk (col) values (0e0);
commit;
insert into t1_double_as_pk (col) values (-0e0);
commit;
select count(distinct col) "t_float_no_pk: count(dist col)" from t_float_no_pk;
select count(*) "t_double_pk: col, count(*)" from t1_double_as_pk group by col;
-- :: NB ::: Problematic key representaion for 0e0 differ in Windows vs Linux!
-- NIX: -Problematic key value is ("COL" = 0.000000000000000)
-- WIN: -Problematic key value is ("COL" = 0.0000000000000000)
-- ^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
act = isql_act('db', test_script, substitutions = [(' = 0.0000000000000000', ' = 0.000000000000000')])
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
where id = 0 1
where id = 0e0 1
where id = (1e0 - 1e0) 1
where id = -0e0 1
where id = -(1e0 - 1e0) 1
where 0e0 = -0e0 1
t_float_no_pk: count(dist col) 1
t_double_pk: col, count(*) 1
2021-12-22 20:23:11 +01:00
"""
2022-01-22 21:59:15 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 23000
violation of PRIMARY or UNIQUE KEY constraint "T1_DOUBLE_PK" on table "T1_DOUBLE_AS_PK"
-Problematic key value is ("COL" = 0.000000000000000)
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3')
2022-01-22 21:59:15 +01:00
def test_1(act: Action):
2022-02-09 20:47:40 +01:00
act.expected_stdout = expected_stdout
act.expected_stderr = expected_stderr
2022-02-09 20:47:40 +01:00
act.execute()
assert (act.clean_stderr == act.clean_expected_stderr and
act.clean_stdout == act.clean_expected_stdout)