Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/fb-cpp/Attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Attachment::Attachment(Client& client, const std::string& uri, const AttachmentO
if (const auto forcedWrites = options.getForcedWrites())
dpbBuilder->insertInt(&statusWrapper, isc_dpb_force_write, *forcedWrites ? 1 : 0);

if (const auto maxInlineBlobSize = options.getMaxInlineBlobSize())
dpbBuilder->insertInt(&statusWrapper, isc_dpb_max_inline_blob_size, static_cast<int>(*maxInlineBlobSize));

if (const auto maxBlobCacheSize = options.getMaxBlobCacheSize())
dpbBuilder->insertInt(&statusWrapper, isc_dpb_max_blob_cache_size, static_cast<int>(*maxBlobCacheSize));

auto dispatcher = fbRef(master->getDispatcher());
const auto dpbBuffer = dpbBuilder->getBuffer(&statusWrapper);
const auto dpbBufferLen = dpbBuilder->getBufferLength(&statusWrapper);
Expand Down
42 changes: 42 additions & 0 deletions src/fb-cpp/Attachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,55 @@ namespace fbcpp
return *this;
}

///
/// Returns the maximum size of blobs the server may send inline with the rows
/// of a result set.
///
const std::optional<std::uint32_t>& getMaxInlineBlobSize() const
{
return maxInlineBlobSize;
}

///
/// Sets the maximum size of blobs the server may send inline with the rows of
/// a result set (`isc_dpb_max_inline_blob_size`), avoiding a round trip per blob
/// over remote connections. Zero disables inline blobs.
/// Requires Firebird 5.0.3 or later; ignored by older versions.
///
AttachmentOptions& setMaxInlineBlobSize(std::uint32_t value)
{
maxInlineBlobSize = value;
return *this;
}

///
/// Returns the maximum size of the client-side cache for inline blobs.
///
const std::optional<std::uint32_t>& getMaxBlobCacheSize() const
{
return maxBlobCacheSize;
}

///
/// Sets the maximum size of the client-side cache for inline blobs
/// (`isc_dpb_max_blob_cache_size`). Zero disables inline blobs.
/// Requires Firebird 5.0.3 or later; ignored by older versions.
///
AttachmentOptions& setMaxBlobCacheSize(std::uint32_t value)
{
maxBlobCacheSize = value;
return *this;
}

private:
std::optional<std::string> connectionCharSet;
std::optional<std::string> userName;
std::optional<std::string> password;
std::optional<std::string> role;
std::optional<std::uint32_t> sqlDialect;
std::optional<bool> forcedWrites;
std::optional<std::uint32_t> maxInlineBlobSize;
std::optional<std::uint32_t> maxBlobCacheSize;
std::vector<std::uint8_t> dpb;
bool createDatabase = false;
};
Expand Down
16 changes: 16 additions & 0 deletions src/test/Attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,4 +860,20 @@ BOOST_AUTO_TEST_CASE(resetSession)
transaction2.commit();
}

BOOST_AUTO_TEST_CASE(inlineBlobOptions)
{
const auto database = getTempFile("Attachment-inlineBlobOptions.fdb");
Attachment attachment1{getClient(), database, AttachmentOptions().setCreateDatabase(true).setForcedWrites(false)};
FbDropDatabase attachmentDrop{attachment1};

Attachment attachment2{
getClient(), database, AttachmentOptions().setMaxInlineBlobSize(1000u).setMaxBlobCacheSize(200000u)};

impl::StatusWrapper statusWrapper{getClient()};
BOOST_CHECK_EQUAL(attachment2.getHandle()->getMaxInlineBlobSize(&statusWrapper), 1000u);
BOOST_CHECK_EQUAL(attachment2.getHandle()->getMaxBlobCacheSize(&statusWrapper), 200000u);

attachment2.disconnect();
}

BOOST_AUTO_TEST_SUITE_END()
Loading