Skip to content

Commit 8343c72

Browse files
authored
Merge pull request #8318 from FirebirdSQL/work/wire_inline_blobs
Send small blobs inline.
2 parents 6f5040d + 7503c84 commit 8343c72

File tree

17 files changed

+1277
-75
lines changed

17 files changed

+1277
-75
lines changed

src/include/fb_types.h

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

8282
typedef ISC_QUAD SQUAD;
8383

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

src/include/firebird/FirebirdInterface.idl

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

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

718732
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:
@@ -2064,6 +2066,33 @@ namespace Firebird
20642066
static_cast<VTable*>(this->cloopVTable)->free(this, status);
20652067
StatusType::checkException(status);
20662068
}
2069+
2070+
template <typename StatusType> unsigned getMaxInlineBlobSize(StatusType* status)
2071+
{
2072+
if (cloopVTable->version < 6)
2073+
{
2074+
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
2075+
StatusType::checkException(status);
2076+
return 0;
2077+
}
2078+
StatusType::clearException(status);
2079+
unsigned ret = static_cast<VTable*>(this->cloopVTable)->getMaxInlineBlobSize(this, status);
2080+
StatusType::checkException(status);
2081+
return ret;
2082+
}
2083+
2084+
template <typename StatusType> void setMaxInlineBlobSize(StatusType* status, unsigned size)
2085+
{
2086+
if (cloopVTable->version < 6)
2087+
{
2088+
StatusType::setVersionError(status, "IStatement", cloopVTable->version, 6);
2089+
StatusType::checkException(status);
2090+
return;
2091+
}
2092+
StatusType::clearException(status);
2093+
static_cast<VTable*>(this->cloopVTable)->setMaxInlineBlobSize(this, status, size);
2094+
StatusType::checkException(status);
2095+
}
20672096
};
20682097

20692098
#define FIREBIRD_IBATCH_VERSION 4u
@@ -2499,7 +2528,7 @@ namespace Firebird
24992528
}
25002529
};
25012530

2502-
#define FIREBIRD_IATTACHMENT_VERSION 5u
2531+
#define FIREBIRD_IATTACHMENT_VERSION 6u
25032532

25042533
class IAttachment : public IReferenceCounted
25052534
{
@@ -2532,6 +2561,10 @@ namespace Firebird
25322561
IReplicator* (CLOOP_CARG *createReplicator)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
25332562
void (CLOOP_CARG *detach)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
25342563
void (CLOOP_CARG *dropDatabase)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2564+
unsigned (CLOOP_CARG *getMaxBlobCacheSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2565+
void (CLOOP_CARG *setMaxBlobCacheSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
2566+
unsigned (CLOOP_CARG *getMaxInlineBlobSize)(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT;
2567+
void (CLOOP_CARG *setMaxInlineBlobSize)(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT;
25352568
};
25362569

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

28052892
#define FIREBIRD_ISERVICE_VERSION 5u
@@ -10554,6 +10641,8 @@ namespace Firebird
1055410641
this->setTimeout = &Name::cloopsetTimeoutDispatcher;
1055510642
this->createBatch = &Name::cloopcreateBatchDispatcher;
1055610643
this->free = &Name::cloopfreeDispatcher;
10644+
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
10645+
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
1055710646
}
1055810647
} vTable;
1055910648

@@ -10780,6 +10869,35 @@ namespace Firebird
1078010869
}
1078110870
}
1078210871

10872+
static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status) CLOOP_NOEXCEPT
10873+
{
10874+
StatusType status2(status);
10875+
10876+
try
10877+
{
10878+
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
10879+
}
10880+
catch (...)
10881+
{
10882+
StatusType::catchException(&status2);
10883+
return static_cast<unsigned>(0);
10884+
}
10885+
}
10886+
10887+
static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IStatement* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
10888+
{
10889+
StatusType status2(status);
10890+
10891+
try
10892+
{
10893+
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
10894+
}
10895+
catch (...)
10896+
{
10897+
StatusType::catchException(&status2);
10898+
}
10899+
}
10900+
1078310901
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
1078410902
{
1078510903
try
@@ -10834,6 +10952,8 @@ namespace Firebird
1083410952
virtual void setTimeout(StatusType* status, unsigned timeOut) = 0;
1083510953
virtual IBatch* createBatch(StatusType* status, IMessageMetadata* inMetadata, unsigned parLength, const unsigned char* par) = 0;
1083610954
virtual void free(StatusType* status) = 0;
10955+
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
10956+
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
1083710957
};
1083810958

