Fixed overflow in rounding functions with integer argument and large negative scale [#CLICKHOUSE-2]

This commit is contained in:
Alexey Milovidov 2018-12-24 02:12:30 +03:00
parent aca29588c7
commit 80f155cfda
5 changed files with 10 additions and 6 deletions

View File

@ -87,7 +87,7 @@ struct IntegerRoundingComputation
return scale;
}
static ALWAYS_INLINE T computeImpl(T x, T scale)
static ALWAYS_INLINE T computeImpl(T x, size_t scale)
{
switch (rounding_mode)
{
@ -122,7 +122,7 @@ struct IntegerRoundingComputation
}
}
static ALWAYS_INLINE T compute(T x, T scale)
static ALWAYS_INLINE T compute(T x, size_t scale)
{
switch (scale_mode)
{

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,4 @@
SET send_logs_level = 'none';
SELECT truncate(895, -16);
SELECT ( SELECT toDecimal128([], rowNumberInBlock()) ) , lcm('', [[(CAST(('>A') AS String))]]); -- { serverError 44 }

View File

@ -1,6 +1,4 @@
SELECT sequenceCount((CAST((( SELECT NULL ) AS rg, ( SELECT ( SELECT [], '<e', caseWithExpr([NULL], -588755.149, []), retention(addWeeks((CAST((-7644612.39732) AS DateTime)), -23578040.02833), (CAST(([]) AS DateTime)), (CAST(([010977.08]) AS String))), emptyArrayToSingle('') ) , '\0', toUInt64([], 't3hw@'), '\0', toStartOfQuarter(-4230.1872, []) ) ) AS Date)));
SELECT ( SELECT toDecimal128([], rowNumberInBlock()) ) , lcm('', [[(CAST(('>A') AS String))]]);
SELECT truncate(895, -16);
SELECT subtractDays((CAST((-5263074.47) AS DateTime)), -737895);
SELECT quantileDeterministic([], findClusterIndex(( SELECT subtractDays((CAST((566450.398706) AS DateTime)), 54) ) )), '\0', [];
SELECT addDays((CAST((96.338) AS DateTime)), -3);

View File

@ -32,7 +32,8 @@ inline uint64_t intExp10(int x)
return table[x];
}
namespace common {
namespace common
{
inline int exp10_i32(int x)
{
@ -123,4 +124,4 @@ inline __int128 exp10_i128(int x)
return values[x];
}
} // common
}