mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix step overflow in range()
This commit is contained in:
parent
79bde24da6
commit
e9d373b5b7
@ -145,8 +145,14 @@ private:
|
||||
for (size_t row_idx = 0; row_idx < input_rows_count; ++row_idx)
|
||||
{
|
||||
for (size_t st = start, ed = end_data[row_idx]; st < ed; st += step)
|
||||
{
|
||||
out_data[offset++] = st;
|
||||
|
||||
if (st > st + step)
|
||||
throw Exception{"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
|
||||
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
|
||||
}
|
||||
|
||||
out_offsets[row_idx] = offset;
|
||||
}
|
||||
|
||||
@ -200,8 +206,14 @@ private:
|
||||
for (size_t row_idx = 0; row_idx < input_rows_count; ++row_idx)
|
||||
{
|
||||
for (size_t st = start_data[row_idx], ed = end_data[row_idx]; st < ed; st += step)
|
||||
{
|
||||
out_data[offset++] = st;
|
||||
|
||||
if (st > st + step)
|
||||
throw Exception{"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
|
||||
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
|
||||
}
|
||||
|
||||
out_offsets[row_idx] = offset;
|
||||
}
|
||||
|
||||
@ -255,8 +267,14 @@ private:
|
||||
for (size_t row_idx = 0; row_idx < input_rows_count; ++row_idx)
|
||||
{
|
||||
for (size_t st = start, ed = end_data[row_idx]; st < ed; st += step_data[row_idx])
|
||||
{
|
||||
out_data[offset++] = st;
|
||||
|
||||
if (st > st + step_data[row_idx])
|
||||
throw Exception{"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
|
||||
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
|
||||
}
|
||||
|
||||
out_offsets[row_idx] = offset;
|
||||
}
|
||||
|
||||
@ -313,8 +331,14 @@ private:
|
||||
for (size_t row_idx = 0; row_idx < input_rows_count; ++row_idx)
|
||||
{
|
||||
for (size_t st = start_data[row_idx], ed = end_start[row_idx]; st < ed; st += step_data[row_idx])
|
||||
{
|
||||
out_data[offset++] = st;
|
||||
|
||||
if (st > st + step_data[row_idx])
|
||||
throw Exception{"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
|
||||
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
|
||||
}
|
||||
|
||||
out_offsets[row_idx] = offset;
|
||||
}
|
||||
|
||||
|
12
tests/queries/0_stateless/01408_range_overflow.sql
Normal file
12
tests/queries/0_stateless/01408_range_overflow.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- executeGeneric()
|
||||
SELECT range(1025, 1048576 + 9223372036854775807, 9223372036854775807); -- { serverError 69; }
|
||||
SELECT range(1025, 1048576 + (9223372036854775807 AS i), i); -- { serverError 69; }
|
||||
|
||||
-- executeConstStep()
|
||||
SELECT range(number, 1048576 + 9223372036854775807, 9223372036854775807) FROM system.numbers LIMIT 1 OFFSET 1025; -- { serverError 69; }
|
||||
|
||||
-- executeConstStartStep()
|
||||
SELECT range(1025, number + 9223372036854775807, 9223372036854775807) FROM system.numbers LIMIT 1 OFFSET 1048576; -- { serverError 69; }
|
||||
|
||||
-- executeConstStart()
|
||||
SELECT range(1025, 1048576 + 9223372036854775807, number + 9223372036854775807) FROM system.numbers LIMIT 1; -- { serverError 69; }
|
Loading…
Reference in New Issue
Block a user