Skip to content

Commit ca96f9e

Browse files
committed
Backport #8318: Send small blobs inline.
1 parent 81c5f17 commit ca96f9e

File tree

17 files changed

+1281
-75
lines changed

17 files changed

+1281
-75
lines changed

src/include/fb_types.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ typedef FB_UINT64 ISC_UINT64;
8080

8181
typedef ISC_QUAD SQUAD;
8282

83+
const SQUAD NULL_BLOB = { 0, 0 };
84+
85+
inline bool operator==(const SQUAD& s1, const SQUAD& s2)
86+
{
87+
return s1.gds_quad_high == s2.gds_quad_high &&
88+
s2.gds_quad_low == s1.gds_quad_low;
89+
}
90+
91+
inline bool operator>(const SQUAD& s1, const SQUAD& s2)
92+
{
93+
return (s1.gds_quad_high > s2.gds_quad_high) ||
94+
(s1.gds_quad_high == s2.gds_quad_high &&
95+
s1.gds_quad_low > s2.gds_quad_low);
96+
}
97+
98+
8399
/*
84100
* TMN: some misc data types from all over the place
85101
*/

src/include/firebird/FirebirdInterface.idl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ version: // 3.0 => 4.0
520520
version: // 3.0.7 => 3.0.8, 4.0.0 => 4.0.1
521521
[notImplementedAction if ::FB_UsedInYValve then defaultAction else call deprecatedFree(status) endif]
522522
void free(Status status);
523+
524+
version: // 5.0.3, 6.0
525+
// Inline blob transfer
526+
uint getMaxInlineBlobSize(Status status);
527+
void setMaxInlineBlobSize(Status status, uint size);
523528
}
524529

525530
interface Batch : ReferenceCounted
@@ -712,6 +717,15 @@ version: // 3.0.7 => 3.0.8, 4.0.0 => 4.0.1
712717
void detach(Status status);
713718
[notImplementedAction if ::FB_UsedInYValve then defaultAction else call deprecatedDropDatabase(status) endif]
714719
void dropDatabase(Status status);
720+
721+
version: // 5.0.3, 6.0
722+
// Blob caching by client
723+
uint getMaxBlobCacheSize(Status status);
724+
void setMaxBlobCacheSize(Status status, uint size);
725+
726+
// Inline blob transfer
727+
uint getMaxInlineBlobSize(Status status);
728+
void setMaxInlineBlobSize(Status status, uint size);
715729
}
716730

717731
interface Service : ReferenceCounted

src/include/firebird/IdlFbInterfaces.h

Lines changed: 188 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ namespace Firebird
18691869
}
18701870
};
18711871

1872-
#define FIREBIRD_ISTATEMENT_VERSION 5u
1872+
#define FIREBIRD_ISTATEMENT_VERSION 6u
18731873

18741874
class IStatement : public IReferenceCounted
18751875
{
@@ -1891,6 +1891,8 @@ namespace Firebird
18911891
void (CLOOP_CARG *setTimeout)(IStatement* self, IStatus* status, unsigned timeOut) CLOOP_NOEXCEPT;
18921892
IBatch* (CLOOP_CARG *createBatch)(IStatement* self, IStatus* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) CLOOP_NOEXCEPT;
18931893
void (CLOOP_CARG *free)(IStatement* self, IStatus* status) CLOOP_NOEXCEPT;
1894+
unsigned (CLOOP_CARG *getMaxInlineBlobSize)(IStatement* self, IStatus* status) CLOOP_NOEXCEPT;
1895+
void (CLOOP_CARG *setMaxInlineBlobSize)(IStatement* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
18941896
};
18951897

18961898
protected:
@@ -2063,6 +2065,33 @@ namespace Firebird
20632065
static_cast<VTable*>(this->cloopVTable)->free(this, status);
20642066
StatusType::checkException(status);
20652067
}
2068+
2069+
template <typename StatusType> unsigned getMaxInlineBlobSize(StatusType* status)
2070+
{
2071+
if (cloopVTable->version < 6)
2072+
{
2073+
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
2074+
StatusType::checkException(status);
2075+
return 0;
2076+
}
2077+
StatusType::clearException(status);
2078+
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxInlineBlobSize(this, status);
2079+
StatusType::checkException(status);
2080+
return ret;
2081+
}
2082+
2083+
template <typename StatusType> void setMaxInlineBlobSize(StatusType* status, unsigned size)
2084+
{
2085+
if (cloopVTable->version < 6)
2086+
{
2087+
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
2088+
StatusType::checkException(status);
2089+
return;
2090+
}
2091+
StatusType::clearException(status);
2092+
static_cast<VTable*>(this->cloopVTable)->setMaxInlineBlobSize(this, status, size);
2093+
StatusType::checkException(status);
2094+
}
20662095
};
20672096

