Skip to content

Commit 6b2a7d5

Browse files
Add support for passthrough of connect strings to the Oracle Client
library parser (for backwards compatibility).
1 parent 950220a commit 6b2a7d5

21 files changed

+260
-42
lines changed

doc/src/api_manual/connect_params.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ ConnectParams Methods
6262
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
6363
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
6464
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
65-
driver_name=oracledb.defaults.driver_name, use_sni=None, handle=None)
65+
driver_name=oracledb.defaults.driver_name, use_sni=None, \
66+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
67+
handle=None)
6668

6769
Sets the values for one or more of the parameters of a ConnectParams
6870
object.
6971

7072
.. versionchanged:: 3.0.0
7173

72-
The ``use_sni`` and ``instance_name`` parameters were added.
74+
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
75+
parameters were added.
7376

7477
.. versionchanged:: 2.5.0
7578

@@ -544,6 +547,18 @@ ConnectParams Attributes
544547

545548
.. versionadded:: 2.5.0
546549

550+
.. attribute:: ConnectParams.thick_mode_dsn_passthrough
551+
552+
This read-only attribute is a boolean which indicates whether the connect
553+
string should be passed unchanged to Oracle Client libraries for parsing or
554+
if python-oracledb should parse the connect string itself when using Thick
555+
mode. The default value is the value of
556+
:attr:`defaults.thick_mode_dsn_passthrough`.
557+
558+
This attribute is only supported in python-oracledb Thick mode.
559+
560+
.. versionadded:: 3.0.0
561+
547562
.. attribute:: ConnectParams.use_tcp_fast_open
548563

549564
This read-only attribute is a boolean which indicates whether to use an

doc/src/api_manual/defaults.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,30 @@ Defaults Attributes
162162
This attribute is only used in python-oracledb Thin mode.
163163

164164
.. versionadded:: 2.5.0
165+
166+
.. attribute:: defaults.thick_mode_dsn_passthrough
167+
168+
The default value that determines whether :ref:`connection strings
169+
<connstr>` passed to :meth:`oracledb.connect()` and
170+
:meth:`oracledb.create_pool()` in python-oracledb Thick mode will be parsed
171+
by Oracle Client libraries or by python-oracledb itself.
172+
173+
When the value of this attribute is *True*, then connection strings passed
174+
to these methods will be sent unchanged to the Oracle Client libraries.
175+
176+
Setting this attribute to *False* makes Thick and Thin mode applications
177+
behave similarly regarding connection string parameter handling and
178+
locating any optional :ref:`tnsnames.ora files <optnetfiles>` configuration
179+
file, see :ref:`usingconfigfiles`. Connection strings used in connection
180+
and pool creation methods in Thick mode are parsed by python-oracledb
181+
itself and a generated connect descriptor is sent to the Oracle Client
182+
libraries. The location of any optional :ref:`tnsnames.ora file
183+
<optnetfiles>` used to resolve a :ref:`TNS Alias <netservice>` is
184+
determined by python-oracledb heuristics instead of by the Oracle Client
185+
libraries.
186+
187+
This attribute has an initial value of *True*.
188+
189+
This attribute is ignored in python-oracledb Thin mode.
190+
191+
.. versionadded:: 3.0.0

doc/src/api_manual/module.rst

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Oracledb Methods
5252
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
5353
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
5454
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
55-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
55+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
56+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
57+
handle=0)
5658

5759
Constructor for creating a connection to the database. Returns a
5860
:ref:`Connection Object <connobj>`. All parameters are optional and can be
@@ -397,6 +399,15 @@ Oracledb Methods
397399
is used in both the python-oracledb Thin and Thick modes. The default is
398400
the value of :attr:`defaults.driver_name`.
399401

402+
The ``thick_mode_dsn_passthrough`` parameter is expected to be a boolean
403+
which indicates whether the connect string should be passed unchanged to
404+
the Oracle Client libraries for parsing when using python-oracledb Thick
405+
mode. If this parameter is set to *False* in Thick mode, connect strings
406+
are parsed by python-oracledb itself and a generated connect descriptor is
407+
sent to the Oracle Client libraries. This value is only used in the
408+
python-oracledb Thick mode. The default value is the value of
409+
:attr:`defaults.thick_mode_dsn_passthrough`.
410+
400411
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
401412
and is only of use when embedding Python in an application (like
402413
PowerBuilder) which has already made the connection. The connection thus
@@ -407,9 +418,9 @@ Oracledb Methods
407418

