From 4a758c0d4eddd62bebe441baecdadbb649697b22 Mon Sep 17 00:00:00 2001
From: Anton Zuev <ant-zuev@inbox.ru>
Date: Fri, 22 Sep 2023 11:27:50 +0300
Subject: [PATCH 1/2] Updated tests/bugs/gh_3810_test.py: index tmp_tbl1_fld2
 was removed from the test. The index does not refer to the fix, while the
 optimizer may produce a plan different from the expected one.

---
 tests/bugs/gh_3810_test.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/bugs/gh_3810_test.py b/tests/bugs/gh_3810_test.py
index 087d5523..ab06c5d0 100644
--- a/tests/bugs/gh_3810_test.py
+++ b/tests/bugs/gh_3810_test.py
@@ -8,6 +8,9 @@
     [14.04.2023] pzotov
     Confirmed poor performance on 3.0.11.33678 (num of fetches = 10'099).
     Checked on 3.0.11.33681 -- all fine, fetches differ for less than 20.
+    [22.09.2023] Zuev
+    Index tmp_tbl1_fld2 was removed from the test because it does not refer to the fix, 
+    while the optimizer may produce a plan different from the expected one.
 """
 
 import pytest
@@ -19,7 +22,6 @@
     set bail on;
     create table tmp_tbl1 (fld1 integer, fld2 integer, fld3 integer);
     create index tmp_tbl1_fld123 on tmp_tbl1(fld1, fld2, fld3);
-    create index tmp_tbl1_fld2 on tmp_tbl1(fld2);
     commit;
     set term ^;
     create or alter procedure tmp_sp1 as
@@ -37,7 +39,6 @@
     execute procedure tmp_sp1;
     commit;
     SET STATISTICS INDEX TMP_TBL1_FLD123;
-    SET STATISTICS INDEX TMP_TBL1_FLD2;
     commit;
 
     recreate view v_check as

From 5bc287b51411b6058911658251b1b2028d16e467 Mon Sep 17 00:00:00 2001
From: Anton Zuev <ant-zuev@inbox.ru>
Date: Tue, 12 Nov 2024 15:27:31 +0300
Subject: [PATCH 2/2] Update tests\bugs\core_5845_test.py: Made the test more
 reliable. Perform prepare using the with manager to avoid uncontrolled
 deletion of the Statement object.

---
 tests/bugs/core_5845_test.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/bugs/core_5845_test.py b/tests/bugs/core_5845_test.py
index 309e4a8c..0d4e976a 100644
--- a/tests/bugs/core_5845_test.py
+++ b/tests/bugs/core_5845_test.py
@@ -88,9 +88,9 @@ def test_1(act: Action, capsys):
     with act.db.connect() as con:
         cur = con.cursor()
         for q in chk_qry_map.keys():
-            ps = cur.prepare(q)
-            print( q )
-            print( ps.plan )
+            with cur.prepare(q) as ps:
+                print( q )
+                print( ps.plan )
     
     act.expected_stdout = '\n'.join(expected_plans_lst)
     act.stdout = capsys.readouterr().out