20682097
#define FIREBIRD_IBATCH_VERSION 4u
@@ -2498,7 +2527,7 @@ namespace Firebird
24982527
}
24992528
};
25002529

2501-
#define FIREBIRD_IATTACHMENT_VERSION 5u
2530+
#define FIREBIRD_IATTACHMENT_VERSION 6u
25022531

25032532
class IAttachment : public IReferenceCounted
25042533
{
@@ -2531,6 +2560,10 @@ namespace Firebird
25312560
IReplicator* (CLOOP_CARG *createReplicator)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
25322561
void (CLOOP_CARG *detach)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
25332562
void (CLOOP_CARG *dropDatabase)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2563+
unsigned (CLOOP_CARG *getMaxBlobCacheSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2564+
void (CLOOP_CARG *setMaxBlobCacheSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
2565+
unsigned (CLOOP_CARG *getMaxInlineBlobSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2566+
void (CLOOP_CARG *setMaxInlineBlobSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
25342567
};
25352568

25362569
protected:
@@ -2799,6 +2832,60 @@ namespace Firebird
27992832
static_cast<VTable*>(this->cloopVTable)->dropDatabase(this, status);
28002833
StatusType::checkException(status);
28012834
}
2835+
2836+
template <typename StatusType> unsigned getMaxBlobCacheSize(StatusType* status)
2837+
{
2838+
if (cloopVTable->version < 6)
2839+
{
2840+
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
2841+
StatusType::checkException(status);
2842+
return 0;
2843+
}
2844+
StatusType::clearException(status);
2845+
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxBlobCacheSize(this, status);
2846+
StatusType::checkException(status);
2847+
return ret;
2848+
}
2849+
2850+
template <typename StatusType> void setMaxBlobCacheSize(StatusType* status, unsigned size)
2851+
{
2852+
if (cloopVTable->version < 6)
2853+
{
2854+
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
2855+
StatusType::checkException(status);
2856+
return;
2857+
}
2858+
StatusType::clearException(status);
2859+
static_cast<VTable*>(this->cloopVTable)->setMaxBlobCacheSize(this, status, size);
2860+
StatusType::checkException(status);
2861+
}
2862+
2863+
template <typename StatusType> unsigned getMaxInlineBlobSize(StatusType* status)
2864+
{
2865+
if (cloopVTable->version < 6)
2866+
{
2867+
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
2868+
StatusType::checkException(status);
2869+
return 0;
2870+
}
2871+
StatusType::clearException(status);
2872+
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxInlineBlobSize(this, status);
2873+
StatusType::checkException(status);
2874+
return ret;
2875+
}
2876+
2877+
template <typename StatusType> void setMaxInlineBlobSize(StatusType* status, unsigned size)
2878+
{
2879+
if (cloopVTable->version < 6)
2880+
{
2881+
StatusType::setVersionError(status, "IAttachment", cloopVTable->version, 6);
2882+
StatusType::checkException(status);
2883+
return;
2884+
}
2885+
StatusType::clearException(status);
2886+
static_cast<VTable*>(this->cloopVTable)->setMaxInlineBlobSize(this, status, size);
2887+
StatusType::checkException(status);
2888+
}
28022889
};
28032890

28042891
#define FIREBIRD_ISERVICE_VERSION 5u
@@ -10549,6 +10636,8 @@ namespace Firebird
1054910636
this->setTimeout = &Name::cloopsetTimeoutDispatcher;
1055010637
this->createBatch = &Name::cloopcreateBatchDispatcher;
1055110638
this->free = &Name::cloopfreeDispatcher;
10639+
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
10640+
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
1055210641
}
1055310642
} vTable;
1055410643

@@ -10775,6 +10864,35 @@ namespace Firebird
1077510864
}
1077610865
}
1077710866

