Skip to content

Commit ddd7a3f

Browse files
Fixed bug when calling cursor.parse() multiple times with the same SQL.
1 parent 7506506 commit ddd7a3f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Thin Mode Changes
2525
in socket reads.
2626
#) Eliminated unnecessary restriction that resulted in error
2727
``DPY-3011: server logon version is not supported``.
28+
#) Fixed bug when calling cursor.parse() multiple times with the same SQL.
2829

2930
Thick Mode Changes
3031
++++++++++++++++++

src/oracledb/impl/thin/messages.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ cdef class MessageWithData(Message):
486486
if self.out_var_impls is None:
487487
return 0
488488
for var_impl in self.out_var_impls:
489-
if var_impl.outconverter is None:
489+
if var_impl is None or var_impl.outconverter is None:
490490
continue
491491
var_impl._last_raw_value = \
492492
var_impl._values[self.cursor_impl._last_row_index]
@@ -1904,7 +1904,7 @@ cdef class ExecuteMessage(MessageWithData):
19041904
cdef:
19051905
Statement stmt = self.cursor_impl._statement
19061906
if stmt._cursor_id != 0 and not stmt._requires_full_execute \
1907-
and not stmt._is_ddl:
1907+
and not self.parse_only and not stmt._is_ddl:
19081908
if stmt._is_query and not stmt._requires_define \
19091909
and self.cursor_impl.prefetchrows > 0:
19101910
self.function_code = TNS_FUNC_REEXECUTE_AND_FETCH

tests/test_4300_cursor_other.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,5 +802,18 @@ def test_4362_change_of_bind_type_with_define(self):
802802
self.cursor.execute(sql, int_col=1)
803803
self.assertEqual(self.cursor.fetchone(), row_for_1)
804804

805+
def test_4363_multiple_parse(self):
806+
"4363 - test calling cursor.parse() twice with the same statement"
807+
self.cursor.execute("truncate table TestTempTable")
808+
data = (4363, "Value for test 4363")
809+
self.cursor.execute("""
810+
insert into TestTempTable (IntCol, StringCol1)
811+
values (:1, :2)""", data)
812+
sql = "update TestTempTable set StringCol1 = :v where IntCol = :i"
813+
for i in range(2):
814+
self.cursor.parse(sql)
815+
self.cursor.execute(sql, ("Updated value", data[0]))
816+
817+
805818
if __name__ == "__main__":
806819
test_env.run_test_cases()

0 commit comments

Comments
 (0)