Skip to content

Commit 40caed2

Browse files
Fixed bug with ordering of binds in SQL when the database version is
12.1 (#135).
1 parent ee07e83 commit 40caed2

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ 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 SQL when the database version is 12.1
37+
(`issue 135 <https://github.com/oracle/python-oracledb/issues/135>`__).
3638
#) Fixed bug with ordering of binds in PL/SQL when the bind variable may
3739
potentially exceed the 32767 byte limit but the actual value bound does not
3840
(`issue 146 <https://github.com/oracle/python-oracledb/issues/146>`__).

src/oracledb/impl/thin/buffer.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ cdef class Buffer:
267267
cdef ssize_t chunk_len
268268
if num_bytes <= TNS_MAX_SHORT_LENGTH:
269269
self.write_uint8(<uint8_t> num_bytes)
270-
self.write_raw(ptr, num_bytes)
270+
if num_bytes > 0:
271+
self.write_raw(ptr, num_bytes)
271272
else:
272273
self.write_uint8(TNS_LONG_LENGTH_INDICATOR)
273274
while num_bytes > 0:

src/oracledb/impl/thin/capabilities.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cdef class Capabilities:
3838
uint16_t ncharset_id
3939
bytearray compile_caps
4040
bytearray runtime_caps
41+
uint32_t max_string_size
4142
bint supports_oob
4243

4344
def __init__(self):
@@ -57,7 +58,10 @@ cdef class Capabilities:
5758

5859
@cython.boundscheck(False)
5960
cdef void _adjust_for_server_runtime_caps(self, bytearray server_caps):
60-
pass
61+
if server_caps[TNS_RCAP_TTC] & TNS_RCAP_TTC_32K:
62+
self.max_string_size = 32767
63+
else:
64+
self.max_string_size = 4000
6165

6266
cdef int _check_ncharset_id(self) except -1:
6367
"""

src/oracledb/impl/thin/constants.pxi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ DEF TNS_MAX_ROWID_LENGTH = 18
716716
DEF TNS_DURATION_MID = 0x80000000
717717
DEF TNS_DURATION_OFFSET = 60
718718
DEF TNS_DURATION_SESSION = 10
719-
DEF TNS_MIN_LONG_LENGTH = 0x8000
720719
DEF TNS_MAX_LONG_LENGTH = 0x7fffffff
721720
DEF TNS_SDU = 8192
722721
DEF TNS_TDU = 65535

src/oracledb/impl/thin/messages.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ cdef class MessageWithData(Message):
934934
# expects that and complains if any other value is sent!
935935
buf.write_uint8(0)
936936
buf.write_uint8(0)
937-
if buffer_size >= TNS_MIN_LONG_LENGTH:
937+
if buffer_size > buf._caps.max_string_size:
938938
buf.write_ub4(TNS_MAX_LONG_LENGTH)
939939
else:
940940
buf.write_ub4(buffer_size)
@@ -1062,7 +1062,7 @@ cdef class MessageWithData(Message):
10621062
self._write_bind_params_column(buf, var_impl, value)
10631063
else:
10641064
if not self.cursor_impl._statement._is_plsql \
1065-
and var_impl.buffer_size >= TNS_MIN_LONG_LENGTH:
1065+
and var_impl.buffer_size > buf._caps.max_string_size:
10661066
found_long = True
10671067
continue
10681068
self._write_bind_params_column(buf, var_impl,
@@ -1072,7 +1072,7 @@ cdef class MessageWithData(Message):
10721072
if bind_info._is_return_bind:
10731073
continue
10741074
var_impl = bind_info._bind_var_impl
1075-
if var_impl.buffer_size < TNS_MIN_LONG_LENGTH:
1075+
if var_impl.buffer_size <= buf._caps.max_string_size:
10761076
continue
10771077
self._write_bind_params_column(buf, var_impl,
10781078
var_impl._values[pos + offset])

0 commit comments

Comments
 (0)