408419
.. versionchanged:: 3.0.0
409420

410-
The ``pool_alias``, ``instance_name`` and ``use_sni`` parameters were
411-
added. The ``pool`` parameter was deprecated. Use
412-
:meth:`ConnectionPool.acquire()` instead.
421+
The ``pool_alias``, ``instance_name``, ``use_sni``, and
422+
``thick_mode_dsn_passthrough`` parameters were added. The ``pool``
423+
parameter was deprecated. Use :meth:`ConnectionPool.acquire()` instead.
413424

414425
.. versionchanged:: 2.5.0
415426

@@ -454,7 +465,9 @@ Oracledb Methods
454465
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
455466
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
456467
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
457-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
468+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
469+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
470+
handle=0)
458471

459472
Constructor for creating a connection to the database. Returns an
460473
:ref:`AsyncConnection Object <asyncconnobj>`. All parameters are optional
@@ -734,13 +747,15 @@ Oracledb Methods
734747
is used in both the python-oracledb Thin and Thick modes. The default is
735748
the value of :attr:`defaults.driver_name`.
736749

737-
The ``handle`` parameter is ignored in the python-oracledb Thin mode.
750+
The ``thick_mode_dsn_passthrough`` and ``handle`` parameters are ignored in
751+
python-oracledb Thin mode.
738752

739753
.. versionchanged:: 3.0.0
740754

741-
The ``pool_alias``, ``instance_name`` and ``use_sni`` parameters were
742-
added. The ``pool`` parameter was deprecated. Use
743-
:meth:`AsyncConnectionPool.acquire()` instead.
755+
The ``pool_alias``, ``instance_name``, ``use_sni``, and
756+
``thick_mode_dsn_passthrough`` parameters were added. The ``pool``
757+
parameter was deprecated. Use :meth:`AsyncConnectionPool.acquire()`
758+
instead.
744759

745760
.. versionchanged:: 2.5.0
746761

@@ -783,7 +798,9 @@ Oracledb Methods
783798
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
784799
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
785800
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
786-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
801+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
802+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
803+
handle=0)
787804

788805
Contains all the parameters that can be used to establish a connection to
789806
the database.
@@ -1082,14 +1099,24 @@ Oracledb Methods
10821099
is used in both the python-oracledb Thin and Thick modes. The default is
10831100
the value of :attr:`defaults.driver_name`.
10841101

1102+
The ``thick_mode_dsn_passthrough`` parameter is expected to be a boolean
1103+
which indicates whether the connect string should be passed unchanged to
1104+
the Oracle Client libraries for parsing when using python-oracledb Thick
1105+
mode. If this parameter is set to *False* in Thick mode, connect strings
1106+
are parsed by python-oracledb itself and a generated connect descriptor is
1107+
sent to the Oracle Client libraries. This value is only used in the
1108+
python-oracledb Thick mode. The default value is the value of
1109+
:attr:`defaults.thick_mode_dsn_passthrough`.
1110+
10851111
The ``handle`` parameter is expected to be an integer which represents a
10861112
pointer to a valid service context handle. This value is only used in the
10871113
python-oracledb Thick mode. It should be used with extreme caution. The
10881114
default value is *0*.
10891115

10901116
.. versionchanged:: 3.0.0
10911117

1092-
The ``use_sni`` and ``instance_name`` parameters were added.
1118+
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
1119+
parameters were added.
10931120

10941121
.. versionchanged:: 2.5.0
10951122

@@ -1150,7 +1177,9 @@ Oracledb Methods
11501177
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
11511178
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
11521179
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
1153-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
1180+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
1181+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1182+
handle=0)
11541183

