Skip to content

Commit 2ec3306

Browse files
committed
Backport fix for #8675 - fbclient incompatible to older ods
1 parent af1e441 commit 2ec3306

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

src/yvalve/YObjects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ class YAttachment final :
519519
void destroy(unsigned dstrFlags);
520520
void shutdown();
521521
isc_db_handle& getHandle();
522+
void getOdsVersion(USHORT* majorVersion, USHORT* minorVersion);
522523

523524
// IAttachment implementation
524525
void getInfo(Firebird::CheckStatusWrapper* status, unsigned int itemsLength,
@@ -596,6 +597,10 @@ class YAttachment final :
596597
HandleArray<YTransaction> childTransactions;
597598
Firebird::Array<CleanupCallback*> cleanupHandlers;
598599
Firebird::StatusHolder savedStatus; // Do not use raise() method of this class in yValve.
600+
601+
private:
602+
USHORT cachedOdsMajorVersion = 0;
603+
USHORT cachedOdsMinorVersion = 0;
599604
};
600605

601606
class YService final :

src/yvalve/blob.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* tran
141141
(FB_INTEGER, characterSetId)
142142
) outputMessage(&statusWrapper, MasterInterfacePtr());
143143

144+
USHORT majorOdsVersion = 0;
145+
USHORT minorOdsVersion = 0;
146+
attachment->getOdsVersion(&majorOdsVersion, &minorOdsVersion);
147+
144148
{ // scope
145149
constexpr auto sql = R"""(
146150
select f.rdb$field_sub_type,
@@ -184,7 +188,7 @@ void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* tran
184188

185189
if (!flag)
186190
{
187-
constexpr auto sql = R"""(
191+
constexpr auto sqlPackages = R"""(
188192
select f.rdb$field_sub_type,
189193
f.rdb$segment_length,
190194
f.rdb$character_set_id
@@ -196,6 +200,19 @@ void iscBlobLookupDescImpl(Why::YAttachment* attachment, Why::YTransaction* tran
196200
pp.rdb$package_name is null
197201
)""";
198202

203+
constexpr auto sqlNoPackages = R"""(
204+
select f.rdb$field_sub_type,
205+
f.rdb$segment_length,
206+
f.rdb$character_set_id
207+
from rdb$procedure_parameters pp
208+
join rdb$fields f
209+
on f.rdb$field_name = pp.rdb$field_source
210+
where pp.rdb$procedure_name = ? and
211+
pp.rdb$parameter_name = ?
212+
)""";
213+
214+
const auto sql = majorOdsVersion >= ODS_VERSION12 ? sqlPackages : sqlNoPackages;
215+
199216
FB_MESSAGE(InputMessage, CheckStatusWrapper,
200217
(FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), procedureName)
201218
(FB_VARCHAR(MAX_SQL_IDENTIFIER_LEN), fieldName)

src/yvalve/utl.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ const int BSTR_input = 0;
117117
const int BSTR_output = 1;
118118
const int BSTR_alloc = 2;
119119

120-
static void get_ods_version(CheckStatusWrapper*, IAttachment*, USHORT*, USHORT*);
121120
static void isc_expand_dpb_internal(const UCHAR** dpb, SSHORT* dpb_size, ...);
122121

123122

@@ -556,7 +555,7 @@ void UtilInterface::getFbVersion(CheckStatusWrapper* status, IAttachment* att,
556555
}
557556

558557
USHORT ods_version, ods_minor_version;
559-
get_ods_version(status, att, &ods_version, &ods_minor_version);
558+
UTL_get_ods_version(status, att, &ods_version, &ods_minor_version);
560559
if (status->getState() & Firebird::IStatus::STATE_ERRORS)
561560
return;
562561

@@ -2947,7 +2946,7 @@ int API_ROUTINE gds__thread_start(FPTR_INT_VOID_PTR* entrypoint,
29472946
#endif
29482947

29492948

2950-
static void get_ods_version(CheckStatusWrapper* status, IAttachment* att,
2949+
void UTL_get_ods_version(CheckStatusWrapper* status, IAttachment* att,
29512950
USHORT* ods_version, USHORT* ods_minor_version)
29522951
{
29532952
/**************************************

src/yvalve/utl_proto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ void setLogin(Firebird::ClumpletWriter& dpb, bool spbFlag);
8484
// Put status vector strings into strings circular buffer
8585
void makePermanentVector(ISC_STATUS* v) throw();
8686

87+
void UTL_get_ods_version(Firebird::CheckStatusWrapper* status, Firebird::IAttachment* att,
88+
USHORT* ods_version, USHORT* ods_minor_version);
89+
8790
namespace Why
8891
{
8992
void threadCleanup();

src/yvalve/why.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,6 +5580,22 @@ isc_db_handle& YAttachment::getHandle()
55805580
return handle;
55815581
}
55825582

5583+
void YAttachment::getOdsVersion(USHORT* majorVersion, USHORT* minorVersion)
5584+
{
5585+
if (cachedOdsMajorVersion == 0)
5586+
{
5587+
FbLocalStatus status;
5588+
return UTL_get_ods_version(&status, this, &cachedOdsMajorVersion, &cachedOdsMinorVersion);
5589+
status.check();
5590+
}
5591+
5592+
if (majorVersion)
5593+
*majorVersion = cachedOdsMajorVersion;
5594+
5595+
if (minorVersion)
5596+
*minorVersion = cachedOdsMinorVersion;
5597+
}
5598+
55835599
YAttachment::~YAttachment()
55845600
{
55855601
if (handle)

0 commit comments

Comments
 (0)