File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -408,6 +408,14 @@ namespace fbcpp
408408 return outMetadata;
409409 }
410410
411+ // /
412+ // / @brief Provides direct access to the raw output message buffer.
413+ // /
414+ std::vector<std::byte>& getOutputMessage () noexcept
415+ {
416+ return outMessage;
417+ }
418+
411419 // /
412420 // / @brief Returns the type classification reported by the server.
413421 // /
Original file line number Diff line number Diff line change @@ -336,6 +336,29 @@ BOOST_AUTO_TEST_CASE(descriptorMetadataFields)
336336 BOOST_CHECK (inDescriptors[0 ].alias .empty ());
337337}
338338
339+ BOOST_AUTO_TEST_CASE (getOutputMessageContainsFetchedValueAtMetadataOffset)
340+ {
341+ const auto database = getTempFile (" Statement-getOutputMessageContainsFetchedValueAtMetadataOffset.fdb" );
342+
343+ Attachment attachment{CLIENT , database, AttachmentOptions ().setCreateDatabase (true )};
344+ FbDropDatabase attachmentDrop{attachment};
345+
346+ Transaction transaction{attachment};
347+ Statement stmt{attachment, transaction, " select 42 from rdb$database" };
348+
349+ auto & outMsg = stmt.getOutputMessage ();
350+ BOOST_CHECK (!outMsg.empty ());
351+
352+ const auto valueOffset = stmt.getOutputDescriptors ()[0 ].offset ;
353+
354+ BOOST_REQUIRE (stmt.execute (transaction));
355+ BOOST_CHECK_EQUAL (stmt.getInt32 (0 ).value (), 42 );
356+
357+ BOOST_REQUIRE_GE (outMsg.size (), valueOffset + sizeof (std::int32_t ));
358+ const auto * data = &outMsg[valueOffset];
359+ BOOST_CHECK_EQUAL (*reinterpret_cast <const std::int32_t *>(data), 42 );
360+ }
361+
339362BOOST_AUTO_TEST_SUITE_END ()
340363
341364
You can’t perform that action at this time.
0 commit comments