11551184
Creates a connection pool with the supplied parameters and returns the
11561185
:ref:`ConnectionPool object <connpool>` for the pool. See :ref:`Connection
@@ -1570,6 +1599,15 @@ Oracledb Methods
15701599
is used in both the python-oracledb Thin and Thick modes. The default is
15711600
the value of :attr:`defaults.driver_name`.
15721601

1602+
The ``thick_mode_dsn_passthrough`` parameter is expected to be a boolean
1603+
which indicates whether the connect string should be passed unchanged to
1604+
the Oracle Client libraries for parsing when using python-oracledb Thick
1605+
mode. If this parameter is set to *False* in Thick mode, connect strings
1606+
are parsed by python-oracledb itself and a generated connect descriptor is
1607+
sent to the Oracle Client libraries. This value is only used in the
1608+
python-oracledb Thick mode. The default value is
1609+
:attr:`defaults.thick_mode_dsn_passthrough`.
1610+
15731611
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
15741612
and is only of use when embedding Python in an application (like
15751613
PowerBuilder) which has already made the connection. The connection thus
@@ -1580,8 +1618,8 @@ Oracledb Methods
15801618

15811619
.. versionchanged:: 3.0.0
15821620

1583-
The ``pool_alias``, ``instance_name`` and ``use_sni`` parameters were
1584-
added.
1621+
The ``pool_alias``, ``instance_name``, ``use_sni``, and
1622+
``thick_mode_dsn_passthrough`` parameters were added.
15851623

15861624
.. versionchanged:: 2.5.0
15871625

@@ -1631,7 +1669,9 @@ Oracledb Methods
16311669
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
16321670
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
16331671
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
1634-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
1672+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
1673+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1674+
handle=0)
16351675

16361676
Creates a connection pool with the supplied parameters and returns the
16371677
:ref:`AsyncConnectionPool object <asyncconnpoolobj>` for the pool.
@@ -1970,12 +2010,13 @@ Oracledb Methods
19702010
is used in both the python-oracledb Thin and Thick modes. The default is
19712011
the value of :attr:`defaults.driver_name`.
19722012

1973-
The ``handle`` parameter is ignored in the python-oracledb Thin mode.
2013+
The ``handle`` and ``thick_mode_dsn_passthrough`` parameters are ignored in
2014+
python-oracledb Thin mode.
19742015

19752016
.. versionchanged:: 3.0.0
19762017

1977-
The ``pool_alias``, ``instance_name`` and ``use_sni`` parameters were
1978-
added.
2018+
The ``pool_alias``, ``instance_name``, ``use_sni``, and
2019+
``thick_mode_dsn_passthrough`` parameters were added.
19792020

19802021
.. versionchanged:: 2.5.0
19812022

@@ -2192,7 +2233,9 @@ Oracledb Methods
21922233
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
21932234
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
21942235
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
2195-
driver_name=oracledb.defaults.driver_name, use_sni=False, handle=0)
2236+
driver_name=oracledb.defaults.driver_name, use_sni=False, \
2237+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
2238+
handle=0)
21962239

21972240
Creates and returns a :ref:`PoolParams Object <poolparam>`. The object
21982241
can be passed to :meth:`oracledb.create_pool()`.
@@ -2555,14 +2598,24 @@ Oracledb Methods
25552598
is used in both the python-oracledb Thin and Thick modes. The default is
25562599
the value of :attr:`defaults.driver_name`.
25572600

2601+
The ``thick_mode_dsn_passthrough`` parameter is expected to be a boolean
2602+
which indicates whether the connect string should be passed unchanged to
2603+
the Oracle Client libraries for parsing when using python-oracledb Thick
2604+
mode. If this parameter is set to *False* in Thick mode, connect strings
2605+
are parsed by python-oracledb itself and a generated connect descriptor is
2606+
sent to the Oracle Client libraries. This value is only used in the
2607+
python-oracledb Thick mode. The default value is
2608+
:attr:`defualts.thick_mode_dsn_passthrough`.
2609+
25582610
The ``handle`` parameter is expected to be an integer which represents a
25592611
pointer to a valid service context handle. This value is only used in the
25602612
python-oracledb Thick mode. It should be used with extreme caution. The
25612613
default value is *0*.
25622614

25632615
.. versionchanged:: 3.0.0
25642616

2565-
The ``use_sni`` and ``instance_name`` parameters were added.
2617+
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
2618+
parameters were added.
25662619

25672620
.. versionchanged:: 2.5.0
25682621

doc/src/api_manual/pool_params.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ PoolParams Methods
5151
pool_boundary=None, use_tcp_fast_open=False, ssl_version=None, \
5252
program=oracledb.defaults.program, machine=oracledb.defaults.machine, \
5353
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
54-
driver_name=oracledb.defaults.driver_name, use_sni=None, handle=None)
54+
driver_name=oracledb.defaults.driver_name, use_sni=None, \
55+
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
56+
handle=None)
5557

5658
Sets one or more of the parameters.
5759

5860
.. versionchanged:: 3.0.0
5961

60-
The ``use_sni`` and ``instance_name`` parameters were added.
62+
The ``use_sni``, ``thick_mode_dsn_passthrough``, and
63+
``instance_name`` parameters were added.
6164

6265
.. versionchanged:: 2.5.0
6366

doc/src/release_notes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ Common Changes
8888
#) Added :meth:`oracledb.register_password_type()` to allow users to register
8989
a function that will be called when a password is supplied as a dictionary
9090
containing the key "type".
91-
#) All connect strings are now parsed by the driver. Previously, only Thin
91+
#) All connect strings are parsed by the driver if the new parameter
92+
``thick_mode_dsn_passthrough`` is set to *True*. Previously, only Thin
9293
mode parsed all connect strings and Thick mode passed the connect string
9394
unchanged to the Oracle Client library to parse. Parameters unrecognized by
9495
the driver in :ref:`Easy Connect strings <easyconnect>` are now ignored.

src/oracledb/base_impl.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ cdef class DefaultsImpl:
241241
public str config_dir
242242
public bint fetch_lobs
243243
public bint fetch_decimals
244+
public bint thick_mode_dsn_passthrough
244245
public uint32_t prefetchrows
245246
public uint32_t stmtcachesize
246247
public str program
@@ -559,6 +560,7 @@ cdef class ConnectParamsImpl:
559560
public str terminal
560561
public str osuser
561562
public str driver_name
563+
public bint thick_mode_dsn_passthrough
562564

563565
cdef int _check_credentials(self) except -1
564566
cdef int _copy(self, ConnectParamsImpl other_params) except -1

src/oracledb/connect_params.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(
105105
osuser: Optional[str] = None,
106106
driver_name: Optional[str] = None,
107107
use_sni: Optional[bool] = None,
108+
thick_mode_dsn_passthrough: Optional[bool] = None,
108109
handle: Optional[int] = None,
109110
):
110111
"""
@@ -302,6 +303,14 @@ def __init__(
302303
bypass the second TLS neogiation that would otherwise be required
303304
(default: False)
304305
306+
- thick_mode_dsn_passthrough: boolean indicating whether to pass the
307+
connect string to the Oracle Client libraries unchanged without
308+
parsing by the driver. Setting this to False makes thick and thin
309+
mode applications behave similarly regarding connection string
310+
parameter handling and locating any optional tnsnames.ora
311+
configuration file (default:
312+
oracledb.defaults.thick_mode_dsn_passthrough)
313+
305314
- handle: an integer representing a pointer to a valid service context
306315
handle. This value is only used in thick mode. It should be used with
307316
extreme caution (default: 0)
@@ -356,7 +365,8 @@ def __repr__(self):
356365
+ f"terminal={self.terminal!r}, "
357366
+ f"osuser={self.osuser!r}, "
358367
+ f"driver_name={self.driver_name!r}, "
359-
+ f"use_sni={self.use_sni!r}"
368+
+ f"use_sni={self.use_sni!r}, "
369+
+ f"thick_mode_dsn_passthrough={self.thick_mode_dsn_passthrough!r}"
360370
+ ")"
361371
)
362372

@@ -740,6 +750,17 @@ def terminal(self) -> str:
740750
"""
741751
return self._impl.terminal
742752

753+
@property
754+
def thick_mode_dsn_passthrough(self) -> bool:
755+
"""
756+
Boolean indicating whether to pass the connect string to the Oracle
757+
Client libraries unchanged without parsing by the driver. Setting this
758+
to False makes thick and thin mode applications behave similarly
759+
regarding connection string parameter handling and locating any
760+
optional tnsnames.ora configuration file.
761+
"""
762+
return self._impl.thick_mode_dsn_passthrough
763+
743764
@property
744765
def user(self) -> str:
745766
"""
@@ -877,6 +898,7 @@ def set(
877898
osuser: Optional[str] = None,
878899
driver_name: Optional[str] = None,
879900
use_sni: Optional[bool] = None,
901+
thick_mode_dsn_passthrough: Optional[bool] = None,
880902
handle: Optional[int] = None,
881903
):
882904
"""
@@ -1061,6 +1083,13 @@ def set(
10611083
- use_sni: boolean indicating whether to use the TLS SNI extension to
10621084
bypass the second TLS neogiation that would otherwise be required
10631085
1086+
- thick_mode_dsn_passthrough: boolean indicating whether to pass the
1087+
connect string to the Oracle Client libraries unchanged without
1088+
parsing by the driver. Setting this to False makes thick and thin
1089+
mode applications behave similarly regarding connection string
1090+
parameter handling and locating any optional tnsnames.ora
1091+
configuration file
1092+
10641093
- handle: an integer representing a pointer to a valid service context
10651094
handle. This value is only used in thick mode. It should be used with
10661095
extreme caution

0 commit comments

Comments
 (0)