Skip to content

Commit 2701ab2

Browse files
Fixed a bug resulting in error "DPI-1046: parameter value cannot be a
NULL pointer" when attributes "condition", "consumername", "correlation", "msgid", "transformation" and "exceptionq" are set on the dequeue options, enqueue options and message properties objects.
1 parent f729235 commit 2701ab2

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

doc/src/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ Thin Mode Changes
2727
Thick Mode Changes
2828
++++++++++++++++++
2929

30+
#) Fixed a bug resulting in error ``DPI-1046: parameter value cannot be a NULL
31+
pointer`` when the attributes :attr:`DeqOptions.condition`,
32+
:attr:`DeqOptions.consumername`, :attr:`DeqOptions.correlation`,
33+
:attr:`DeqOptions.msgid`, :attr:`DeqOptions.transformation`,
34+
:attr:`EnqOptions.transformation`, :attr:`MessageProperties.correlation`,
35+
or :attr:`MessageProperties.exceptionq` are set to ``None``.
36+
3037
Common Changes
3138
++++++++++++++
3239

src/oracledb/impl/thick/queue.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ cdef class ThickDeqOptionsImpl(BaseDeqOptionsImpl):
263263
Internal method for setting the condition.
264264
"""
265265
cdef StringBuffer buf = StringBuffer()
266-
buf.set_value(value)
266+
buf.set_value(value or "")
267267
if dpiDeqOptions_setCondition(self._handle, buf.ptr, buf.length) < 0:
268268
_raise_from_odpi()
269269

@@ -272,7 +272,7 @@ cdef class ThickDeqOptionsImpl(BaseDeqOptionsImpl):
272272
Internal method for setting the consumer name.
273273
"""
274274
cdef StringBuffer buf = StringBuffer()
275-
buf.set_value(value)
275+
buf.set_value(value or "")
276276
if dpiDeqOptions_setConsumerName(self._handle, buf.ptr,
277277
buf.length) < 0:
278278
_raise_from_odpi()
@@ -282,7 +282,7 @@ cdef class ThickDeqOptionsImpl(BaseDeqOptionsImpl):
282282
Internal method for setting the correlation.
283283
"""
284284
cdef StringBuffer buf = StringBuffer()
285-
buf.set_value(value)
285+
buf.set_value(value or "")
286286
if dpiDeqOptions_setCorrelation(self._handle, buf.ptr, buf.length) < 0:
287287
_raise_from_odpi()
288288

@@ -305,7 +305,7 @@ cdef class ThickDeqOptionsImpl(BaseDeqOptionsImpl):
305305
Internal method for setting the message id.
306306
"""
307307
cdef StringBuffer buf = StringBuffer()
308-
buf.set_value(value)
308+
buf.set_value(value or "")
309309
if dpiDeqOptions_setMsgId(self._handle, buf.ptr, buf.length) < 0:
310310
_raise_from_odpi()
311311

@@ -321,7 +321,7 @@ cdef class ThickDeqOptionsImpl(BaseDeqOptionsImpl):
321321
Internal method for setting the transformation.
322322
"""
323323
cdef StringBuffer buf = StringBuffer()
324-
buf.set_value(value)
324+
buf.set_value(value or "")
325325
if dpiDeqOptions_setTransformation(self._handle, buf.ptr,
326326
buf.length) < 0:
327327
_raise_from_odpi()
@@ -383,7 +383,7 @@ cdef class ThickEnqOptionsImpl(BaseEnqOptionsImpl):
383383
Internal method for setting the transformation.
384384
"""
385385
cdef StringBuffer buf = StringBuffer()
386-
buf.set_value(value)
386+
buf.set_value(value or "")
387387
if dpiEnqOptions_setTransformation(self._handle, buf.ptr,
388388
buf.length) < 0:
389389
_raise_from_odpi()
@@ -543,7 +543,7 @@ cdef class ThickMsgPropsImpl(BaseMsgPropsImpl):
543543
Internal method for setting the correlation.
544544
"""
545545
cdef StringBuffer buf = StringBuffer()
546-
buf.set_value(value)
546+
buf.set_value(value or "")
547547
if dpiMsgProps_setCorrelation(self._handle, buf.ptr, buf.length) < 0:
548548
_raise_from_odpi()
549549

@@ -559,7 +559,7 @@ cdef class ThickMsgPropsImpl(BaseMsgPropsImpl):
559559
Internal method for setting the exception queue.
560560
"""
561561
cdef StringBuffer buf = StringBuffer()
562-
buf.set_value(value)
562+
buf.set_value(value or "")
563563
if dpiMsgProps_setExceptionQ(self._handle, buf.ptr, buf.length) < 0:
564564
_raise_from_odpi()
565565

tests/test_7800_aq_raw.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,47 @@ def test_7825(self):
421421
with self.assertRaisesFullCode("DPY-2062"):
422422
queue.enqone(props)
423423

424+
def test_7826(self):
425+
"7826 - test providing null values on queue dequeue options"
426+
queue = self.conn.queue("TEST_RAW_QUEUE")
427+
str_value = "test - 7826"
428+
bytes_value = str_value.encode()
429+
for name in [
430+
"condition",
431+
"consumername",
432+
"correlation",
433+
"msgid",
434+
"transformation",
435+
]:
436+
value = bytes_value if name == "msgid" else str_value
437+
with self.subTest(name=name):
438+
setattr(queue.deqoptions, name, value)
439+
self.assertEqual(getattr(queue.deqoptions, name), value)
440+
setattr(queue.deqoptions, name, None)
441+
self.assertIsNone(getattr(queue.deqoptions, name))
442+
443+
def test_7827(self):
444+
"7827 - test providing null values on queue enqueue options"
445+
queue = self.conn.queue("TEST_RAW_QUEUE")
446+
value = "test - 7827"
447+
for name in ["transformation"]:
448+
with self.subTest(name=name):
449+
setattr(queue.enqoptions, name, value)
450+
self.assertEqual(getattr(queue.enqoptions, name), value)
451+
setattr(queue.enqoptions, name, None)
452+
self.assertIsNone(getattr(queue.enqoptions, name))
453+
454+
def test_7828(self):
455+
"7828 - test providing null correlation on message properties"
456+
props = self.conn.msgproperties()
457+
value = "test - 7828"
458+
for name in ["correlation", "exceptionq"]:
459+
with self.subTest(name=name):
460+
setattr(props, name, value)
461+
self.assertEqual(getattr(props, name), value)
462+
setattr(props, name, None)
463+
self.assertIsNone(getattr(props, name))
464+
424465

425466
if __name__ == "__main__":
426467
test_env.run_test_cases()

0 commit comments

Comments
 (0)