Skip to content

Commit cd52799

Browse files
committed
Prepare for backporting of "Send small blobs inline (PR #8318)".
1 parent 287d690 commit cd52799

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/remote/inet.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,11 @@ rem_port* INET_analyze(ClntAuthBlock* cBlock,
717717
REMOTE_PROTOCOL(PROTOCOL_VERSION16, ptype_lazy_send, 7),
718718
REMOTE_PROTOCOL(PROTOCOL_VERSION17, ptype_lazy_send, 8),
719719
REMOTE_PROTOCOL(PROTOCOL_VERSION18, ptype_lazy_send, 9),
720-
REMOTE_PROTOCOL(PROTOCOL_VERSION19, ptype_lazy_send, 10)
720+
REMOTE_PROTOCOL(PROTOCOL_VERSION19, ptype_lazy_send, 10),
721+
REMOTE_PROTOCOL(PROTOCOL_VERSION20, ptype_lazy_send, 11)
721722
};
722-
fb_assert(FB_NELEM(protocols_to_try) <= FB_NELEM(cnct->p_cnct_versions));
723+
static_assert(FB_NELEM(protocols_to_try) <= MAX_CNCT_VERSIONS);
724+
723725
cnct->p_cnct_count = FB_NELEM(protocols_to_try);
724726

725727
for (size_t i = 0; i < cnct->p_cnct_count; i++) {

src/remote/os/win32/xnet.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,11 @@ rem_port* XNET_analyze(ClntAuthBlock* cBlock,
308308
REMOTE_PROTOCOL(PROTOCOL_VERSION16, ptype_batch_send, 7),
309309
REMOTE_PROTOCOL(PROTOCOL_VERSION17, ptype_batch_send, 8),
310310
REMOTE_PROTOCOL(PROTOCOL_VERSION18, ptype_batch_send, 9),
311-
REMOTE_PROTOCOL(PROTOCOL_VERSION19, ptype_batch_send, 10)
311+
REMOTE_PROTOCOL(PROTOCOL_VERSION19, ptype_batch_send, 10),
312+
REMOTE_PROTOCOL(PROTOCOL_VERSION20, ptype_batch_send, 11)
312313
};
313-
fb_assert(FB_NELEM(protocols_to_try) <= FB_NELEM(cnct->p_cnct_versions));
314+
static_assert(FB_NELEM(protocols_to_try) <= MAX_CNCT_VERSIONS);
315+
314316
cnct->p_cnct_count = FB_NELEM(protocols_to_try);
315317

316318
for (size_t i = 0; i < cnct->p_cnct_count; i++) {

src/remote/protocol.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,12 @@ bool_t xdr_protocol(RemoteXdr* xdrs, PACKET* p)
328328

329329
MAP(xdr_cstring_const, connect->p_cnct_user_id);
330330

331-
const size_t CNCT_VERSIONS = FB_NELEM(connect->p_cnct_versions);
332331
tail = connect->p_cnct_versions;
333332
for (USHORT i = 0; i < connect->p_cnct_count; i++, tail++)
334333
{
335334
// ignore the rest of protocols in case of too many suggested versions
336335
p_cnct::p_cnct_repeat dummy;
337-
if (i >= CNCT_VERSIONS)
336+
if (i >= MAX_CNCT_VERSIONS)
338337
{
339338
tail = &dummy;
340339
}
@@ -347,9 +346,9 @@ bool_t xdr_protocol(RemoteXdr* xdrs, PACKET* p)
347346
}
348347

349348
// ignore the rest of protocols in case of too many suggested versions
350-
if (connect->p_cnct_count > CNCT_VERSIONS)
349+
if (connect->p_cnct_count > MAX_CNCT_VERSIONS)
351350
{
352-
connect->p_cnct_count = CNCT_VERSIONS;
351+
connect->p_cnct_count = MAX_CNCT_VERSIONS;
353352
}
354353

355354
DEBUG_PRINTSIZE(xdrs, p->p_operation);
@@ -711,7 +710,7 @@ bool_t xdr_protocol(RemoteXdr* xdrs, PACKET* p)
711710
// p_sqlst_buffer_length was USHORT in older versions
712711
fixupLength(xdrs, prep_stmt->p_sqlst_buffer_length);
713712

714-
if (port->port_protocol >= PROTOCOL_VERSION19)
713+
if (port->port_protocol >= PROTOCOL_PREPARE_FLAG)
715714
MAP(xdr_short, reinterpret_cast<SSHORT&>(prep_stmt->p_sqlst_flags));
716715

717716
DEBUG_PRINTSIZE(xdrs, p->p_operation);

src/remote/protocol.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,17 @@ const USHORT PROTOCOL_VERSION18 = (FB_PROTOCOL_FLAG | 18);
108108
const USHORT PROTOCOL_FETCH_SCROLL = PROTOCOL_VERSION18;
109109

110110
// Protocol 19:
111-
// - supports passing flags to IStatement::prepare
112111
// - supports op_inline_blob
113112

114113
const USHORT PROTOCOL_VERSION19 = (FB_PROTOCOL_FLAG | 19);
115114
const USHORT PROTOCOL_INLINE_BLOB = PROTOCOL_VERSION19;
116115

116+
// Protocol 20:
117+
// - supports passing flags to IStatement::prepare
118+
119+
const USHORT PROTOCOL_VERSION20 = (FB_PROTOCOL_FLAG | 20);
120+
const USHORT PROTOCOL_PREPARE_FLAG = PROTOCOL_VERSION20;
121+
117122
// Architecture types
118123

119124
enum P_ARCH
@@ -380,6 +385,9 @@ typedef struct p_malloc
380385

381386
// Connect Block (Client to server)
382387

388+
// Servers before FB6 (PROTOCOL_VERSION20) uses only first 10 elements of p_cnct_versions
389+
constexpr size_t MAX_CNCT_VERSIONS = 11;
390+
383391
typedef struct p_cnct
384392
{
385393
USHORT p_cnct_operation; // unused
@@ -395,7 +403,7 @@ typedef struct p_cnct
395403
USHORT p_cnct_min_type; // Minimum type (unused)
396404
USHORT p_cnct_max_type; // Maximum type
397405
USHORT p_cnct_weight; // Preference weight
398-
} p_cnct_versions[10];
406+
} p_cnct_versions[MAX_CNCT_VERSIONS];
399407
} P_CNCT;
400408

401409
#ifdef ASYMMETRIC_PROTOCOLS_ONLY

0 commit comments

Comments
 (0)