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 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'. 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 import pytest
@ -544,47 +548,42 @@ fb4x_expected_out = f"""
fb5x_expected_out = f""" fb5x_expected_out = f"""
1000 1000
{query_map[1000][0]} select txt_short from test a01 order by id
{query_map[1000][1]} Must NOT use refetch because length of non-key column is less than threshold
Select Expression Select Expression
....-> Sort (record length: 1036, key length: 8) ....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" as "A01" Full Scan ........-> Table "TEST" as "A01" Full Scan
1010 1010
{query_map[1010][0]} select txt_broad from test a02 order by id
{query_map[1010][1]} MUST use refetch because length of non-key column is greater than threshold
Select Expression Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" as "A02" Full Scan ............-> Table "TEST" as "A02" Full Scan
1020 1020
{query_map[1020][0]} select txt_short from test a03 order by id rows 1
{query_map[1020][1]} MUST use refetch regardless on length of column because ROWS <N> presents
Select Expression Select Expression
....-> First N Records ....-> First N Records
........-> Refetch ........-> Refetch
............-> Sort (record length: 28, key length: 8) ............-> Sort (record length: 28, key length: 8)
................-> Table "TEST" as "A03" Full Scan ................-> Table "TEST" as "A03" Full Scan
2000 2000
{query_map[2000][0]} select id, computed_ts_dup from test order by id
{query_map[2000][1]} Must NOT use refetch because computed column is based on txt_short with length < threshold
Select Expression Select Expression
....-> Sort (record length: 1036, key length: 8) ....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" Full Scan ........-> Table "TEST" Full Scan
2010 2010
{query_map[2010][0]} select id, computed_tb_dup from test order by id
{query_map[2010][1]} MUST use refetch because computed column is based on txt_broad which has length >= threshold
Select Expression Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" Full Scan ............-> Table "TEST" Full Scan
3000 3000
{query_map[3000][0]} select id from test a04 where '' in (select txt_short from test x04 where txt_short = '' order by id)
{query_map[3000][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Sort (record length: 1036, key length: 8) ........-> Sort (record length: 1036, key length: 8)
@ -593,10 +592,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A04" Full Scan ........-> Table "TEST" as "A04" Full Scan
3010 3010
{query_map[3010][0]} select id from test a05 where '' in (select txt_broad from test x05 where txt_broad = '' order by id)
{query_map[3010][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Refetch ........-> Refetch
@ -606,31 +604,29 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A05" Full Scan ........-> Table "TEST" as "A05" Full Scan
3020 3020
{query_map[3020][0]} select id from test a06 where '' not in (select txt_short from test x06 where txt_short>'' order by id)
{query_map[3020][1]} *** not [yet] commented ***
Select Expression Sub-query (invariant)
....-> Sort (record length: 1036, key length: 8) ....-> Sort (record length: 1036, key length: 8)
........-> Filter ........-> Filter
............-> Table "TEST" as "X06" Full Scan ............-> Table "TEST" as "X06" Full Scan
Select Expression Sub-query (invariant)
....-> Sort (record length: 1036, key length: 8) ....-> Sort (record length: 1036, key length: 8)
........-> Filter ........-> Filter
............-> Table "TEST" as "X06" Full Scan ............-> Table "TEST" as "X06" Full Scan
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A06" Full Scan ........-> Table "TEST" as "A06" Full Scan
3030 3030
{query_map[3030][0]} select id from test a07 where '' not in (select txt_broad from test x07 where txt_broad>'' order by id)
{query_map[3030][1]} *** not [yet] commented ***
Select Expression Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
............-> Filter ............-> Filter
................-> Table "TEST" as "X07" Full Scan ................-> Table "TEST" as "X07" Full Scan
Select Expression Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
............-> Filter ............-> Filter
@ -638,10 +634,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A07" Full Scan ........-> Table "TEST" as "A07" Full Scan
3040 3040
{query_map[3040][0]} select id from test a08 where '' > all (select id from test x08 where txt_short>'' order by id)
{query_map[3040][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Sort (record length: 1036, key length: 8) ........-> Sort (record length: 1036, key length: 8)
@ -650,10 +645,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A08" Full Scan ........-> Table "TEST" as "A08" Full Scan
3050 3050
{query_map[3050][0]} select id from test a09 where '' > all (select id from test x09 where txt_broad>'' order by id)
{query_map[3050][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Refetch ........-> Refetch
@ -663,10 +657,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A09" Full Scan ........-> Table "TEST" as "A09" Full Scan
3060 3060
{query_map[3060][0]} select id from test a10 where '' <> any (select id from test x10 where txt_short>'' order by id)
{query_map[3060][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Sort (record length: 1036, key length: 8) ........-> Sort (record length: 1036, key length: 8)
@ -675,10 +668,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A10" Full Scan ........-> Table "TEST" as "A10" Full Scan
3070 3070
{query_map[3070][0]} select id from test a11 where '' <> any (select id from test x11 where txt_broad>'' order by id)
{query_map[3070][1]} *** not [yet] commented ***
Sub-query (invariant) Sub-query (invariant)
....-> Filter ....-> Filter
........-> Refetch ........-> Refetch
@ -688,10 +680,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A11" Full Scan ........-> Table "TEST" as "A11" Full Scan
4000 4000
{query_map[4000][0]} select id,txt_short from test a12 where exists(select 1 from test x12 where txt_short>'' order by id)
{query_map[4000][1]} MUST use refetch: column x12.txt_short not present in order by
Sub-query (invariant) Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
@ -700,10 +691,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A12" Full Scan ........-> Table "TEST" as "A12" Full Scan
4010 4010
{query_map[4010][0]} select id,txt_short from test a13 where exists(select 1 from test x13 where computed_id_dup > 0 order by id)
{query_map[4010][1]} 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) Sub-query (invariant)
....-> Sort (record length: 28, key length: 8) ....-> Sort (record length: 28, key length: 8)
........-> Filter ........-> Filter
@ -711,10 +701,13 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A13" Full Scan ........-> Table "TEST" as "A13" Full Scan
4020 4020
{query_map[4020][0]} select id,txt_short from test a14 where exists(select 1 from test x14 where computed_id_dup > 0 order by computed_id_dup)
{query_map[4020][1]} 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) Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 36, key length: 12) ........-> Sort (record length: 36, key length: 12)
@ -723,10 +716,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A14" Full Scan ........-> Table "TEST" as "A14" Full Scan
4030 4030
{query_map[4030][0]} select id,txt_short from test a15 where exists(select 1 from test x15 where f02>0 and f01>0 order by f01, f02)
{query_map[4030][1]} Must NOT use refetch: all persistent columns from WHERE expression (f01, f02) belong to ORDER BY list
Sub-query (invariant) Sub-query (invariant)
....-> Sort (record length: 36, key length: 16) ....-> Sort (record length: 36, key length: 16)
........-> Filter ........-> Filter
@ -734,10 +726,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A15" Full Scan ........-> Table "TEST" as "A15" Full Scan
4040 4040
{query_map[4040][0]} select id,txt_short from test a16 where exists(select 1 from test x16 where id>0 and f01>0 order by f01, f02)
{query_map[4040][1]} Must use refetch: one of columns from WHERE expr (id) does not belong to ORDER BY list
Sub-query (invariant) Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 36, key length: 16) ........-> Sort (record length: 36, key length: 16)
@ -746,10 +737,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A16" Full Scan ........-> Table "TEST" as "A16" Full Scan
4050 4050
{query_map[4050][0]} select id,txt_short from test a17 where exists(select 1 from test x17 where computed_id_dup > 0 order by f01)
{query_map[4050][1]} Must use refetch: computed column in WHERE expr does not belong to ORDER BY list
Sub-query (invariant) Sub-query (invariant)
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
@ -758,10 +748,9 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A17" Full Scan ........-> Table "TEST" as "A17" Full Scan
4060 4060
{query_map[4060][0]} select id,txt_short from test a18 where exists(select 1 from test x18 where computed_guid > '' order by f01)
{query_map[4060][1]} Must NOT use refetch: computed column x18.computed_guid does is evaluated via GUID and does not refer to any columns
Sub-query (invariant) Sub-query (invariant)
....-> Sort (record length: 28, key length: 8) ....-> Sort (record length: 28, key length: 8)
........-> Filter ........-> Filter
@ -769,10 +758,20 @@ fb5x_expected_out = f"""
Select Expression Select Expression
....-> Filter (preliminary) ....-> Filter (preliminary)
........-> Table "TEST" as "A18" Full Scan ........-> Table "TEST" as "A18" Full Scan
4070 4070
{query_map[4070][0]} with recursive
{query_map[4070][1]} 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 Sub-query
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
@ -789,73 +788,66 @@ fb5x_expected_out = f"""
............-> Table "TEST" as "R A19" Full Scan ............-> Table "TEST" as "R A19" Full Scan
........-> Filter ........-> Filter
............-> Table "TEST" as "R I" Full Scan ............-> Table "TEST" as "R I" Full Scan
5000 5000
{query_map[5000][0]} select txt_broad from v_unioned v01 order by id
{query_map[5000][1]} Must NOT use refetch because view DDL includes UNION
Select Expression Select Expression
....-> Sort (record length: 4044, key length: 8) ....-> Sort (record length: 4044, key length: 8)
........-> First N Records ........-> First N Records
............-> Union ............-> Union
................-> Table "TEST" as "V01 TEST" Full Scan ................-> Table "TEST" as "V01 TEST" Full Scan
................-> Table "RDB$DATABASE" as "V01 RDB$DATABASE" Full Scan ................-> Table "RDB$DATABASE" as "V01 RDB$DATABASE" Full Scan
6000 6000
{query_map[6000][0]} select left(txt_broad, 50) as txt from test a21 order by id
{query_map[6000][1]} 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 Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 28, key length: 8) ........-> Sort (record length: 28, key length: 8)
............-> Table "TEST" as "A21" Full Scan ............-> Table "TEST" as "A21" Full Scan
6010 6010
{query_map[6010][0]} select left( txt_short || txt_short, 2000) as txt from test a22 order by id
{query_map[6010][1]} 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 Select Expression
....-> Sort (record length: 1036, key length: 8) ....-> Sort (record length: 1036, key length: 8)
........-> Table "TEST" as "A22" Full Scan ........-> Table "TEST" as "A22" Full Scan
7000 7000
{query_map[7000][0]} select * from test_ns_01 a23 order by id
{query_map[7000][1]} MUST use refetch
Select Expression Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 44, key length: 24) ........-> Sort (record length: 44, key length: 24)
............-> Table "TEST_NS_01" as "A23" Full Scan ............-> Table "TEST_NS_01" as "A23" Full Scan
7010 7010
{query_map[7010][0]} select * from test_ns_02 a24 order by id
{query_map[7010][1]} Must NOT refetch
Select Expression Select Expression
....-> Sort (record length: 1052, key length: 24) ....-> Sort (record length: 1052, key length: 24)
........-> Table "TEST_NS_02" as "A24" Full Scan ........-> Table "TEST_NS_02" as "A24" Full Scan
7020 7020
{query_map[7020][0]} select * from test_ns_03 order by id
{query_map[7020][1]} MUST use refetch
Select Expression Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 36, key length: 12) ........-> Sort (record length: 36, key length: 12)
............-> Table "TEST_NS_03" Full Scan ............-> Table "TEST_NS_03" Full Scan
7030 7030
{query_map[7030][0]} select * from test_ns_04 order by id
{query_map[7030][1]} Must NOT use refetch
Select Expression Select Expression
....-> Sort (record length: 1036, key length: 12) ....-> Sort (record length: 1036, key length: 12)
........-> Table "TEST_NS_04" Full Scan ........-> Table "TEST_NS_04" Full Scan
7040 7040
{query_map[7040][0]} select * from test_ns_05 order by id
{query_map[7040][1]} MUST use refetch
Select Expression Select Expression
....-> Refetch ....-> Refetch
........-> Sort (record length: 36, key length: 12) ........-> Sort (record length: 36, key length: 12)
............-> Table "TEST_NS_05" Full Scan ............-> Table "TEST_NS_05" Full Scan
7050 7050
{query_map[7050][0]} select * from test_ns_06 order by id
{query_map[7050][1]} Must NOT use refetch
Select Expression Select Expression
....-> Sort (record length: 1036, key length: 12) ....-> Sort (record length: 1036, key length: 12)
........-> Table "TEST_NS_06" Full Scan ........-> Table "TEST_NS_06" Full Scan