2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
"""
|
|
|
|
ID: issue-4891
|
|
|
|
ISSUE: 4891
|
|
|
|
TITLE: Regression: Incorrect result in subquery with aggregate
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-4574
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_4574
|
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
|
|
|
db = db_factory()
|
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 list on;
|
|
|
|
with
|
|
|
|
a as (
|
|
|
|
select 1 id from rdb$database
|
|
|
|
union all
|
|
|
|
select 2 from rdb$database
|
|
|
|
union all
|
|
|
|
select 3 from rdb$database
|
|
|
|
),
|
|
|
|
b as (
|
|
|
|
select 1 id1, null id2 from rdb$database
|
|
|
|
union all
|
|
|
|
select 2, null from rdb$database
|
|
|
|
union all
|
|
|
|
select 3, null from rdb$database
|
|
|
|
)
|
|
|
|
select
|
|
|
|
sum((select count(*) from B where B.ID1 = A.ID)) s1
|
|
|
|
,sum((select count(*) from B where B.ID2 = A.ID)) s2
|
|
|
|
-- must be (3,0) (FB2.5) , but not (3,3) (FB3.0)
|
|
|
|
from a;
|
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=[('[ \t]+', ' ')])
|
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
|
|
|
S1 3
|
|
|
|
S2 0
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
@pytest.mark.version('>=3')
|
|
|
|
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
|
|
|
|