mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Print nicer exception if BLAKE3 is unavailable
This commit is contained in:
parent
2933a28a5d
commit
9dd15998c7
@ -43,7 +43,6 @@ REGISTER_FUNCTION(Hashing)
|
||||
factory.registerFunction<FunctionWyHash64>();
|
||||
|
||||
|
||||
#if USE_BLAKE3
|
||||
factory.registerFunction<FunctionBLAKE3>(
|
||||
{
|
||||
R"(
|
||||
@ -53,10 +52,9 @@ The function is rather fast and shows approximately two times faster performance
|
||||
It returns a BLAKE3 hash as a byte array with type FixedString(32).
|
||||
)",
|
||||
Documentation::Examples{
|
||||
{"hash", "SELECT hex(blake3('ABC'))"}},
|
||||
{"hash", "SELECT hex(BLAKE3('ABC'))"}},
|
||||
Documentation::Categories{"Hash"}
|
||||
},
|
||||
FunctionFactory::CaseSensitive);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ namespace ErrorCodes
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
extern const int NOT_IMPLEMENTED;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
extern const int SUPPORT_IS_DISABLED;
|
||||
}
|
||||
|
||||
|
||||
@ -620,29 +621,38 @@ struct ImplXxHash64
|
||||
};
|
||||
|
||||
|
||||
#if USE_BLAKE3
|
||||
struct ImplBLAKE3
|
||||
{
|
||||
static constexpr auto name = "blake3";
|
||||
static constexpr auto name = "BLAKE3";
|
||||
enum { length = 32 };
|
||||
|
||||
#if !USE_BLAKE3
|
||||
[[ noreturn ]]
|
||||
#endif
|
||||
static void apply(const char * begin, const size_t size, unsigned char* out_char_data)
|
||||
{
|
||||
#if defined(MEMORY_SANITIZER)
|
||||
auto err_msg = blake3_apply_shim_msan_compat(begin, size, out_char_data);
|
||||
__msan_unpoison(out_char_data, length);
|
||||
#if USE_BLAKE3
|
||||
#if defined(MEMORY_SANITIZER)
|
||||
auto err_msg = blake3_apply_shim_msan_compat(begin, size, out_char_data);
|
||||
__msan_unpoison(out_char_data, length);
|
||||
#else
|
||||
auto err_msg = blake3_apply_shim(begin, size, out_char_data);
|
||||
#endif
|
||||
if (err_msg != nullptr)
|
||||
{
|
||||
auto err_st = std::string(err_msg);
|
||||
blake3_free_char_pointer(err_msg);
|
||||
throw Exception("Function returned error message: " + std::string(err_msg), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
#else
|
||||
auto err_msg = blake3_apply_shim(begin, size, out_char_data);
|
||||
(void) begin;
|
||||
(void) size;
|
||||
(void) out_char_data;
|
||||
throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "BLAKE3 is not available. Rust code or BLAKE3 itself may be disabled.");
|
||||
#endif
|
||||
if (err_msg != nullptr)
|
||||
{
|
||||
auto err_st = std::string(err_msg);
|
||||
blake3_free_char_pointer(err_msg);
|
||||
throw Exception("Function returned error message: " + std::string(err_msg), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template <typename Impl>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<value>SHA224</value>
|
||||
<value>SHA256</value>
|
||||
<value>halfMD5</value>
|
||||
<value>blake3</value>
|
||||
<value>BLAKE3</value>
|
||||
</values>
|
||||
</substitution>
|
||||
<substitution>
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Tags: no-fasttest
|
||||
|
||||
SELECT hex(blake3('test_1'));
|
||||
SELECT hex(blake3('test_2'));
|
||||
SELECT hex(blake3('test_3'));
|
||||
SELECT hex(BLAKE3('test_1'));
|
||||
SELECT hex(BLAKE3('test_2'));
|
||||
SELECT hex(BLAKE3('test_3'));
|
||||
|
Loading…
Reference in New Issue
Block a user