Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/fb-cpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ namespace fbcpp
return outMetadata;
}

///
/// @brief Provides direct access to the raw output message buffer.
///
std::vector<std::byte>& getOutputMessage() noexcept
{
return outMessage;
}

///
/// @brief Returns the type classification reported by the server.
///
Expand Down
23 changes: 23 additions & 0 deletions src/test/Statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,29 @@ BOOST_AUTO_TEST_CASE(descriptorMetadataFields)
BOOST_CHECK(inDescriptors[0].alias.empty());
}

BOOST_AUTO_TEST_CASE(getOutputMessageContainsFetchedValueAtMetadataOffset)
{
const auto database = getTempFile("Statement-getOutputMessageContainsFetchedValueAtMetadataOffset.fdb");

Attachment attachment{CLIENT, database, AttachmentOptions().setCreateDatabase(true)};
FbDropDatabase attachmentDrop{attachment};

Transaction transaction{attachment};
Statement stmt{attachment, transaction, "select 42 from rdb$database"};

auto& outMsg = stmt.getOutputMessage();
BOOST_CHECK(!outMsg.empty());

const auto valueOffset = stmt.getOutputDescriptors()[0].offset;

BOOST_REQUIRE(stmt.execute(transaction));
BOOST_CHECK_EQUAL(stmt.getInt32(0).value(), 42);

BOOST_REQUIRE_GE(outMsg.size(), valueOffset + sizeof(std::int32_t));
const auto* data = &outMsg[valueOffset];
BOOST_CHECK_EQUAL(*reinterpret_cast<const std::int32_t*>(data), 42);
}

BOOST_AUTO_TEST_SUITE_END()


Expand Down
Loading