2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
"""
|
|
|
|
ID: issue-3322
|
|
|
|
ISSUE: 3322
|
|
|
|
TITLE: Trace output could contain garbage data left from filtered out statements
|
|
|
|
DESCRIPTION:
|
2022-02-08 18:14:29 +01:00
|
|
|
[08.02.2022] pcisar
|
|
|
|
Fails on Windows 3.0.8 with unexpected additional output line:
|
|
|
|
+ 0 records fetched
|
|
|
|
1 records fetched
|
2022-03-02 19:04:43 +01:00
|
|
|
[02.03.2022] pzotov: RESOLVED.
|
|
|
|
Problem on Windows was caused by excessive query:
|
|
|
|
"select current_user, current_role from rdb$database"
|
|
|
|
-- which is done by ISQL 3.x when it gets commands from STDIN via PIPE mechanism.
|
|
|
|
Strange ZERO in "0 records" (instead of expected "1 record") can be considered as non-identified bug in trace or ISQL.
|
|
|
|
Additional parameter in the trace config (include_filter) and using query with apropriate code (which contain required "tag")
|
|
|
|
filters out this excessive query and trace log became identical in Windows and Linux, both for FB 3.x and 4.x
|
|
|
|
|
|
|
|
Discussed with Alex et al, since 28-feb-2022 18:05 +0300.
|
|
|
|
Alex explanation: 28-feb-2022 19:52 +0300
|
|
|
|
subj: "Firebird new-QA: weird result for trivial test (outcome depends on presence of... running trace session!)"
|
|
|
|
|
|
|
|
Checked on 3.0.8.33535, 4.0.1.2692.
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
JIRA: CORE-2940
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_2940
|
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
|
2022-02-08 18:14:29 +01:00
|
|
|
import platform
|
2022-01-21 18:49:26 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
db = db_factory()
|
2022-03-02 19:04:43 +01:00
|
|
|
act = python_act('db', substitutions=[('^((?!((records fetched)|tag_for)).)*$', '')])
|
2021-11-16 19:44:53 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
expected_stdout = """
|
2022-03-02 19:04:43 +01:00
|
|
|
select /* tag_for_include */ 1 as k1 from rdb$types rows 15
|
|
|
|
15 records fetched
|
2021-11-16 19:44:53 +01:00
|
|
|
"""
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
test_script = """
|
2022-03-02 19:04:43 +01:00
|
|
|
select /* tag_for_include */ 1 as k1 from rdb$types rows 15;
|
|
|
|
|
2021-11-16 19:44:53 +01:00
|
|
|
-- statistics for this statement should NOT appear in trace log:
|
2022-03-02 19:04:43 +01:00
|
|
|
select 2 k2 from rdb$types rows 2 /* tag_for_exclude */;
|
|
|
|
|
2021-11-16 19:44:53 +01:00
|
|
|
-- statistics for this statement should NOT appear in trace log:
|
2022-03-02 19:04:43 +01:00
|
|
|
select 3 tag_for_exclude from rdb$types rows 3;
|
|
|
|
|
2021-11-16 19:44:53 +01:00
|
|
|
-- statistics for this statement should NOT appear in trace log:
|
|
|
|
set term ^;
|
|
|
|
execute block returns(k4 int) as
|
|
|
|
begin
|
|
|
|
for select 4 from rdb$types rows 4 into k4 do suspend;
|
2022-03-02 19:04:43 +01:00
|
|
|
end -- tag_for_exclude
|
2021-11-16 19:44:53 +01:00
|
|
|
^
|
|
|
|
set term ;^
|
2022-03-02 19:04:43 +01:00
|
|
|
quit;
|
2021-11-16 19:44:53 +01:00
|
|
|
"""
|
|
|
|
|
2022-03-02 19:04:43 +01:00
|
|
|
trace = [
|
|
|
|
'log_statement_finish = true'
|
|
|
|
,'include_filter = "%tag_for_include%"'
|
|
|
|
,'exclude_filter = "%tag_for_exclude%"'
|
|
|
|
,'print_perf = true'
|
|
|
|
,'time_threshold = 0'
|
2022-02-24 19:21:22 +01:00
|
|
|
]
|
2021-11-16 19:44:53 +01:00
|
|
|
|
2022-03-02 19:04:43 +01:00
|
|
|
|
2024-05-15 19:26:01 +02:00
|
|
|
@pytest.mark.trace
|
2021-11-16 19:44:53 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-21 18:49:26 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
with act.trace(db_events=trace):
|
2022-03-02 19:04:43 +01:00
|
|
|
act.isql(switches=[], input=test_script)
|
2022-01-21 18:49:26 +01:00
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.trace_to_stdout()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|