6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

Added/Updated tests\bugs\core_2650_test.py: Changed expected_out for FB 5.x after e24e0 2025.01.13. See notes.

This commit is contained in:
pavel-zotov 2025-01-16 08:44:36 +03:00
parent aab05ab88b
commit 621bc55e2a

View File

@ -43,7 +43,11 @@ NOTES:
7. Parameter OptimizeForFirstRows must have default value fcor this test (i.e. false). To prevent test fail in case of occasional changing of
this parameter, session-level command is used for FB 5.x+: 'set optimize for all rows'.
Checked 6.0.0.573-c20f37a
[16.01.2025] pzotov
8. Changed expected_out for FB 5.x after e24e0 2025.01.13 ("More correct plan output for subqueries generated during NOT IN transformation").
Despite that now expected_out strings for 5.x and 6.x become equal, they remain separated in case of future changes in 6.x+
Checked 6.0.0.573-c20f37a; 5.0.2.1592-2d11769
"""
import pytest
@ -544,47 +548,42 @@ fb4x_expected_out = f"""
fb5x_expected_out = f"""
1000
{query_map[1000][0]}
{query_map[1000][1]}
select txt_short from test a01 order by id
Must NOT use refetch because length of non-key column is less than threshold
Select Expression
....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" as "A01" Full Scan
1010
{query_map[1010][0]}
{query_map[1010][1]}
select txt_broad from test a02 order by id
MUST use refetch because length of non-key column is greater than threshold
Select Expression
....-> Refetch
........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" as "A02" Full Scan
1020
{query_map[1020][0]}
{query_map[1020][1]}
select txt_short from test a03 order by id rows 1
MUST use refetch regardless on length of column because ROWS <N> presents
Select Expression
....-> First N Records
........-> Refetch
............-> Sort (record length: 28, key length: 8)
................-> Table "TEST" as "A03" Full Scan
2000
{query_map[2000][0]}
{query_map[2000][1]}
select id, computed_ts_dup from test order by id
Must NOT use refetch because computed column is based on txt_short with length < threshold
Select Expression
....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" Full Scan
2010
{query_map[2010][0]}
{query_map[2010][1]}
select id, computed_tb_dup from test order by id
MUST use refetch because computed column is based on txt_broad which has length >= threshold
Select Expression
....-> Refetch
........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" Full Scan
3000
{query_map[3000][0]}
{query_map[3000][1]}
select id from test a04 where '' in (select txt_short from test x04 where txt_short = '' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Sort (record length: 1036, key length: 8)
@ -593,10 +592,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A04" Full Scan
3010
{query_map[3010][0]}
{query_map[3010][1]}
select id from test a05 where '' in (select txt_broad from test x05 where txt_broad = '' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Refetch
@ -606,31 +604,29 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A05" Full Scan
3020
{query_map[3020][0]}
{query_map[3020][1]}
Select Expression
select id from test a06 where '' not in (select txt_short from test x06 where txt_short>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Sort (record length: 1036, key length: 8)
........-> Filter
............-> Table "TEST" as "X06" Full Scan
Select Expression
Sub-query (invariant)
....-> Sort (record length: 1036, key length: 8)
........-> Filter
............-> Table "TEST" as "X06" Full Scan
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A06" Full Scan
3030
{query_map[3030][0]}
{query_map[3030][1]}
Select Expression
select id from test a07 where '' not in (select txt_broad from test x07 where txt_broad>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 28, key length: 8)
............-> Filter
................-> Table "TEST" as "X07" Full Scan
Select Expression
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 28, key length: 8)
............-> Filter
@ -638,10 +634,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A07" Full Scan
3040
{query_map[3040][0]}
{query_map[3040][1]}
select id from test a08 where '' > all (select id from test x08 where txt_short>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Sort (record length: 1036, key length: 8)
@ -650,10 +645,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A08" Full Scan
3050
{query_map[3050][0]}
{query_map[3050][1]}
select id from test a09 where '' > all (select id from test x09 where txt_broad>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Refetch
@ -663,10 +657,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A09" Full Scan
3060
{query_map[3060][0]}
{query_map[3060][1]}
select id from test a10 where '' <> any (select id from test x10 where txt_short>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Sort (record length: 1036, key length: 8)
@ -675,10 +668,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A10" Full Scan
3070
{query_map[3070][0]}
{query_map[3070][1]}
select id from test a11 where '' <> any (select id from test x11 where txt_broad>'' order by id)
*** not [yet] commented ***
Sub-query (invariant)
....-> Filter
........-> Refetch
@ -688,10 +680,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A11" Full Scan
4000
{query_map[4000][0]}
{query_map[4000][1]}
select id,txt_short from test a12 where exists(select 1 from test x12 where txt_short>'' order by id)
MUST use refetch: column x12.txt_short not present in order by
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 28, key length: 8)
@ -700,10 +691,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A12" Full Scan
4010
{query_map[4010][0]}
{query_map[4010][1]}
select id,txt_short from test a13 where exists(select 1 from test x13 where computed_id_dup > 0 order by id)
Must NOT use refetch: ORDER BY list contains the single element: ID, and it is base for x13.computed_id_dup column
Sub-query (invariant)
....-> Sort (record length: 28, key length: 8)
........-> Filter
@ -711,10 +701,13 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A13" Full Scan
4020
{query_map[4020][0]}
{query_map[4020][1]}
select id,txt_short from test a14 where exists(select 1 from test x14 where computed_id_dup > 0 order by computed_id_dup)
MUST use refetch! See letter from dimitr 28.12.2020 14:49
Sort procedure will get:
a KEY = result of evaluating 'computed_id_dup';
a VAL = value of the field 'ID' which is base for computing 'computed_id_dup'
Thus sorter will have a field which not equals to a key, which leads to refetch.
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 36, key length: 12)
@ -723,10 +716,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A14" Full Scan
4030
{query_map[4030][0]}
{query_map[4030][1]}
select id,txt_short from test a15 where exists(select 1 from test x15 where f02>0 and f01>0 order by f01, f02)
Must NOT use refetch: all persistent columns from WHERE expression (f01, f02) belong to ORDER BY list
Sub-query (invariant)
....-> Sort (record length: 36, key length: 16)
........-> Filter
@ -734,10 +726,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A15" Full Scan
4040
{query_map[4040][0]}
{query_map[4040][1]}
select id,txt_short from test a16 where exists(select 1 from test x16 where id>0 and f01>0 order by f01, f02)
Must use refetch: one of columns from WHERE expr (id) does not belong to ORDER BY list
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 36, key length: 16)
@ -746,10 +737,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A16" Full Scan
4050
{query_map[4050][0]}
{query_map[4050][1]}
select id,txt_short from test a17 where exists(select 1 from test x17 where computed_id_dup > 0 order by f01)
Must use refetch: computed column in WHERE expr does not belong to ORDER BY list
Sub-query (invariant)
....-> Refetch
........-> Sort (record length: 28, key length: 8)
@ -758,10 +748,9 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A17" Full Scan
4060
{query_map[4060][0]}
{query_map[4060][1]}
select id,txt_short from test a18 where exists(select 1 from test x18 where computed_guid > '' order by f01)
Must NOT use refetch: computed column x18.computed_guid does is evaluated via GUID and does not refer to any columns
Sub-query (invariant)
....-> Sort (record length: 28, key length: 8)
........-> Filter
@ -769,10 +758,20 @@ fb5x_expected_out = f"""
Select Expression
....-> Filter (preliminary)
........-> Table "TEST" as "A18" Full Scan
4070
{query_map[4070][0]}
{query_map[4070][1]}
with recursive
r as (
select a19.id, a19.txt_short
from test a19
where not exists(select * from test x where x.txt_short < a19.txt_short order by id)
UNION ALL
select i.id, i.txt_short
from test i
join r on i.id > r.id
and not exists( select * from test x where x.txt_short between r.txt_short and i.txt_short order by id )
)
select * from r
MUST use refetch both in anchor and recursive parts
Sub-query
....-> Refetch
........-> Sort (record length: 28, key length: 8)
@ -789,73 +788,66 @@ fb5x_expected_out = f"""
............-> Table "TEST" as "R A19" Full Scan
........-> Filter
............-> Table "TEST" as "R I" Full Scan
5000
{query_map[5000][0]}
{query_map[5000][1]}
select txt_broad from v_unioned v01 order by id
Must NOT use refetch because view DDL includes UNION
Select Expression
....-> Sort (record length: 4044, key length: 8)
........-> First N Records
............-> Union
................-> Table "TEST" as "V01 TEST" Full Scan
................-> Table "RDB$DATABASE" as "V01 RDB$DATABASE" Full Scan
6000
{query_map[6000][0]}
{query_map[6000][1]}
select left(txt_broad, 50) as txt from test a21 order by id
MUST use refetch because expression is based on column which has length >= threshold
(even if final length of expression result is much less than threshold)
Select Expression
....-> Refetch
........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" as "A21" Full Scan
6010
{query_map[6010][0]}
{query_map[6010][1]}
select left( txt_short || txt_short, 2000) as txt from test a22 order by id
Must NOT use refetch because expression is based on column which has length < threshold
(even if final length of expression result is much bigger than threshold)
Select Expression
....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" as "A22" Full Scan
7000
{query_map[7000][0]}
{query_map[7000][1]}
select * from test_ns_01 a23 order by id
MUST use refetch
Select Expression
....-> Refetch
........-> Sort (record length: 44, key length: 24)
............-> Table "TEST_NS_01" as "A23" Full Scan
7010
{query_map[7010][0]}
{query_map[7010][1]}
select * from test_ns_02 a24 order by id
Must NOT refetch
Select Expression
....-> Sort (record length: 1052, key length: 24)
........-> Table "TEST_NS_02" as "A24" Full Scan
7020
{query_map[7020][0]}
{query_map[7020][1]}
select * from test_ns_03 order by id
MUST use refetch
Select Expression
....-> Refetch
........-> Sort (record length: 36, key length: 12)
............-> Table "TEST_NS_03" Full Scan
7030
{query_map[7030][0]}
{query_map[7030][1]}
select * from test_ns_04 order by id
Must NOT use refetch
Select Expression
....-> Sort (record length: 1036, key length: 12)
........-> Table "TEST_NS_04" Full Scan
7040
{query_map[7040][0]}
{query_map[7040][1]}
select * from test_ns_05 order by id
MUST use refetch
Select Expression
....-> Refetch
........-> Sort (record length: 36, key length: 12)
............-> Table "TEST_NS_05" Full Scan
7050
{query_map[7050][0]}
{query_map[7050][1]}
select * from test_ns_06 order by id
Must NOT use refetch
Select Expression
....-> Sort (record length: 1036, key length: 12)
........-> Table "TEST_NS_06" Full Scan