From e785bb908ec0a1f70fe653cf20b05c30fad1788c Mon Sep 17 00:00:00 2001 From: Andrey Zvonov Date: Mon, 18 Nov 2024 23:17:10 +0000 Subject: [PATCH] fix after review --- src/Client/Connection.cpp | 6 ++++-- src/Interpreters/Context.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Client/Connection.cpp b/src/Client/Connection.cpp index 5587d793ec2..ace3c2fe9af 100644 --- a/src/Client/Connection.cpp +++ b/src/Client/Connection.cpp @@ -833,7 +833,7 @@ void Connection::sendQuery( writeVectorBinary(external_roles, buffer); buffer.finalize(); - LOG_DEBUG(log_wrapper.get(), "Sending external_roles with query: [{}] ({})", fmt::join(external_roles, ", "), external_roles.size()); + LOG_TRACE(log_wrapper.get(), "Sending external_roles with query: [{}] ({})", fmt::join(external_roles, ", "), external_roles.size()); writeStringBinary(external_roles_str, *out); } @@ -858,7 +858,9 @@ void Connection::sendQuery( data += query; data += query_id; data += client_info->initial_user; - data += external_roles_str; + // Also for backwards compatibility + if (server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_INTERSERVER_EXTERNALLY_GRANTED_ROLES) + data += external_roles_str; /// TODO: add source/target host/ip-address std::string hash = encodeSHA256(data); diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 953fcfb253c..ce788842e3e 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -1569,8 +1569,8 @@ void Context::setExternalRolesWithLock(const std::vector & new_external_ro current_roles->insert(current_roles->end(), new_external_roles.begin(), new_external_roles.end()); else current_roles = std::make_shared>(new_external_roles); + need_recalculate_access = true; } - need_recalculate_access = true; } void Context::setCurrentRolesImpl(const std::vector & new_current_roles, bool throw_if_not_granted, bool skip_if_not_granted, const std::shared_ptr & user)