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

100 lines
2.5 KiB
Python

#coding:utf-8
"""
ID: issue-5348
ISSUE: 5348
TITLE: ISQL plan output is unexpectedly truncated after a query is simplified to become shorter
DESCRIPTION:
Start of discussion: letter to dimitr, 30-dec-2015 13:57; its subject refers to core-4708.
It was found that explained plan produced by ISQL is unexpectedly ends on WI-V3.0.0.32256.
This test uses that query, but instead of verifying plan text itself (which can be changed in the future)
it is sufficient to check only that plan does NOT contain lines with ellipsis or 'truncated' or 'error'.
This mean that 'expected_stdout' section must be EMPTY. Otherwise expected_stdout will contain info
about error or invalid plan.
JIRA: CORE-5061
"""
import pytest
from firebird.qa import *
db = db_factory()
test_script = """
set list on;
set explain on;
set planonly;
set blob all;
with recursive
r1 as (
select 1 as i from rdb$database
union all
select r.i+1 from r1 r where r.i < 2
)
--select count(*) from r1;
,r2 as (
select first 1 row_number() over() i
from r1 ra
full join r1 rb on rb.i=ra.i
group by ra.i
having count(*)>0
union all
select rx.i+1 from r2 rx
where rx.i+1 <= 2
)
--select count(*) from r2
,r3 as (
select first 1 row_number() over() i
from r2 ra
full join r2 rb on rb.i=ra.i
group by ra.i
having count(*)>0
union all
select rx.i+1 from r3 rx
where rx.i+1 <= 2
)
--select count(*) from r3
,r4 as (
select first 1 row_number() over() i
from r3 ra
full join r3 rb on rb.i=ra.i
group by ra.i
having count(*)>0
union all
select rx.i+1 from r4 rx
where rx.i+1 <= 2
)
,rn as (
select row_number() over() i
from rdb$database r full join rdb$database r2 on r2.rdb$relation_id=r.rdb$relation_id
group by r.rdb$relation_id
having count(*)>0
order by r.rdb$relation_id
rows 1 to 1
)
select
char_length(mon$explained_plan)
,(select count(*) from r4)
,(select count(*) from rn)
--,(select count(*) from rn)
from mon$statements
;
"""
act = isql_act('db', test_script)
@pytest.mark.version('>=3.0')
def test_1(act: Action):
act.execute()
i = 0
for line in act.stdout.splitlines():
i += 1
if '...' in line or 'truncated' in line or 'error' in line:
pytest.fail(f"Plan is truncated or empty. Found at line {i}")