Fix crash in sqidDecode

This commit is contained in:
Robert Schulze 2024-09-10 15:35:59 +00:00
parent 5ef98cd275
commit 04dcf73e8f
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
3 changed files with 9 additions and 1 deletions

View File

@ -124,7 +124,7 @@ public:
std::string_view sqid = col_non_const->getDataAt(i).toView();
std::vector<UInt64> integers = sqids.decode(String(sqid));
res_nested_data.insert(integers.begin(), integers.end());
res_offsets_data.push_back(integers.size());
res_offsets_data.push_back(i == 0 ? integers.size() : res_offsets_data.back() + integers.size());
}
}
else

View File

@ -13,5 +13,6 @@ Td1EnWQo [1,2,3,4]
XMbT
-- invalid sqid
[]
-- bug 69450
-- alias
XMbT

View File

@ -25,5 +25,12 @@ SELECT sqidEncode(toNullable(materialize(1)), toLowCardinality(materialize(2)));
SELECT '-- invalid sqid';
SELECT sqidDecode('invalid sqid');
SELECT '-- bug 69450';
DROP TABLE IF EXISTS tab;
CREATE TABLE tab (id String) ENGINE = MergeTree ORDER BY id;
INSERT INTO tab SELECT * FROM generateRandom() LIMIT 1000000;
SELECT sqidDecode(id) FROM tab FORMAT Null;
DROP TABLE tab;
SELECT '-- alias';
SELECT sqid(1, 2);