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

53 lines
1.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6219
ISSUE: 6219
TITLE: FB3 Optimiser chooses less efficient plan than FB2.5 optimiser
DESCRIPTION:
Filling of database with data from ticket can take noticable time.
Instead of this it was decided to extract form ZIP archieve .fbk and then to restore it.
Instead of actual execution we can only obtain PLAN by querying cursor read-only property "plan"
JIRA: CORE-5965
FBTEST: bugs.core_5965
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-10 19:50:31 +01:00
import zipfile
from pathlib import Path
2022-01-26 21:10:46 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory()
db_tmp = db_factory(filename='tmp_core_5965.fdb', do_not_create=True)
2021-12-10 19:50:31 +01:00
2022-01-26 21:10:46 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PLAN SORT (OPT_TEST INDEX (O_CLID_CUSTTY_CUSTID))
PLAN SORT (OPT_TEST INDEX (O_CLID_CUSTTY_CUSTID))
2021-12-10 19:50:31 +01:00
"""
2021-04-26 20:07:00 +02:00
2021-12-10 19:50:31 +01:00
fbk_file = temp_file('core_5965.fbk')
2021-04-26 20:07:00 +02:00
2021-12-10 19:50:31 +01:00
@pytest.mark.version('>=3.0')
2022-01-26 21:10:46 +01:00
def test_1(act: Action, fbk_file: Path, db_tmp: Database, capsys):
zipped_fbk_file = zipfile.Path(act.files_dir / 'core_5965.zip', at='core_5965.fbk')
2021-12-10 19:50:31 +01:00
fbk_file.write_bytes(zipped_fbk_file.read_bytes())
#
2022-01-26 21:10:46 +01:00
with act.connect_server() as srv:
srv.database.restore(backup=fbk_file, database=db_tmp.db_path)
2021-12-10 19:50:31 +01:00
srv.wait()
# Test
2022-01-26 21:10:46 +01:00
with db_tmp.connect() as con:
2021-12-10 19:50:31 +01:00
c1 = con.cursor()
c2 = con.cursor()
c1.execute("select 1 from opt_test where clid = 23 and cust_type = 1 and cust_id = 73 order by order_no desc")
print(c1.statement.plan)
#
c2.execute("select 2 from opt_test where sysid = 1 and clid = 23 and cust_type = 1 and cust_id = 73 order by order_no desc")
print(c2.statement.plan)
# Check
2022-01-26 21:10:46 +01:00
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout