mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #40002 from Algunenano/fix_hashid
Fix hashId crash and salt parameter not being used
This commit is contained in:
commit
547662f88b
@ -52,6 +52,7 @@ public:
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return true; }
|
||||
ColumnNumbers getArgumentsThatAreAlwaysConstant() const override { return {1, 2, 3}; }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override
|
||||
{
|
||||
@ -69,7 +70,7 @@ public:
|
||||
if (arguments.size() > 1)
|
||||
{
|
||||
const auto & hash_col = arguments[1];
|
||||
if (!isString(hash_col.type) || !isColumnConst(*hash_col.column.get()))
|
||||
if (!isString(hash_col.type))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Second argument of function {} must be String, got {}",
|
||||
@ -80,7 +81,7 @@ public:
|
||||
if (arguments.size() > 2)
|
||||
{
|
||||
const auto & min_length_col = arguments[2];
|
||||
if (!isUInt8(min_length_col.type) || !isColumnConst(*min_length_col.column.get()))
|
||||
if (!isUInt8(min_length_col.type))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Third argument of function {} must be UInt8, got {}",
|
||||
@ -91,7 +92,7 @@ public:
|
||||
if (arguments.size() > 3)
|
||||
{
|
||||
const auto & alphabet_col = arguments[3];
|
||||
if (!isString(alphabet_col.type) || !isColumnConst(*alphabet_col.column.get()))
|
||||
if (!isString(alphabet_col.type))
|
||||
throw Exception(
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
|
||||
"Fourth argument of function {} must be String, got {}",
|
||||
|
@ -8,5 +8,8 @@
|
||||
2 obmgndljgajpkeao
|
||||
3 dldokmpjpgjgeanb
|
||||
4 nkdlpgajngjnobme
|
||||
xkOpDGxQpVB
|
||||
jR
|
||||
YQrvD5XGvbx
|
||||
Bm3zaOq7zbp
|
||||
oV
|
||||
oV
|
||||
6b
|
||||
|
@ -1,7 +1,16 @@
|
||||
-- Tags: no-backward-compatibility-check
|
||||
SET allow_experimental_hash_functions = 1;
|
||||
|
||||
select number, hashid(number) from system.numbers limit 5;
|
||||
select number, hashid(number, 's3cr3t', 16, 'abcdefghijklmnop') from system.numbers limit 5;
|
||||
select hashid(1234567890123456, 's3cr3t');
|
||||
select hashid(1234567890123456, 's3cr3t2');
|
||||
|
||||
SELECT hashid(1, hashid(2));
|
||||
SELECT hashid(1, 'k5');
|
||||
SELECT hashid(1, 'k5_othersalt');
|
||||
|
||||
-- https://github.com/ClickHouse/ClickHouse/issues/39672
|
||||
SELECT
|
||||
JSONExtractRaw(257, NULL),
|
||||
hashid(1024, if(rand() % 10, 'truetruetruetrue', NULL), 's3\0r3t'); -- {serverError 43}
|
||||
|
Loading…
Reference in New Issue
Block a user