From 1680be19ca24ca15af9e95ed8a4a0c57520e005c Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Wed, 3 Aug 2022 16:36:52 -0400 Subject: [PATCH] some refactoring --- src/Client/Connection.cpp | 5 +++-- src/Core/ProtocolDefines.h | 2 ++ src/Server/TCPHandler.cpp | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Client/Connection.cpp b/src/Client/Connection.cpp index 602f2d812c4..bbd4c380831 100644 --- a/src/Client/Connection.cpp +++ b/src/Client/Connection.cpp @@ -170,7 +170,7 @@ void Connection::connect(const ConnectionTimeouts & timeouts) sendHello(); receiveHello(); - if (server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY) + if (server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) sendAddendum(); LOG_TRACE(log_wrapper.get(), "Connected to {} server version {}.{}.{}.", @@ -271,7 +271,8 @@ void Connection::sendHello() void Connection::sendAddendum() { - writeStringBinary(quota_key, *out); + if (server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY) + writeStringBinary(quota_key, *out); out->next(); } diff --git a/src/Core/ProtocolDefines.h b/src/Core/ProtocolDefines.h index 5794cf5f6d6..cf0a9d8b887 100644 --- a/src/Core/ProtocolDefines.h +++ b/src/Core/ProtocolDefines.h @@ -60,4 +60,6 @@ #define DBMS_MIN_PROTOCOL_VERSION_WITH_VIEW_IF_PERMITTED 54457 +#define DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM 54458 + #define DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY 54458 diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index 0076ee5eb0c..d0d061590ca 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -134,7 +134,7 @@ void TCPHandler::runImpl() { receiveHello(); sendHello(); - if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY) + if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) receiveAddendum(); if (!is_interserver_mode) /// In interserver mode queries are executed without a session context. @@ -1082,8 +1082,11 @@ void TCPHandler::receiveHello() void TCPHandler::receiveAddendum() { - readStringBinary(quota_key, *in); - session->getClientInfo().quota_key = quota_key; + if (client_tcp_protocol_version >= DBMS_MIN_PROTOCOL_VERSION_WITH_QUOTA_KEY) + { + readStringBinary(quota_key, *in); + session->getClientInfo().quota_key = quota_key; + } }