From 03bdb93dd919edfab2fed0d19c22584028a1da57 Mon Sep 17 00:00:00 2001 From: zvonand Date: Sun, 13 Nov 2022 13:34:33 +0300 Subject: [PATCH] fix fuzzer(3) --- src/Functions/FunctionsDecimalArithmetics.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Functions/FunctionsDecimalArithmetics.h b/src/Functions/FunctionsDecimalArithmetics.h index e6d3cf7a900..dd63ca2598f 100644 --- a/src/Functions/FunctionsDecimalArithmetics.h +++ b/src/Functions/FunctionsDecimalArithmetics.h @@ -320,9 +320,15 @@ public: if (!isDecimal(arguments[0].type) || !isDecimal(arguments[1].type)) throw Exception("Arguments for " + getName() + " function must be Decimal", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - if (arguments.size() == 3 && !isUnsignedInteger(arguments[2].type)) - throw Exception("Illegal type " + arguments[2].type->getName() + " of third argument of function " + getName() + - ". Should be constant Integer from range[0, 76]", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + if (arguments.size() == 3) + { + WhichDataType which_scale(arguments[2].type.get()); + if (which_scale.isUInt16()) + throw Exception( + "Illegal type " + arguments[2].type->getName() + " of third argument of function " + getName() + + ". Should be constant Integer from range[0, 76]", + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); + } UInt16 scale = arguments.size() == 3 ? checkAndGetColumnConst(arguments[2].column.get())->getValue() : std::max(getDecimalScale(*arguments[0].type->getPtr()), getDecimalScale(*arguments[1].type->getPtr()));