diff --git a/src/Functions/array/arrayEnumerateExtended.h b/src/Functions/array/arrayEnumerateExtended.h index 412fe9e7858..39bdd2a515e 100644 --- a/src/Functions/array/arrayEnumerateExtended.h +++ b/src/Functions/array/arrayEnumerateExtended.h @@ -353,6 +353,9 @@ bool FunctionArrayEnumerateExtended::execute128bit( keys_bytes += key_sizes[j]; } + if (keys_bytes > 16) + return false; + executeMethod(offsets, columns, key_sizes, nullptr, res_values); return true; } diff --git a/tests/queries/0_stateless/01677_array_enumerate_bug.reference b/tests/queries/0_stateless/01677_array_enumerate_bug.reference new file mode 100644 index 00000000000..9c0e526801f --- /dev/null +++ b/tests/queries/0_stateless/01677_array_enumerate_bug.reference @@ -0,0 +1,2 @@ +[1,1,2] +[1,1,1] diff --git a/tests/queries/0_stateless/01677_array_enumerate_bug.sql b/tests/queries/0_stateless/01677_array_enumerate_bug.sql new file mode 100644 index 00000000000..0db0c51fe5b --- /dev/null +++ b/tests/queries/0_stateless/01677_array_enumerate_bug.sql @@ -0,0 +1,13 @@ +-- there was a bug - missing check of the total size of keys for the case with hash table with 128bit key. + +SELECT arrayEnumerateUniq(arrayEnumerateUniq([toInt256(10), toInt256(100), toInt256(2)]), [toInt256(123), toInt256(1023), toInt256(123)]); + +SELECT arrayEnumerateUniq( + [111111, 222222, 333333], + [444444, 555555, 666666], + [111111, 222222, 333333], + [444444, 555555, 666666], + [111111, 222222, 333333], + [444444, 555555, 666666], + [111111, 222222, 333333], + [444444, 555555, 666666]);