#include #include #include namespace DB { template struct MultiplyImpl { using ResultType = typename NumberTraits::ResultOfAdditionMultiplication::Type; static const constexpr bool allow_decimal = true; template static inline NO_SANITIZE_UNDEFINED Result apply(A a, B b) { return static_cast(a) * b; } /// Apply operation and check overflow. It's used for Deciamal operations. @returns true if overflowed, false othervise. template static inline bool apply(A a, B b, Result & c) { return common::mulOverflow(static_cast(a), b, c); } #if USE_EMBEDDED_COMPILER static constexpr bool compilable = true; static inline llvm::Value * compile(llvm::IRBuilder<> & b, llvm::Value * left, llvm::Value * right, bool) { return left->getType()->isIntegerTy() ? b.CreateMul(left, right) : b.CreateFMul(left, right); } #endif }; struct NameMultiply { static constexpr auto name = "multiply"; }; using FunctionMultiply = FunctionBinaryArithmetic; void registerFunctionMultiply(FunctionFactory & factory) { factory.registerFunction(); } }