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

169 lines
2.8 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-2563
ISSUE: 2563
TITLE: Indexed retrieval cannot be chosen if a stored procedure is used inside the comparison predicate
DESCRIPTION:
JIRA: CORE-2132
"""
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 = """create table t1 (col int primary key);
2021-04-26 20:07:00 +02:00
set term ^ ;
create procedure p1 returns (ret int) as begin ret = 0; suspend; end ^
create procedure p2 (prm int) returns (ret int) as begin ret = prm; suspend; end ^
set term ; ^
commit;
insert into t1 (col) values (0);
commit;
"""
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 = """set plan on ;
2021-04-26 20:07:00 +02:00
-- index
select * from t1 where col = 0;
-- natural
select * from t1 where col = col;
-- index
select * from t1 where col = ( select 0 from rdb$database );
-- natural
select * from t1 where col = ( select col from rdb$database );
-- index (currently natural)
select * from t1 where col = ( select 0 from p1 );
-- index (currently natural)
select * from t1 where col = ( select ret from p1 );
-- natural
select * from t1 where col = ( select col from p1 );
-- index (currently natural)
select * from t1 where col = ( select 0 from p2(0) );
-- index (currently natural)
select * from t1 where col = ( select ret from p2(0) );
-- natural
select * from t1 where col = ( select col from p2(0) );
-- natural
select * from t1 where col = ( select 0 from p2(col) );
-- natural
select * from t1 where col = ( select ret from p2(col) );
-- natural
select * from t1 where col = ( select col from p2(col) );
"""
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
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (T1 NATURAL)
COL
============
0
PLAN (RDB$DATABASE NATURAL)
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (RDB$DATABASE NATURAL)
PLAN (T1 NATURAL)
COL
============
0
PLAN (P1 NATURAL)
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (P1 NATURAL)
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (P1 NATURAL)
PLAN (T1 NATURAL)
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 INDEX (RDB$PRIMARY1))
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 NATURAL)
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 NATURAL)
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 NATURAL)
COL
============
0
PLAN (P2 NATURAL)
PLAN (T1 NATURAL)
COL
============
0
"""
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3.0')
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