6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00

Added/Updated tests\bugs\core_4809_test.py: Adjusted expected execution plans for FB 5.x. Explained by dimitr, letter 31-JUL-2023 11:00, see notes.

This commit is contained in:
pavel-zotov 2023-07-31 14:02:20 +03:00
parent 02f6f92b19
commit 317e4a06ba

View File

@ -3,8 +3,7 @@
""" """
ID: issue-5107 ID: issue-5107
ISSUE: 5107 ISSUE: 5107
TITLE: HASH/MERGE JOIN is not used for more than two streams if they are joined via TITLE: HASH/MERGE JOIN is not used for more than two streams if they are joined via USING/NATURAL clauses and join is based on DBKEY concatenations
USING/NATURAL clauses and join is based on DBKEY concatenations
DESCRIPTION: DESCRIPTION:
JIRA: CORE-4809 JIRA: CORE-4809
FBTEST: bugs.core_4809 FBTEST: bugs.core_4809
@ -13,6 +12,12 @@ NOTES:
FB 5.0.0.455 and later: data sources with equal cardinality now present in the HASH plan in order they are specified in the query. FB 5.0.0.455 and later: data sources with equal cardinality now present in the HASH plan in order they are specified in the query.
Reversed order was used before this build. Because of this, two cases of expected stdout must be taken in account, see variables Reversed order was used before this build. Because of this, two cases of expected stdout must be taken in account, see variables
'fb3x_checked_stdout' and 'fb5x_checked_stdout'. 'fb3x_checked_stdout' and 'fb5x_checked_stdout'.
[31.07.2023] pzotov
Adjusted expected execution plans for FB 5.x after commit: 8ef5b9838129ff1ae90a3672ddc6f0e924b42166
("Fixed cardinality for hash joins"). Explained by dimitr, letter 31-JUL-2023 11:00:
result of HASH(A, B) is considered now as having greater cardinality than HASH(C).
This causes optimizer to put HASH(A,B) as first source.
Checked on 5.0.0.1149.
""" """
import pytest import pytest
@ -160,84 +165,71 @@ act = isql_act('db', test_script)
fb3x_checked_stdout = """ fb3x_checked_stdout = """
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (HASH (DATASOURCE_C TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) PLAN HASH (HASH (DATASOURCE_C TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL)
PLAN HASH (HASH (HASH (DATASOURCE_D TK NATURAL, DATASOURCE_C TK NATURAL), DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) PLAN HASH (HASH (HASH (DATASOURCE_D TK NATURAL, DATASOURCE_C TK NATURAL), DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)))
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)))
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (HASH (DATASOURCE_C TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) PLAN HASH (HASH (DATASOURCE_C TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL)
PLAN HASH (HASH (HASH (DATASOURCE_D TF NATURAL, DATASOURCE_C TF NATURAL), DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) PLAN HASH (HASH (HASH (DATASOURCE_D TF NATURAL, DATASOURCE_C TF NATURAL), DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)))
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)))
""" """
fb4x_checked_stdout = """
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (HASH (DATASOURCE_C TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL)
PLAN HASH (HASH (HASH (DATASOURCE_D TK NATURAL, DATASOURCE_C TK NATURAL), DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)))
PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)))
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (HASH (DATASOURCE_C TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL)
PLAN HASH (HASH (HASH (DATASOURCE_D TF NATURAL, DATASOURCE_C TF NATURAL), DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)))
PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)))
"""
fb5x_checked_stdout = """ fb5x_checked_stdout = """
PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)
PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL)
PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL, DATASOURCE_D TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL, DATASOURCE_D TK NATURAL)
PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)
PLAN HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)) PLAN HASH (HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL), DATASOURCE_D TK NATURAL)
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)))
PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)
PLAN HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL)
PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)) PLAN HASH (HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL), DATASOURCE_D TK NATURAL)
PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)))
PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)
PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL)
PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL, DATASOURCE_D TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL, DATASOURCE_D TF NATURAL)
PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)
PLAN HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)) PLAN HASH (HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL), DATASOURCE_D TF NATURAL)
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)))
PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)
PLAN HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL)
PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)) PLAN HASH (HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL), DATASOURCE_D TF NATURAL)
PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)))
""" """
@pytest.mark.version('>=3.0') @pytest.mark.version('>=3.0')
def test_1(act: Action): def test_1(act: Action):
act.expected_stdout = fb3x_checked_stdout if act.is_version('<5') else fb5x_checked_stdout act.expected_stdout = fb3x_checked_stdout if act.is_version('<4') else fb4x_checked_stdout if act.is_version('<5') else fb5x_checked_stdout
act.execute(combine_output = True) act.execute(combine_output = True)
assert act.clean_stdout == act.clean_expected_stdout assert act.clean_stdout == act.clean_expected_stdout