2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
|
|
|
ID: issue-2038
|
|
|
|
ISSUE: 2038
|
|
|
|
TITLE: Nested OR conditions may lead to incorrest results
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-5268
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5268
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
-- Reproduced wrong result on WI-T4.0.0.238.
|
|
|
|
-- (note on single difference between sp_test and sp_test2: parenthesis that enclose 'OR' expression.
|
|
|
|
-- Checked on LI-T4.0.0.242 after fix was committed - all works fine.
|
|
|
|
|
|
|
|
create or alter procedure sp_test(a_inp varchar(50)) as begin end;
|
|
|
|
create or alter procedure sp_test2(a_inp varchar(50)) as begin end;
|
|
|
|
recreate table testtab (
|
|
|
|
feld_a varchar(50),
|
|
|
|
feld_b varchar(10),
|
|
|
|
feld_c char(10)
|
|
|
|
);
|
|
|
|
|
|
|
|
recreate table result (
|
|
|
|
feld_a varchar(50),
|
|
|
|
feld_b varchar(10),
|
|
|
|
feld_c char(10)
|
|
|
|
);
|
2022-01-25 22:55:48 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
create index testtab_idx1 on testtab (feld_b);
|
|
|
|
create index testtab_idx2 on testtab (feld_a);
|
|
|
|
commit;
|
|
|
|
|
|
|
|
insert into testtab (feld_a, feld_b, feld_c) values ('aaaa', 'bb', 'cc ');
|
|
|
|
insert into testtab (feld_a, feld_b, feld_c) values ('aaa', 'aa', 'aaa ');
|
|
|
|
insert into testtab (feld_a, feld_b, feld_c) values ('uuu', 'uuu', 'uuu ');
|
|
|
|
insert into testtab (feld_a, feld_b, feld_c) values ('uuu', 'uu', 'uu ');
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
|
|
|
|
|
|
|
|
|
|
|
-- test sqls
|
|
|
|
-- wrong: should get at least 3 records, but gives only 1
|
|
|
|
set term ^;
|
|
|
|
create or alter procedure sp_test(a_inp varchar(50)) as
|
|
|
|
begin
|
|
|
|
delete from result;
|
|
|
|
insert into result
|
2022-01-25 22:55:48 +01:00
|
|
|
select *
|
2021-04-26 20:07:00 +02:00
|
|
|
from testtab t
|
|
|
|
where
|
|
|
|
:a_inp='123456' -- a_inp = 'blub' for testcase
|
|
|
|
or
|
|
|
|
(
|
|
|
|
upper(t.feld_b) starting with upper('u')
|
|
|
|
or
|
|
|
|
t.feld_a starting with 'a' /* with index */
|
|
|
|
)
|
|
|
|
;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
|
|
|
|
create or alter procedure sp_test2(a_inp varchar(50)) as
|
|
|
|
begin
|
|
|
|
delete from result;
|
|
|
|
insert into result
|
2022-01-25 22:55:48 +01:00
|
|
|
select *
|
2021-04-26 20:07:00 +02:00
|
|
|
from testtab t
|
|
|
|
where
|
|
|
|
:a_inp='123456' -- a_inp = 'blub' for testcase
|
|
|
|
or
|
|
|
|
upper(t.feld_b) starting with upper('u')
|
|
|
|
or
|
|
|
|
t.feld_a starting with 'a' /* with index */
|
|
|
|
;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set list on;
|
|
|
|
|
|
|
|
execute procedure sp_test('blub');
|
|
|
|
select '1' as result, r.* from result r;
|
|
|
|
|
|
|
|
execute procedure sp_test2('blub');
|
|
|
|
select '2' as result, r.* from result r;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
RESULT 1
|
|
|
|
FELD_A aaaa
|
|
|
|
FELD_B bb
|
|
|
|
FELD_C cc
|
|
|
|
|
|
|
|
RESULT 1
|
|
|
|
FELD_A aaa
|
|
|
|
FELD_B aa
|
|
|
|
FELD_C aaa
|
|
|
|
|
|
|
|
RESULT 1
|
|
|
|
FELD_A uuu
|
|
|
|
FELD_B uuu
|
|
|
|
FELD_C uuu
|
|
|
|
|
|
|
|
RESULT 1
|
|
|
|
FELD_A uuu
|
|
|
|
FELD_B uu
|
|
|
|
FELD_C uu
|
|
|
|
|
|
|
|
|
|
|
|
RESULT 2
|
|
|
|
FELD_A aaaa
|
|
|
|
FELD_B bb
|
|
|
|
FELD_C cc
|
|
|
|
|
|
|
|
RESULT 2
|
|
|
|
FELD_A aaa
|
|
|
|
FELD_B aa
|
|
|
|
FELD_C aaa
|
|
|
|
|
|
|
|
RESULT 2
|
|
|
|
FELD_A uuu
|
|
|
|
FELD_B uuu
|
|
|
|
FELD_C uuu
|
|
|
|
|
|
|
|
RESULT 2
|
|
|
|
FELD_A uuu
|
|
|
|
FELD_B uu
|
|
|
|
FELD_C uu
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0.1')
|
2022-01-25 22:55:48 +01:00
|
|
|
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
|
|
|
|