Skip to content

Commit f11a0bc

Browse files
committed
Added/Updated tests\bugs\gh_7466_plans_tracking_test.py: see notes
1 parent 7e3ddec commit f11a0bc

File tree

1 file changed

+104
-81
lines changed

1 file changed

+104
-81
lines changed

tests/bugs/gh_7466_plans_tracking_test.py

Lines changed: 104 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
Discussed with dimitr, letters 18.08.2023.
2929
3030
Checked on 5.0.0.1164
31+
32+
[08-sep-2023] pzotov
33+
1. Changed plan output: it is desirable to show indentations but they are 'swallowed' when act.clean_stdout is displayed.
34+
Because of that, explained plan lines are 'padded' with dot character to their original length.
35+
2. Adjusted execution plan for one of queries to actual: one need to replace "Range Scan" with "List Scan" if we have
36+
subquery with IN-list which refers to some columns from outer query.
37+
See: https://github.com/FirebirdSQL/firebird/commit/5df6668c7bf5a4b27e15f687f8c6cc40e260ced8
38+
(Allow computable but non-invariant lists to be used for index lookup)
39+
40+
Checked on 5.0.0.1200
3141
"""
3242
import locale
3343
import re
@@ -51,6 +61,10 @@
5161
'explain_plan = true',
5262
]
5363

64+
def replace_leading(source, char="#"):
65+
stripped = source.lstrip()
66+
return char * (len(source) - len(stripped)) + stripped
67+
5468
@pytest.mark.version('>=5.0')
5569
def test_1(act: Action, capsys):
5670

@@ -98,7 +112,19 @@ def test_1(act: Action, capsys):
98112
select r.i + 1, dx.id, dx.pid
99113
from tdetl dx
100114
join r on dx.pid = r.id
101-
where exists(select * from tmain m0a where m0a.id <> dx.pid and m0a.x in(dx.y, dx.z) )
115+
where exists(
116+
select * from tmain m0a
117+
where
118+
m0a.id <> dx.pid
119+
-- ::: NB ::: Rest part is IN-list with computable but non-invariant elements.
120+
-- Execution plan for this kind was changed 07-sep-2023, see:
121+
-- https://github.com/FirebirdSQL/firebird/commit/5df6668c7bf5a4b27e15f687f8c6cc40e260ced8
122+
-- (Allow computable but non-invariant lists to be used for index lookup)
123+
-- See also: tests/functional/tabloid/test_e260ced8.py
124+
-- Here "Index "TMAIN_X" List Scan (full match)" will be!
125+
-- Old: "Index "TMAIN_X" Range Scan (full match)"
126+
and m0a.x in (dx.y, dx.z) -- ### ATTENTION ###
127+
)
102128
)
103129
select count(*) from r where r.i > 2
104130
into c;
@@ -146,92 +172,89 @@ def test_1(act: Action, capsys):
146172
start_show = 1
147173
continue
148174
if start_show and line.rstrip().split():
149-
print(line)
175+
print( replace_leading(line,'.') )
150176

151177
expected_stdout = f"""
152178
Sub-query (invariant)
153-
-> Filter
154-
-> Aggregate
155-
-> Table "TDETL" as "K DY" Access By ID
156-
-> Index "TDETL_FK" Full Scan
157-
Cursor "K" (line 3, column 13)
158-
-> Filter (preliminary)
159-
-> Nested Loop Join (inner)
160-
-> Table "TMAIN" as "K M4" Full Scan
161-
-> Filter
162-
-> Table "TDETL" as "K D4 DX" Access By ID
163-
-> Bitmap And
164-
-> Bitmap
165-
-> Index "TDETL_FK" Range Scan (full match)
166-
-> Bitmap
167-
-> Index "TDETL_Y" Range Scan (upper bound: 1/1)
179+
....-> Filter
180+
........-> Aggregate
181+
............-> Table "TDETL" as "K DY" Access By ID
182+
................-> Index "TDETL_FK" Full Scan
183+
Cursor "K"(line, column)
184+
....-> Filter (preliminary)
185+
........-> Nested Loop Join (inner)
186+
............-> Table "TMAIN" as "K M4" Full Scan
187+
............-> Filter
188+
................-> Table "TDETL" as "K D4 DX" Access By ID
189+
....................-> Bitmap And
190+
........................-> Bitmap
191+
............................-> Index "TDETL_FK" Range Scan (full match)
192+
........................-> Bitmap
193+
............................-> Index "TDETL_Y" Range Scan (upper bound: 1/1)
168194
Sub-query
169-
-> Filter
170-
-> Table "TMAIN" as "M0" Access By ID
171-
-> Bitmap
172-
-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
195+
....-> Filter
196+
........-> Table "TMAIN" as "M0" Access By ID
197+
............-> Bitmap
198+
................-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
173199
Sub-query
174-
-> Filter
175-
-> Table "TMAIN" as "R M0A" Access By ID
176-
-> Bitmap Or
177-
-> Bitmap
178-
-> Index "TMAIN_X" Range Scan (full match)
179-
-> Bitmap
180-
-> Index "TMAIN_X" Range Scan (full match)
181-
Select Expression (line 22, column 13)
182-
-> Singularity Check
183-
-> Aggregate
184-
-> Filter
185-
-> Recursion
186-
-> Filter
187-
-> Table "TDETL" as "R D0" Access By ID
188-
-> Bitmap
189-
-> Index "TDETL_FK" Range Scan (full match)
190-
-> Filter
191-
-> Table "TDETL" as "R DX" Access By ID
192-
-> Bitmap
193-
-> Index "TDETL_FK" Range Scan (full match)
194-
Sub-query (line 37, column 26)
195-
-> Singularity Check
196-
-> Aggregate
197-
-> Table "TMAIN" as "M1A" Full Scan
198-
Sub-query (line 38, column 30)
199-
-> Singularity Check
200-
-> Aggregate
201-
-> Table "TMAIN" as "M1B" Access By ID
202-
-> Index "TMAIN_X" Full Scan
203-
Sub-query (line 39, column 30)
204-
-> Singularity Check
205-
-> Aggregate
206-
-> Table "TDETL" as "D1B" Access By ID
207-
-> Index "TDETL_FK" Full Scan
208-
Sub-query (line 40, column 30)
209-
-> Singularity Check
210-
-> Aggregate
211-
-> Table "TDETL" as "D1C" Full Scan
212-
Select Expression (line 44, column 13)
213-
-> Aggregate
214-
-> Nested Loop Join (inner)
215-
-> Filter
216-
-> Table "TMAIN" as "M2" Access By ID
217-
-> Index "TMAIN_PK" Full Scan
218-
-> Bitmap
219-
-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
220-
-> Filter
221-
-> Table "TDETL" as "D" Access By ID
222-
-> Bitmap
223-
-> Index "TDETL_PK" Unique Scan
200+
....-> Filter
201+
........-> Table "TMAIN" as "R M0A" Access By ID
202+
............-> Bitmap
203+
................-> Index "TMAIN_X" List Scan (full match)
204+
Select Expression(line, column)
205+
....-> Singularity Check
206+
........-> Aggregate
207+
............-> Filter
208+
................-> Recursion
209+
....................-> Filter
210+
........................-> Table "TDETL" as "R D0" Access By ID
211+
............................-> Bitmap
212+
................................-> Index "TDETL_FK" Range Scan (full match)
213+
....................-> Filter
214+
........................-> Table "TDETL" as "R DX" Access By ID
215+
............................-> Bitmap
216+
................................-> Index "TDETL_FK" Range Scan (full match)
217+
Sub-query(line, column)
218+
....-> Singularity Check
219+
........-> Aggregate
220+
............-> Table "TMAIN" as "M1A" Full Scan
221+
Sub-query(line, column)
222+
....-> Singularity Check
223+
........-> Aggregate
224+
............-> Table "TMAIN" as "M1B" Access By ID
225+
................-> Index "TMAIN_X" Full Scan
226+
Sub-query(line, column)
227+
....-> Singularity Check
228+
........-> Aggregate
229+
............-> Table "TDETL" as "D1B" Access By ID
230+
................-> Index "TDETL_FK" Full Scan
231+
Sub-query(line, column)
232+
....-> Singularity Check
233+
........-> Aggregate
234+
............-> Table "TDETL" as "D1C" Full Scan
235+
Select Expression(line, column)
236+
....-> Aggregate
237+
........-> Nested Loop Join (inner)
238+
............-> Filter
239+
................-> Table "TMAIN" as "M2" Access By ID
240+
....................-> Index "TMAIN_PK" Full Scan
241+
........................-> Bitmap
242+
............................-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
243+
............-> Filter
244+
................-> Table "TDETL" as "D" Access By ID
245+
....................-> Bitmap
246+
........................-> Index "TDETL_PK" Unique Scan
224247
Sub-query
225-
-> Filter
226-
-> Table "TDETL" as "D" Access By ID
227-
-> Bitmap
228-
-> Index "TDETL_FK" Range Scan (full match)
229-
Select Expression (line 54, column 13)
230-
-> Filter
231-
-> Table "TMAIN" as "M3" Access By ID
232-
-> Bitmap
233-
-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
234-
0 ms
248+
....-> Filter
249+
........-> Table "TDETL" as "D" Access By ID
250+
............-> Bitmap
251+
................-> Index "TDETL_FK" Range Scan (full match)
252+
Select Expression(line, column)
253+
....-> Filter
254+
........-> Table "TMAIN" as "M3" Access By ID
255+
............-> Bitmap
256+
................-> Index "TMAIN_X" Range Scan (lower bound: 1/1)
257+
......0 ms
235258
"""
236259

237260
act.expected_stdout = expected_stdout

0 commit comments

Comments
 (0)