diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 5b2e37f..758d26d 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -33,6 +33,8 @@ Thin Mode Changes #) Fixed bug with SQL containing multibyte characters with certain database character sets (`issue 133 `__). +#) Fixed bug with ordering of binds in SQL when the database version is 12.1 + (`issue 135 `__). #) 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 (`issue 146 `__). diff --git a/src/oracledb/impl/thin/buffer.pyx b/src/oracledb/impl/thin/buffer.pyx index dc77186..f8cd79b 100644 --- a/src/oracledb/impl/thin/buffer.pyx +++ b/src/oracledb/impl/thin/buffer.pyx @@ -267,7 +267,8 @@ cdef class Buffer: cdef ssize_t chunk_len if num_bytes <= TNS_MAX_SHORT_LENGTH: self.write_uint8( num_bytes) - self.write_raw(ptr, num_bytes) + if num_bytes > 0: + self.write_raw(ptr, num_bytes) else: self.write_uint8(TNS_LONG_LENGTH_INDICATOR) while num_bytes > 0: diff --git a/src/oracledb/impl/thin/capabilities.pyx b/src/oracledb/impl/thin/capabilities.pyx index da60f7a..af8bf59 100644 --- a/src/oracledb/impl/thin/capabilities.pyx +++ b/src/oracledb/impl/thin/capabilities.pyx @@ -38,6 +38,7 @@ cdef class Capabilities: uint16_t ncharset_id bytearray compile_caps bytearray runtime_caps + uint32_t max_string_size bint supports_oob def __init__(self): @@ -57,7 +58,10 @@ cdef class Capabilities: @cython.boundscheck(False) cdef void _adjust_for_server_runtime_caps(self, bytearray server_caps): - pass + if server_caps[TNS_RCAP_TTC] & TNS_RCAP_TTC_32K: + self.max_string_size = 32767 + else: + self.max_string_size = 4000 cdef int _check_ncharset_id(self) except -1: """ diff --git a/src/oracledb/impl/thin/constants.pxi b/src/oracledb/impl/thin/constants.pxi index 816e20c..91bfcf1 100644 --- a/src/oracledb/impl/thin/constants.pxi +++ b/src/oracledb/impl/thin/constants.pxi @@ -716,7 +716,6 @@ DEF TNS_MAX_ROWID_LENGTH = 18 DEF TNS_DURATION_MID = 0x80000000 DEF TNS_DURATION_OFFSET = 60 DEF TNS_DURATION_SESSION = 10 -DEF TNS_MIN_LONG_LENGTH = 0x8000 DEF TNS_MAX_LONG_LENGTH = 0x7fffffff DEF TNS_SDU = 8192 DEF TNS_TDU = 65535 diff --git a/src/oracledb/impl/thin/messages.pyx b/src/oracledb/impl/thin/messages.pyx index 1634d7b..5b9a1ed 100644 --- a/src/oracledb/impl/thin/messages.pyx +++ b/src/oracledb/impl/thin/messages.pyx @@ -934,7 +934,7 @@ cdef class MessageWithData(Message): # expects that and complains if any other value is sent! buf.write_uint8(0) buf.write_uint8(0) - if buffer_size >= TNS_MIN_LONG_LENGTH: + if buffer_size > buf._caps.max_string_size: buf.write_ub4(TNS_MAX_LONG_LENGTH) else: buf.write_ub4(buffer_size) @@ -1062,7 +1062,7 @@ cdef class MessageWithData(Message): self._write_bind_params_column(buf, var_impl, value) else: if not self.cursor_impl._statement._is_plsql \ - and var_impl.buffer_size >= TNS_MIN_LONG_LENGTH: + and var_impl.buffer_size > buf._caps.max_string_size: found_long = True continue self._write_bind_params_column(buf, var_impl, @@ -1072,7 +1072,7 @@ cdef class MessageWithData(Message): if bind_info._is_return_bind: continue var_impl = bind_info._bind_var_impl - if var_impl.buffer_size < TNS_MIN_LONG_LENGTH: + if var_impl.buffer_size <= buf._caps.max_string_size: continue self._write_bind_params_column(buf, var_impl, var_impl._values[pos + offset])