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

102 lines
2.4 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3277
ISSUE: 3277
TITLE: Expression in a subquery may be treated as invariant and produce incorrect results
DESCRIPTION:
JIRA: CORE-2893
FBTEST: bugs.core_2893
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
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table test_z (c varchar(10));
commit;
insert into test_z values (1);
insert into test_z values (1);
insert into test_z values (2);
insert into test_z values (3);
commit;
-- From CORE-3031:
create view v_test (f1, f2, f3) as
select '1.1', '1.2', '1.3' from rdb$database
union all
select '2.1', '2.2', '2.3' from rdb$database
union all
select '3.1', '3.2', '3.3' from rdb$database
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set count on;
set list on;
select 'Test-1' as msg, t.*
from (
select (select case when R.RDB$Relation_ID = 0 then 0 else 1 end from RDB$Database) TypeID
from RDB$Relations R
where R.RDB$Relation_ID < 2
) t;
2022-01-21 18:49:26 +01:00
select 'Test-2' as msg, z.c
from test_z z
where
2021-04-26 20:07:00 +02:00
(
select z.c || '' from rdb$database
) = '1'
;
commit;
-- From CORE-3031:
select 'Test-3' as msg, t.*
from (
select
t.f1 || '; ' || t.f2 || '; ' || t.f3 as f123_concat,
(
select
'' || t.f3
from rdb$database
) as f3_concat
from v_test t
) t;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
MSG Test-1
TYPEID 0
MSG Test-1
TYPEID 1
Records affected: 2
MSG Test-2
C 1
MSG Test-2
C 1
Records affected: 2
MSG Test-3
F123_CONCAT 1.1; 1.2; 1.3
F3_CONCAT 1.3
MSG Test-3
F123_CONCAT 2.1; 2.2; 2.3
F3_CONCAT 2.3
MSG Test-3
F123_CONCAT 3.1; 3.2; 3.3
F3_CONCAT 3.3
Records affected: 3
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +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