File tree Expand file tree Collapse file tree 10 files changed +68
-0
lines changed
Expand file tree Collapse file tree 10 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -526,6 +526,15 @@ AsyncConnection Attributes
526526 This attribute is only available when Oracle Database 12.1 or later is
527527 in use
528528
529+ .. attribute :: AsyncConnection.max_identifier_length
530+
531+ This read-only attribute specifies the maximum length of bytes supported by
532+ the database to which the connection has been established. See `Database
533+ Object Naming Rules <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&
534+ id=GUID-75337742-67FD-4EC0-985F-741C93D918DA> `__.
535+
536+ .. versionadded :: 2.5.0
537+
529538.. attribute :: AsyncConnection.max_open_cursors
530539
531540 This read-only attribute specifies the maximum number of cursors that the
Original file line number Diff line number Diff line change @@ -755,6 +755,14 @@ Connection Attributes
755755 available when Oracle Database 12.1 or higher is in use on both the
756756 server and the client.
757757
758+ .. attribute :: Connection.max_identifier_length
759+
760+ This read-only attribute specifies the maximum length of bytes supported
761+ by the database to which the connection has been established. See `Database
762+ Object Naming Rules <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&
763+ id=GUID-75337742-67FD-4EC0-985F-741C93D918DA> `__.
764+
765+ .. versionadded :: 2.5.0
758766
759767.. attribute :: Connection.max_open_cursors
760768
Original file line number Diff line number Diff line change @@ -75,6 +75,9 @@ Thick Mode Changes
7575Common Changes
7676++++++++++++++
7777
78+ #) Added support for returning the maximum identifier length allowed by the
79+ database using the new property :data: `Connection.max_identifier_length `
80+ (`issue 395 <https://github.com/oracle/python-oracledb/issues/395 >`__).
7881#) Improved type hints for cursors
7982 (`issue 391 <https://github.com/oracle/python-oracledb/issues/391 >`__).
8083#) Improved error message when attempting to access attributes on a connection
Original file line number Diff line number Diff line change @@ -350,6 +350,15 @@ def ltxid(self) -> bytes:
350350 self ._verify_connected ()
351351 return self ._impl .get_ltxid ()
352352
353+ @property
354+ def max_identifier_length (self ) -> int :
355+ """
356+ Returns the maximum length of identifiers supported by the database to
357+ which this connection has been established.
358+ """
359+ self ._verify_connected ()
360+ return self ._impl .get_max_identifier_length ()
361+
353362 @property
354363 def max_open_cursors (self ) -> int :
355364 """
Original file line number Diff line number Diff line change @@ -270,6 +270,9 @@ cdef class BaseConnImpl:
270270 def get_ltxid (self ):
271271 errors._raise_not_supported(" getting the logical transaction id" )
272272
273+ def get_max_identifier_length (self ):
274+ errors._raise_not_supported(" getting the maximum identifier length" )
275+
273276 def get_max_open_cursors (self ):
274277 errors._raise_not_supported(
275278 " getting the maximum number of open cursors"
Original file line number Diff line number Diff line change @@ -664,6 +664,12 @@ cdef class ThickConnImpl(BaseConnImpl):
664664 _raise_from_odpi()
665665 return value[:value_length]
666666
667+ def get_max_identifier_length (self ):
668+ cdef dpiConnInfo info
669+ if dpiConn_getInfo(self ._handle, & info) < 0 :
670+ _raise_from_odpi()
671+ return info.maxIdentifierLength
672+
667673 def get_max_open_cursors (self ):
668674 cdef uint32_t value
669675 if dpiConn_getMaxOpenCursors(self ._handle, & value) < 0 :
Original file line number Diff line number Diff line change @@ -337,6 +337,19 @@ cdef extern from "impl/thick/odpi/embed/dpi.c":
337337 uint8_t numSuperShardingKeyColumns
338338 bint outNewSession
339339
340+ ctypedef struct dpiConnInfo:
341+ const char * dbDomain
342+ uint32_t dbDomainLength
343+ const char * dbName
344+ uint32_t dbNameLength
345+ const char * instanceName
346+ uint32_t instanceNameLength
347+ const char * serviceName
348+ uint32_t serviceNameLength
349+ uint32_t maxIdentifierLength
350+ uint32_t maxOpenCursors
351+ uint8_t serverType
352+
340353 ctypedef struct dpiContextCreateParams:
341354 const char * defaultDriverName
342355 const char * defaultEncoding
@@ -619,6 +632,8 @@ cdef extern from "impl/thick/odpi/embed/dpi.c":
619632
620633 int dpiConn_getHandle(dpiConn * conn, void ** handle) nogil
621634
635+ int dpiConn_getInfo(dpiConn * conn, dpiConnInfo * info) nogil
636+
622637 int dpiConn_getInstanceName(dpiConn * conn, const char ** value,
623638 uint32_t * valueLength) nogil
624639
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ cdef class BaseThinConnImpl(BaseConnImpl):
5050 bytes _ltxid
5151 str _current_schema
5252 bint _current_schema_modified
53+ uint8_t _max_identifier_length
5354 uint32_t _max_open_cursors
5455 str _db_domain
5556 str _db_name
@@ -241,6 +242,9 @@ cdef class BaseThinConnImpl(BaseConnImpl):
241242 def get_ltxid (self ):
242243 return self ._ltxid or b' '
243244
245+ def get_max_identifier_length (self ):
246+ return self ._max_identifier_length
247+
244248 def get_max_open_cursors (self ):
245249 return self ._max_open_cursors
246250
Original file line number Diff line number Diff line change @@ -1639,6 +1639,8 @@ cdef class AuthMessage(Message):
16391639 self .session_data.get(" AUTH_SC_SERVICE_NAME" )
16401640 self .conn_impl._instance_name = \
16411641 self .session_data.get(" AUTH_INSTANCENAME" )
1642+ self .conn_impl._max_identifier_length = \
1643+ int (self .session_data.get(" AUTH_MAX_IDEN_LENGTH" , 30 ))
16421644 self .conn_impl.server_version = self ._get_version_tuple(buf)
16431645 self .conn_impl.supports_bool = \
16441646 buf._caps.ttc_field_version >= TNS_CCAP_FIELD_VERSION_23_1
Original file line number Diff line number Diff line change @@ -348,6 +348,15 @@ def ltxid(self) -> bytes:
348348 self ._verify_connected ()
349349 return self ._impl .get_ltxid ()
350350
351+ @property
352+ def max_identifier_length (self ) -> int :
353+ """
354+ Returns the maximum length of identifiers supported by the database to
355+ which this connection has been established.
356+ """
357+ self ._verify_connected ()
358+ return self ._impl .get_max_identifier_length ()
359+
351360 @property
352361 def max_open_cursors (self ) -> int :
353362 """
You can’t perform that action at this time.
0 commit comments