Skip to content

Commit

Permalink
Implemented #6954: fb_info_protocol_version support
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPeshkoff committed Sep 9, 2021
1 parent 5d99498 commit 18d59a5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/isql/show.epp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ static const UCHAR db_items[] =
isc_info_db_id,
#endif
fb_info_crypt_state,
fb_info_protocol_version,
fb_info_wire_crypt,
isc_info_end
};
Expand Down Expand Up @@ -560,6 +561,14 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
sprintf (info, "Wire crypt plugin: %.*s%s", length, d, separator);
break;

case fb_info_protocol_version:
value_out = ISQL_vax_integer(d, length);
if (value_out)
sprintf(info, "Protocol version = %" SQUADFORMAT"%s", value_out, separator);
else
sprintf(info, "Embedded connection%s", separator);
break;

#ifdef DEV_BUILD
case isc_info_db_id:
{
Expand Down Expand Up @@ -3536,7 +3545,7 @@ static void show_db()
return;
END_ERROR;

SCHAR info_buf[BUFFER_LENGTH400];
SCHAR info_buf[BUFFER_LENGTH512];

// First general database parameters

Expand Down
4 changes: 4 additions & 0 deletions src/jrd/inf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,10 @@ void INF_database_info(thread_db* tdbb,
length = INF_convert(att->getActualIdleTimeout(), buffer);
break;

case fb_info_protocol_version:
length = INF_convert(0, buffer);
break;

case fb_info_features:
{
static const unsigned char features[] = ENGINE_FEATURES;
Expand Down
7 changes: 6 additions & 1 deletion src/remote/client/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,11 @@ void Attachment::getInfo(CheckStatusWrapper* status,
HalfStaticArray<UCHAR, 1024> temp;

CHECK_HANDLE(rdb, isc_bad_db_handle);

rem_port* port = rdb->rdb_port;
USHORT protocol = memchr(items, fb_info_protocol_version, item_length) ? port->port_protocol : 0;
protocol &= FB_PROTOCOL_MASK;

RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION);

UCHAR* temp_buffer = temp.getBuffer(buffer_length);
Expand All @@ -1902,7 +1906,8 @@ void Attachment::getInfo(CheckStatusWrapper* status,
MERGE_database_info(temp_buffer, buffer, buffer_length,
DbImplementation::current.backwardCompatibleImplementation(), 3, 1,
reinterpret_cast<const UCHAR*>(version.c_str()),
reinterpret_cast<const UCHAR*>(port->port_host->str_data));
reinterpret_cast<const UCHAR*>(port->port_host->str_data),
protocol);
}
catch (const Exception& ex)
{
Expand Down
24 changes: 23 additions & 1 deletion src/remote/merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ USHORT MERGE_database_info(const UCHAR* const in,
USHORT class_,
USHORT base_level,
const UCHAR* version,
const UCHAR* id)
const UCHAR* id,
USHORT protocol)
{
/**************************************
*
Expand Down Expand Up @@ -98,6 +99,23 @@ USHORT MERGE_database_info(const UCHAR* const in,
switch (input.getClumpTag())
{
case isc_info_end:
if (protocol)
{
--out;
if (out + (1 + 2 + 2 + 1) <= end)
{
PUT(out, (UCHAR)fb_info_protocol_version);
PUT_WORD(out, 2u);
PUT_WORD(out, protocol);
protocol = 0;

PUT(out, (UCHAR)isc_info_end);
}
else
PUT(out, (UCHAR)isc_info_truncated);
}
// fall down...

case isc_info_truncated:
return out - start;

Expand Down Expand Up @@ -142,6 +160,10 @@ USHORT MERGE_database_info(const UCHAR* const in,
PUT(out, (UCHAR) base_level);
break;

case fb_info_protocol_version:
--out;
break;

default:
{
USHORT length = input.getClumpLength();
Expand Down
2 changes: 1 addition & 1 deletion src/remote/merge_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define REMOTE_MERGE_PROTO_H

USHORT MERGE_database_info(const UCHAR*, UCHAR*, USHORT, USHORT,
USHORT, USHORT, const UCHAR*, const UCHAR*); //, ULONG);
USHORT, USHORT, const UCHAR*, const UCHAR*, USHORT);

#endif // REMOTE_MERGE_PROTO_H

5 changes: 4 additions & 1 deletion src/remote/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4391,11 +4391,14 @@ void rem_port::info(P_OP op, P_INFO* stuff, PACKET* sendL)
{
string version;
versionInfo(version);
USHORT protocol = memchr(stuff->p_info_items.cstr_address, fb_info_protocol_version,
stuff->p_info_items.cstr_length) ? port_protocol & FB_PROTOCOL_MASK : 0;
info_db_len = MERGE_database_info(temp_buffer, //temp
buffer, buffer_length,
DbImplementation::current.backwardCompatibleImplementation(), 4, 1,
reinterpret_cast<const UCHAR*>(version.c_str()),
reinterpret_cast<const UCHAR*>(this->port_host->str_data));
reinterpret_cast<const UCHAR*>(this->port_host->str_data),
protocol);
}
break;

Expand Down

0 comments on commit 18d59a5

Please sign in to comment.