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

108 lines
3.1 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-2731
ISSUE: 2731
TITLE: Incomplete API information values
DESCRIPTION:
Test creates lot of tables with names starting with 'TEST'.
Then we retrieve from rdb$relations min and max values of this tables ID ('r_min', 'r_max').
After each table is scanned via execute statement, statistics that we retrieve by call db_into()
is filled with pair: {relation_id, number_of_seq_reads}.
We have to ckeck that number of entries in this set with r_min <= relation_id <= rmax NOT LESS than
number of created tables.
Also, scan for every table should take at least 1 sequential read - and this is checked too.
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
NOTE: we can SKIP checking concrete values of 'number_of_seq_reads', it does not matter in this test!
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
Info about 'isc_info_read_seq_count':
Number of sequential database reads, that is, the number of sequential table scans (row reads)
Reported per table.
Calculated since the current database attachment started.
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
Confirmed bug on WI-V2.1.2.18118: db_into() received imcompleted data (i.e. not for all tables).
JIRA: CORE-2307
FBTEST: bugs.core_2307
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 *
from firebird.driver import DbInfoCode
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
NUM_OF_TABLES = 1000
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
sql_ddl = f"""
set term ^;
Execute block as
2021-11-15 19:01:46 +01:00
declare variable i integer = 0;
2022-01-21 18:49:26 +01:00
begin
while ( i < {NUM_OF_TABLES} )
do
2021-11-15 19:01:46 +01:00
begin
2022-01-21 18:49:26 +01:00
execute statement 'create table test' || cast(:i as varchar(5)) || ' (c integer)';
i = i + 1 ;
2021-11-15 19:01:46 +01:00
end
2022-01-21 18:49:26 +01:00
end ^
commit ^
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
execute block as
declare variable i integer = 0;
begin
while (i < {NUM_OF_TABLES} )
do
begin
execute statement 'insert into test' || cast(:i as varchar(5)) || ' (c) values (1)';
i = i + 1 ;
2021-11-15 19:01:46 +01:00
end
2022-01-21 18:49:26 +01:00
end
^
set term ;^
commit;
"""
sql_dml = """
execute block returns(r_min int, r_max int) as
declare n varchar(31);
declare i integer;
begin
for
select min(rdb$relation_id),max(rdb$relation_id)
from rdb$relations
where rdb$relation_name starting with upper('test')
into r_min, r_max
do
suspend;
for
select rdb$relation_name
from rdb$relations
-- 4 debug only! >> rows 100
into :n
do
execute statement 'select 1 as k from ' || :n || ' rows 1' into :i;
end
"""
@pytest.mark.version('>=3')
def test_1(act: Action):
# prepare DB for testing: create lot of tables:
act.isql(switches=[], input=sql_ddl)
with act.db.connect() as con:
2021-11-15 19:01:46 +01:00
c = con.cursor()
c.execute(sql_dml)
r_min = 99999999
r_max = -9999999
for r in c:
r_min = r[0] # minimal ID in rdb$relations for user tables ('TEST1')
r_max = r[1] # maximal ID in rdb$relations for user tables ('TESTnnnnn')
#
info = con.info.get_info(DbInfoCode.READ_SEQ_COUNT)
cnt = 0
for k, v in info.items():
cnt = cnt + 1 if k >= r_min and k <= r_max and v >= 1 else cnt
2022-01-21 18:49:26 +01:00
assert cnt >= NUM_OF_TABLES