mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_8115_test.py: Resultset of cursor that executes using instance of selectable PreparedStatement must be stored in some variable in order to have ability close it EXPLICITLY, before PS will be freed. Otherwise access violation can raises when Python runs garbage collection.
This commit is contained in:
parent
df454c615b
commit
b480a3fe43
@ -14,6 +14,13 @@ NOTES:
|
|||||||
https://github.com/FirebirdSQL/firebird/commit/bbd35ab07c129e9735f081fcd29172a8187aa8ab
|
https://github.com/FirebirdSQL/firebird/commit/bbd35ab07c129e9735f081fcd29172a8187aa8ab
|
||||||
Avoid reading/hashing the inner stream(s) if the leader stream is empty
|
Avoid reading/hashing the inner stream(s) if the leader stream is empty
|
||||||
|
|
||||||
|
[18.01.2025] pzotov
|
||||||
|
Resultset of cursor that executes using instance of selectable PreparedStatement must be stored
|
||||||
|
in some variable in order to have ability close it EXPLICITLY (before PS will be freed).
|
||||||
|
Otherwise access violation raises during Python GC and pytest hangs at final point (does not return control to OS).
|
||||||
|
This occurs at least for: Python 3.11.2 / pytest: 7.4.4 / firebird.driver: 1.10.6 / Firebird.Qa: 0.19.3
|
||||||
|
The reason of that was explained by Vlad, 26.10.24 17:42 ("oddities when use instances of selective statements").
|
||||||
|
|
||||||
Checked on 6.0.0.457, 5.0.2.1499
|
Checked on 6.0.0.457, 5.0.2.1499
|
||||||
"""
|
"""
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -57,17 +64,29 @@ def test_1(act: Action, tmp_fbk: Path, capsys):
|
|||||||
|
|
||||||
with act.db.connect() as con:
|
with act.db.connect() as con:
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
ps = cur.prepare(test_sql)
|
ps, rs = None, None
|
||||||
print( '\n'.join([replace_leading(s) for s in ps.detailed_plan.split('\n')]) )
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cur.execute(ps)
|
ps = cur.prepare(test_sql)
|
||||||
for r in cur:
|
print( '\n'.join([replace_leading(s) for s in ps.detailed_plan.split('\n')]) )
|
||||||
|
|
||||||
|
# ::: NB ::: 'ps' returns data, i.e. this is SELECTABLE expression.
|
||||||
|
# We have to store result of cur.execute(<psInstance>) in order to
|
||||||
|
# close it explicitly.
|
||||||
|
# Otherwise AV can occur during Python garbage collection and this
|
||||||
|
# causes pytest to hang on its final point.
|
||||||
|
# Explained by hvlad, email 26.10.24 17:42
|
||||||
|
rs = cur.execute(ps)
|
||||||
|
for r in rs:
|
||||||
for p in r:
|
for p in r:
|
||||||
print(p)
|
print(p)
|
||||||
except DatabaseError as e:
|
except DatabaseError as e:
|
||||||
print(e.__str__())
|
print(e.__str__())
|
||||||
print(e.gds_codes)
|
print(e.gds_codes)
|
||||||
|
finally:
|
||||||
|
if rs:
|
||||||
|
rs.close() # <<< EXPLICITLY CLOSING CURSOR RESULTS
|
||||||
|
if ps:
|
||||||
|
ps.free()
|
||||||
|
|
||||||
expected_stdout_5x = """
|
expected_stdout_5x = """
|
||||||
Select Expression
|
Select Expression
|
||||||
|
Loading…
Reference in New Issue
Block a user