Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send small blobs inline. #8318

Merged
merged 10 commits into from
Feb 5, 2025
16 changes: 16 additions & 0 deletions src/include/fb_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ typedef FB_UINT64 ISC_UINT64;

typedef ISC_QUAD SQUAD;

const SQUAD NULL_BLOB = { 0, 0 };

inline bool operator==(const SQUAD& s1, const SQUAD& s2)
{
return s1.gds_quad_high == s2.gds_quad_high &&
s2.gds_quad_low == s1.gds_quad_low;
}

inline bool operator>(const SQUAD& s1, const SQUAD& s2)
{
return (s1.gds_quad_high > s2.gds_quad_high) ||
(s1.gds_quad_high == s2.gds_quad_high &&
s1.gds_quad_low > s2.gds_quad_low);
}


/*
* TMN: some misc data types from all over the place
*/
Expand Down
14 changes: 14 additions & 0 deletions src/include/firebird/FirebirdInterface.idl
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ version: // 3.0 => 4.0
version: // 3.0.7 => 3.0.8, 4.0.0 => 4.0.1
[notImplementedAction if ::FB_UsedInYValve then defaultAction else call deprecatedFree(status) endif]
void free(Status status);

version: // 6.0
// Inline blob transfer
uint getMaxInlineBlobSize(Status status);
void setMaxInlineBlobSize(Status status, uint size);
}

interface Batch : ReferenceCounted
Expand Down Expand Up @@ -713,6 +718,15 @@ version: // 3.0.7 => 3.0.8, 4.0.0 => 4.0.1
void detach(Status status);
[notImplementedAction if ::FB_UsedInYValve then defaultAction else call deprecatedDropDatabase(status) endif]
void dropDatabase(Status status);

version: // 6.0
// Blob caching by client
uint getMaxBlobCacheSize(Status status);
void setMaxBlobCacheSize(Status status, uint size);

// Inline blob transfer
uint getMaxInlineBlobSize(Status status);
void setMaxInlineBlobSize(Status status, uint size);
}

interface Service : ReferenceCounted
Expand Down
190 changes: 188 additions & 2 deletions src/include/firebird/IdlFbInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ namespace Firebird
}
};

#define FIREBIRD_ISTATEMENT_VERSION 5u
#define FIREBIRD_ISTATEMENT_VERSION 6u

class IStatement : public IReferenceCounted
{
Expand All @@ -1891,6 +1891,8 @@ namespace Firebird
void (CLOOP_CARG *setTimeout)(IStatement* self, IStatus* status, unsigned timeOut) CLOOP_NOEXCEPT;
IBatch* (CLOOP_CARG *createBatch)(IStatement* self, IStatus* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) CLOOP_NOEXCEPT;
void (CLOOP_CARG *free)(IStatement* self, IStatus* status) CLOOP_NOEXCEPT;
unsigned (CLOOP_CARG *getMaxInlineBlobSize)(IStatement* self, IStatus* status) CLOOP_NOEXCEPT;
void (CLOOP_CARG *setMaxInlineBlobSize)(IStatement* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
};

protected:
Expand Down Expand Up @@ -2064,6 +2066,33 @@ namespace Firebird
static_cast<VTable*>(this->cloopVTable)->free(this, status);
StatusType::checkException(status);
}

template <typename StatusType> unsigned getMaxInlineBlobSize(StatusType* status)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
StatusType::checkException(status);
return 0;
}
StatusType::clearException(status);
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxInlineBlobSize(this, status);
StatusType::checkException(status);
return ret;
}

template <typename StatusType> void setMaxInlineBlobSize(StatusType* status, unsigned size)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
StatusType::checkException(status);
return;
}
StatusType::clearException(status);
static_cast<VTable*>(this->cloopVTable)->setMaxInlineBlobSize(this, status, size);
StatusType::checkException(status);
}
};

#define FIREBIRD_IBATCH_VERSION 4u
Expand Down Expand Up @@ -2499,7 +2528,7 @@ namespace Firebird
}
};

#define FIREBIRD_IATTACHMENT_VERSION 5u
#define FIREBIRD_IATTACHMENT_VERSION 6u

