2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
|
|
|
ID: issue-2508
|
|
|
|
ISSUE: 2508
|
|
|
|
TITLE: Expression indexes bug: incorrect result for the inverted boolean
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-1000
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_2073
|
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
|
|
|
init_script = """CREATE TABLE TMP_DATE1
|
2021-04-26 20:07:00 +02:00
|
|
|
(
|
|
|
|
DATE1 DATE,
|
|
|
|
DATE2 DATE
|
|
|
|
);
|
|
|
|
COMMIT;
|
|
|
|
SET TERM !!;
|
|
|
|
EXECUTE BLOCK
|
|
|
|
AS
|
|
|
|
DECLARE VARIABLE D DATE;
|
|
|
|
BEGIN
|
|
|
|
D = '01.01.2008';
|
|
|
|
WHILE (D < '01.08.2008') DO BEGIN
|
|
|
|
INSERT INTO TMP_DATE1(DATE1, DATE2)
|
|
|
|
VALUES(:D, :D + 100);
|
|
|
|
D = D + 1;
|
|
|
|
END
|
|
|
|
END!!
|
|
|
|
SET TERM ;!!
|
|
|
|
COMMIT;
|
|
|
|
CREATE INDEX TMP_DATE1_IDX1 ON TMP_DATE1 COMPUTED BY (DATE1+0);
|
|
|
|
CREATE INDEX TMP_DATE1_IDX2 ON TMP_DATE1 (DATE1);
|
|
|
|
COMMIT;
|
|
|
|
"""
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
test_script = """SET PLAN ON;
|
2021-04-26 20:07:00 +02:00
|
|
|
SELECT count(*) FROM TMP_DATE1 T WHERE '01.03.2008' BETWEEN T.DATE1+0 AND T.DATE2;
|
|
|
|
SELECT count(*) FROM TMP_DATE1 T WHERE '01.03.2008' >= T.DATE1;
|
|
|
|
"""
|
|
|
|
|
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
|
|
|
PLAN (T INDEX (TMP_DATE1_IDX1))
|
|
|
|
|
|
|
|
COUNT
|
|
|
|
=====================
|
|
|
|
61
|
|
|
|
|
|
|
|
|
|
|
|
PLAN (T INDEX (TMP_DATE1_IDX2))
|
|
|
|
|
|
|
|
COUNT
|
|
|
|
=====================
|
|
|
|
61
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-21 18:49:26 +01:00
|
|
|
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
|
|
|
|