diff --git a/doc/README.wire.compression.html b/doc/README.wire.compression.html
new file mode 100644
index 0000000000..798b501683
--- /dev/null
+++ b/doc/README.wire.compression.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Compressing data passed
+over the wire.
+
+
+In most of cases compressing data passed over the wire is useless
+– one spends more time to compress a packet of data than to
+pass it over the typical LAN. But for WAN access data compression may
+be rather efficient way to enhance performance, specially when it can
+provide instead package size decrees packages' number decrees –
+that's the case for Firebird when it transfers a lot of data like big
+result set. zlib library (http://www.zlib.net/)
+is used by Firebird to compress data passed over the wire.
+By default wire compression is off, to turn it on you should set
+“WireCompression=true” in Firebird configuration on
+client. Compression setting is done by client to let only some
+clients that really need it use compression. Server gets compression
+setting from client when connection is established. Certainly only
+Firebird 3 (or higher) wire protocol supports compression. When
+compression is turned on Z flag is shown in client/server version
+info – for example: LI-T3.0.0.31451 Firebird 3.0 Beta 1/tcp
+(fbs)/P13:Z.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/remote/client/interface.cpp b/src/remote/client/interface.cpp
index 244c9260e1..7e4e5ef71b 100644
--- a/src/remote/client/interface.cpp
+++ b/src/remote/client/interface.cpp
@@ -1456,8 +1456,7 @@ void Attachment::getInfo(IStatus* status,
item_length, items, 0, 0, buffer_length, temp_buffer);
string version;
- version.printf("%s/%s%s", FB_VERSION, port->port_version->str_data,
- port->port_crypt_complete ? ":C" : "");
+ port->versionInfo(version);
MERGE_database_info(temp_buffer, buffer, buffer_length,
DbImplementation::current.backwardCompatibleImplementation(), 3, 1,
diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp
index 5611498e07..97119fd387 100644
--- a/src/remote/remote.cpp
+++ b/src/remote/remote.cpp
@@ -37,6 +37,7 @@
#include "../common/db_alias.h"
#include "firebird/Interface.h"
#include "../common/os/mod_loader.h"
+#include "../jrd/license.h"
#ifdef DEV_BUILD
Firebird::AtomicCounter rem_port::portCounter;
@@ -1360,6 +1361,23 @@ void SrvAuthBlock::putKey(Firebird::IStatus* status, Firebird::FbCryptKey* crypt
}
}
+void rem_port::versionInfo(Firebird::string& version)
+{
+ version.printf("%s/%s", FB_VERSION, port_version->str_data);
+#ifndef WIRE_COMPRESS_SUPPORT
+ if (port_crypt_plugin)
+ version += ":C";
+#else
+ if (port_crypt_plugin || port_compressed)
+ version += ':';
+ if (port_crypt_plugin)
+ version += 'C';
+ if (port_compressed)
+ version += 'Z';
+#endif
+}
+
+
#ifdef WIRE_COMPRESS_SUPPORT
namespace {
class ZLib
@@ -1402,6 +1420,16 @@ namespace {
};
Firebird::InitInstance zlib;
+
+ void* allocFunc(void*, uInt items, uInt size)
+ {
+ return MemoryPool::globalAlloc(items * size);
+ }
+
+ void freeFunc(void*, void* address)
+ {
+ MemoryPool::globalFree(address);
+ }
}
#endif // WIRE_COMPRESS_SUPPORT
@@ -1597,16 +1625,16 @@ void rem_port::initCompression()
#ifdef WIRE_COMPRESS_SUPPORT
if (port_protocol >= PROTOCOL_VERSION13 && !port_compressed)
{
- port_send_stream.zalloc = Z_NULL;
- port_send_stream.zfree = Z_NULL;
+ port_send_stream.zalloc = allocFunc;
+ port_send_stream.zfree = freeFunc;
port_send_stream.opaque = Z_NULL;
int ret = zlib().deflateInit(&port_send_stream, Z_DEFAULT_COMPRESSION);
if (ret != Z_OK)
(Firebird::Arg::Gds(isc_random) << "compression stream init error").raise(); // add error code
port_send_stream.next_out = NULL;
- port_recv_stream.zalloc = Z_NULL;
- port_recv_stream.zfree = Z_NULL;
+ port_recv_stream.zalloc = allocFunc;
+ port_recv_stream.zfree = freeFunc;
port_recv_stream.opaque = Z_NULL;
port_recv_stream.avail_in = 0;
port_recv_stream.next_in = Z_NULL;
diff --git a/src/remote/remote.h b/src/remote/remote.h
index d83ccb0865..93025e8ad9 100644
--- a/src/remote/remote.h
+++ b/src/remote/remote.h
@@ -989,6 +989,7 @@ public:
void linkParent(rem_port* const parent);
void unlinkParent();
const Firebird::RefPtr& getPortConfig() const;
+ void versionInfo(Firebird::string& version);
template
void getHandle(T*& blk, OBJCT id)
diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp
index a2bcaca6f3..a2604d5021 100644
--- a/src/remote/server/server.cpp
+++ b/src/remote/server/server.cpp
@@ -39,7 +39,6 @@
#include "../remote/remote.h"
#include "../common/file_params.h"
#include "../common/ThreadStart.h"
-#include "../jrd/license.h"
#include "../common/classes/timestamp.h"
#include "../remote/merge_proto.h"
#include "../remote/parse_proto.h"
@@ -3746,8 +3745,7 @@ void rem_port::info(P_OP op, P_INFO* stuff, PACKET* sendL)
if (!(status_vector.getStatus() & Firebird::IStatus::FB_HAS_ERRORS))
{
string version;
- version.printf("%s/%s%s", FB_VERSION, this->port_version->str_data,
- this->port_crypt_complete ? ":C" : "");
+ versionInfo(version);
info_db_len = MERGE_database_info(temp_buffer, //temp
buffer, buffer_length,
DbImplementation::current.backwardCompatibleImplementation(), 4, 1,