class IAttachment : public IReferenceCounted
{
Expand Down Expand Up @@ -2532,6 +2561,10 @@ namespace Firebird
IReplicator* (CLOOP_CARG *createReplicator)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
void (CLOOP_CARG *detach)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
void (CLOOP_CARG *dropDatabase)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
unsigned (CLOOP_CARG *getMaxBlobCacheSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
void (CLOOP_CARG *setMaxBlobCacheSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
unsigned (CLOOP_CARG *getMaxInlineBlobSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
void (CLOOP_CARG *setMaxInlineBlobSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
};

protected:
Expand Down Expand Up @@ -2800,6 +2833,60 @@ namespace Firebird
static_cast<VTable*>(this->cloopVTable)->dropDatabase(this, status);
StatusType::checkException(status);
}

template <typename StatusType> unsigned getMaxBlobCacheSize(StatusType* status)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
StatusType::checkException(status);
return 0;
}
StatusType::clearException(status);
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxBlobCacheSize(this, status);
StatusType::checkException(status);
return ret;
}

template <typename StatusType> void setMaxBlobCacheSize(StatusType* status, unsigned size)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
StatusType::checkException(status);
return;
}
StatusType::clearException(status);
static_cast<VTable*>(this->cloopVTable)->setMaxBlobCacheSize(this, status, size);
StatusType::checkException(status);
}

template <typename StatusType> unsigned getMaxInlineBlobSize(StatusType* status)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
StatusType::checkException(status);
return 0;
}
StatusType::clearException(status);
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxInlineBlobSize(this, status);
StatusType::checkException(status);
return ret;
}

template <typename StatusType> void setMaxInlineBlobSize(StatusType* status, unsigned size)
{
if (cloopVTable->version < 6)
{
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
StatusType::checkException(status);
return;
}
StatusType::clearException(status);
static_cast<VTable*>(this->cloopVTable)->setMaxInlineBlobSize(this, status, size);
StatusType::checkException(status);
}
};

#define FIREBIRD_ISERVICE_VERSION 5u
Expand Down Expand Up @@ -10525,6 +10612,8 @@ namespace Firebird
this->setTimeout = &Name::cloopsetTimeoutDispatcher;
this->createBatch = &Name::cloopcreateBatchDispatcher;
this->free = &Name::cloopfreeDispatcher;
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
}
} vTable;

Expand Down Expand Up @@ -10751,6 +10840,35 @@ namespace Firebird
}
}

static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
}
catch (...)
{
StatusType::catchException(&status2);
return static_cast<unsigned>(0);
}
}

static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
}
catch (...)
{
StatusType::catchException(&status2);
}
}

static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
{
try
Expand Down Expand Up @@ -10805,6 +10923,8 @@ namespace Firebird
virtual void setTimeout(StatusType* status, unsigned timeOut) = 0;
virtual IBatch* createBatch(StatusType* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) = 0;
virtual void free(StatusType* status) = 0;
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
};

template <typename Name, typename StatusType, typename Base>
Expand Down Expand Up @@ -11630,6 +11750,10 @@ namespace Firebird
this->createReplicator = &Name::cloopcreateReplicatorDispatcher;
this->detach = &Name::cloopdetachDispatcher;
this->dropDatabase = &Name::cloopdropDatabaseDispatcher;
this->getMaxBlobCacheSize = &Name::cloopgetBlobCacheSizeDispatcher;
this->setMaxBlobCacheSize = &Name::cloopsetBlobCacheSizeDispatcher;
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
}
} vTable;

Expand Down Expand Up @@ -12014,6 +12138,64 @@ namespace Firebird
}
}

static unsigned CLOOP_CARG cloopgetBlobCacheSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
return static_cast<Name*>(self)->Name::getMaxBlobCacheSize(&status2);
}
catch (...)
{
StatusType::catchException(&status2);
return static_cast<unsigned>(0);
}
}

static void CLOOP_CARG cloopsetBlobCacheSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
static_cast<Name*>(self)->Name::setMaxBlobCacheSize(&status2, size);
}
catch (...)
{
StatusType::catchException(&status2);
}
}

static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
}
catch (...)
{
StatusType::catchException(&status2);
return static_cast<unsigned>(0);
}
}

static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
{
StatusType status2(status);

try
{
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
}
catch (...)
{
StatusType::catchException(&status2);
}
}

static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
{
try
Expand Down Expand Up @@ -12079,6 +12261,10 @@ namespace Firebird
virtual IReplicator* createReplicator(StatusType* status) = 0;
virtual void detach(StatusType* status) = 0;
virtual void dropDatabase(StatusType* status) = 0;
virtual unsigned getMaxBlobCacheSize(StatusType* status) = 0;
virtual void setMaxBlobCacheSize(StatusType* status, unsigned size) = 0;
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
};

template <typename Name, typename StatusType, typename Base>
Expand Down
Loading
Loading