mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #22964 from ClickHouse/uniq-up-to-ubsan
Check out of range values in FieldVisitorConverToNumber
This commit is contained in:
commit
b9fe85d537
@ -185,12 +185,20 @@ public:
|
||||
/// Conversion of infinite values to integer is undefined.
|
||||
throw Exception("Cannot convert infinite value to integer type", ErrorCodes::CANNOT_CONVERT_TYPE);
|
||||
}
|
||||
else if (x > std::numeric_limits<T>::max() || x < std::numeric_limits<T>::lowest())
|
||||
{
|
||||
throw Exception("Cannot convert out of range floating point value to integer type", ErrorCodes::CANNOT_CONVERT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<Decimal256, T>)
|
||||
{
|
||||
return Int256(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
return T(x);
|
||||
}
|
||||
}
|
||||
|
||||
T operator() (const UInt128 &) const
|
||||
|
@ -1,4 +1,3 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
@ -12,7 +12,7 @@ SETTINGS index_granularity = 8192;
|
||||
INSERT INTO t0 VALUES (0, 0);
|
||||
|
||||
SELECT t0.c1 FROM t0 WHERE NOT (t0.c1 OR (t0.c0 AND -1524532316));
|
||||
SELECT t0.c1 FROM t0 WHERE NOT (t0.c1 OR (t0.c0 AND -1.0));
|
||||
SELECT t0.c1 FROM t0 WHERE NOT (t0.c1 OR (t0.c0 AND -1.0)); -- { serverError 70 }
|
||||
SELECT t0.c1 FROM t0 WHERE NOT (t0.c1 OR (t0.c0 AND inf));
|
||||
SELECT t0.c1 FROM t0 WHERE NOT (t0.c1 OR (t0.c0 AND nan));
|
||||
|
||||
|
2
tests/queries/0_stateless/01804_uniq_up_to_ubsan.sql
Normal file
2
tests/queries/0_stateless/01804_uniq_up_to_ubsan.sql
Normal file
@ -0,0 +1,2 @@
|
||||
SELECT uniqUpTo(1e100)(number) FROM numbers(5); -- { serverError 70 }
|
||||
SELECT uniqUpTo(-1e100)(number) FROM numbers(5); -- { serverError 70 }
|
Loading…
Reference in New Issue
Block a user