Fix keyed hash issue with empty array/map input

This commit is contained in:
Salvatore Mesoraca 2024-08-08 10:07:05 +02:00 committed by Robert Schulze
parent 1c54c0d239
commit 4d0fc70227
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
3 changed files with 13 additions and 3 deletions

View File

@ -96,9 +96,8 @@ namespace impl
{
const auto *const begin = offsets->begin();
const auto * upper = std::upper_bound(begin, offsets->end(), i);
if (upper == offsets->end())
throw Exception(ErrorCodes::LOGICAL_ERROR, "offset {} not found in function SipHashKeyColumns::getKey", i);
i = upper - begin;
if (upper != offsets->end())
i = upper - begin;
}
const auto & key0data = assert_cast<const ColumnUInt64 &>(*key0).getData();
const auto & key1data = assert_cast<const ColumnUInt64 &>(*key1).getData();

View File

@ -239,3 +239,8 @@ Check bug found fuzzing
Check bug 2 found fuzzing
608E1FF030C9E206185B112C2A25F1A7
ABB65AE97711A2E053E324ED88B1D08B
Check bug 3 found fuzzing
4761183170873013810
0AD04BFD000000000000000000000000
4761183170873013810
0AD04BFD000000000000000000000000

View File

@ -345,3 +345,9 @@ CREATE TABLE sipHashKeyed_keys (`a` Map(String, String)) ENGINE = Memory;
INSERT INTO sipHashKeyed_keys FORMAT VALUES ({'a':'b', 'c':'d'}), ({'e':'f', 'g':'h'});
SELECT hex(sipHash128ReferenceKeyed((0::UInt64, materialize(0::UInt64)), a)) FROM sipHashKeyed_keys ORDER BY a;
DROP TABLE sipHashKeyed_keys;
SELECT 'Check bug 3 found fuzzing';
SELECT sipHash64Keyed((1::UInt64, 2::UInt64), []::Array(UInt8));
SELECT hex(sipHash128Keyed((1::UInt64, 2::UInt64), []::Array(UInt8)));
SELECT sipHash64Keyed((1::UInt64, 2::UInt64), mapFromArrays([], []));
SELECT hex(sipHash128Keyed((1::UInt64, 2::UInt64), mapFromArrays([], [])));