Skip to content

Commit 00e371d

Browse files
Improved parsers (#352, #362).
1 parent 8b594bd commit 00e371d

File tree

11 files changed

+925
-327
lines changed

11 files changed

+925
-327
lines changed

doc/src/release_notes.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ Thin Mode Changes
2222
(`issue 368 <https://github.com/oracle/python-oracledb/issues/368>`__).
2323
#) Fixed bug resulting in an inability to connect to Oracle Database 23ai
2424
instances which have fast authentication disabled.
25+
#) Reworked connection string parser:
26+
27+
- Fixed parsing an :ref:`Easy Connect <easyconnect>` string starting
28+
with "`//`" (`issue 352
29+
<https://github.com/oracle/python-oracledb/issues/352>`__).
30+
- Fixed parsing an Easy Connect string with multiple hosts (a comma for
31+
multiple addresses and a semicolon for multiple address lists).
32+
- Fixed parsing an Easy Connect string with a static IPv6 address.
33+
- Improved error when a connect descriptor parameter like DESCRIPTION or
34+
ADDRESS incorrectly contains a simple value instead of nested values.
35+
36+
#) Reworked :ref:`tnsnames.ora<optnetfiles>` file parser to handle multiple
37+
aliases found on separate lines (`issue 362
38+
<https://github.com/oracle/python-oracledb/issues/362>`__).
39+
2540

2641
Thick Mode Changes
2742
++++++++++++++++++

src/oracledb/base_impl.pxd

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ cdef class Address(ConnectParamsNode):
398398
public uint32_t https_proxy_port
399399

400400
cdef str build_connect_string(self)
401+
cdef int set_protocol(self, str value) except -1
401402

402403

403404
cdef class AddressList(ConnectParamsNode):
@@ -429,6 +430,7 @@ cdef class Description(ConnectParamsNode):
429430

430431
cdef str _build_duration_str(self, double value)
431432
cdef str build_connect_string(self, str cid=*)
433+
cdef int set_server_type(self, str value) except -1
432434

433435

434436
cdef class DescriptionList(ConnectParamsNode):
@@ -482,10 +484,6 @@ cdef class ConnectParamsImpl:
482484
cdef object _get_token_expires(self, str token)
483485
cdef str _get_wallet_password(self)
484486
cdef int _parse_connect_string(self, str connect_string) except -1
485-
cdef int _parse_easy_connect_string(self, str connect_string,
486-
object match) except -1
487-
cdef int _process_connect_descriptor(self, str connecte_string,
488-
dict args) except -1
489487
cdef int _set_access_token(self, object val, int error_num) except -1
490488
cdef int _set_access_token_param(self, object val) except -1
491489
cdef int _set_new_password(self, str password) except -1
@@ -788,6 +786,21 @@ cdef class BindVar:
788786
uint32_t row_num, uint32_t num_elements,
789787
bint defer_type_assignment) except -1
790788

789+
cdef class BaseParser:
790+
791+
cdef:
792+
ssize_t pos, temp_pos, num_chars
793+
str data_as_str
794+
int data_kind
795+
void *data
796+
797+
cdef Py_UCS4 get_current_char(self)
798+
cdef int initialize(self, str data_to_parse) except -1
799+
cdef int parse_keyword(self) except -1
800+
cdef int parse_quoted_string(self, Py_UCS4 quote_type) except -1
801+
cdef int skip_spaces(self) except -1
802+
803+
791804
cdef int get_preferred_num_type(int16_t precision, int8_t scale)
792805
cdef void pack_uint16(char_type *buf, uint16_t x, int order)
793806
cdef void pack_uint32(char_type *buf, uint32_t x, int order)

src/oracledb/base_impl.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import inspect
5050
import json
5151
import os
5252
import random
53-
import re
5453
import secrets
5554
import ssl
5655
import sys
@@ -94,6 +93,7 @@ include "impl/base/constants.pxi"
9493
include "impl/base/defaults.pyx"
9594
include "impl/base/utils.pyx"
9695
include "impl/base/buffer.pyx"
96+
include "impl/base/parsers.pyx"
9797
include "impl/base/oson.pyx"
9898
include "impl/base/vector.pyx"
9999
include "impl/base/connect_params.pyx"

src/oracledb/errors.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ def _raise_not_supported(feature: str) -> None:
247247
ERR_INVALID_COLL_INDEX_GET = 2038
248248
ERR_INVALID_COLL_INDEX_SET = 2039
249249
ERR_EXECUTE_MODE_ONLY_FOR_DML = 2040
250-
ERR_MISSING_QUOTE_IN_STRING = 2041
251-
ERR_MISSING_QUOTE_IN_IDENTIFIER = 2042
250+
ERR_MISSING_ENDING_SINGLE_QUOTE = 2041
251+
ERR_MISSING_ENDING_DOUBLE_QUOTE = 2042
252252
ERR_DBOBJECT_ATTR_MAX_SIZE_VIOLATED = 2043
253253
ERR_DBOBJECT_ELEMENT_MAX_SIZE_VIOLATED = 2044
254254
ERR_INVALID_ARRAYSIZE = 2045
@@ -349,8 +349,8 @@ def _raise_not_supported(feature: str) -> None:
349349
28: ERR_CONNECTION_CLOSED,
350350
600: ERR_CONNECTION_CLOSED,
351351
1005: ERR_NO_CREDENTIALS,
352-
1740: ERR_MISSING_QUOTE_IN_IDENTIFIER,
353-
1756: ERR_MISSING_QUOTE_IN_STRING,
352+
1740: ERR_MISSING_ENDING_DOUBLE_QUOTE,
353+
1756: ERR_MISSING_ENDING_SINGLE_QUOTE,
354354
22165: (
355355
ERR_INVALID_COLL_INDEX_SET,
356356
r"index \[(?P<index>\d+)\] must be in the range of "
@@ -610,8 +610,8 @@ def _raise_not_supported(feature: str) -> None:
610610
"not provided"
611611
),
612612
ERR_MISSING_FILE: "file '{file_name}' is missing or unreadable",
613-
ERR_MISSING_QUOTE_IN_IDENTIFIER: 'missing ending quote (") in identifier',
614-
ERR_MISSING_QUOTE_IN_STRING: "missing ending quote (') in string",
613+
ERR_MISSING_ENDING_DOUBLE_QUOTE: 'missing ending quote (")',
614+
ERR_MISSING_ENDING_SINGLE_QUOTE: "missing ending quote (')",
615615
ERR_MISSING_TYPE_NAME_FOR_OBJECT_VAR: (
616616
"no object type specified for object variable"
617617
),

0 commit comments

Comments
 (0)