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

89 lines
1.9 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4492
ISSUE: 4492
TITLE: Replace the hierarchical union execution with the plain one
DESCRIPTION:
JIRA: CORE-4165
FBTEST: bugs.core_4165
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table t1(id int);
recreate table t2(id int);
recreate table t3(id int);
commit;
insert into t1 select rand()*100 from rdb$types,rdb$types;
commit;
insert into t2 select * from t1;
insert into t3 select * from t1;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set planonly;
set explain on;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select 0 i from t1
union all
select 1 from t1
union all
select 2 from t1
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select 0 i from t2
union
select 1 from t2
union
select 2 from t2
;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
select 0 i from t3
union distinct
select 1 from t3
union all
select 2 from t3
;
-- Note: values in 'record length' and 'key length' should be suppressed
-- because they contain not only size of field(s) but also db_key.
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script, substitutions=[('record length.*', ''), ('key length.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Select Expression
-> Union
-> Table "T1" Full Scan
-> Table "T1" Full Scan
-> Table "T1" Full Scan
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
Select Expression
-> Unique Sort (record length: 52, key length: 8)
-> Union
-> Table "T2" Full Scan
-> Table "T2" Full Scan
-> Table "T2" Full Scan
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
Select Expression
-> Union
-> Unique Sort (record length: 44, key length: 8)
-> Union
-> Table "T3" Full Scan
-> Table "T3" Full Scan
-> Table "T3" Full Scan
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout