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

107 lines
3.1 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-4979
ISSUE: 4979
TITLE: Select from mon$table_stats doesn`t work on SC and CS
DESCRIPTION:
JIRA: CORE-4668
FBTEST: bugs.core_4668
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
create or alter view v_stat as select 1 id from rdb$database;
recreate table t(id int, s varchar(36)); commit;
insert into t select row_number()over(), uuid_to_char(gen_uuid()) from rdb$types,rdb$types rows 2000;
commit;
create index t_s on t(s);
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
create or alter view v_stat as
select
r.mon$record_inserts rec_ins
,r.mon$record_updates rec_upd
,r.mon$record_deletes rec_del
,r.mon$record_backouts rec_bko
,r.mon$record_purges rec_pur
,r.mon$record_expunges rec_exp
-----------
,r.mon$record_seq_reads read_nat
,r.mon$record_idx_reads read_idx
,r.mon$record_rpt_reads read_rpt
,r.mon$backversion_reads read_bkv
,r.mon$fragment_reads read_frg
------------
,a.mon$stat_id
from mon$record_stats r
join mon$table_stats t on r.mon$stat_id = t.mon$record_stat_id
join mon$attachments a on t.mon$stat_id = a.mon$stat_id
where
a.mon$attachment_id = current_connection
and t.mon$table_name = upper('t')
;
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set list on;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set count on;
select read_nat, read_idx, rec_ins, rec_upd, rec_del from v_stat; -- , rec_pur, rec_exp from v_stat;
set count off;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
--delete from t rows 1000; commit; -- purge/expunge: can`t get exact values in SS because of background GC thread!
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
select count(*) from t
union all
select count(*) from t where s>=''
;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
insert into t select row_number()over(), uuid_to_char(gen_uuid()) from rdb$types,rdb$types rows 500;
update t set s = null rows 100;
update t set s = null order by s rows 100;
delete from t rows 200;
delete from t order by s rows 200;
commit;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
set count on;
select read_nat, read_idx, rec_ins, rec_upd, rec_del from v_stat; -- , rec_pur, rec_exp from v_stat;
-- Confirmed wrong result on WI-T3.0.0.31374
-- Records affected: 0
-- COUNT 2000
-- COUNT 2000
-- Records affected: 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
READ_NAT 0
READ_IDX 0
REC_INS 2000
REC_UPD 0
REC_DEL 0
Records affected: 1
COUNT 2000
COUNT 2000
READ_NAT 2300
READ_IDX 2300
REC_INS 2500
REC_UPD 200
REC_DEL 400
Records affected: 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +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