mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix overflow in mapPopulateSeries
This commit is contained in:
parent
b0f201df72
commit
1209c02869
@ -16,6 +16,7 @@ namespace ErrorCodes
|
|||||||
extern const int ILLEGAL_COLUMN;
|
extern const int ILLEGAL_COLUMN;
|
||||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||||
|
extern const int TOO_LARGE_ARRAY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FunctionMapPopulateSeries : public IFunction
|
class FunctionMapPopulateSeries : public IFunction
|
||||||
@ -188,9 +189,13 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr size_t MAX_ARRAY_SIZE = 1ULL << 30;
|
||||||
|
if (static_cast<size_t>(max_key - min_key) > MAX_ARRAY_SIZE)
|
||||||
|
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Too large array size in the result of function {}", getName());
|
||||||
|
|
||||||
/* fill the result arrays */
|
/* fill the result arrays */
|
||||||
KeyType key;
|
KeyType key;
|
||||||
for (key = min_key; key <= max_key; ++key)
|
for (key = min_key;; ++key)
|
||||||
{
|
{
|
||||||
to_keys_data.insert(key);
|
to_keys_data.insert(key);
|
||||||
|
|
||||||
@ -205,6 +210,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
++offset;
|
++offset;
|
||||||
|
if (key == max_key)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_keys_offsets.push_back(offset);
|
to_keys_offsets.push_back(offset);
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
([18446744073709551615],[0])
|
@ -0,0 +1,2 @@
|
|||||||
|
SELECT mapPopulateSeries([0xFFFFFFFFFFFFFFFF], [0], 0xFFFFFFFFFFFFFFFF);
|
||||||
|
SELECT mapPopulateSeries([toUInt64(1)], [1], 0xFFFFFFFFFFFFFFFF); -- { serverError 128 }
|
Loading…
Reference in New Issue
Block a user