Skip to content

Commit ee07e83

Browse files
Fixed bug with ordering of binds in PL/SQL when the bind variable may
potentially exceed the 32767 byte limit but the actual value bound does not (#146).
1 parent a315a52 commit ee07e83

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Thin Mode Changes
3333
#) Fixed bug with SQL containing multibyte characters with certain database
3434
character sets
3535
(`issue 133 <https://github.com/oracle/python-oracledb/issues/133>`__).
36+
#) Fixed bug with ordering of binds in PL/SQL when the bind variable may
37+
potentially exceed the 32767 byte limit but the actual value bound does not
38+
(`issue 146 <https://github.com/oracle/python-oracledb/issues/146>`__).
3639
#) Fixed bug connecting to an IPv6 address with IAM tokens.
3740
#) Implementation changes:
3841

src/oracledb/impl/thin/messages.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,8 @@ cdef class MessageWithData(Message):
10611061
for value in var_impl._values[:num_elements]:
10621062
self._write_bind_params_column(buf, var_impl, value)
10631063
else:
1064-
if var_impl.buffer_size >= TNS_MIN_LONG_LENGTH:
1064+
if not self.cursor_impl._statement._is_plsql \
1065+
and var_impl.buffer_size >= TNS_MIN_LONG_LENGTH:
10651066
found_long = True
10661067
continue
10671068
self._write_bind_params_column(buf, var_impl,

tests/test_4300_cursor_other.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,5 +888,28 @@ def test_4368_cursor_rowcount_for_queries(self):
888888
self.cursor.fetchall()
889889
self.assertEqual(self.cursor.rowcount, max_rows)
890890

891+
def test_4369_bind_order_for_plsql(self):
892+
"4369 - test bind order for PL/SQL"
893+
self.cursor.execute("truncate table TestClobs")
894+
sql = """
895+
insert into TestClobs (IntCol, CLOBCol, ExtraNumCol1)
896+
values (:1, :2, :3)"""
897+
data = "x" * 9000
898+
rows = [
899+
(1, data, 5),
900+
(2, data, 6)
901+
]
902+
self.cursor.execute(sql, rows[0])
903+
plsql = f"begin {sql}; end;"
904+
self.cursor.execute(plsql, rows[1])
905+
self.connection.commit()
906+
oracledb.defaults.fetch_lobs = False
907+
self.cursor.execute("""
908+
select IntCol, CLOBCol, ExtraNumCol1
909+
from TestCLOBs
910+
order by IntCol""")
911+
fetched_rows = self.cursor.fetchall()
912+
self.assertEqual(fetched_rows, rows)
913+
891914
if __name__ == "__main__":
892915
test_env.run_test_cases()

0 commit comments

Comments
 (0)