Skip to content

Commit 40d2b97

Browse files
Tightened up code looking for the end of a database request.
1 parent 972018b commit 40d2b97

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Thin Mode Changes
1616
#) Fixed bug when calling :meth:`~Connection.gettype()` with an object type
1717
name containing ``%ROWTYPE``
1818
(`issue 304 <https://github.com/oracle/python-oracledb/issues/304>`__).
19+
#) Tightened up code looking for the end of a database request.
1920
#) Restored error message raised when attempting to connect to Oracle Database
2021
11g.
2122

src/oracledb/impl/thin/capabilities.pyx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,6 @@ cdef class Capabilities:
7979
errors._raise_err(errors.ERR_NCHAR_CS_NOT_SUPPORTED,
8080
charset_id=self.ncharset_id)
8181

82-
cdef void _check_supports_end_of_request(self):
83-
"""
84-
Checks whether the end of request flag is sent and sets a boolean to
85-
avoid calculating it each time.
86-
"""
87-
if self.ttc_field_version >= TNS_CCAP_FIELD_VERSION_19_1 \
88-
and self.compile_caps[TNS_CCAP_TTC4] & TNS_CCAP_END_OF_REQUEST:
89-
self.supports_end_of_request = True
90-
9182
@cython.boundscheck(False)
9283
cdef void _init_compile_caps(self):
9384
self.ttc_field_version = TNS_CCAP_FIELD_VERSION_MAX

src/oracledb/impl/thin/constants.pxi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ cdef enum:
4747

4848
# data flags
4949
cdef enum:
50+
TNS_DATA_FLAGS_END_OF_REQUEST = 0x2000
5051
TNS_DATA_FLAGS_EOF = 0x0040
5152

5253
# marker types
@@ -740,6 +741,7 @@ cdef enum:
740741
# accept flags
741742
cdef enum:
742743
TNS_ACCEPT_FLAG_FAST_AUTH = 0x10000000
744+
TNS_ACCEPT_FLAG_HAS_END_OF_REQUEST = 0x02000000
743745

744746
# other constants
745747
cdef enum:

src/oracledb/impl/thin/messages.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,8 @@ cdef class ConnectMessage(Message):
18471847
buf.read_uint32(&flags)
18481848
if flags & TNS_ACCEPT_FLAG_FAST_AUTH:
18491849
buf._caps.supports_fast_auth = True
1850+
if flags & TNS_ACCEPT_FLAG_HAS_END_OF_REQUEST:
1851+
buf._caps.supports_end_of_request = True
18501852
buf._caps._adjust_for_protocol(protocol_version, protocol_options)
18511853
buf._transport._full_packet_size = True
18521854
elif buf._current_packet.packet_type == TNS_PACKET_TYPE_REFUSE:
@@ -1923,7 +1925,6 @@ cdef class DataTypesMessage(Message):
19231925
buf.read_uint16(&conv_data_type)
19241926
if conv_data_type != 0:
19251927
buf.skip_raw_bytes(4)
1926-
buf._caps._check_supports_end_of_request()
19271928

19281929
cdef int _write_message(self, WriteBuffer buf) except -1:
19291930
cdef:

src/oracledb/impl/thin/packet.pyx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ cdef class Packet:
6060
Returns a boolean indicating if the end of request byte is found at the
6161
end of the packet.
6262
"""
63-
cdef char *ptr = cpython.PyBytes_AS_STRING(self.buf)
64-
return ptr[self.packet_size - 1] == TNS_MSG_TYPE_END_OF_REQUEST
63+
cdef:
64+
uint16_t flags
65+
char *ptr
66+
ptr = cpython.PyBytes_AS_STRING(self.buf)
67+
flags = unpack_uint16(<const char_type*> &ptr[PACKET_HEADER_SIZE],
68+
BYTE_ORDER_MSB)
69+
return flags & TNS_DATA_FLAGS_END_OF_REQUEST
6570

6671

6772
@cython.final

0 commit comments

Comments
 (0)