From 76dee30deebaad1e8e7bdb463d10aaa31ee59444 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Sun, 1 Dec 2024 17:54:05 +0000 Subject: [PATCH 1/3] make Field rvalue reference safeGet to return a copy of its content instead of reference --- src/Core/Field.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Core/Field.h b/src/Core/Field.h index 5a6ee9cdf29..560002de4c6 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -479,12 +479,20 @@ public: return true; } - template auto & safeGet() const + template const auto & safeGet() const & { return const_cast(this)->safeGet(); } + template auto safeGet() const && + { + return safeGet(); + } - template auto & safeGet(); + template auto & safeGet() &; + template auto safeGet() && + { + return safeGet(); + } bool operator< (const Field & rhs) const { @@ -880,7 +888,7 @@ constexpr bool isInt64OrUInt64orBoolFieldType(Field::Types::Which t) } template -auto & Field::safeGet() +auto & Field::safeGet() & { const Types::Which target = TypeToEnum>>::value; From 54108d5c1616a5f7d55b6ae0165eb9f072cc1557 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Mon, 2 Dec 2024 00:08:00 +0000 Subject: [PATCH 2/3] fix tidy --- src/Interpreters/InterpreterSelectQuery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index 7e65e20724e..901abf8641f 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -406,8 +406,8 @@ ASTPtr parseAdditionalFilterConditionForTable( for (const auto & additional_filter : additional_table_filters) { const auto & tuple = additional_filter.safeGet(); - auto & table = tuple.at(0).safeGet(); - auto & filter = tuple.at(1).safeGet(); + const auto & table = tuple.at(0).safeGet(); + const auto & filter = tuple.at(1).safeGet(); if (table == target.alias || (table == target.table && context.getCurrentDatabase() == target.database) || From 57e77cc8158383e5496cf0886b4cd59e90551b4c Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Mon, 2 Dec 2024 21:46:57 +0000 Subject: [PATCH 3/3] add move semantics --- src/Core/Field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/Field.h b/src/Core/Field.h index 560002de4c6..ebccd366089 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -485,13 +485,13 @@ public: } template auto safeGet() const && { - return safeGet(); + return std::move(const_cast(this)->safeGet()); } template auto & safeGet() &; template auto safeGet() && { - return safeGet(); + return std::move(safeGet()); } bool operator< (const Field & rhs) const