8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:03:02 +01:00

Implemented #6954: fb_info_protocol_version support

This commit is contained in:
Alex Peshkoff 2021-09-09 17:26:15 +03:00
parent 5d99498645
commit 18d59a5e79
6 changed files with 48 additions and 5 deletions

View File

@ -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
};
@ -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:
{
@ -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

View File

@ -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;

View File

@ -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);
@ -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)
{

View File

@ -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)
{
/**************************************
*
@ -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;
@ -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();

View File

@ -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

View File

@ -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;