1083910959
template <typename Name, typename StatusType, typename Base>
@@ -11659,6 +11779,10 @@ namespace Firebird
1165911779
this->createReplicator = &Name::cloopcreateReplicatorDispatcher;
1166011780
this->detach = &Name::cloopdetachDispatcher;
1166111781
this->dropDatabase = &Name::cloopdropDatabaseDispatcher;
11782+
this->getMaxBlobCacheSize = &Name::cloopgetBlobCacheSizeDispatcher;
11783+
this->setMaxBlobCacheSize = &Name::cloopsetBlobCacheSizeDispatcher;
11784+
this->getMaxInlineBlobSize = &Name::cloopgetMaxInlineBlobSizeDispatcher;
11785+
this->setMaxInlineBlobSize = &Name::cloopsetMaxInlineBlobSizeDispatcher;
1166211786
}
1166311787
} vTable;
1166411788

@@ -12043,6 +12167,64 @@ namespace Firebird
1204312167
}
1204412168
}
1204512169

12170+
static unsigned CLOOP_CARG cloopgetBlobCacheSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
12171+
{
12172+
StatusType status2(status);
12173+
12174+
try
12175+
{
12176+
return static_cast<Name*>(self)->Name::getMaxBlobCacheSize(&status2);
12177+
}
12178+
catch (...)
12179+
{
12180+
StatusType::catchException(&status2);
12181+
return static_cast<unsigned>(0);
12182+
}
12183+
}
12184+
12185+
static void CLOOP_CARG cloopsetBlobCacheSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
12186+
{
12187+
StatusType status2(status);
12188+
12189+
try
12190+
{
12191+
static_cast<Name*>(self)->Name::setMaxBlobCacheSize(&status2, size);
12192+
}
12193+
catch (...)
12194+
{
12195+
StatusType::catchException(&status2);
12196+
}
12197+
}
12198+
12199+
static unsigned CLOOP_CARG cloopgetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status) CLOOP_NOEXCEPT
12200+
{
12201+
StatusType status2(status);
12202+
12203+
try
12204+
{
12205+
return static_cast<Name*>(self)->Name::getMaxInlineBlobSize(&status2);
12206+
}
12207+
catch (...)
12208+
{
12209+
StatusType::catchException(&status2);
12210+
return static_cast<unsigned>(0);
12211+
}
12212+
}
12213+
12214+
static void CLOOP_CARG cloopsetMaxInlineBlobSizeDispatcher(IAttachment* self, IStatus* status, unsigned size) CLOOP_NOEXCEPT
12215+
{
12216+
StatusType status2(status);
12217+
12218+
try
12219+
{
12220+
static_cast<Name*>(self)->Name::setMaxInlineBlobSize(&status2, size);
12221+
}
12222+
catch (...)
12223+
{
12224+
StatusType::catchException(&status2);
12225+
}
12226+
}
12227+
1204612228
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) CLOOP_NOEXCEPT
1204712229
{
1204812230
try
@@ -12108,6 +12290,10 @@ namespace Firebird
1210812290
virtual IReplicator* createReplicator(StatusType* status) = 0;
1210912291
virtual void detach(StatusType* status) = 0;
1211012292
virtual void dropDatabase(StatusType* status) = 0;
12293+
virtual unsigned getMaxBlobCacheSize(StatusType* status) = 0;
12294+
virtual void setMaxBlobCacheSize(StatusType* status, unsigned size) = 0;
12295+
virtual unsigned getMaxInlineBlobSize(StatusType* status) = 0;
12296+
virtual void setMaxInlineBlobSize(StatusType* status, unsigned size) = 0;
1211112297
};
1211212298

1211312299
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
@@ -133,6 +133,8 @@
133133
#define isc_dpb_parallel_workers 100
134134
#define isc_dpb_worker_attach 101
135135
#define isc_dpb_owner 102
136+
#define isc_dpb_max_blob_cache_size 103
137+
#define isc_dpb_max_inline_blob_size 104
136138

137139

138140
/**************************************************/

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)