10867+
static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status) CLOOP_NOEXCEPT
10868+
{
10869+
StatusType status2(status);
10870+
10871+
try
10872+
{
10873+
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
10874+
}
10875+
catch (...)
10876+
{
10877+
StatusType::catchException(&status2);
10878+
return static_cast<unsigned>(0);
10879+
}
10880+
}
10881+
10882+
static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
10883+
{
10884+
StatusType status2(status);
10885+
10886+
try
10887+
{
10888+
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
10889+
}
10890+
catch (...)
10891+
{
10892+
StatusType::catchException(&status2);
10893+
}
10894+
}
10895+
1077810896
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
1077910897
{
1078010898
try
@@ -10829,6 +10947,8 @@ namespace Firebird
1082910947
virtual void setTimeout(StatusType* status, unsigned timeOut) = 0;
1083010948
virtual IBatch* createBatch(StatusType* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) = 0;
1083110949
virtual void free(StatusType* status) = 0;
10950+
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
10951+
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
1083210952
};
1083310953

1083410954
template <typename Name, typename StatusType, typename Base>
@@ -11654,6 +11774,10 @@ namespace Firebird
1165411774
this->createReplicator = &Name::cloopcreateReplicatorDispatcher;
1165511775
this->detach = &Name::cloopdetachDispatcher;
1165611776
this->dropDatabase = &Name::cloopdropDatabaseDispatcher;
11777+
this->getMaxBlobCacheSize = &Name::cloopgetMaxBlobCacheSizeDispatcher;
11778+
this->setMaxBlobCacheSize = &Name::cloopsetMaxBlobCacheSizeDispatcher;
11779+
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
11780+
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
1165711781
}
1165811782
} vTable;
1165911783

@@ -12038,6 +12162,64 @@ namespace Firebird
1203812162
}
1203912163
}
1204012164

12165+
static unsigned CLOOP_CARG cloopgetMaxBlobCacheSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
12166+
{
12167+
StatusType status2(status);
12168+
12169+
try
12170+
{
12171+
return static_cast<Name*>(self)->Name::getMaxBlobCacheSize(&status2);
12172+
}
12173+
catch (...)
12174+
{
12175+
StatusType::catchException(&status2);
12176+
return static_cast<unsigned>(0);
12177+
}
12178+
}
12179+
12180+
static void CLOOP_CARG cloopsetMaxBlobCacheSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
12181+
{
12182+
StatusType status2(status);
12183+
12184+
try
12185+
{
12186+
static_cast<Name*>(self)->Name::setMaxBlobCacheSize(&status2, size);
12187+
}
12188+
catch (...)
12189+
{
12190+
StatusType::catchException(&status2);
12191+
}
12192+
}
12193+
12194+
static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
12195+
{
12196+
StatusType status2(status);
12197+
12198+
try
12199+
{
12200+
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
12201+
}
12202+
catch (...)
12203+
{
12204+
StatusType::catchException(&status2);
12205+
return static_cast<unsigned>(0);
12206+
}
12207+
}
12208+
12209+
static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
12210+
{
12211+
StatusType status2(status);
12212+
12213+
try
12214+
{
12215+
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
12216+
}
12217+
catch (...)
12218+
{
12219+
StatusType::catchException(&status2);
12220+
}
12221+
}
12222+
1204112223
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
1204212224
{
1204312225
try
@@ -12103,6 +12285,10 @@ namespace Firebird
1210312285
virtual IReplicator* createReplicator(StatusType* status) = 0;
1210412286
virtual void detach(StatusType* status) = 0;
1210512287
virtual void dropDatabase(StatusType* status) = 0;
12288+
virtual unsigned getMaxBlobCacheSize(StatusType* status) = 0;
12289+
virtual void setMaxBlobCacheSize(StatusType* status, unsigned size) = 0;
12290+
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
12291+
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
1210612292
};
1210712293

1210812294
template <typename Name, typename StatusType, typename Base>

src/include/firebird/impl/consts_pub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
#define isc_dpb_upgrade_db 97
133133
#define isc_dpb_parallel_workers 100
134134
#define isc_dpb_worker_attach 101
135+
#define isc_dpb_max_blob_cache_size 103
136+
#define isc_dpb_max_inline_blob_size 104
135137

136138

137139
/**************************************************/

src/include/firebird/impl/inf_pub.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ enum db_info_types
189189
fb_info_wire_rcv_bytes = 157,
190190
fb_info_wire_roundtrips = 158,
191191

192+
fb_info_max_blob_cache_size = 159,
193+
fb_info_max_inline_blob_size = 160,
194+
192195
isc_info_db_last_value /* Leave this LAST! */
193196
};
194197

0 commit comments

Comments
 (0)