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

77 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_6440
# title: Expression indexes containing COALESCE inside cannot be matched by the optimizer after migration from v2.5 to v3.0
# decription:
# Confirmed bug on 3.0.7.33388 (wrong plans of queris specified in the ticked; need to RESTORE database from 2.5 on 3.x).
# Test uses .fbk that was created on FB 2.5.9, file: core6440-ods11.fbk
#
# Checked on 4.0.0.2269; 3.0.8.33390 -- all OK.
#
# tracker_id: CORE-6440
# min_versions: []
# versions: 3.0.8
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0.8
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(from_backup='core6440-ods11.fbk', init=init_script_1)
test_script_1 = """
set planonly;
--set echo on;
--Uses a proper index: PLAN (TEST INDEX (PK_TEST))
select * from test where field_1 = 1;
--Uses a proper index: PLAN (TEST INDEX (TEST_IDX4))
select * from test where (UPPER(FIELD_2)) = 'TEST1';
--Doesn't uses a proper index: PLAN (TEST NATURAL)
select * from test where (UPPER(COALESCE(FIELD_2,''))) = 'TEST1';
--Uses PLAN (TEST INDEX (TEST_IDX2))
select * from test where (UPPER(FIELD_2)||UPPER(FIELD_3)) = 'TEST1TEST1_1';
--Doesn't uses a proper index: PLAN (TEST NATURAL)
select * from test where (UPPER(COALESCE(FIELD_2,''))||UPPER(COALESCE(FIELD_3,''))) = 'TEST1TEST1_1';
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
PLAN (TEST INDEX (PK_TEST))
PLAN (TEST INDEX (TEST_IDX4))
PLAN (TEST INDEX (TEST_IDX3))
PLAN (TEST INDEX (TEST_IDX2))
PLAN (TEST INDEX (TEST_IDX1))
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.8')
2021-04-28 12:42:11 +02:00
def test_1(act_1: Action):
2021-04-26 20:07:00 +02:00
act_1.expected_stdout = expected_stdout_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00