6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_1389_test.py

60 lines
1.8 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-1807
ISSUE: 1807
TITLE: Indexed MIN/MAX aggregates produce three index reads instead of the expected one indexed read
DESCRIPTION:
JIRA: CORE-1389
FBTEST: bugs.core_1389
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-20 17:32:14 +01:00
from firebird.qa import *
2021-11-11 18:01:08 +01:00
from firebird.driver import DbInfoCode
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table test(x int, y int);
commit;
insert into test(x, y)
select -1, 1 from (select 1 i from rdb$types rows 200) a, (select 1 i from rdb$types rows 200) b;
commit;
create index test_x on test(x);
create descending index test_y on test(y);
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
expected_stdout = """Number of indexed reads: 1
2021-11-11 18:01:08 +01:00
Number of indexed reads: 1
Number of indexed reads: 1
Number of indexed reads: 1
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action, capsys):
with act.db.connect() as con:
2021-11-11 18:01:08 +01:00
c = con.cursor()
c.execute("select rdb$relation_id from rdb$relations where trim(rdb$relation_name)=upper('test')")
test_rel = c.fetchone()[0]
#
sql_set=['select min(x) from test',
'select x from test order by x rows 1',
'select max(y) from test',
'select y from test order by y desc rows 1']
previous_idx_counter = 0
for cmd in sql_set:
c.execute(cmd).fetchone()
counts = con.info.get_info(DbInfoCode.READ_IDX_COUNT)
for k, cumulative_idx_counter in counts.items():
if k == test_rel:
print('Number of indexed reads:', cumulative_idx_counter - previous_idx_counter)
previous_idx_counter = cumulative_idx_counter
#
output = capsys.readouterr()
2022-01-20 17:32:14 +01:00
assert output.out == expected_stdout