Skip to content

Commit 1cad058

Browse files
Add support for OSON containing field names > 255 bytes and relative
offsets in compressed OSON.
1 parent 3574d72 commit 1cad058

File tree

8 files changed

+539
-167
lines changed

8 files changed

+539
-167
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ oracledb 2.0.0 (TBD)
1313
Thin Mode Changes
1414
+++++++++++++++++
1515

16+
#) Added support for an Oracle Database 23c JSON feature allowing for field
17+
names with more than 255 UTF-8 encoded bytes.
18+
#) Added support for an Oracle Database 23c JSON feature improving JSON
19+
storage usage.
1620
#) Fixed bug in detecting the current time zone
1721
(`issue 257 <https://github.com/oracle/python-oracledb/issues/257>`__).
1822
#) Added connection establishment parameter :data:`ConnectParams.ssl_context`

src/oracledb/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def _raise_from_string(exc_type: Exception, message: str) -> None:
516516
),
517517
ERR_ORACLE_TYPE_NOT_SUPPORTED: "Oracle data type {num} is not supported",
518518
ERR_OSON_FIELD_NAME_LIMITATION: (
519-
"OSON field names may not exceed 255 UTF-8 encoded bytes"
519+
"OSON field names may not exceed {max_fname_size} UTF-8 encoded bytes"
520520
),
521521
ERR_OSON_NODE_TYPE_NOT_SUPPORTED: (
522522
"OSON node type 0x{node_type:x} is not supported"

src/oracledb/impl/thin/capabilities.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ cdef class Capabilities:
4040
bytearray runtime_caps
4141
uint32_t max_string_size
4242
bint supports_oob
43+
ssize_t oson_max_fname_size
4344

4445
def __init__(self):
4546
self._init_compile_caps()
@@ -55,6 +56,9 @@ cdef class Capabilities:
5556
if server_caps[TNS_CCAP_FIELD_VERSION] < self.ttc_field_version:
5657
self.ttc_field_version = server_caps[TNS_CCAP_FIELD_VERSION]
5758
self.compile_caps[TNS_CCAP_FIELD_VERSION] = self.ttc_field_version
59+
self.oson_max_fname_size = 65535 \
60+
if self.ttc_field_version >= TNS_CCAP_FIELD_VERSION_23_1 \
61+
else 255
5862

5963
@cython.boundscheck(False)
6064
cdef void _adjust_for_server_runtime_caps(self, bytearray server_caps):

src/oracledb/impl/thin/constants.pxi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ cdef enum:
564564
TNS_JSON_MAGIC_BYTE_1 = 0xff
565565
TNS_JSON_MAGIC_BYTE_2 = 0x4a # 'J'
566566
TNS_JSON_MAGIC_BYTE_3 = 0x5a # 'Z'
567-
TNS_JSON_VERSION = 1
567+
TNS_JSON_VERSION_MAX_FNAME_255 = 1
568+
TNS_JSON_VERSION_MAX_FNAME_65535 = 3
568569
TNS_JSON_FLAG_HASH_ID_UINT8 = 0x0100
569-
TNS_JSON_FLAG_HASH_ID_UINT16 = 0x0200
570570
TNS_JSON_FLAG_NUM_FNAMES_UINT16 = 0x0400
571571
TNS_JSON_FLAG_FNAMES_SEG_UINT32 = 0x0800
572572
TNS_JSON_FLAG_TINY_NODES_STAT = 0x2000
@@ -576,6 +576,7 @@ cdef enum:
576576
TNS_JSON_FLAG_LEN_IN_PCODE = 0x04
577577
TNS_JSON_FLAG_NUM_FNAMES_UINT32 = 0x08
578578
TNS_JSON_FLAG_IS_SCALAR = 0x10
579+
TNS_JSON_FLAG_SEC_FNAMES_SEG_UINT16 = 0x0100
579580

580581
# JSON data types
581582
cdef enum:

0 commit comments

Comments
 (0)