Skip to content

Commit c8678fa

Browse files
Fixed bug using AQ when attempting to dequeue with an invalid message
id.
1 parent 883c148 commit c8678fa

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Thin Mode Changes
4242
:attr:`DeqOptions.correlation` for buffered delivery mode.
4343
#) Fixed bug when fetching multiple consecutive null values into a :ref:`data
4444
frame <dataframeformat>`.
45+
#) Fixed bug using :ref:`Oracle Advanced Queuing <aqusermanual>` when
46+
attempting to dequeue using an invalid :attr:`DeqOptions.msgid`.
4547

4648
Thick Mode Changes
4749
++++++++++++++++++

src/oracledb/impl/thin/messages/aq_deq.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ cdef class AqDeqMessage(AqBaseMessage):
6767
bytes consumer_name_bytes
6868
bytes correlation_bytes
6969
bytes condition_bytes
70+
bytes msgid_bytes
7071
uint16_t delivery_mode
7172
int deq_flags
7273
self._write_function_code(buf)
@@ -135,7 +136,10 @@ cdef class AqDeqMessage(AqBaseMessage):
135136
if consumer_name_bytes is not None:
136137
buf.write_bytes_with_length(consumer_name_bytes)
137138
if self.deq_options_impl.msgid:
138-
buf.write_bytes(self.deq_options_impl.msgid)
139+
msgid_bytes = self.deq_options_impl.msgid[:16]
140+
if len(msgid_bytes) < 16:
141+
msgid_bytes += bytes(16 - len(msgid_bytes))
142+
buf.write_bytes(msgid_bytes)
139143
if correlation_bytes is not None:
140144
buf.write_bytes_with_length(correlation_bytes)
141145
buf.write_bytes(self.queue_impl.payload_toid)

tests/test_7800_aq_raw.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,22 @@ def test_7829(self):
482482
self.conn.commit()
483483
self.assertEqual(msg.payload, value)
484484

485+
def test_7830(self):
486+
"7830 - test deq options with msgid > 16 bytes"
487+
queue = self.get_and_clear_queue("TEST_RAW_QUEUE")
488+
queue.deqoptions.msgid = b"invalid_msgid_123456789"
489+
queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
490+
with self.assertRaisesFullCode("ORA-25263"):
491+
queue.deqone()
492+
493+
def test_7831(self):
494+
"7831 - test deq options with msgid < 16 bytes"
495+
queue = self.get_and_clear_queue("TEST_RAW_QUEUE")
496+
queue.deqoptions.msgid = b"short_msgid"
497+
queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
498+
with self.assertRaisesFullCode("ORA-25263"):
499+
queue.deqone()
500+
485501

486502
if __name__ == "__main__":
487503
test_env.run_test_cases()

tests/test_7900_aq_raw_async.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,22 @@ async def test_7925(self):
421421
await self.conn.commit()
422422
self.assertEqual(msg.payload, value)
423423

424+
async def test_7926(self):
425+
"7926 - test deq options with msgid > 16 bytes"
426+
queue = await self.get_and_clear_queue("TEST_RAW_QUEUE")
427+
queue.deqoptions.msgid = b"invalid_msgid_123456789"
428+
queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
429+
with self.assertRaisesFullCode("ORA-25263"):
430+
await queue.deqone()
431+
432+
async def test_7927(self):
433+
"7927 - test deq options with msgid < 16 bytes"
434+
queue = await self.get_and_clear_queue("TEST_RAW_QUEUE")
435+
queue.deqoptions.msgid = b"short_msgid"
436+
queue.deqoptions.wait = oracledb.DEQ_NO_WAIT
437+
with self.assertRaisesFullCode("ORA-25263"):
438+
await queue.deqone()
439+
424440

425441
if __name__ == "__main__":
426442
test_env.run_test_cases()

0 commit comments

Comments
 (0)