diff --git a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h index 721a1bbd32f..63eece3dcb4 100644 --- a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h +++ b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h @@ -2,8 +2,6 @@ #include -#include - #include #include #include @@ -149,8 +147,6 @@ public: }; -using Poco::SharedPtr; - -using AggregateFunctionPtr = SharedPtr; +using AggregateFunctionPtr = std::shared_ptr; } diff --git a/dbms/include/DB/Columns/ColumnAggregateFunction.h b/dbms/include/DB/Columns/ColumnAggregateFunction.h index 76bb4781ade..c92c37d1955 100644 --- a/dbms/include/DB/Columns/ColumnAggregateFunction.h +++ b/dbms/include/DB/Columns/ColumnAggregateFunction.h @@ -12,6 +12,8 @@ #include #include +#include + namespace DB { @@ -57,7 +59,7 @@ private: struct Holder { - using Ptr = SharedPtr; + using Ptr = Poco::SharedPtr; AggregateFunctionPtr func; /// Используется для уничтожения состояний и для финализации значений. const Ptr src; /// Источник. Используется, если данный столбец создан из другого и использует все или часть его значений. @@ -68,11 +70,9 @@ private: ~Holder() { - IAggregateFunction * function = func; - - if (!function->hasTrivialDestructor() && src.isNull()) + if (!func->hasTrivialDestructor() && src.isNull()) for (auto val : data) - function->destroy(val); + func->destroy(val); } void popBack(size_t n) @@ -188,7 +188,7 @@ public: void insert(const Field & x) override { - IAggregateFunction * function = holder.get()->func; + IAggregateFunction * function = holder.get()->func.get(); Arena & arena = createOrGetArena(); @@ -200,7 +200,7 @@ public: void insertDefault() override { - IAggregateFunction * function = holder.get()->func; + IAggregateFunction * function = holder.get()->func.get(); Arena & arena = createOrGetArena(); diff --git a/dbms/include/DB/Functions/FunctionFactory.h b/dbms/include/DB/Functions/FunctionFactory.h index 010712ec4c5..6a36a3277fa 100644 --- a/dbms/include/DB/Functions/FunctionFactory.h +++ b/dbms/include/DB/Functions/FunctionFactory.h @@ -19,7 +19,7 @@ class FunctionFactory : public Singleton friend class StorageSystemFunctions; private: - typedef IFunction* (*Creator)(const Context & context); /// Не std::function, так как меньше indirection и размер объекта. + typedef FunctionPtr (*Creator)(const Context & context); /// Не std::function, так как меньше indirection и размер объекта. std::unordered_map functions; public: diff --git a/dbms/include/DB/Functions/FunctionsArithmetic.h b/dbms/include/DB/Functions/FunctionsArithmetic.h index 8c9009653a0..06e80c5feb7 100644 --- a/dbms/include/DB/Functions/FunctionsArithmetic.h +++ b/dbms/include/DB/Functions/FunctionsArithmetic.h @@ -469,7 +469,7 @@ class FunctionBinaryArithmetic : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionBinaryArithmetic; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: /// Overload for InvalidType @@ -729,7 +729,7 @@ class FunctionUnaryArithmetic : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionUnaryArithmetic; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: template diff --git a/dbms/include/DB/Functions/FunctionsArray.h b/dbms/include/DB/Functions/FunctionsArray.h index d2768a0d698..a1c0ed6d639 100644 --- a/dbms/include/DB/Functions/FunctionsArray.h +++ b/dbms/include/DB/Functions/FunctionsArray.h @@ -71,7 +71,7 @@ class FunctionArray : public IFunction { public: static constexpr auto name = "array"; - static IFunction * create(const Context & context) { return new FunctionArray; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: /// Получить имя функции. @@ -479,7 +479,7 @@ class FunctionArrayElement : public IFunction { public: static constexpr auto name = "arrayElement"; - static IFunction * create(const Context & context) { return new FunctionArrayElement; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: template @@ -958,7 +958,7 @@ class FunctionArrayIndex : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionArrayIndex; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: using ResultColumnType = ColumnVector; @@ -1162,7 +1162,7 @@ class FunctionArrayEnumerate : public IFunction { public: static constexpr auto name = "arrayEnumerate"; - static IFunction * create (const Context & context) { return new FunctionArrayEnumerate; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1238,7 +1238,7 @@ class FunctionArrayUniq : public IFunction { public: static constexpr auto name = "arrayUniq"; - static IFunction * create(const Context & context) { return new FunctionArrayUniq; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1468,7 +1468,7 @@ class FunctionArrayEnumerateUniq : public IFunction { public: static constexpr auto name = "arrayEnumerateUniq"; - static IFunction * create(const Context & context) { return new FunctionArrayEnumerateUniq; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1713,7 +1713,7 @@ struct FunctionEmptyArray : public IFunction { static constexpr auto base_name = "emptyArray"; static const String name; - static IFunction * create(const Context & context) { return new FunctionEmptyArray; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: String getName() const override @@ -1749,7 +1749,7 @@ class FunctionRange : public IFunction public: static constexpr auto max_elements = 100000000; static constexpr auto name = "range"; - static IFunction * create(const Context &) { return new FunctionRange; } + static FunctionPtr create(const Context &) { return std::make_shared(); } private: String getName() const override @@ -1888,7 +1888,7 @@ class FunctionEmptyArrayToSingle : public IFunction { public: static constexpr auto name = "emptyArrayToSingle"; - static IFunction * create(const Context & context) { return new FunctionEmptyArrayToSingle; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -2138,7 +2138,7 @@ class FunctionArrayReverse : public IFunction { public: static constexpr auto name = "reverse"; - static IFunction * create(const Context & context) { return new FunctionArrayReverse; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -2360,7 +2360,7 @@ class FunctionArrayReduce : public IFunction { public: static constexpr auto name = "arrayReduce"; - static IFunction * create(const Context & context) { return new FunctionArrayReduce; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsCoding.h b/dbms/include/DB/Functions/FunctionsCoding.h index 64bbfb15fe9..9551739dbf1 100644 --- a/dbms/include/DB/Functions/FunctionsCoding.h +++ b/dbms/include/DB/Functions/FunctionsCoding.h @@ -171,7 +171,7 @@ class FunctionIPv6NumToString : public IFunction { public: static constexpr auto name = "IPv6NumToString"; - static IFunction * create(const Context & context) { return new FunctionIPv6NumToString; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -257,7 +257,7 @@ class FunctionCutIPv6 : public IFunction { public: static constexpr auto name = "cutIPv6"; - static IFunction * create(const Context & context) { return new FunctionCutIPv6; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -423,7 +423,7 @@ class FunctionIPv6StringToNum : public IFunction { public: static constexpr auto name = "IPv6StringToNum"; - static IFunction * create(const Context & context) { return new FunctionIPv6StringToNum; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -638,7 +638,7 @@ class FunctionIPv4NumToString : public IFunction { public: static constexpr auto name = "IPv4NumToString"; - static IFunction * create(const Context & context) { return new FunctionIPv4NumToString; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -743,7 +743,7 @@ class FunctionIPv4StringToNum : public IFunction { public: static constexpr auto name = "IPv4StringToNum"; - static IFunction * create(const Context & context) { return new FunctionIPv4StringToNum; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -834,7 +834,7 @@ class FunctionIPv4NumToStringClassC : public IFunction { public: static constexpr auto name = "IPv4NumToStringClassC"; - static IFunction * create(const Context & context) { return new FunctionIPv4NumToStringClassC; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -942,7 +942,7 @@ class FunctionIPv4ToIPv6 : public IFunction { public: static constexpr auto name = "IPv4ToIPv6"; - static IFunction * create(const Context & context) { return new FunctionIPv4ToIPv6; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -1007,7 +1007,7 @@ class FunctionHex : public IFunction { public: static constexpr auto name = "hex"; - static IFunction * create(const Context & context) { return new FunctionHex; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1255,7 +1255,7 @@ class FunctionUnhex : public IFunction { public: static constexpr auto name = "unhex"; - static IFunction * create(const Context & context) { return new FunctionUnhex; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1363,7 +1363,7 @@ class FunctionBitmaskToArray : public IFunction { public: static constexpr auto name = "bitmaskToArray"; - static IFunction * create(const Context & context) { return new FunctionBitmaskToArray; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1476,7 +1476,7 @@ class FunctionToStringCutToZero : public IFunction { public: static constexpr auto name = "toStringCutToZero"; - static IFunction * create(const Context & context) { return new FunctionToStringCutToZero; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1624,7 +1624,7 @@ class FunctionBitTest : public IFunction { public: static constexpr auto name = "bitTest"; - static IFunction * create(const Context &) { return new FunctionBitTest; } + static FunctionPtr create(const Context &) { return std::make_shared(); } String getName() const override { return name; } @@ -1805,7 +1805,7 @@ struct FunctionBitTestMany : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context &) { return new FunctionBitTestMany; } + static FunctionPtr create(const Context &) { return std::make_shared(); } String getName() const override { return name; } diff --git a/dbms/include/DB/Functions/FunctionsComparison.h b/dbms/include/DB/Functions/FunctionsComparison.h index f36a91b7869..b0e64e0244e 100644 --- a/dbms/include/DB/Functions/FunctionsComparison.h +++ b/dbms/include/DB/Functions/FunctionsComparison.h @@ -404,7 +404,7 @@ class FunctionComparison : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionComparison; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; private: template diff --git a/dbms/include/DB/Functions/FunctionsConditional.h b/dbms/include/DB/Functions/FunctionsConditional.h index 8ffccf60257..a6d1b71ac32 100644 --- a/dbms/include/DB/Functions/FunctionsConditional.h +++ b/dbms/include/DB/Functions/FunctionsConditional.h @@ -821,7 +821,7 @@ class FunctionIf : public IFunction { public: static constexpr auto name = "if"; - static IFunction * create(const Context & context) { return new FunctionIf; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: template @@ -1399,7 +1399,7 @@ class FunctionMultiIf final : public IFunction { public: static constexpr auto name = "multiIf"; - static IFunction * create(const Context & context) { return new FunctionMultiIf; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } public: String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsConversion.h b/dbms/include/DB/Functions/FunctionsConversion.h index c0f5e032ffe..e7ef0d1beb6 100644 --- a/dbms/include/DB/Functions/FunctionsConversion.h +++ b/dbms/include/DB/Functions/FunctionsConversion.h @@ -1066,7 +1066,7 @@ public: using Monotonic = MonotonicityImpl; static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionConvert; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1213,7 +1213,7 @@ class FunctionToFixedString : public IFunction { public: static constexpr auto name = "toFixedString"; - static IFunction * create(const Context & context) { return new FunctionToFixedString; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -1870,7 +1870,7 @@ class FunctionCast final : public IFunction public: static constexpr auto name = "CAST"; - static IFunction * create(const Context & context) { return new FunctionCast{context}; } + static FunctionPtr create(const Context & context) { return std::make_shared(context); } String getName() const override { return name; } diff --git a/dbms/include/DB/Functions/FunctionsDateTime.h b/dbms/include/DB/Functions/FunctionsDateTime.h index fa928001f2a..38e70c21402 100644 --- a/dbms/include/DB/Functions/FunctionsDateTime.h +++ b/dbms/include/DB/Functions/FunctionsDateTime.h @@ -571,7 +571,7 @@ class FunctionDateOrDateTimeToSomething : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionDateOrDateTimeToSomething; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -669,7 +669,7 @@ class FunctionNow : public IFunction { public: static constexpr auto name = "now"; - static IFunction * create(const Context & context) { return new FunctionNow; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -702,7 +702,7 @@ class FunctionToday : public IFunction { public: static constexpr auto name = "today"; - static IFunction * create(const Context & context) { return new FunctionToday; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -735,7 +735,7 @@ class FunctionYesterday : public IFunction { public: static constexpr auto name = "yesterday"; - static IFunction * create(const Context & context) { return new FunctionYesterday; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -768,7 +768,7 @@ class FunctionTimeSlot : public IFunction { public: static constexpr auto name = "timeSlot"; - static IFunction * create(const Context & context) { return new FunctionTimeSlot; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -904,7 +904,7 @@ class FunctionTimeSlots : public IFunction { public: static constexpr auto name = "timeSlots"; - static IFunction * create(const Context & context) { return new FunctionTimeSlots; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsDictionaries.h b/dbms/include/DB/Functions/FunctionsDictionaries.h index 3713b98560c..a5f91e3716e 100644 --- a/dbms/include/DB/Functions/FunctionsDictionaries.h +++ b/dbms/include/DB/Functions/FunctionsDictionaries.h @@ -540,7 +540,7 @@ struct NameSEHierarchy { static constexpr auto name = "SEHierarchy"; }; struct FunctionRegionToCity : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -549,7 +549,7 @@ struct FunctionRegionToCity : struct FunctionRegionToArea : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -558,7 +558,7 @@ struct FunctionRegionToArea : struct FunctionRegionToDistrict : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -567,7 +567,7 @@ struct FunctionRegionToDistrict : struct FunctionRegionToCountry : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -576,7 +576,7 @@ struct FunctionRegionToCountry : struct FunctionRegionToContinent : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -585,7 +585,7 @@ struct FunctionRegionToContinent : struct FunctionRegionToTopContinent : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -594,7 +594,7 @@ struct FunctionRegionToTopContinent : struct FunctionRegionToPopulation : public FunctionTransformWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -603,7 +603,7 @@ struct FunctionRegionToPopulation : struct FunctionOSToRoot : public FunctionTransformWithDictionary, NameOSToRoot> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -612,7 +612,7 @@ struct FunctionOSToRoot : struct FunctionSEToRoot : public FunctionTransformWithDictionary, NameSEToRoot> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -621,7 +621,7 @@ struct FunctionSEToRoot : struct FunctionRegionIn : public FunctionIsInWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -630,7 +630,7 @@ struct FunctionRegionIn : struct FunctionOSIn : public FunctionIsInWithDictionary, NameOSIn> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -639,7 +639,7 @@ struct FunctionOSIn : struct FunctionSEIn : public FunctionIsInWithDictionary, NameSEIn> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -648,7 +648,7 @@ struct FunctionSEIn : struct FunctionRegionHierarchy : public FunctionHierarchyWithDictionary { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getRegionsHierarchies()}; } @@ -657,7 +657,7 @@ struct FunctionRegionHierarchy : struct FunctionOSHierarchy : public FunctionHierarchyWithDictionary, NameOSHierarchy> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -666,7 +666,7 @@ struct FunctionOSHierarchy : struct FunctionSEHierarchy : public FunctionHierarchyWithDictionary, NameSEHierarchy> { - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { return new base_type{context.getDictionaries().getTechDataHierarchy()}; } @@ -678,9 +678,9 @@ class FunctionRegionToName : public IFunction { public: static constexpr auto name = "regionToName"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionRegionToName(context.getDictionaries().getRegionsNames()); + return std::make_shared(context.getDictionaries().getRegionsNames()); } private: @@ -772,9 +772,9 @@ class FunctionDictHas final : public IFunction public: static constexpr auto name = "dictHas"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictHas{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictHas(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -915,9 +915,9 @@ class FunctionDictGetString final : public IFunction public: static constexpr auto name = "dictGetString"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictGetString{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictGetString(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -1190,9 +1190,9 @@ class FunctionDictGetStringOrDefault final : public IFunction public: static constexpr auto name = "dictGetStringOrDefault"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictGetStringOrDefault{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictGetStringOrDefault(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -1483,9 +1483,9 @@ class FunctionDictGet final : public IFunction public: static const std::string name; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictGet{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictGet(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -1795,9 +1795,9 @@ class FunctionDictGetOrDefault final : public IFunction public: static const std::string name; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictGetOrDefault{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictGetOrDefault(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -2066,9 +2066,9 @@ class FunctionDictGetHierarchy final : public IFunction public: static constexpr auto name = "dictGetHierarchy"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictGetHierarchy{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictGetHierarchy(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} @@ -2229,9 +2229,9 @@ class FunctionDictIsIn final : public IFunction public: static constexpr auto name = "dictIsIn"; - static IFunction * create(const Context & context) + static FunctionPtr create(const Context & context) { - return new FunctionDictIsIn{context.getExternalDictionaries()}; + return std::make_shared(context.getExternalDictionaries()); } FunctionDictIsIn(const ExternalDictionaries & dictionaries) : dictionaries(dictionaries) {} diff --git a/dbms/include/DB/Functions/FunctionsFormatting.h b/dbms/include/DB/Functions/FunctionsFormatting.h index fb694eb11d0..476e1a24103 100644 --- a/dbms/include/DB/Functions/FunctionsFormatting.h +++ b/dbms/include/DB/Functions/FunctionsFormatting.h @@ -22,7 +22,7 @@ class FunctionBitmaskToList : public IFunction { public: static constexpr auto name = "bitmaskToList"; - static IFunction * create(const Context & context) { return new FunctionBitmaskToList; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить основное имя функции. virtual String getName() const override @@ -135,7 +135,7 @@ class FunctionFormatReadableSize : public IFunction { public: static constexpr auto name = "formatReadableSize"; - static IFunction * create(const Context & context) { return new FunctionFormatReadableSize; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить основное имя функции. virtual String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsHashing.h b/dbms/include/DB/Functions/FunctionsHashing.h index 72a1a593715..a601040a476 100644 --- a/dbms/include/DB/Functions/FunctionsHashing.h +++ b/dbms/include/DB/Functions/FunctionsHashing.h @@ -171,7 +171,7 @@ class FunctionStringHash64 : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionStringHash64; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -232,7 +232,7 @@ class FunctionStringHashFixedString : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context & context) { return new FunctionStringHashFixedString; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -300,7 +300,7 @@ class FunctionIntHash : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionIntHash; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; private: using ToType = typename Impl::ReturnType; @@ -396,7 +396,7 @@ class FunctionNeighbourhoodHash64 : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context & context) { return new FunctionNeighbourhoodHash64; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; private: template @@ -699,7 +699,7 @@ class FunctionURLHash : public IFunction { public: static constexpr auto name = "URLHash"; - static IFunction * create(const Context &) { return new FunctionURLHash; } + static FunctionPtr create(const Context &) { return std::make_shared(); } String getName() const override { return name; } diff --git a/dbms/include/DB/Functions/FunctionsHigherOrder.h b/dbms/include/DB/Functions/FunctionsHigherOrder.h index 1296bd88cb4..dbe836bf34a 100644 --- a/dbms/include/DB/Functions/FunctionsHigherOrder.h +++ b/dbms/include/DB/Functions/FunctionsHigherOrder.h @@ -545,7 +545,7 @@ class FunctionArrayMapped : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionArrayMapped; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -640,7 +640,7 @@ public: Names replicate_arguments; replicate_arguments.push_back(required_columns[i]); replicate_arguments.push_back(arguments[1].name); - out_prerequisites.push_back(ExpressionAction::applyFunction(new FunctionReplicate, replicate_arguments)); + out_prerequisites.push_back(ExpressionAction::applyFunction(std::make_shared(), replicate_arguments)); } DataTypePtr return_type = column_expression->getReturnType(); diff --git a/dbms/include/DB/Functions/FunctionsLogical.h b/dbms/include/DB/Functions/FunctionsLogical.h index af376175198..33675c43344 100644 --- a/dbms/include/DB/Functions/FunctionsLogical.h +++ b/dbms/include/DB/Functions/FunctionsLogical.h @@ -154,7 +154,7 @@ class FunctionAnyArityLogical : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionAnyArityLogical; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; private: bool extractConstColumns(ColumnPlainPtrs & in, UInt8 & res) @@ -363,7 +363,7 @@ class FunctionUnaryLogical : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionUnaryLogical; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; private: template diff --git a/dbms/include/DB/Functions/FunctionsMath.h b/dbms/include/DB/Functions/FunctionsMath.h index 34e72ea9dcd..3f402ca4a3b 100644 --- a/dbms/include/DB/Functions/FunctionsMath.h +++ b/dbms/include/DB/Functions/FunctionsMath.h @@ -17,7 +17,7 @@ class FunctionMathNullaryConstFloat64 : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context &) { return new FunctionMathNullaryConstFloat64; } + static FunctionPtr create(const Context &) { return std::make_shared(); } private: String getName() const override { return name; } @@ -47,7 +47,7 @@ template class FunctionMathUnaryFloat64 : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context &) { return new FunctionMathUnaryFloat64; } + static FunctionPtr create(const Context &) { return std::make_shared(); } static_assert(Impl::rows_per_iteration > 0, "Impl must process at least one row per iteration"); private: @@ -198,7 +198,7 @@ template class FunctionMathBinaryFloat64 : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context &) { return new FunctionMathBinaryFloat64; } + static FunctionPtr create(const Context &) { return std::make_shared(); } static_assert(Impl::rows_per_iteration > 0, "Impl must process at least one row per iteration"); private: diff --git a/dbms/include/DB/Functions/FunctionsMiscellaneous.h b/dbms/include/DB/Functions/FunctionsMiscellaneous.h index de402127067..4ee7ada586a 100644 --- a/dbms/include/DB/Functions/FunctionsMiscellaneous.h +++ b/dbms/include/DB/Functions/FunctionsMiscellaneous.h @@ -98,7 +98,7 @@ class FunctionCurrentDatabase : public IFunction public: static constexpr auto name = "currentDatabase"; - static IFunction * create(const Context & context) { return new FunctionCurrentDatabase{context.getCurrentDatabase()}; } + static FunctionPtr create(const Context & context) { return std::make_shared(context.getCurrentDatabase()); } explicit FunctionCurrentDatabase(const String & db_name) : db_name{db_name} {} @@ -129,7 +129,7 @@ class FunctionHostName : public IFunction { public: static constexpr auto name = "hostName"; - static IFunction * create(const Context & context) { return new FunctionHostName; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -163,7 +163,7 @@ class FunctionVisibleWidth : public IFunction { public: static constexpr auto name = "visibleWidth"; - static IFunction * create(const Context & context) { return new FunctionVisibleWidth; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -191,7 +191,7 @@ class FunctionToTypeName : public IFunction { public: static constexpr auto name = "toTypeName"; - static IFunction * create(const Context & context) { return new FunctionToTypeName; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -222,7 +222,7 @@ class FunctionBlockSize : public IFunction { public: static constexpr auto name = "blockSize"; - static IFunction * create(const Context & context) { return new FunctionBlockSize; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -254,7 +254,7 @@ class FunctionRowNumberInBlock : public IFunction { public: static constexpr auto name = "rowNumberInBlock"; - static IFunction * create(const Context & context) { return new FunctionRowNumberInBlock; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -295,7 +295,7 @@ private: public: static constexpr auto name = "blockNumber"; - static IFunction * create(const Context & context) { return new FunctionBlockNumber; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -327,7 +327,7 @@ class FunctionSleep : public IFunction { public: static constexpr auto name = "sleep"; - static IFunction * create(const Context & context) { return new FunctionSleep; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -396,7 +396,7 @@ class FunctionMaterialize : public IFunction { public: static constexpr auto name = "materialize"; - static IFunction * create(const Context & context) { return new FunctionMaterialize; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -437,7 +437,7 @@ class FunctionIn : public IFunction { public: static constexpr auto name = FunctionInName::name; - static IFunction * create(const Context & context) { return new FunctionIn; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -484,7 +484,7 @@ class FunctionTuple : public IFunction { public: static constexpr auto name = "tuple"; - static IFunction * create(const Context & context) { return new FunctionTuple; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -518,7 +518,7 @@ class FunctionTupleElement : public IFunction { public: static constexpr auto name = "tupleElement"; - static IFunction * create(const Context & context) { return new FunctionTupleElement; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -585,7 +585,7 @@ class FunctionIgnore : public IFunction { public: static constexpr auto name = "ignore"; - static IFunction * create(const Context & context) { return new FunctionIgnore; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } DataTypePtr getReturnType(const DataTypes & arguments) const override { return std::make_shared(); } @@ -614,7 +614,7 @@ class FunctionIndexHint : public IFunction { public: static constexpr auto name = "indexHint"; - static IFunction * create(const Context & context) { return new FunctionIndexHint; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } DataTypePtr getReturnType(const DataTypes & arguments) const override { return std::make_shared(); } @@ -631,7 +631,7 @@ class FunctionIdentity : public IFunction { public: static constexpr auto name = "identity"; - static IFunction * create(const Context & context) { return new FunctionIdentity; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -661,7 +661,7 @@ class FunctionArrayJoin : public IFunction { public: static constexpr auto name = "arrayJoin"; - static IFunction * create(const Context & context) { return new FunctionArrayJoin; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. @@ -698,7 +698,7 @@ class FunctionReplicate : public IFunction { public: static constexpr auto name = "replicate"; - static IFunction * create(const Context & context) { return new FunctionReplicate; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -749,7 +749,7 @@ class FunctionBar : public IFunction { public: static constexpr auto name = "bar"; - static IFunction * create(const Context & context) { return new FunctionBar; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -910,7 +910,7 @@ class FunctionNumericPredicate : public IFunction { public: static constexpr auto name = Impl::name; - static IFunction * create(const Context &) { return new FunctionNumericPredicate; } + static FunctionPtr create(const Context &) { return std::make_shared(); } String getName() const override { return name; } @@ -1021,7 +1021,7 @@ class FunctionVersion : public IFunction { public: static constexpr auto name = "version"; - static IFunction * create(const Context & context) { return new FunctionVersion; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -1052,7 +1052,7 @@ class FunctionUptime : public IFunction { public: static constexpr auto name = "uptime"; - static IFunction * create(const Context & context) { return new FunctionUptime(context.getUptimeSeconds()); } + static FunctionPtr create(const Context & context) { return std::make_shared(context.getUptimeSeconds()); } FunctionUptime(time_t uptime_) : uptime(uptime_) {} @@ -1085,7 +1085,7 @@ class FunctionRunningAccumulate : public IFunction { public: static constexpr auto name = "runningAccumulate"; - static IFunction * create(const Context & context) { return new FunctionRunningAccumulate; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } @@ -1139,7 +1139,7 @@ class FunctionFinalizeAggregation : public IFunction { public: static constexpr auto name = "finalizeAggregation"; - static IFunction * create(const Context & context) { return new FunctionFinalizeAggregation; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { return name; } diff --git a/dbms/include/DB/Functions/FunctionsRandom.h b/dbms/include/DB/Functions/FunctionsRandom.h index 85a8cebfbfd..d0bd0accdb5 100644 --- a/dbms/include/DB/Functions/FunctionsRandom.h +++ b/dbms/include/DB/Functions/FunctionsRandom.h @@ -154,7 +154,7 @@ private: public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionRandom; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -200,7 +200,7 @@ private: public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionRandomConstant; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsReinterpret.h b/dbms/include/DB/Functions/FunctionsReinterpret.h index f17bd507312..a31d65be095 100644 --- a/dbms/include/DB/Functions/FunctionsReinterpret.h +++ b/dbms/include/DB/Functions/FunctionsReinterpret.h @@ -24,7 +24,7 @@ class FunctionReinterpretAsStringImpl : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionReinterpretAsStringImpl; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; /// Получить имя функции. String getName() const override @@ -120,7 +120,7 @@ class FunctionReinterpretStringAs : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionReinterpretStringAs; }; + static FunctionPtr create(const Context & context) { return std::make_shared(); }; using ToFieldType = typename ToDataType::FieldType; diff --git a/dbms/include/DB/Functions/FunctionsRound.h b/dbms/include/DB/Functions/FunctionsRound.h index 7428b18ec22..ccda1e57c74 100644 --- a/dbms/include/DB/Functions/FunctionsRound.h +++ b/dbms/include/DB/Functions/FunctionsRound.h @@ -1034,7 +1034,7 @@ namespace { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionRounding; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } private: template diff --git a/dbms/include/DB/Functions/FunctionsString.h b/dbms/include/DB/Functions/FunctionsString.h index f30570d1980..54e3c205fca 100644 --- a/dbms/include/DB/Functions/FunctionsString.h +++ b/dbms/include/DB/Functions/FunctionsString.h @@ -775,7 +775,7 @@ class FunctionStringOrArrayToT : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionStringOrArrayToT; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -871,7 +871,7 @@ class FunctionStringToString : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionStringToString; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -932,7 +932,7 @@ class FunctionReverse : public IFunction { public: static constexpr auto name = "reverse"; - static IFunction * create(const Context & context) { return new FunctionReverse; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -998,7 +998,7 @@ class ConcatImpl : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new ConcatImpl; } + static FunctionPtr create(const Context & context) { return new ConcatImpl; } /// Получить имя функции. String getName() const override @@ -1469,7 +1469,7 @@ class FunctionStringNumNumToString : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionStringNumNumToString; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1550,7 +1550,7 @@ class FunctionAppendTrailingCharIfAbsent : public IFunction { public: static constexpr auto name = "appendTrailingCharIfAbsent"; - static IFunction * create(const Context & context) { return new FunctionAppendTrailingCharIfAbsent; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } String getName() const override { diff --git a/dbms/include/DB/Functions/FunctionsStringArray.h b/dbms/include/DB/Functions/FunctionsStringArray.h index b0d2b08afe1..0d17087bfa2 100644 --- a/dbms/include/DB/Functions/FunctionsStringArray.h +++ b/dbms/include/DB/Functions/FunctionsStringArray.h @@ -314,7 +314,7 @@ class FunctionTokens : public IFunction { public: static constexpr auto name = Generator::name; - static IFunction * create(const Context & context) { return new FunctionTokens; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -479,7 +479,7 @@ private: public: static constexpr auto name = "arrayStringConcat"; - static IFunction * create(const Context & context) { return new FunctionArrayStringConcat; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsStringSearch.h b/dbms/include/DB/Functions/FunctionsStringSearch.h index aad04b8cbd1..dabbd13bf26 100644 --- a/dbms/include/DB/Functions/FunctionsStringSearch.h +++ b/dbms/include/DB/Functions/FunctionsStringSearch.h @@ -1161,7 +1161,7 @@ class FunctionStringReplace : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionStringReplace; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1248,7 +1248,7 @@ class FunctionsStringSearch : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionsStringSearch; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override @@ -1333,7 +1333,7 @@ class FunctionsStringSearchToString : public IFunction { public: static constexpr auto name = Name::name; - static IFunction * create(const Context & context) { return new FunctionsStringSearchToString; } + static FunctionPtr create(const Context & context) { return std::make_shared(); } /// Получить имя функции. String getName() const override diff --git a/dbms/include/DB/Functions/FunctionsTransform.h b/dbms/include/DB/Functions/FunctionsTransform.h index b1d07b2609d..7d218b021db 100644 --- a/dbms/include/DB/Functions/FunctionsTransform.h +++ b/dbms/include/DB/Functions/FunctionsTransform.h @@ -48,7 +48,7 @@ class FunctionTransform : public IFunction { public: static constexpr auto name = "transform"; - static IFunction * create(const Context &) { return new FunctionTransform; } + static FunctionPtr create(const Context &) { return std::make_shared(); } String getName() const override { diff --git a/dbms/include/DB/Functions/IFunction.h b/dbms/include/DB/Functions/IFunction.h index a33796e2941..6f625b61148 100644 --- a/dbms/include/DB/Functions/IFunction.h +++ b/dbms/include/DB/Functions/IFunction.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -122,9 +122,7 @@ public: }; -using Poco::SharedPtr; - -using FunctionPtr = SharedPtr; +using FunctionPtr = std::shared_ptr; } diff --git a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h index 188e1e1a9d3..44978de9e62 100644 --- a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h +++ b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h @@ -271,8 +271,8 @@ private: if (sub_select_query.database.isNull()) { - sub_select_query.database = new ASTIdentifier{{}, distributed_storage.getRemoteDatabaseName(), - ASTIdentifier::Database}; + sub_select_query.database = std::make_shared({}, distributed_storage.getRemoteDatabaseName(), + ASTIdentifier::Database); /// Поскольку был создан новый узел для БД, необходимо его вставить в список /// потомков этого подзапроса. См. ParserSelectQuery для структуры потомков. diff --git a/dbms/include/DB/Interpreters/evaluateConstantExpression.h b/dbms/include/DB/Interpreters/evaluateConstantExpression.h index 660ce2e9756..504278fbb59 100644 --- a/dbms/include/DB/Interpreters/evaluateConstantExpression.h +++ b/dbms/include/DB/Interpreters/evaluateConstantExpression.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include @@ -14,6 +14,6 @@ class Context; * Используется в редких случаях - для элемента множества в IN, для данных для INSERT. * Весьма неоптимально. */ -Field evaluateConstantExpression(Poco::SharedPtr & node, const Context & context); +Field evaluateConstantExpression(std::shared_ptr & node, const Context & context); } diff --git a/dbms/include/DB/Interpreters/reinterpretAsIdentifier.h b/dbms/include/DB/Interpreters/reinterpretAsIdentifier.h index 0f6190666b1..6e67a8bc263 100644 --- a/dbms/include/DB/Interpreters/reinterpretAsIdentifier.h +++ b/dbms/include/DB/Interpreters/reinterpretAsIdentifier.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace DB @@ -13,6 +13,6 @@ class Context; /** \brief if `expr` is not already ASTIdentifier evaluates it * and replaces by a new ASTIdentifier with the result of evaluation as its name. * `expr` must evaluate to a String type */ -ASTIdentifier & reinterpretAsIdentifier(Poco::SharedPtr & expr, const Context & context); +ASTIdentifier & reinterpretAsIdentifier(std::shared_ptr & expr, const Context & context); } diff --git a/dbms/include/DB/Parsers/ASTAsterisk.h b/dbms/include/DB/Parsers/ASTAsterisk.h index f0741539267..cac4fa85580 100644 --- a/dbms/include/DB/Parsers/ASTAsterisk.h +++ b/dbms/include/DB/Parsers/ASTAsterisk.h @@ -14,7 +14,7 @@ public: ASTAsterisk() = default; ASTAsterisk(StringRange range_) : IAST(range_) {} String getID() const override { return "Asterisk"; } - ASTPtr clone() const override { return new ASTAsterisk(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } String getColumnName() const override { return "*"; } protected: diff --git a/dbms/include/DB/Parsers/ASTCheckQuery.h b/dbms/include/DB/Parsers/ASTCheckQuery.h index 166004b6253..3210bd1dd05 100644 --- a/dbms/include/DB/Parsers/ASTCheckQuery.h +++ b/dbms/include/DB/Parsers/ASTCheckQuery.h @@ -14,7 +14,7 @@ struct ASTCheckQuery : public ASTQueryWithOutput ASTPtr clone() const override { - return new ASTCheckQuery(*this); + return std::make_shared(*this); } std::string database; diff --git a/dbms/include/DB/Parsers/ASTColumnDeclaration.h b/dbms/include/DB/Parsers/ASTColumnDeclaration.h index 722bc6d8283..7c688cc08bd 100644 --- a/dbms/include/DB/Parsers/ASTColumnDeclaration.h +++ b/dbms/include/DB/Parsers/ASTColumnDeclaration.h @@ -23,7 +23,7 @@ public: ASTPtr clone() const override { - const auto res = new ASTColumnDeclaration{*this}; + const auto res = std::make_shared(*this); ASTPtr ptr{res}; res->children.clear(); diff --git a/dbms/include/DB/Parsers/ASTCreateQuery.h b/dbms/include/DB/Parsers/ASTCreateQuery.h index 99b27b900d3..8a852c9235e 100644 --- a/dbms/include/DB/Parsers/ASTCreateQuery.h +++ b/dbms/include/DB/Parsers/ASTCreateQuery.h @@ -36,9 +36,7 @@ public: ASTPtr clone() const override { - ASTCreateQuery * res = new ASTCreateQuery(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (columns) { res->columns = columns->clone(); res->children.push_back(res->columns); } @@ -46,7 +44,7 @@ public: if (select) { res->select = select->clone(); res->children.push_back(res->select); } if (inner_storage) { res->inner_storage = inner_storage->clone(); res->children.push_back(res->inner_storage); } - return ptr; + return res; } protected: diff --git a/dbms/include/DB/Parsers/ASTDropQuery.h b/dbms/include/DB/Parsers/ASTDropQuery.h index 897f9afd4c6..b1fb5378432 100644 --- a/dbms/include/DB/Parsers/ASTDropQuery.h +++ b/dbms/include/DB/Parsers/ASTDropQuery.h @@ -23,7 +23,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return (detach ? "DetachQuery_" : "DropQuery_") + database + "_" + table; }; - ASTPtr clone() const override { return new ASTDropQuery(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTEnumElement.h b/dbms/include/DB/Parsers/ASTEnumElement.h index 5bc8f554eaa..7e147d4b756 100644 --- a/dbms/include/DB/Parsers/ASTEnumElement.h +++ b/dbms/include/DB/Parsers/ASTEnumElement.h @@ -21,7 +21,7 @@ public: ASTPtr clone() const override { - return new ASTEnumElement{{}, name, value}; + return std::make_shared({}, name, value); } protected: diff --git a/dbms/include/DB/Parsers/ASTExpressionList.h b/dbms/include/DB/Parsers/ASTExpressionList.h index 86ccc539ad3..7bccbd5e271 100644 --- a/dbms/include/DB/Parsers/ASTExpressionList.h +++ b/dbms/include/DB/Parsers/ASTExpressionList.h @@ -19,7 +19,7 @@ public: ASTPtr clone() const override { - const auto res = new ASTExpressionList(*this); + const auto res = std::make_shared(*this); ASTPtr ptr{res}; res->children.clear(); diff --git a/dbms/include/DB/Parsers/ASTFunction.h b/dbms/include/DB/Parsers/ASTFunction.h index 3662b655a92..2e5f0de59e7 100644 --- a/dbms/include/DB/Parsers/ASTFunction.h +++ b/dbms/include/DB/Parsers/ASTFunction.h @@ -66,11 +66,11 @@ private: template ASTPtr makeASTFunction(const String & name, Args &&... args) { - const auto function = new ASTFunction{}; + const auto function = std::make_shared(); ASTPtr result{function}; function->name = name; - function->arguments = new ASTExpressionList{}; + function->arguments = std::make_shared(); function->children.push_back(function->arguments); function->arguments->children = { std::forward(args)... }; @@ -83,11 +83,11 @@ template ASTPtr makeASTFunction(const String & name, const StringRange & function_range, const StringRange & arguments_range, Args &&... args) { - const auto function = new ASTFunction{function_range}; + const auto function = std::make_shared(function_range); ASTPtr result{function}; function->name = name; - function->arguments = new ASTExpressionList{arguments_range}; + function->arguments = std::make_shared(arguments_range); function->children.push_back(function->arguments); function->arguments->children = { std::forward(args)... }; diff --git a/dbms/include/DB/Parsers/ASTIdentifier.h b/dbms/include/DB/Parsers/ASTIdentifier.h index 5032387e5b0..d6acfbd7530 100644 --- a/dbms/include/DB/Parsers/ASTIdentifier.h +++ b/dbms/include/DB/Parsers/ASTIdentifier.h @@ -36,7 +36,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "Identifier_" + name; } - ASTPtr clone() const override { return new ASTIdentifier(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } void collectIdentifierNames(IdentifierNameSet & set) const override { diff --git a/dbms/include/DB/Parsers/ASTInsertQuery.h b/dbms/include/DB/Parsers/ASTInsertQuery.h index c7a1879b55d..93fbb4451c4 100644 --- a/dbms/include/DB/Parsers/ASTInsertQuery.h +++ b/dbms/include/DB/Parsers/ASTInsertQuery.h @@ -26,21 +26,19 @@ public: ASTInsertQuery() = default; ASTInsertQuery(const StringRange range_) : IAST(range_) {} - + /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "InsertQuery_" + database + "_" + table; }; ASTPtr clone() const override { - ASTInsertQuery * res = new ASTInsertQuery(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (columns) { res->columns = columns->clone(); res->children.push_back(res->columns); } if (select) { res->select = select->clone(); res->children.push_back(res->select); } - return ptr; + return res; } protected: diff --git a/dbms/include/DB/Parsers/ASTJoin.h b/dbms/include/DB/Parsers/ASTJoin.h index bd6b5b42f04..08d5670d38d 100644 --- a/dbms/include/DB/Parsers/ASTJoin.h +++ b/dbms/include/DB/Parsers/ASTJoin.h @@ -74,15 +74,13 @@ public: ASTPtr clone() const override { - ASTJoin * res = new ASTJoin(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (table) { res->table = table->clone(); res->children.push_back(res->table); } if (using_expr_list) { res->using_expr_list = using_expr_list->clone(); res->children.push_back(res->using_expr_list); } - return ptr; + return res; } protected: diff --git a/dbms/include/DB/Parsers/ASTLiteral.h b/dbms/include/DB/Parsers/ASTLiteral.h index c001cccaf5f..4a2646557eb 100644 --- a/dbms/include/DB/Parsers/ASTLiteral.h +++ b/dbms/include/DB/Parsers/ASTLiteral.h @@ -24,7 +24,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "Literal_" + apply_visitor(FieldVisitorDump(), value); } - ASTPtr clone() const override { return new ASTLiteral(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTNameTypePair.h b/dbms/include/DB/Parsers/ASTNameTypePair.h index b9cbb25ee8b..c098b06b5dc 100644 --- a/dbms/include/DB/Parsers/ASTNameTypePair.h +++ b/dbms/include/DB/Parsers/ASTNameTypePair.h @@ -25,14 +25,12 @@ public: ASTPtr clone() const override { - ASTNameTypePair * res = new ASTNameTypePair(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (type) { res->type = type->clone(); res->children.push_back(res->type); } - return ptr; + return res; } protected: diff --git a/dbms/include/DB/Parsers/ASTOptimizeQuery.h b/dbms/include/DB/Parsers/ASTOptimizeQuery.h index ed856c3dcda..a47afa19157 100644 --- a/dbms/include/DB/Parsers/ASTOptimizeQuery.h +++ b/dbms/include/DB/Parsers/ASTOptimizeQuery.h @@ -26,7 +26,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "OptimizeQuery_" + database + "_" + table + "_" + partition + "_" + toString(final); }; - ASTPtr clone() const override { return new ASTOptimizeQuery(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTOrderByElement.h b/dbms/include/DB/Parsers/ASTOrderByElement.h index e9e92c48d6a..521a4ddbabd 100644 --- a/dbms/include/DB/Parsers/ASTOrderByElement.h +++ b/dbms/include/DB/Parsers/ASTOrderByElement.h @@ -25,7 +25,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "OrderByElement"; } - ASTPtr clone() const override { return new ASTOrderByElement(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTRenameQuery.h b/dbms/include/DB/Parsers/ASTRenameQuery.h index 8addac8280c..5876767c53d 100644 --- a/dbms/include/DB/Parsers/ASTRenameQuery.h +++ b/dbms/include/DB/Parsers/ASTRenameQuery.h @@ -33,7 +33,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "Rename"; }; - ASTPtr clone() const override { return new ASTRenameQuery(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTSampleRatio.h b/dbms/include/DB/Parsers/ASTSampleRatio.h index 050becadd1f..772f0f098bf 100644 --- a/dbms/include/DB/Parsers/ASTSampleRatio.h +++ b/dbms/include/DB/Parsers/ASTSampleRatio.h @@ -28,7 +28,7 @@ public: String getID() const override { return "SampleRatio_" + toString(ratio); } - ASTPtr clone() const override { return new ASTSampleRatio(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } static String toString(BigNum num); static String toString(Rational ratio); diff --git a/dbms/include/DB/Parsers/ASTSet.h b/dbms/include/DB/Parsers/ASTSet.h index d3af0b5f30f..b5b53862e20 100644 --- a/dbms/include/DB/Parsers/ASTSet.h +++ b/dbms/include/DB/Parsers/ASTSet.h @@ -20,7 +20,7 @@ public: ASTSet(const String & column_name_) : column_name(column_name_) {} ASTSet(const StringRange range_, const String & column_name_) : IAST(range_), column_name(column_name_) {} String getID() const override { return "Set_" + getColumnName(); } - ASTPtr clone() const override { return new ASTSet(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } String getColumnName() const override { return column_name; } protected: diff --git a/dbms/include/DB/Parsers/ASTSetQuery.h b/dbms/include/DB/Parsers/ASTSetQuery.h index 3d07623315b..3b718fcd714 100644 --- a/dbms/include/DB/Parsers/ASTSetQuery.h +++ b/dbms/include/DB/Parsers/ASTSetQuery.h @@ -31,7 +31,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "Set"; }; - ASTPtr clone() const override { return new ASTSetQuery(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTShowTablesQuery.h b/dbms/include/DB/Parsers/ASTShowTablesQuery.h index ccd40bb164e..625aa82c317 100644 --- a/dbms/include/DB/Parsers/ASTShowTablesQuery.h +++ b/dbms/include/DB/Parsers/ASTShowTablesQuery.h @@ -27,9 +27,7 @@ public: ASTPtr clone() const override { - ASTShowTablesQuery * res = new ASTShowTablesQuery(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (format) @@ -38,7 +36,7 @@ public: res->children.push_back(res->format); } - return ptr; + return res; } protected: diff --git a/dbms/include/DB/Parsers/ASTSubquery.h b/dbms/include/DB/Parsers/ASTSubquery.h index 55d7621129f..7146a8bb9ff 100644 --- a/dbms/include/DB/Parsers/ASTSubquery.h +++ b/dbms/include/DB/Parsers/ASTSubquery.h @@ -22,7 +22,7 @@ public: ASTPtr clone() const override { - const auto res = new ASTSubquery{*this}; + const auto res = std::make_shared(*this); ASTPtr ptr{res}; res->children.clear(); diff --git a/dbms/include/DB/Parsers/ASTUseQuery.h b/dbms/include/DB/Parsers/ASTUseQuery.h index a1e354b39b0..c218906a81d 100644 --- a/dbms/include/DB/Parsers/ASTUseQuery.h +++ b/dbms/include/DB/Parsers/ASTUseQuery.h @@ -20,7 +20,7 @@ public: /** Получить текст, который идентифицирует этот элемент. */ String getID() const override { return "UseQuery_" + database; }; - ASTPtr clone() const override { return new ASTUseQuery(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override diff --git a/dbms/include/DB/Parsers/ASTWeightedZooKeeperPath.h b/dbms/include/DB/Parsers/ASTWeightedZooKeeperPath.h index b3f0b16a2af..e6a97db0dcf 100644 --- a/dbms/include/DB/Parsers/ASTWeightedZooKeeperPath.h +++ b/dbms/include/DB/Parsers/ASTWeightedZooKeeperPath.h @@ -13,7 +13,7 @@ public: ASTWeightedZooKeeperPath() = default; ASTWeightedZooKeeperPath(StringRange range_) : IAST(range_) {} String getID() const override { return "Weighted_ZooKeeper_Path"; } - ASTPtr clone() const override { return new ASTWeightedZooKeeperPath(*this); } + ASTPtr clone() const override { return std::make_shared(*this); } public: String path; diff --git a/dbms/include/DB/Parsers/IAST.h b/dbms/include/DB/Parsers/IAST.h index bc838c936a6..c5de9e371d4 100644 --- a/dbms/include/DB/Parsers/IAST.h +++ b/dbms/include/DB/Parsers/IAST.h @@ -4,10 +4,9 @@ #include #include #include +#include #include -#include - #include #include @@ -28,16 +27,18 @@ namespace ErrorCodes extern const int UNKNOWN_ELEMENT_IN_AST; } -using Poco::SharedPtr; using IdentifierNameSet = std::set; +class IAST; +using ASTPtr = std::shared_ptr; +using ASTs = std::vector; + /** Элемент синтаксического дерева (в дальнейшем - направленного ациклического графа с элементами семантики) */ class IAST { public: - using ASTs = std::vector>; ASTs children; StringRange range; @@ -98,7 +99,7 @@ public: virtual String getID() const = 0; /** Получить глубокую копию дерева. */ - virtual SharedPtr clone() const = 0; + virtual ASTPtr clone() const = 0; /// Рекурсивно установить атрибуты в поддереве, корнем которого является текущий узел. void setAttributes(Attributes attributes_) @@ -135,8 +136,8 @@ public: { String indent_str(indent, '-'); ostr << indent_str << getID() << ", " << this << std::endl; - for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it) - (*it)->dumpTree(ostr, indent + 1); + for (const auto & child : children) + child->dumpTree(ostr, indent + 1); } /** Проверить глубину дерева. @@ -153,8 +154,8 @@ public: size_t checkSize(size_t max_size) const { size_t res = 1; - for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it) - res += (*it)->checkSize(max_size); + for (const auto & child : children) + res += child->checkSize(max_size); if (res > max_size) throw Exception("AST is too big. Maximum: " + toString(max_size), ErrorCodes::TOO_BIG_AST); @@ -166,8 +167,8 @@ public: */ virtual void collectIdentifierNames(IdentifierNameSet & set) const { - for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it) - (*it)->collectIdentifierNames(set); + for (const auto & child : children) + child->collectIdentifierNames(set); } @@ -236,11 +237,11 @@ private: size_t checkDepthImpl(size_t max_depth, size_t level) const { size_t res = level + 1; - for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it) + for (const auto & child : children) { if (level >= max_depth) throw Exception("AST is too deep. Maximum: " + toString(max_depth), ErrorCodes::TOO_DEEP_AST); - res = std::max(res, (*it)->checkDepthImpl(max_depth, level + 1)); + res = std::max(res, child->checkDepthImpl(max_depth, level + 1)); } return res; @@ -248,10 +249,6 @@ private: }; -using ASTPtr = SharedPtr; -using ASTs = std::vector; - - /// Квотировать идентификатор обратными кавычками, если это требуется. String backQuoteIfNeed(const String & x); diff --git a/dbms/include/DB/Parsers/ParserCreateQuery.h b/dbms/include/DB/Parsers/ParserCreateQuery.h index b8054af6e22..dac747ff397 100644 --- a/dbms/include/DB/Parsers/ParserCreateQuery.h +++ b/dbms/include/DB/Parsers/ParserCreateQuery.h @@ -82,11 +82,11 @@ bool IParserNameTypePair::parseImpl(Pos & pos, Pos end, ASTPtr & nod && ws_parser.ignore(pos, end, max_parsed_pos, expected) && type_parser.parse(pos, end, type, max_parsed_pos, expected)) { - ASTNameTypePair * name_type_pair = new ASTNameTypePair(StringRange(begin, pos)); - node = name_type_pair; + auto name_type_pair = std::make_shared(StringRange(begin, pos)); name_type_pair->name = typeid_cast(*name).name; name_type_pair->type = type; name_type_pair->children.push_back(type); + node = name_type_pair; return true; } @@ -167,7 +167,7 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, Pos end, ASTPtr else if (!type) return false; /// reject sole column name without type - const auto column_declaration = new ASTColumnDeclaration{StringRange{begin, pos}}; + const auto column_declaration = std::make_shared(StringRange{begin, pos}); node = column_declaration; column_declaration->name = typeid_cast(*name).name; if (type) diff --git a/dbms/include/DB/Parsers/ParserEnumElement.h b/dbms/include/DB/Parsers/ParserEnumElement.h index 15d5653aac3..20302f3ebf1 100644 --- a/dbms/include/DB/Parsers/ParserEnumElement.h +++ b/dbms/include/DB/Parsers/ParserEnumElement.h @@ -36,11 +36,10 @@ protected: if (!value_parser.parse(pos, end, value, max_parsed_pos, expected)) return false; - node = new ASTEnumElement{ + node = std::make_shared( { begin, pos }, static_cast(*name).value.get(), - static_cast(*value).value - }; + static_cast(*value).value); return true; } diff --git a/dbms/include/DB/Parsers/ParserShowProcesslistQuery.h b/dbms/include/DB/Parsers/ParserShowProcesslistQuery.h index 5db0b8496a5..6ce8c9d854c 100644 --- a/dbms/include/DB/Parsers/ParserShowProcesslistQuery.h +++ b/dbms/include/DB/Parsers/ParserShowProcesslistQuery.h @@ -24,8 +24,7 @@ protected: ParserString s_show("SHOW", true, true); ParserString s_processlist("PROCESSLIST", true, true); - ASTShowProcesslistQuery * query = new ASTShowProcesslistQuery; - ASTPtr query_ptr = query; + auto query = std::make_shared(); ws.ignore(pos, end); @@ -44,7 +43,7 @@ protected: return false; query->range = StringRange(begin, pos); - node = query_ptr; + node = query; return true; } diff --git a/dbms/include/DB/Parsers/ParserUseQuery.h b/dbms/include/DB/Parsers/ParserUseQuery.h index f7c87157cd8..006895906af 100644 --- a/dbms/include/DB/Parsers/ParserUseQuery.h +++ b/dbms/include/DB/Parsers/ParserUseQuery.h @@ -38,10 +38,9 @@ protected: ws.ignore(pos, end); - ASTUseQuery * query = new ASTUseQuery(StringRange(begin, pos)); - node = query; - + auto query = std::make_shared(StringRange(begin, pos)); query->database = typeid_cast(*database).name; + node = query; return true; } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionArray.cpp b/dbms/src/AggregateFunctions/AggregateFunctionArray.cpp index 832d144c4f4..199af509c99 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionArray.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionArray.cpp @@ -5,7 +5,7 @@ namespace DB AggregateFunctionPtr createAggregateFunctionArray(AggregateFunctionPtr & nested) { - return new AggregateFunctionArray(nested); + return std::make_shared(nested); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionAvg.cpp b/dbms/src/AggregateFunctions/AggregateFunctionAvg.cpp index 1e96f00b63b..39ce6d42ce3 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionAvg.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionAvg.cpp @@ -13,7 +13,7 @@ AggregateFunctionPtr createAggregateFunctionAvg(const std::string & name, const if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/dbms/src/AggregateFunctions/AggregateFunctionCount.cpp b/dbms/src/AggregateFunctions/AggregateFunctionCount.cpp index d67f77c45a5..017e7b14a5f 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionCount.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionCount.cpp @@ -9,7 +9,7 @@ namespace AggregateFunctionPtr createAggregateFunctionCount(const std::string & name, const DataTypes & argument_types) { - return new AggregateFunctionCount; + return std::make_shared(); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionDebug.cpp b/dbms/src/AggregateFunctions/AggregateFunctionDebug.cpp index f7137ac0507..a0b6f8d149b 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionDebug.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionDebug.cpp @@ -78,7 +78,7 @@ public: AggregateFunctionPtr createAggregateFunctionDebug(const std::string & name, const DataTypes & argument_types) { - return new AggregateFunctionDebug; + return std::make_shared(); } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionGroupArray.cpp b/dbms/src/AggregateFunctions/AggregateFunctionGroupArray.cpp index 44999ad6ec4..644fe3a0906 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionGroupArray.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionGroupArray.cpp @@ -14,10 +14,10 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(const std::string & name, throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) - res = new AggregateFunctionGroupArrayGeneric; + res = std::make_shared(); return res; } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp b/dbms/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp index af115816645..baf6e6b990c 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp @@ -14,7 +14,7 @@ AggregateFunctionPtr createAggregateFunctionGroupUniqArray(const std::string & n throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + diff --git a/dbms/src/AggregateFunctions/AggregateFunctionIf.cpp b/dbms/src/AggregateFunctions/AggregateFunctionIf.cpp index 56836d552d3..14bd1551ee5 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionIf.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionIf.cpp @@ -5,7 +5,7 @@ namespace DB AggregateFunctionPtr createAggregateFunctionIf(AggregateFunctionPtr & nested) { - return new AggregateFunctionIf(nested); + return std::make_shared(nested); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionMerge.cpp b/dbms/src/AggregateFunctions/AggregateFunctionMerge.cpp index fa619f0df3e..73bd179953f 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionMerge.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionMerge.cpp @@ -5,7 +5,7 @@ namespace DB AggregateFunctionPtr createAggregateFunctionMerge(AggregateFunctionPtr & nested) { - return new AggregateFunctionMerge(nested); + return std::make_shared(nested); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionQuantileExact.cpp b/dbms/src/AggregateFunctions/AggregateFunctionQuantileExact.cpp index b81a2ffa765..31acf2b0b43 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionQuantileExact.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionQuantileExact.cpp @@ -15,18 +15,20 @@ AggregateFunctionPtr createAggregateFunctionQuantileExact(const std::string & na const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileExact; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } @@ -39,18 +41,20 @@ AggregateFunctionPtr createAggregateFunctionQuantilesExact(const std::string & n const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesExact; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionQuantileExactWeighted.cpp b/dbms/src/AggregateFunctions/AggregateFunctionQuantileExactWeighted.cpp index 47c337d14cc..b605ffa60fe 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionQuantileExactWeighted.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionQuantileExactWeighted.cpp @@ -13,7 +13,7 @@ AggregateFunctionPtr createAggregateFunctionQuantileExactWeighted(const std::str if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() @@ -27,7 +27,7 @@ AggregateFunctionPtr createAggregateFunctionQuantilesExactWeighted(const std::st if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() diff --git a/dbms/src/AggregateFunctions/AggregateFunctionState.cpp b/dbms/src/AggregateFunctions/AggregateFunctionState.cpp index 8813a990d10..c341305771f 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionState.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionState.cpp @@ -5,7 +5,7 @@ namespace DB AggregateFunctionPtr createAggregateFunctionState(AggregateFunctionPtr & nested) { - return new AggregateFunctionState(nested); + return std::make_shared(nested); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionSum.cpp b/dbms/src/AggregateFunctions/AggregateFunctionSum.cpp index ca3bdb624ae..40d3322ac89 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionSum.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionSum.cpp @@ -13,7 +13,7 @@ AggregateFunctionPtr createAggregateFunctionSum(const std::string & name, const if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/dbms/src/AggregateFunctions/AggregateFunctionUniqUpTo.cpp b/dbms/src/AggregateFunctions/AggregateFunctionUniqUpTo.cpp index 5420e57f756..9247e2210d9 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionUniqUpTo.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionUniqUpTo.cpp @@ -14,18 +14,18 @@ AggregateFunctionPtr createAggregateFunctionUniqUpTo(const std::string & name, c { const IDataType & argument_type = *argument_types[0]; - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (res) return res; else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniqUpTo; + return std::make_shared>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniqUpTo; + return std::make_shared>(); else if (typeid_cast(&argument_type) || typeid_cast(&argument_type)) - return new AggregateFunctionUniqUpTo; + return std::make_shared>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniqUpToVariadic; + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } @@ -37,7 +37,7 @@ AggregateFunctionPtr createAggregateFunctionUniqUpTo(const std::string & name, c throw Exception("Tuple argument of function " + name + " must be the only argument", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - return new AggregateFunctionUniqUpToVariadic; + return std::make_shared>(); } else throw Exception("Incorrect number of arguments for aggregate function " + name, diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsMinMaxAny.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsMinMaxAny.cpp index a82d45db712..9b4bb14bd4d 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsMinMaxAny.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsMinMaxAny.cpp @@ -9,32 +9,32 @@ namespace AggregateFunctionPtr createAggregateFunctionAny(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionSingleValue(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionSingleValue(name, argument_types)); } AggregateFunctionPtr createAggregateFunctionAnyLast(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionSingleValue(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionSingleValue(name, argument_types)); } AggregateFunctionPtr createAggregateFunctionMin(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionSingleValue(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionSingleValue(name, argument_types)); } AggregateFunctionPtr createAggregateFunctionMax(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionSingleValue(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionSingleValue(name, argument_types)); } AggregateFunctionPtr createAggregateFunctionArgMin(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionArgMinMax(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionArgMinMax(name, argument_types)); } AggregateFunctionPtr createAggregateFunctionArgMax(const std::string & name, const DataTypes & argument_types) { - return createAggregateFunctionArgMinMax(name, argument_types); + return AggregateFunctionPtr(createAggregateFunctionArgMinMax(name, argument_types)); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsQuantile.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsQuantile.cpp index 0e1d7a70c20..96c6455820d 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsQuantile.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsQuantile.cpp @@ -15,18 +15,20 @@ AggregateFunctionPtr createAggregateFunctionQuantile(const std::string & name, c const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantile; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } @@ -39,18 +41,20 @@ AggregateFunctionPtr createAggregateFunctionQuantiles(const std::string & name, const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantiles; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_sharedv; + else if (typeid_cast(&argument_type)) + return std::make_shared>(); + else if (typeid_cast(&argument_type)) + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileDeterministic.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileDeterministic.cpp index fc1d2970dad..bb239e17aaf 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileDeterministic.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileDeterministic.cpp @@ -28,18 +28,18 @@ AggregateFunctionPtr createAggregateFunctionQuantileDeterministic(const std::str const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantileDeterministic; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } @@ -65,18 +65,18 @@ AggregateFunctionPtr createAggregateFunctionQuantilesDeterministic(const std::st const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; - else if (typeid_cast(&argument_type)) return new AggregateFunctionQuantilesDeterministic; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTDigest.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTDigest.cpp index 6c146c1b95b..5e94ca126ff 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTDigest.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTDigest.cpp @@ -16,18 +16,18 @@ AggregateFunctionPtr createAggregateFunctionQuantileTDigest(const std::string & const IDataType & argument_type = *argument_types[0]; - if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_type.getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } @@ -37,16 +37,16 @@ AggregateFunctionPtr createAggregateFunctionQuantileTDigestWeightedImpl(const st { const IDataType & argument_type = *argument_types[1]; - if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; - else if (typeid_cast(&argument_type)) return new FunctionTemplate; + if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); + else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_type.getName() + " of second argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTiming.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTiming.cpp index 1484928e62c..f474720c231 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTiming.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsQuantileTiming.cpp @@ -13,7 +13,7 @@ AggregateFunctionPtr createAggregateFunctionQuantileTiming(const std::string & n if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -26,7 +26,7 @@ AggregateFunctionPtr createAggregateFunctionQuantilesTiming(const std::string & if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -39,7 +39,7 @@ AggregateFunctionPtr createAggregateFunctionQuantileTimingWeighted(const std::st if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() @@ -53,7 +53,7 @@ AggregateFunctionPtr createAggregateFunctionQuantilesTimingWeighted(const std::s if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsSequenceMatch.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsSequenceMatch.cpp index ee436858620..55c0108291b 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsSequenceMatch.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsSequenceMatch.cpp @@ -12,7 +12,7 @@ AggregateFunctionPtr createAggregateFunctionSequenceCount(const std::string & na if (!AggregateFunctionSequenceCount::sufficientArgs(argument_types.size())) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - return new AggregateFunctionSequenceCount; + return std::make_shared(); } AggregateFunctionPtr createAggregateFunctionSequenceMatch(const std::string & name, const DataTypes & argument_types) @@ -20,7 +20,7 @@ AggregateFunctionPtr createAggregateFunctionSequenceMatch(const std::string & na if (!AggregateFunctionSequenceMatch::sufficientArgs(argument_types.size())) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - return new AggregateFunctionSequenceMatch; + return std::make_shared(); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsStatistics.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsStatistics.cpp index b8b358c9776..073144318c4 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsStatistics.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsStatistics.cpp @@ -13,7 +13,7 @@ AggregateFunctionPtr createAggregateFunctionVarPop(const std::string & name, con if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -26,7 +26,7 @@ AggregateFunctionPtr createAggregateFunctionVarSamp(const std::string & name, co if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -39,7 +39,7 @@ AggregateFunctionPtr createAggregateFunctionStdDevPop(const std::string & name, if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -52,7 +52,7 @@ AggregateFunctionPtr createAggregateFunctionStdDevSamp(const std::string & name, if (argument_types.size() != 1) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (!res) throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -65,7 +65,7 @@ AggregateFunctionPtr createAggregateFunctionCovarPop(const std::string & name, c if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() + " of arguments for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -78,7 +78,7 @@ AggregateFunctionPtr createAggregateFunctionCovarSamp(const std::string & name, if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() + " of arguments for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -92,7 +92,7 @@ AggregateFunctionPtr createAggregateFunctionCorr(const std::string & name, const if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); - AggregateFunctionPtr res = createWithTwoNumericTypes(*argument_types[0], *argument_types[1]); + AggregateFunctionPtr res(createWithTwoNumericTypes(*argument_types[0], *argument_types[1])); if (!res) throw Exception("Illegal types " + argument_types[0]->getName() + " and " + argument_types[1]->getName() + " of arguments for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/dbms/src/AggregateFunctions/AggregateFunctionsUniq.cpp b/dbms/src/AggregateFunctions/AggregateFunctionsUniq.cpp index 01def64d5dd..5e62413f4e4 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionsUniq.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionsUniq.cpp @@ -19,18 +19,18 @@ AggregateFunctionPtr createAggregateFunctionUniq(const std::string & name, const { const IDataType & argument_type = *argument_types[0]; - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (res) return res; else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniq; + return std::make_shared>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniq; + return std::make_shared>(); else if (typeid_cast(&argument_type) || typeid_cast(&argument_type)) - return new AggregateFunctionUniq; + return std::make_shared>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniqVariadic; + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -43,7 +43,7 @@ AggregateFunctionPtr createAggregateFunctionUniq(const std::string & name, const throw Exception("Tuple argument of function " + name + " must be the only argument", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - return new AggregateFunctionUniqVariadic; + return std::make_shared>(); } else throw Exception("Incorrect number of arguments for aggregate function " + name, @@ -57,18 +57,18 @@ AggregateFunctionPtr createAggregateFunctionUniq(const std::string & name, const { const IDataType & argument_type = *argument_types[0]; - AggregateFunctionPtr res = createWithNumericType(*argument_types[0]); + AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (res) return res; else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniq>; + return std::make_shared>>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniq>; + return std::make_shared>>(); else if (typeid_cast(&argument_type) || typeid_cast(&argument_type)) - return new AggregateFunctionUniq>; + return std::make_shared>>(); else if (typeid_cast(&argument_type)) - return new AggregateFunctionUniqVariadic; + return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); @@ -81,7 +81,7 @@ AggregateFunctionPtr createAggregateFunctionUniq(const std::string & name, const throw Exception("Tuple argument of function " + name + " must be the only argument", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - return new AggregateFunctionUniqVariadic; + return std::make_shared>(); } else throw Exception("Incorrect number of arguments for aggregate function " + name, diff --git a/dbms/src/Columns/ColumnAggregateFunction.cpp b/dbms/src/Columns/ColumnAggregateFunction.cpp index 47901d6e56a..7b39198f315 100644 --- a/dbms/src/Columns/ColumnAggregateFunction.cpp +++ b/dbms/src/Columns/ColumnAggregateFunction.cpp @@ -7,7 +7,7 @@ namespace DB ColumnPtr ColumnAggregateFunction::convertToValues() const { - const IAggregateFunction * function = holder->func; + const IAggregateFunction * function = holder->func.get(); ColumnPtr res = function->getReturnType()->createColumn(); /** Если агрегатная функция возвращает нефинализированное состояние, diff --git a/dbms/src/Common/VirtualColumnUtils.cpp b/dbms/src/Common/VirtualColumnUtils.cpp index bedfc667d0b..3b393e5bed1 100644 --- a/dbms/src/Common/VirtualColumnUtils.cpp +++ b/dbms/src/Common/VirtualColumnUtils.cpp @@ -70,7 +70,7 @@ void rewriteEntityInAst(ASTPtr ast, const String & column_name, const Field & va ASTSelectQuery & select = typeid_cast(*ast); ASTExpressionList & node = typeid_cast(*select.select_expression_list); ASTs & asts = node.children; - ASTLiteral * cur = new ASTLiteral(StringRange(), value); + auto cur = std::make_shared(StringRange(), value); cur->alias = column_name; ASTPtr column_value = cur; bool is_replaced = false; @@ -124,10 +124,10 @@ static ASTPtr buildWhereExpression(const ASTs & functions) { if (functions.size() == 0) return nullptr; if (functions.size() == 1) return functions[0]; - ASTPtr new_query = new ASTFunction(); + ASTPtr new_query = std::make_shared(); ASTFunction & new_function = typeid_cast(*new_query); new_function.name = "and"; - new_function.arguments = new ASTExpressionList(); + new_function.arguments = std::make_shared(); new_function.arguments->children = functions; new_function.children.push_back(new_function.arguments); return new_query; diff --git a/dbms/src/Functions/tests/logical_functions_performance.cpp b/dbms/src/Functions/tests/logical_functions_performance.cpp index 83da8c2360b..7f26ffbdda4 100644 --- a/dbms/src/Functions/tests/logical_functions_performance.cpp +++ b/dbms/src/Functions/tests/logical_functions_performance.cpp @@ -357,7 +357,7 @@ int main(int argc, char ** argv) for (size_t arity = 2; arity <= columns; ++arity) { - FunctionPtr function = new FunctionAnd; + FunctionPtr function = std::make_shared(); function->getReturnType(DataTypes(arity, DataTypePtr(std::make_shared()))); ColumnNumbers arguments(arity); diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.cpp b/dbms/src/Interpreters/ExpressionAnalyzer.cpp index 113dbc9fb3d..eba3fbb5bef 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.cpp +++ b/dbms/src/Interpreters/ExpressionAnalyzer.cpp @@ -418,43 +418,43 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name) * вместо выполнения подзапроса, надо будет просто из неё прочитать. */ - subquery_or_table_name = new ASTIdentifier(StringRange(), external_table_name, ASTIdentifier::Table); + subquery_or_table_name = std::make_shared(StringRange(), external_table_name, ASTIdentifier::Table); } else if (settings.global_subqueries_method == GlobalSubqueriesMethod::PULL) { String host_port = getFQDNOrHostName() + ":" + toString(context.getTCPPort()); String database = "_query_" + context.getCurrentQueryId(); - auto subquery = new ASTSubquery; + auto subquery = std::make_shared(); subquery_or_table_name = subquery; - auto select = new ASTSelectQuery; + auto select = std::make_shared(); subquery->children.push_back(select); - auto exp_list = new ASTExpressionList; + auto exp_list = std::make_shared(); select->select_expression_list = exp_list; select->children.push_back(select->select_expression_list); Names column_names = external_storage->getColumnNamesList(); for (const auto & name : column_names) - exp_list->children.push_back(new ASTIdentifier({}, name)); + exp_list->children.push_back(std::make_shared({}, name)); - auto table_func = new ASTFunction; + auto table_func = std::make_shared(); select->table = table_func; select->children.push_back(select->table); table_func->name = "remote"; - auto args = new ASTExpressionList; + auto args = std::make_shared(); table_func->arguments = args; table_func->children.push_back(table_func->arguments); - auto address_lit = new ASTLiteral({}, host_port); + auto address_lit = std::make_shared({}, host_port); args->children.push_back(address_lit); - auto database_lit = new ASTLiteral({}, database); + auto database_lit = std::make_shared({}, database); args->children.push_back(database_lit); - auto table_lit = new ASTLiteral({}, external_table_name); + auto table_lit = std::make_shared({}, external_table_name); args->children.push_back(table_lit); } else @@ -572,8 +572,7 @@ void ExpressionAnalyzer::normalizeTreeImpl( NamesAndTypesList::const_iterator it = findColumn(function_string); if (columns.end() != it) { - ASTIdentifier * ast_id = new ASTIdentifier(func_node->range, function_string); - ast = ast_id; + ast = std::make_shared(func_node->range, function_string); current_asts.insert(ast); replaced = true; } @@ -626,7 +625,7 @@ void ExpressionAnalyzer::normalizeTreeImpl( { ASTs all_columns; for (const auto & column_name_type : columns) - all_columns.emplace_back(new ASTIdentifier(asterisk->range, column_name_type.name)); + all_columns.emplace_back(std::make_shared(asterisk->range, column_name_type.name)); asts.erase(asts.begin() + i); asts.insert(asts.begin() + i, all_columns.begin(), all_columns.end()); @@ -759,17 +758,17 @@ void ExpressionAnalyzer::executeScalarSubqueries() static ASTPtr addTypeConversion(ASTLiteral * ast_, const String & type_name) { auto ast = std::unique_ptr(ast_); - ASTFunction * func = new ASTFunction(ast->range); + auto func = std::make_shared(ast->range); ASTPtr res = func; func->alias = ast->alias; ast->alias.clear(); func->kind = ASTFunction::FUNCTION; func->name = "CAST"; - ASTExpressionList * exp_list = new ASTExpressionList(ast->range); + auto exp_list = std::make_shared(ast->range); func->arguments = exp_list; func->children.push_back(func->arguments); exp_list->children.emplace_back(ast.release()); - exp_list->children.emplace_back(new ASTLiteral{{}, type_name}); + exp_list->children.emplace_back(std::make_shared({}, type_name)); return res; } @@ -826,18 +825,18 @@ void ExpressionAnalyzer::executeScalarSubqueriesImpl(ASTPtr & ast) size_t columns = block.columns(); if (columns == 1) { - ASTLiteral * lit = new ASTLiteral(ast->range, (*block.getByPosition(0).column)[0]); + auto lit = std::make_shared(ast->range, (*block.getByPosition(0).column)[0]); lit->alias = subquery->alias; ast = addTypeConversion(lit, block.getByPosition(0).type->getName()); } else { - ASTFunction * tuple = new ASTFunction(ast->range); + auto tuple = std::make_shared(ast->range); tuple->alias = subquery->alias; ast = tuple; tuple->kind = ASTFunction::FUNCTION; tuple->name = "tuple"; - ASTExpressionList * exp_list = new ASTExpressionList(ast->range); + auto exp_list = std::make_shared(ast->range); tuple->arguments = exp_list; tuple->children.push_back(tuple->arguments); @@ -845,7 +844,7 @@ void ExpressionAnalyzer::executeScalarSubqueriesImpl(ASTPtr & ast) for (size_t i = 0; i < columns; ++i) { exp_list->children[i] = addTypeConversion( - new ASTLiteral(ast->range, (*block.getByPosition(i).column)[0]), + std::make_shared(ast->range, (*block.getByPosition(i).column)[0]), block.getByPosition(i).type->getName()); } } @@ -975,8 +974,8 @@ void ExpressionAnalyzer::optimizeGroupBy() unused_column_name = toString(unused_column); } - select_query->group_expression_list = new ASTExpressionList; - select_query->group_expression_list->children.push_back(new ASTLiteral(StringRange(), UInt64(unused_column))); + select_query->group_expression_list = std::make_shared(); + select_query->group_expression_list->children.emplace_back(std::make_shared(StringRange(), UInt64(unused_column))); } } @@ -1076,10 +1075,10 @@ static std::shared_ptr interpretSubquery( if (table) { /// create ASTSelectQuery for "SELECT * FROM table" as if written by hand - const auto select_query = new ASTSelectQuery; + const auto select_query = std::make_shared(); query = select_query; - const auto select_expression_list = new ASTExpressionList; + const auto select_expression_list = std::make_shared(); select_query->select_expression_list = select_expression_list; select_query->children.emplace_back(select_query->select_expression_list); @@ -1090,9 +1089,8 @@ static std::shared_ptr interpretSubquery( /// manually substitute column names in place of asterisk for (const auto & column : columns) - select_expression_list->children.emplace_back(new ASTIdentifier{ - StringRange{}, column.name - }); + select_expression_list->children.emplace_back(std::make_shared( + StringRange{}, column.name)); select_query->table = subquery_or_table_name; select_query->children.emplace_back(select_query->table); @@ -1165,7 +1163,7 @@ void ExpressionAnalyzer::makeSet(ASTFunction * node, const Block & sample_block) { /// Получаем поток блоков для подзапроса. Создаём Set и кладём на место подзапроса. String set_id = arg->getColumnName(); - ASTSet * ast_set = new ASTSet(set_id); + auto ast_set = std::make_shared(set_id); ASTPtr ast_set_ptr = ast_set; /// Особый случай - если справа оператора IN указано имя таблицы, при чём, таблица имеет тип Set (заранее подготовленное множество). @@ -1332,17 +1330,16 @@ void ExpressionAnalyzer::makeExplicitSet(ASTFunction * node, const Block & sampl if (single_value) { - ASTPtr exp_list = new ASTExpressionList; + ASTPtr exp_list = std::make_shared(); exp_list->children.push_back(elements_ast); elements_ast = exp_list; } - ASTSet * ast_set = new ASTSet(arg->getColumnName()); - ASTPtr ast_set_ptr = ast_set; + auto ast_set = std::make_shared(arg->getColumnName()); ast_set->set = std::make_shared(settings.limits); ast_set->is_explicit = true; ast_set->set->createFromAST(set_element_types, elements_ast, context, create_ordered_set); - arg = ast_set_ptr; + arg = ast_set; } diff --git a/dbms/src/Interpreters/InterpreterCreateQuery.cpp b/dbms/src/Interpreters/InterpreterCreateQuery.cpp index e9934cd571e..a189beb6fac 100644 --- a/dbms/src/Interpreters/InterpreterCreateQuery.cpp +++ b/dbms/src/Interpreters/InterpreterCreateQuery.cpp @@ -72,7 +72,7 @@ void InterpreterCreateQuery::createDatabase(ASTCreateQuery & create) if (!create.storage) { database_engine_name = "Ordinary"; /// Движок баз данных по-умолчанию. - ASTFunction * func = new ASTFunction(); + auto func = std::make_shared(); func->name = database_engine_name; create.storage = func; } @@ -161,7 +161,7 @@ static ColumnsAndDefaults parseColumns( /** all default_expressions as a single expression list, * mixed with conversion-columns for each explicitly specified type */ - ASTPtr default_expr_list{new ASTExpressionList}; + ASTPtr default_expr_list = std::make_shared(); default_expr_list->children.reserve(column_list_ast.children.size()); const DataTypeFactory & data_type_factory = DataTypeFactory::instance(); @@ -195,8 +195,8 @@ static ColumnsAndDefaults parseColumns( const auto data_type_ptr = columns.back().type.get(); default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, - ASTPtr{new ASTLiteral{{}, data_type_ptr->getName()}}), final_column_name)); + makeASTFunction("CAST", std::make_shared({}, tmp_column_name), + std::make_shared({}, data_type_ptr->getName()), final_column_name)); default_expr_list->children.emplace_back(setAlias(col_decl.default_expression->clone(), tmp_column_name)); } else @@ -229,7 +229,7 @@ static ColumnsAndDefaults parseColumns( if (explicit_type->getName() != deduced_type->getName()) { col_decl_ptr->default_expression = makeASTFunction("CAST", col_decl_ptr->default_expression, - new ASTLiteral{{}, explicit_type->getName()}); + std::make_shared({}, explicit_type->getName())); col_decl_ptr->children.clear(); col_decl_ptr->children.push_back(col_decl_ptr->type); @@ -277,12 +277,11 @@ static NamesAndTypesList removeAndReturnColumns( ASTPtr InterpreterCreateQuery::formatColumns(const NamesAndTypesList & columns) { - ASTPtr columns_list_ptr{new ASTExpressionList}; - ASTExpressionList & columns_list = typeid_cast(*columns_list_ptr); + auto columns_list = std::make_shared; for (const auto & column : columns) { - const auto column_declaration = new ASTColumnDeclaration; + const auto column_declaration = std::make_shared(); ASTPtr column_declaration_ptr{column_declaration}; column_declaration->name = column.name; @@ -294,10 +293,10 @@ ASTPtr InterpreterCreateQuery::formatColumns(const NamesAndTypesList & columns) ParserIdentifierWithOptionalParameters storage_p; column_declaration->type = parseQuery(storage_p, pos, end, "data type"); column_declaration->type->query_string = type_name; - columns_list.children.push_back(column_declaration_ptr); + columns_list->children.push_back(column_declaration_ptr); } - return columns_list_ptr; + return columns_list; } ASTPtr InterpreterCreateQuery::formatColumns(NamesAndTypesList columns, @@ -308,12 +307,11 @@ ASTPtr InterpreterCreateQuery::formatColumns(NamesAndTypesList columns, columns.insert(std::end(columns), std::begin(materialized_columns), std::end(materialized_columns)); columns.insert(std::end(columns), std::begin(alias_columns), std::end(alias_columns)); - ASTPtr columns_list_ptr{new ASTExpressionList}; - ASTExpressionList & columns_list = typeid_cast(*columns_list_ptr); + auto columns_list = std::make_shared(); for (const auto & column : columns) { - const auto column_declaration = new ASTColumnDeclaration; + const auto column_declaration = std::make_shared(); ASTPtr column_declaration_ptr{column_declaration}; column_declaration->name = column.name; @@ -333,10 +331,10 @@ ASTPtr InterpreterCreateQuery::formatColumns(NamesAndTypesList columns, column_declaration->default_expression = it->second.expression->clone(); } - columns_list.children.push_back(column_declaration_ptr); + columns_list->children.push_back(column_declaration_ptr); } - return columns_list_ptr; + return columns_list; } @@ -409,7 +407,7 @@ String InterpreterCreateQuery::setEngine( auto set_engine = [&](const char * engine) { storage_name = engine; - ASTFunction * func = new ASTFunction(); + auto func = std::make_shared(); func->name = engine; create.storage = func; }; diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index cb99e7402f7..73a74a1b2da 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -680,7 +680,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns() if (alias_columns_required) { /// Составим выражение для возврата всех запрошенных столбцов, с вычислением требуемых ALIAS столбцов. - ASTPtr required_columns_expr_list{new ASTExpressionList}; + auto required_columns_expr_list = std::make_shared(); for (const auto & column : required_columns) { @@ -688,7 +688,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns() if (default_it != std::end(storage->column_defaults) && default_it->second.type == ColumnDefaultType::Alias) required_columns_expr_list->children.emplace_back(setAlias(default_it->second.expression->clone(), column)); else - required_columns_expr_list->children.emplace_back(new ASTIdentifier{{}, column}); + required_columns_expr_list->children.emplace_back(std::make_shared({}, column)); } alias_actions = ExpressionAnalyzer{required_columns_expr_list, context, storage, table_column_names}.getActions(true); diff --git a/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp b/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp index 187240663f1..a0f8e63e91c 100644 --- a/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp +++ b/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp @@ -214,8 +214,6 @@ bool LogicalExpressionsOptimizer::mayOptimizeDisjunctiveEqualityChain(const Disj void LogicalExpressionsOptimizer::addInExpression(const DisjunctiveEqualityChain & chain) { - using ASTFunctionPtr = Poco::SharedPtr; - const auto & or_with_expression = chain.first; const auto & equalities = chain.second; const auto & equality_functions = equalities.functions; @@ -223,7 +221,7 @@ void LogicalExpressionsOptimizer::addInExpression(const DisjunctiveEqualityChain /// 1. Создать новое выражение IN на основе информации из OR-цепочки. /// Построить список литералов x1, ..., xN из цепочки expr = x1 OR ... OR expr = xN - ASTPtr value_list = new ASTExpressionList; + ASTPtr value_list = std::make_shared(); for (const auto function : equality_functions) { const auto & operands = getFunctionOperands(function); @@ -247,17 +245,17 @@ void LogicalExpressionsOptimizer::addInExpression(const DisjunctiveEqualityChain equals_expr_lhs = operands[0]; } - ASTFunctionPtr tuple_function = new ASTFunction; + auto tuple_function = std::make_shared(); tuple_function->name = "tuple"; tuple_function->arguments = value_list; tuple_function->children.push_back(tuple_function->arguments); - ASTPtr expression_list = new ASTExpressionList; + ASTPtr expression_list = std::make_shared(); expression_list->children.push_back(equals_expr_lhs); expression_list->children.push_back(tuple_function); /// Построить выражение expr IN (x1, ..., xN) - ASTFunctionPtr in_function = new ASTFunction; + auto in_function = std::make_shared(); in_function->name = "in"; in_function->arguments = expression_list; in_function->children.push_back(in_function->arguments); diff --git a/dbms/src/Interpreters/QueryLog.cpp b/dbms/src/Interpreters/QueryLog.cpp index 17220b544e0..e2d1d73455a 100644 --- a/dbms/src/Interpreters/QueryLog.cpp +++ b/dbms/src/Interpreters/QueryLog.cpp @@ -49,8 +49,7 @@ QueryLog::QueryLog(Context & context_, const String & database_name_, const Stri while (context.isTableExist(database_name, table_name + "_" + toString(suffix))) ++suffix; - ASTRenameQuery * rename = new ASTRenameQuery; - ASTPtr holder = rename; + auto rename = std::make_shared(); ASTRenameQuery::Table from; from.database = database_name; @@ -69,7 +68,7 @@ QueryLog::QueryLog(Context & context_, const String & database_name_, const Stri LOG_DEBUG(log, "Existing table " << description << " for query log has obsolete or different structure." " Renaming it to " << backQuoteIfNeed(to.table)); - InterpreterRenameQuery(holder, context).execute(); + InterpreterRenameQuery(rename, context).execute(); /// Нужная таблица будет создана. table = nullptr; @@ -83,8 +82,7 @@ QueryLog::QueryLog(Context & context_, const String & database_name_, const Stri /// Создаём таблицу. LOG_DEBUG(log, "Creating new table " << description << " for query log."); - ASTCreateQuery * create = new ASTCreateQuery; - ASTPtr holder = create; + auto create = std::make_shared(); create->database = database_name; create->table = table_name; @@ -97,7 +95,7 @@ QueryLog::QueryLog(Context & context_, const String & database_name_, const Stri create->storage = parseQuery(engine_parser, engine.data(), engine.data() + engine.size(), "ENGINE to create table for query log"); - InterpreterCreateQuery(holder, context).execute(); + InterpreterCreateQuery(create, context).execute(); table = context.getTable(database_name, table_name); } diff --git a/dbms/src/Interpreters/reinterpretAsIdentifier.cpp b/dbms/src/Interpreters/reinterpretAsIdentifier.cpp index 24702f6f0a8..2f0ecfc95e1 100644 --- a/dbms/src/Interpreters/reinterpretAsIdentifier.cpp +++ b/dbms/src/Interpreters/reinterpretAsIdentifier.cpp @@ -16,7 +16,7 @@ namespace { /// for string literal return its value if (const auto literal = typeid_cast(expr.get())) - return new ASTIdentifier{{}, safeGet(literal->value)}; + return std::make_shared({}, safeGet(literal->value)); /// otherwise evaluate the expression Block block{}; @@ -33,7 +33,7 @@ namespace if (!typeid_cast(column_name_type.type.get())) throw Exception{"Expression must evaluate to a String"}; - return new ASTIdentifier{{}, column_name_type.column->getDataAt(0).toString()}; + return std::make_shared({}, column_name_type.column->getDataAt(0).toString()); } } diff --git a/dbms/src/Parsers/ASTAlterQuery.cpp b/dbms/src/Parsers/ASTAlterQuery.cpp index 926d09e600d..03e83e6522b 100644 --- a/dbms/src/Parsers/ASTAlterQuery.cpp +++ b/dbms/src/Parsers/ASTAlterQuery.cpp @@ -56,7 +56,7 @@ String ASTAlterQuery::getID() const ASTPtr ASTAlterQuery::clone() const { - ASTAlterQuery * res = new ASTAlterQuery(*this); + auto res = std::make_shared(*this); for (ParameterContainer::size_type i = 0; i < parameters.size(); ++i) parameters[i].clone(res->parameters[i]); return res; diff --git a/dbms/src/Parsers/ASTFunction.cpp b/dbms/src/Parsers/ASTFunction.cpp index 1bf2eb943a4..67756afa0e2 100644 --- a/dbms/src/Parsers/ASTFunction.cpp +++ b/dbms/src/Parsers/ASTFunction.cpp @@ -50,15 +50,13 @@ String ASTFunction::getID() const ASTPtr ASTFunction::clone() const { - ASTFunction * res = new ASTFunction(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); if (arguments) { res->arguments = arguments->clone(); res->children.push_back(res->arguments); } if (parameters) { res->parameters = parameters->clone(); res->children.push_back(res->parameters); } - return ptr; + return res; } void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const diff --git a/dbms/src/Parsers/ASTSelectQuery.cpp b/dbms/src/Parsers/ASTSelectQuery.cpp index dd384659c5b..242e1451b35 100644 --- a/dbms/src/Parsers/ASTSelectQuery.cpp +++ b/dbms/src/Parsers/ASTSelectQuery.cpp @@ -66,7 +66,7 @@ void ASTSelectQuery::renameColumns(const ASTSelectQuery & source) void ASTSelectQuery::rewriteSelectExpressionList(const Names & column_names) { - ASTPtr result = new ASTExpressionList; + ASTPtr result = std::make_shared(); ASTs asts = select_expression_list->children; /// Создать отображение. @@ -175,9 +175,7 @@ ASTPtr ASTSelectQuery::cloneFirstSelect() const ASTPtr ASTSelectQuery::cloneImpl(bool traverse_union_all) const { - ASTSelectQuery * res = new ASTSelectQuery(*this); - ASTPtr ptr{res}; - + auto res = std::make_shared(*this); res->children.clear(); #define CLONE(member) if (member) { res->member = member->clone(); res->children.push_back(res->member); } @@ -222,7 +220,7 @@ ASTPtr ASTSelectQuery::cloneImpl(bool traverse_union_all) const else res->next_union_all = nullptr; - return ptr; + return res; } const IAST * ASTSelectQuery::getFormat() const diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index 793c6e652a8..2bd98309955 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -51,7 +51,7 @@ bool ParserArray::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_ if (!close.ignore(pos, end, max_parsed_pos, expected)) return false; - ASTFunction * function_node = new ASTFunction(StringRange(begin, pos)); + auto function_node = std::make_shared(StringRange(begin, pos)); function_node->name = "array"; function_node->arguments = contents_node; function_node->children.push_back(contents_node); @@ -95,7 +95,7 @@ bool ParserParenthesisExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, P } else { - ASTFunction * function_node = new ASTFunction(StringRange(begin, pos)); + auto function_node = std::make_shared(StringRange(begin, pos)); function_node->name = "tuple"; function_node->arguments = contents_node; function_node->children.push_back(contents_node); @@ -125,7 +125,7 @@ bool ParserSubquery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pars if (!close.ignore(pos, end, max_parsed_pos, expected)) return false; - node = new ASTSubquery(StringRange(begin, pos)); + node = std::make_shared(StringRange(begin, pos)); typeid_cast(*node).children.push_back(select_node); return true; } @@ -146,7 +146,7 @@ bool ParserIdentifier::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pa return false; pos += buf.count(); - node = new ASTIdentifier(StringRange(begin, pos), s); + node = std::make_shared(StringRange(begin, pos), s); return true; } else @@ -160,7 +160,7 @@ bool ParserIdentifier::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pa if (pos != begin) { - node = new ASTIdentifier(StringRange(begin, pos), String(begin, pos - begin)); + node = std::make_shared(StringRange(begin, pos), String(begin, pos - begin)); return true; } else @@ -187,7 +187,7 @@ bool ParserCompoundIdentifier::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos name += static_cast(*child.get()).name; } - node = new ASTIdentifier(StringRange(begin, pos), name); + node = std::make_shared(StringRange(begin, pos), name); /// В children запомним идентификаторы-составляющие, если их больше одного. if (list.children.size() > 1) @@ -266,7 +266,7 @@ bool ParserFunction::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pars return false; } - ASTFunction * function_node = new ASTFunction(StringRange(begin, pos)); + auto function_node = std::make_shared(StringRange(begin, pos)); ASTPtr node_holder{function_node}; function_node->name = typeid_cast(*identifier).name; @@ -335,10 +335,10 @@ bool ParserCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma return false; } - expr_list_args = new ASTExpressionList{StringRange{contents_begin, end}}; + expr_list_args = std::make_shared(StringRange{contents_begin, end}); first_argument->setAlias({}); expr_list_args->children.push_back(first_argument); - expr_list_args->children.emplace_back(new ASTLiteral{{}, type}); + expr_list_args->children.emplace_back(std::make_shared({}, type)); } else { @@ -366,7 +366,7 @@ bool ParserCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma return false; } - expr_list_args = new ASTExpressionList{StringRange{contents_begin, end}}; + expr_list_args = std::make_shared(StringRange{contents_begin, end}); expr_list_args->children.push_back(first_argument); expr_list_args->children.push_back(type_as_literal); } @@ -379,7 +379,7 @@ bool ParserCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma return false; } - const auto function_node = new ASTFunction(StringRange(begin, pos)); + const auto function_node = std::make_shared(StringRange(begin, pos)); ASTPtr node_holder{function_node}; function_node->name = name; @@ -397,7 +397,7 @@ bool ParserNull::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p ParserString nested_parser("NULL", true); if (nested_parser.parse(pos, end, node, max_parsed_pos, expected)) { - node = new ASTLiteral(StringRange(StringRange(begin, pos)), Null()); + node = std::make_shared(StringRange(StringRange(begin, pos)), Null()); return true; } else @@ -451,7 +451,7 @@ bool ParserNumber::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed } pos += pos_double - buf; - node = new ASTLiteral(StringRange(begin, pos), res); + node = std::make_shared(StringRange(begin, pos), res); return true; } @@ -474,7 +474,7 @@ bool ParserUnsignedInteger::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & m res = x; pos += in.count(); - node = new ASTLiteral(StringRange(begin, pos), res); + node = std::make_shared(StringRange(begin, pos), res); return true; } @@ -503,7 +503,7 @@ bool ParserStringLiteral::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max } pos += in.count(); - node = new ASTLiteral(StringRange(begin, pos), s); + node = std::make_shared(StringRange(begin, pos), s); return true; } @@ -533,7 +533,7 @@ bool ParserArrayOfLiterals::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & m if (*pos == ']') { ++pos; - node = new ASTLiteral(StringRange(begin, pos), arr); + node = std::make_shared(StringRange(begin, pos), arr); return true; } else if (*pos == ',') @@ -684,7 +684,7 @@ bool ParserExpressionElement::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & if (asterisk_p.parse(pos, end, node, max_parsed_pos, expected)) { - node = new ASTAsterisk(StringRange(begin, pos)); + node = std::make_shared(StringRange(begin, pos)); return true; } @@ -790,7 +790,7 @@ bool ParserOrderByElement::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma collator = std::make_shared(locale); } - node = new ASTOrderByElement(StringRange(begin, pos), direction, collator); + node = std::make_shared(StringRange(begin, pos), direction, collator); node->children.push_back(expr_elem); return true; } @@ -802,7 +802,7 @@ bool ParserWeightedZooKeeperPath::parseImpl(Pos & pos, Pos end, ASTPtr & node, P ParserUnsignedInteger weight_p; ParserWhiteSpaceOrComments ws; - auto weighted_zookeeper_path = new ASTWeightedZooKeeperPath; + auto weighted_zookeeper_path = std::make_shared(); node = weighted_zookeeper_path; ws.ignore(pos, end); diff --git a/dbms/src/Parsers/ExpressionListParsers.cpp b/dbms/src/Parsers/ExpressionListParsers.cpp index 00c1f603b15..cb5524e48a8 100644 --- a/dbms/src/Parsers/ExpressionListParsers.cpp +++ b/dbms/src/Parsers/ExpressionListParsers.cpp @@ -78,7 +78,7 @@ bool ParserList::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p bool first = true; ParserWhiteSpaceOrComments ws; - ASTExpressionList * list = new ASTExpressionList; + auto list = std::make_shared(); node = list; while (1) @@ -151,30 +151,26 @@ bool ParserLeftAssociativeBinaryOperatorList::parseImpl(Pos & pos, Pos end, ASTP ws.ignore(pos, end); /// функция, соответствующая оператору - ASTFunction * p_function = new ASTFunction; - ASTFunction & function = *p_function; - ASTPtr function_node = p_function; + auto function = std::make_shared(); /// аргументы функции - ASTExpressionList * p_exp_list = new ASTExpressionList; - ASTExpressionList & exp_list = *p_exp_list; - ASTPtr exp_list_node = p_exp_list; + auto exp_list = std::make_shared(); ASTPtr elem; if (!(remaining_elem_parser ? remaining_elem_parser : first_elem_parser)->parse(pos, end, elem, max_parsed_pos, expected)) return false; /// первым аргументом функции будет предыдущий элемент, вторым - следующий - function.range.first = begin; - function.range.second = pos; - function.name = it[1]; - function.arguments = exp_list_node; - function.children.push_back(exp_list_node); + function->range.first = begin; + function->range.second = pos; + function->name = it[1]; + function->arguments = exp_list; + function->children.push_back(exp_list); - exp_list.children.push_back(node); - exp_list.children.push_back(elem); - exp_list.range.first = begin; - exp_list.range.second = pos; + exp_list->children.push_back(node); + exp_list->children.push_back(elem); + exp_list->range.first = begin; + exp_list->range.second = pos; /** специальное исключение для оператора доступа к элементу массива x[y], который * содержит инфиксную часть '[' и суффиксную ']' (задаётся в виде '[') @@ -188,7 +184,7 @@ bool ParserLeftAssociativeBinaryOperatorList::parseImpl(Pos & pos, Pos end, ASTP return false; } - node = function_node; + node = function; } } @@ -354,28 +350,24 @@ bool ParserTernaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr & nod return false; /// функция, соответствующая оператору - ASTFunction * p_function = new ASTFunction; - ASTFunction & function = *p_function; - ASTPtr function_node = p_function; + auto function = std::make_shared(); /// аргументы функции - ASTExpressionList * p_exp_list = new ASTExpressionList; - ASTExpressionList & exp_list = *p_exp_list; - ASTPtr exp_list_node = p_exp_list; + auto exp_list = std::make_shared(); - function.range.first = begin; - function.range.second = pos; - function.name = "if"; - function.arguments = exp_list_node; - function.children.push_back(exp_list_node); + function->range.first = begin; + function->range.second = pos; + function->name = "if"; + function->arguments = exp_list; + function->children.push_back(exp_list); - exp_list.children.push_back(elem_cond); - exp_list.children.push_back(elem_then); - exp_list.children.push_back(elem_else); - exp_list.range.first = begin; - exp_list.range.second = pos; + exp_list->children.push_back(elem_cond); + exp_list->children.push_back(elem_then); + exp_list->children.push_back(elem_else); + exp_list->range.first = begin; + exp_list->range.second = pos; - node = function_node; + node = function; } return true; @@ -424,15 +416,15 @@ bool ParserLambdaExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & /// lambda(tuple(inner_arguments), expression) - ASTFunction * lambda = new ASTFunction; + auto lambda = std::make_shared(); node = lambda; lambda->name = "lambda"; - ASTExpressionList * outer_arguments = new ASTExpressionList; + auto outer_arguments = std::make_shared(); lambda->arguments = outer_arguments; lambda->children.push_back(lambda->arguments); - ASTFunction * tuple = new ASTFunction; + auto tuple = std::make_shared(); outer_arguments->children.push_back(tuple); tuple->name = "tuple"; tuple->arguments = inner_arguments; @@ -505,26 +497,22 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr & else { /// функция, соответствующая оператору - ASTFunction * p_function = new ASTFunction; - ASTFunction & function = *p_function; - ASTPtr function_node = p_function; + auto function = std::make_shared(); /// аргументы функции - ASTExpressionList * p_exp_list = new ASTExpressionList; - ASTExpressionList & exp_list = *p_exp_list; - ASTPtr exp_list_node = p_exp_list; + auto exp_list = std::make_shared(); - function.range.first = begin; - function.range.second = pos; - function.name = it[1]; - function.arguments = exp_list_node; - function.children.push_back(exp_list_node); + function->range.first = begin; + function->range.second = pos; + function->name = it[1]; + function->arguments = exp_list; + function->children.push_back(exp_list); - exp_list.children.push_back(elem); - exp_list.range.first = begin; - exp_list.range.second = pos; + exp_list->children.push_back(elem); + exp_list->range.first = begin; + exp_list->range.second = pos; - node = function_node; + node = function; } return true; diff --git a/dbms/src/Parsers/ParserAlterQuery.cpp b/dbms/src/Parsers/ParserAlterQuery.cpp index 9baa5eb3e0c..1d4957c1b98 100644 --- a/dbms/src/Parsers/ParserAlterQuery.cpp +++ b/dbms/src/Parsers/ParserAlterQuery.cpp @@ -57,8 +57,7 @@ bool ParserAlterQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pa ASTPtr col_after; ASTPtr col_drop; - ASTAlterQuery * query = new ASTAlterQuery(); - ASTPtr query_ptr = query; + auto query = std::make_shared(); ws.ignore(pos, end); if (!s_alter.ignore(pos, end, max_parsed_pos, expected)) @@ -373,7 +372,7 @@ bool ParserAlterQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pa while (!parsing_finished); query->range = StringRange(begin, end); - node = query_ptr; + node = query; return true; } diff --git a/dbms/src/Parsers/ParserCase.cpp b/dbms/src/Parsers/ParserCase.cpp index f89154d1e3f..a02a0856d19 100644 --- a/dbms/src/Parsers/ParserCase.cpp +++ b/dbms/src/Parsers/ParserCase.cpp @@ -36,9 +36,6 @@ bool ParserCase::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p ASTs args; - using ASTFunctionPtr = Poco::SharedPtr; - using ASTExpressionListPtr = Poco::SharedPtr; - auto parse_branches = [&]() { bool has_branch = false; @@ -103,8 +100,8 @@ bool ParserCase::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p return false; /// Hand-craft a transform() function. - ASTExpressionListPtr src_expr_list = new ASTExpressionList{StringRange{begin, pos}}; - ASTExpressionListPtr dst_expr_list = new ASTExpressionList{StringRange{begin, pos}}; + auto src_expr_list = std::make_shared(StringRange{begin, pos}); + auto dst_expr_list = std::make_shared(StringRange{begin, pos}); for (size_t i = 0; i < (args.size() - 1); ++i) { @@ -114,25 +111,25 @@ bool ParserCase::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p dst_expr_list->children.push_back(args[i]); } - ASTFunctionPtr src_array_function = new ASTFunction{StringRange{begin, pos}}; + auto src_array_function = std::make_shared(StringRange{begin, pos}); src_array_function->name = "array"; src_array_function->genus = ASTFunction::Genus::CASE_ARRAY; src_array_function->arguments = src_expr_list; src_array_function->children.push_back(src_array_function->arguments); - ASTFunctionPtr dst_array_function = new ASTFunction{StringRange{begin, pos}}; + auto dst_array_function = std::make_shared(StringRange{begin, pos}); dst_array_function->name = "array"; dst_array_function->genus = ASTFunction::Genus::CASE_ARRAY; dst_array_function->arguments = dst_expr_list; dst_array_function->children.push_back(dst_array_function->arguments); - ASTPtr function_args = new ASTExpressionList{StringRange{begin, pos}}; + auto function_args = std::make_shared(StringRange{begin, pos}); function_args->children.push_back(case_expr); function_args->children.push_back(src_array_function); function_args->children.push_back(dst_array_function); function_args->children.emplace_back(args.back()); - ASTFunctionPtr function = new ASTFunction{StringRange{begin, pos}}; + auto function = std::make_shared(StringRange{begin, pos}); function->name = "transform"; function->genus = ASTFunction::Genus::CASE_WITH_EXPR; function->arguments = function_args; @@ -146,10 +143,10 @@ bool ParserCase::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p return false; /// Hand-craft a multiIf() function. - ASTPtr function_args = new ASTExpressionList{StringRange{begin, pos}}; + auto function_args = std::make_shared(StringRange{begin, pos}); function_args->children = std::move(args); - ASTFunctionPtr function = new ASTFunction{StringRange{begin, pos}}; + auto function = std::make_shared(StringRange{begin, pos}); function->name = "multiIf"; function->genus = ASTFunction::Genus::CASE_WITHOUT_EXPR; function->arguments = function_args; diff --git a/dbms/src/Parsers/ParserCheckQuery.cpp b/dbms/src/Parsers/ParserCheckQuery.cpp index 96a9ba66b03..c7d1cb62377 100644 --- a/dbms/src/Parsers/ParserCheckQuery.cpp +++ b/dbms/src/Parsers/ParserCheckQuery.cpp @@ -17,7 +17,7 @@ bool ParserCheckQuery::parseImpl(IParser::Pos & pos, IParser::Pos end, ASTPtr & ASTPtr table; ASTPtr database; - Poco::SharedPtr query = new ASTCheckQuery(StringRange(pos, end)); + auto query = std::make_shared(StringRange(pos, end)); ws.ignore(pos, end); diff --git a/dbms/src/Parsers/ParserCreateQuery.cpp b/dbms/src/Parsers/ParserCreateQuery.cpp index 313d45b54da..269dfd0c6df 100644 --- a/dbms/src/Parsers/ParserCreateQuery.cpp +++ b/dbms/src/Parsers/ParserCreateQuery.cpp @@ -42,11 +42,11 @@ bool ParserNestedTable::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p if (!close.ignore(pos, end)) return false; - ASTFunction * func = new ASTFunction(StringRange(begin, pos)); - node = func; + auto func = std::make_shared(StringRange(begin, pos)); func->name = typeid_cast(*name).name; func->arguments = columns; func->children.push_back(columns); + node = func; return true; } @@ -79,9 +79,9 @@ bool ParserIdentifierWithOptionalParameters::parseImpl(Pos & pos, Pos end, ASTPt ASTPtr ident; if (non_parametric.parse(pos, end, ident, max_parsed_pos, expected)) { - ASTFunction * func = new ASTFunction(StringRange(begin, pos)); - node = func; + auto func = std::make_shared(StringRange(begin, pos)); func->name = typeid_cast(*ident).name; + node = func; return true; } @@ -93,9 +93,7 @@ bool ParserTypeInCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Po if (ParserIdentifierWithOptionalParameters::parseImpl(pos, end, node, max_parsed_pos, expected)) { const auto & id_with_params = typeid_cast(*node); - - node = new ASTIdentifier{id_with_params.range, { id_with_params.range.first, id_with_params.range.second }}; - + node = std::make_shared(id_with_params.range, { id_with_params.range.first, id_with_params.range.second }); return true; } @@ -389,7 +387,7 @@ bool ParserCreateQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p ws.ignore(pos, end); - ASTCreateQuery * query = new ASTCreateQuery(StringRange(begin, pos)); + auto query = std::make_shared(StringRange(begin, pos)); node = query; query->attach = attach; diff --git a/dbms/src/Parsers/ParserDropQuery.cpp b/dbms/src/Parsers/ParserDropQuery.cpp index 2e275d57167..f4767356755 100644 --- a/dbms/src/Parsers/ParserDropQuery.cpp +++ b/dbms/src/Parsers/ParserDropQuery.cpp @@ -83,7 +83,7 @@ bool ParserDropQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_par ws.ignore(pos, end); - ASTDropQuery * query = new ASTDropQuery(StringRange(begin, pos)); + auto query = std::make_shared(StringRange(begin, pos)); node = query; query->detach = detach; diff --git a/dbms/src/Parsers/ParserInsertQuery.cpp b/dbms/src/Parsers/ParserInsertQuery.cpp index 86967c51644..b539b41d1de 100644 --- a/dbms/src/Parsers/ParserInsertQuery.cpp +++ b/dbms/src/Parsers/ParserInsertQuery.cpp @@ -149,7 +149,7 @@ bool ParserInsertQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p return false; } - ASTInsertQuery * query = new ASTInsertQuery(StringRange(begin, data ? data : pos)); + auto query = std::make_shared(StringRange(begin, data ? data : pos)); node = query; if (database) diff --git a/dbms/src/Parsers/ParserJoin.cpp b/dbms/src/Parsers/ParserJoin.cpp index b4dc76317a4..2045b21f37a 100644 --- a/dbms/src/Parsers/ParserJoin.cpp +++ b/dbms/src/Parsers/ParserJoin.cpp @@ -18,7 +18,7 @@ bool ParserJoin::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_p { Pos begin = pos; - ASTJoin * join = new ASTJoin(StringRange(begin, pos)); + auto join = std::make_shared(StringRange(begin, pos)); node = join; ParserWhiteSpaceOrComments ws; diff --git a/dbms/src/Parsers/ParserOptimizeQuery.cpp b/dbms/src/Parsers/ParserOptimizeQuery.cpp index c19d6732ee2..f892b4e2c93 100644 --- a/dbms/src/Parsers/ParserOptimizeQuery.cpp +++ b/dbms/src/Parsers/ParserOptimizeQuery.cpp @@ -69,7 +69,7 @@ bool ParserOptimizeQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max if (s_final.ignore(pos, end, max_parsed_pos, expected)) final = true; - ASTOptimizeQuery * query = new ASTOptimizeQuery(StringRange(begin, pos)); + auto query = std::make_shared(StringRange(begin, pos)); node = query; if (database) diff --git a/dbms/src/Parsers/ParserRenameQuery.cpp b/dbms/src/Parsers/ParserRenameQuery.cpp index d7c8880e0fd..6405c2a5a9c 100644 --- a/dbms/src/Parsers/ParserRenameQuery.cpp +++ b/dbms/src/Parsers/ParserRenameQuery.cpp @@ -82,7 +82,7 @@ bool ParserRenameQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p return false; } - ASTRenameQuery * query = new ASTRenameQuery(StringRange(begin, pos)); + auto query = std::make_shared(StringRange(begin, pos)); node = query; query->elements = elements; diff --git a/dbms/src/Parsers/ParserSampleRatio.cpp b/dbms/src/Parsers/ParserSampleRatio.cpp index 89bf1c4f029..286895e7374 100644 --- a/dbms/src/Parsers/ParserSampleRatio.cpp +++ b/dbms/src/Parsers/ParserSampleRatio.cpp @@ -121,7 +121,7 @@ bool ParserSampleRatio::parseImpl(IParser::Pos & pos, IParser::Pos end, ASTPtr & ws.ignore(pos, end); - node = new ASTSampleRatio(StringRange(begin, pos), res); + node = std::make_shared(StringRange(begin, pos), res); return true; } diff --git a/dbms/src/Parsers/ParserSelectQuery.cpp b/dbms/src/Parsers/ParserSelectQuery.cpp index b243dad0b05..899fdd8c6f5 100644 --- a/dbms/src/Parsers/ParserSelectQuery.cpp +++ b/dbms/src/Parsers/ParserSelectQuery.cpp @@ -24,7 +24,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_p { Pos begin = pos; - ASTSelectQuery * select_query = new ASTSelectQuery; + auto select_query = std::make_shared(); node = select_query; ParserString s_select("SELECT", true, true); diff --git a/dbms/src/Parsers/ParserSetQuery.cpp b/dbms/src/Parsers/ParserSetQuery.cpp index 43291df42b0..b68b3b57f57 100644 --- a/dbms/src/Parsers/ParserSetQuery.cpp +++ b/dbms/src/Parsers/ParserSetQuery.cpp @@ -86,7 +86,7 @@ bool ParserSetQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_pars return false; } - ASTSetQuery * query = new ASTSetQuery(StringRange(begin, pos)); + auto query = std::make_shared(StringRange(begin, pos)); node = query; query->changes = changes; diff --git a/dbms/src/Parsers/ParserShowTablesQuery.cpp b/dbms/src/Parsers/ParserShowTablesQuery.cpp index 0c0d12b0756..651b1072812 100644 --- a/dbms/src/Parsers/ParserShowTablesQuery.cpp +++ b/dbms/src/Parsers/ParserShowTablesQuery.cpp @@ -27,8 +27,7 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & m ASTPtr like; ASTPtr database; - ASTShowTablesQuery * query = new ASTShowTablesQuery; - ASTPtr query_ptr = query; + auto query = std::make_shared(); ws.ignore(pos, end); @@ -90,7 +89,7 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & m if (query->format) query->children.push_back(query->format); - node = query_ptr; + node = query; return true; } diff --git a/dbms/src/Parsers/ParserTablePropertiesQuery.cpp b/dbms/src/Parsers/ParserTablePropertiesQuery.cpp index ae374a0822d..88ec36061f2 100644 --- a/dbms/src/Parsers/ParserTablePropertiesQuery.cpp +++ b/dbms/src/Parsers/ParserTablePropertiesQuery.cpp @@ -30,11 +30,11 @@ bool ParserTablePropertiesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Po if (s_exists.ignore(pos, end, max_parsed_pos, expected)) { - query_ptr = new ASTExistsQuery; + query_ptr = std::make_shared(); } else if (s_describe.ignore(pos, end, max_parsed_pos, expected) || s_desc.ignore(pos, end, max_parsed_pos, expected)) { - query_ptr = new ASTDescribeQuery; + query_ptr = std::make_shared(); } else if (s_show.ignore(pos, end, max_parsed_pos, expected)) { @@ -43,7 +43,7 @@ bool ParserTablePropertiesQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Po if (!s_create.ignore(pos, end, max_parsed_pos, expected)) return false; - query_ptr = new ASTShowCreateQuery; + query_ptr = std::make_shared(); } else { diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index ebffd347331..97d569d64e1 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -195,7 +195,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) std::vector> defaulted_columns{}; - ASTPtr default_expr_list{new ASTExpressionList}; + auto default_expr_list = std::make_shared(); default_expr_list->children.reserve(defaults.size()); for (AlterCommand & command : *this) @@ -239,8 +239,8 @@ void AlterCommands::validate(IStorage * table, const Context & context) const auto column_type_raw_ptr = command.data_type.get(); default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, - ASTPtr{new ASTLiteral{{}, column_type_raw_ptr->getName()}}), + makeASTFunction("CAST", std::make_shared({}, tmp_column_name), + std::make_shared({}, column_type_raw_ptr->getName())), final_column_name)); default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name)); @@ -293,8 +293,8 @@ void AlterCommands::validate(IStorage * table, const Context & context) const auto & column_type_ptr = column_it->type; default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, - ASTPtr{new ASTLiteral{{}, column_type_ptr->getName()}}), + makeASTFunction("CAST", std::make_shared({}, tmp_column_name), + std::make_shared({}, column_type_ptr->getName())), column_name)); default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name)); @@ -339,7 +339,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) } command_ptr->default_expression = makeASTFunction("CAST", command_ptr->default_expression->clone(), - ASTPtr{new ASTLiteral{{}, explicit_type->getName()}}); + std::make_shared({}, explicit_type->getName())); } } else diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 619d873b4bf..68b73d85e85 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -232,8 +232,7 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( /// Семплирование. Names column_names_to_read = real_column_names; - using ASTFunctionPtr = Poco::SharedPtr; - ASTFunctionPtr filter_function; + std::shared_ptr filter_function; ExpressionActionsPtr filter_expression; RelativeSize relative_sample_size = 0; @@ -391,19 +390,19 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( { /// Добавим условия, чтобы отсечь еще что-нибудь при повторном просмотре индекса и при обработке запроса. - ASTFunctionPtr lower_function; - ASTFunctionPtr upper_function; + std::shared_ptr lower_function; + std::shared_ptr upper_function; if (has_lower_limit) { if (!key_condition.addCondition(data.sampling_expression->getColumnName(), Range::createLeftBounded(lower, true))) throw Exception("Sampling column not in primary key", ErrorCodes::ILLEGAL_COLUMN); - ASTPtr args = new ASTExpressionList; + ASTPtr args = std::make_shared(); args->children.push_back(data.sampling_expression); - args->children.push_back(new ASTLiteral(StringRange(), lower)); + args->children.push_back(std::make_shared(StringRange(), lower)); - lower_function = new ASTFunction; + lower_function = std::make_shared(); lower_function->name = "greaterOrEquals"; lower_function->arguments = args; lower_function->children.push_back(lower_function->arguments); @@ -416,11 +415,11 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( if (!key_condition.addCondition(data.sampling_expression->getColumnName(), Range::createRightBounded(upper, false))) throw Exception("Sampling column not in primary key", ErrorCodes::ILLEGAL_COLUMN); - ASTPtr args = new ASTExpressionList; + ASTPtr args = std::make_shared(); args->children.push_back(data.sampling_expression); - args->children.push_back(new ASTLiteral(StringRange(), upper)); + args->children.push_back(std::make_shared(StringRange(), upper)); - upper_function = new ASTFunction; + upper_function = std::make_shared(); upper_function->name = "less"; upper_function->arguments = args; upper_function->children.push_back(upper_function->arguments); @@ -430,11 +429,11 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( if (has_lower_limit && has_upper_limit) { - ASTPtr args = new ASTExpressionList; + ASTPtr args = std::make_shared(); args->children.push_back(lower_function); args->children.push_back(upper_function); - filter_function = new ASTFunction; + filter_function = std::make_shared(); filter_function->name = "and"; filter_function->arguments = args; filter_function->children.push_back(filter_function->arguments); @@ -825,31 +824,24 @@ BlockInputStreams MergeTreeDataSelectExecutor::spreadMarkRangesAmongThreadsFinal void MergeTreeDataSelectExecutor::createPositiveSignCondition( ExpressionActionsPtr & out_expression, String & out_column, const Context & context) const { - ASTFunction * function = new ASTFunction; - ASTPtr function_ptr = function; - - ASTExpressionList * arguments = new ASTExpressionList; - ASTPtr arguments_ptr = arguments; - - ASTIdentifier * sign = new ASTIdentifier; - ASTPtr sign_ptr = sign; - - ASTLiteral * one = new ASTLiteral; - ASTPtr one_ptr = one; + auto function = std::make_shared(); + auto arguments = std::make_shared(); + auto sign = std::make_shared(); + auto one = std::make_shared(); function->name = "equals"; - function->arguments = arguments_ptr; - function->children.push_back(arguments_ptr); + function->arguments = arguments; + function->children.push_back(arguments); - arguments->children.push_back(sign_ptr); - arguments->children.push_back(one_ptr); + arguments->children.push_back(sign); + arguments->children.push_back(one); sign->name = data.merging_params.sign_column; sign->kind = ASTIdentifier::Column; one->value = Field(static_cast(1)); - out_expression = ExpressionAnalyzer(function_ptr, context, {}, data.getColumnsList()).getActions(false); + out_expression = ExpressionAnalyzer(function, context, {}, data.getColumnsList()).getActions(false); out_column = function->getColumnName(); } diff --git a/dbms/src/Storages/StorageBuffer.cpp b/dbms/src/Storages/StorageBuffer.cpp index 8e3c8768922..28d519cea78 100644 --- a/dbms/src/Storages/StorageBuffer.cpp +++ b/dbms/src/Storages/StorageBuffer.cpp @@ -431,8 +431,7 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl return; } - ASTInsertQuery * insert = new ASTInsertQuery; - ASTPtr ast_ptr = insert; + auto insert = std::make_shared(); insert->database = destination_database; insert->table = destination_table; @@ -469,13 +468,13 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl LOG_WARNING(log, "Not all columns from block in buffer exist in destination table " << destination_database << "." << destination_table << ". Some columns are discarded."); - ASTExpressionList * list_of_columns = new ASTExpressionList; + auto list_of_columns = std::make_shared(); insert->columns = list_of_columns; list_of_columns->children.reserve(columns_intersection.size()); for (const String & column : columns_intersection) - list_of_columns->children.push_back(new ASTIdentifier(StringRange(), column, ASTIdentifier::Column)); + list_of_columns->children.push_back(std::make_shared(StringRange(), column, ASTIdentifier::Column)); - InterpreterInsertQuery interpreter{ast_ptr, context}; + InterpreterInsertQuery interpreter{insert, context}; auto block_io = interpreter.execute(); block_io.out->writePrefix(); diff --git a/dbms/src/Storages/StorageDistributed.cpp b/dbms/src/Storages/StorageDistributed.cpp index 5c93d6866c4..d080d558adc 100644 --- a/dbms/src/Storages/StorageDistributed.cpp +++ b/dbms/src/Storages/StorageDistributed.cpp @@ -55,8 +55,8 @@ namespace auto modified_query_ast = query->clone(); auto & actual_query = typeid_cast(*modified_query_ast); - actual_query.database = new ASTIdentifier{{}, database, ASTIdentifier::Database}; - actual_query.table = new ASTIdentifier{{}, table, ASTIdentifier::Table}; + actual_query.database = std::make_shared({}, database, ASTIdentifier::Database); + actual_query.table = std::make_shared({}, table, ASTIdentifier::Table); return modified_query_ast; } @@ -276,7 +276,7 @@ void StorageDistributed::reshardPartitions(ASTPtr query, const String & database { /// Создать запрос ALTER TABLE ... RESHARD [COPY] PARTITION ... COORDINATE WITH ... - ASTPtr alter_query_ptr = new ASTAlterQuery; + ASTPtr alter_query_ptr = std::make_shared(); auto & alter_query = static_cast(*alter_query_ptr); alter_query.database = remote_database; @@ -287,14 +287,14 @@ void StorageDistributed::reshardPartitions(ASTPtr query, const String & database parameters.type = ASTAlterQuery::RESHARD_PARTITION; if (!first_partition.isNull()) - parameters.partition = new ASTLiteral{{}, first_partition}; + parameters.partition = std::make_shared({}, first_partition); if (!last_partition.isNull()) - parameters.last_partition = new ASTLiteral{{}, last_partition}; + parameters.last_partition = std::make_shared({}, last_partition); - ASTPtr expr_list = new ASTExpressionList; + ASTPtr expr_list = std::make_shared(); for (const auto & entry : weighted_zookeeper_paths) { - ASTPtr weighted_path_ptr = new ASTWeightedZooKeeperPath; + ASTPtr weighted_path_ptr = std::make_shared(); auto & weighted_path = static_cast(*weighted_path_ptr); weighted_path.path = entry.first; weighted_path.weight = entry.second; @@ -304,7 +304,7 @@ void StorageDistributed::reshardPartitions(ASTPtr query, const String & database parameters.weighted_zookeeper_paths = expr_list; parameters.sharding_key_expr = sharding_key_expr; parameters.do_copy = do_copy; - parameters.coordinator = new ASTLiteral{{}, coordinator_id}; + parameters.coordinator = std::make_shared({}, coordinator_id); resharding_worker.registerQuery(coordinator_id, queryToString(alter_query_ptr)); @@ -379,7 +379,7 @@ BlockInputStreams StorageDistributed::describe(const Context & context, const Se { /// Создать запрос DESCRIBE TABLE. - ASTPtr describe_query_ptr = new ASTDescribeQuery; + ASTPtr describe_query_ptr = std::make_shared(); auto & describe_query = static_cast(*describe_query_ptr); describe_query.database = remote_database; diff --git a/dbms/src/Storages/StorageFactory.cpp b/dbms/src/Storages/StorageFactory.cpp index c8a20b2c409..80d09a785ee 100644 --- a/dbms/src/Storages/StorageFactory.cpp +++ b/dbms/src/Storages/StorageFactory.cpp @@ -72,10 +72,9 @@ static ASTPtr extractPrimaryKey(const ASTPtr & node) else { /// Первичный ключ состоит из одного столбца. - ASTExpressionList * res = new ASTExpressionList; - ASTPtr res_ptr = res; + auto res = std::make_shared(); res->children.push_back(node); - return res_ptr; + return res; } } diff --git a/dbms/src/Storages/StorageMaterializedView.cpp b/dbms/src/Storages/StorageMaterializedView.cpp index ae24b2b4bcf..f56b902d27a 100644 --- a/dbms/src/Storages/StorageMaterializedView.cpp +++ b/dbms/src/Storages/StorageMaterializedView.cpp @@ -55,18 +55,17 @@ StorageMaterializedView::StorageMaterializedView( if (!attach_) { /// Составим запрос для создания внутреннего хранилища. - ASTCreateQuery * manual_create_query = new ASTCreateQuery(); + auto manual_create_query = std::make_shared(); manual_create_query->database = database_name; manual_create_query->table = inner_table_name; manual_create_query->columns = create.columns; manual_create_query->children.push_back(manual_create_query->columns); - ASTPtr ast_create_query = manual_create_query; /// Если не указан в запросе тип хранилища попробовать извлечь его из запроса Select. if (!create.inner_storage) { /// TODO так же попытаться извлечь params для создания хранилища - ASTFunction * func = new ASTFunction(); + auto func = std::make_shared(); func->name = context.getTable(select_database_name, select_table_name)->getName(); manual_create_query->storage = func; } @@ -76,7 +75,7 @@ StorageMaterializedView::StorageMaterializedView( manual_create_query->children.push_back(manual_create_query->storage); /// Выполним запрос. - InterpreterCreateQuery create_interpreter(ast_create_query, context); + InterpreterCreateQuery create_interpreter(manual_create_query, context); create_interpreter.execute(); } } @@ -123,7 +122,7 @@ void StorageMaterializedView::drop() if (context.tryGetTable(database_name, inner_table_name)) { /// Состваляем и выполняем запрос drop для внутреннего хранилища. - ASTDropQuery *drop_query = new ASTDropQuery; + ASTDropQuery *drop_query = std::make_shared(); drop_query->database = database_name; drop_query->table = inner_table_name; ASTPtr ast_drop_query = drop_query; diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 6afe8d8accb..1650520200f 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -213,7 +213,7 @@ void StorageMergeTree::alter( if (primary_key_is_modified) engine_modifier = [&new_primary_key_ast] (ASTPtr & engine_ast) { - ASTFunction * tuple = new ASTFunction(new_primary_key_ast->range); + auto tuple = std::make_shared(new_primary_key_ast->range); tuple->name = "tuple"; tuple->arguments = new_primary_key_ast; tuple->children.push_back(tuple->arguments); diff --git a/dbms/src/Storages/StorageView.cpp b/dbms/src/Storages/StorageView.cpp index d3df577fd84..418486537a0 100644 --- a/dbms/src/Storages/StorageView.cpp +++ b/dbms/src/Storages/StorageView.cpp @@ -50,7 +50,7 @@ StorageView::StorageView( /// Если во внутреннем запросе не указана база данных, получить ее из контекста и записать в запрос. if (!select.database) { - select.database = new ASTIdentifier(StringRange(), database_name_, ASTIdentifier::Database); + select.database = std::make_shared(StringRange(), database_name_, ASTIdentifier::Database); select.children.push_back(select.database); }