From 9c48ac79c81b99f9a2c2107dffef02f59d80831f Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Sun, 22 Jan 2023 16:16:56 +0000 Subject: [PATCH] Fix issue #45195 --- src/Compression/CompressionCodecGorilla.cpp | 2 +- .../02536_delta_gorilla_corruption.reference | 9 +++++ .../02536_delta_gorilla_corruption.sql | 34 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/02536_delta_gorilla_corruption.reference create mode 100644 tests/queries/0_stateless/02536_delta_gorilla_corruption.sql diff --git a/src/Compression/CompressionCodecGorilla.cpp b/src/Compression/CompressionCodecGorilla.cpp index cbae30d774e..6c7c7138776 100644 --- a/src/Compression/CompressionCodecGorilla.cpp +++ b/src/Compression/CompressionCodecGorilla.cpp @@ -403,7 +403,7 @@ UInt32 CompressionCodecGorilla::doCompressData(const char * source, UInt32 sourc break; } - return 1 + 1 + result_size; + return 2 + bytes_to_skip + result_size; } void CompressionCodecGorilla::doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const diff --git a/tests/queries/0_stateless/02536_delta_gorilla_corruption.reference b/tests/queries/0_stateless/02536_delta_gorilla_corruption.reference new file mode 100644 index 00000000000..82220c1598a --- /dev/null +++ b/tests/queries/0_stateless/02536_delta_gorilla_corruption.reference @@ -0,0 +1,9 @@ +Original bug: the same query executed multiple times yielded different results. +For unclear reasons this happened only in Release builds, not in Debug builds. +0 +0 +0 +The same issue in a much smaller repro happens also in Debug builds +0 +1 +3 diff --git a/tests/queries/0_stateless/02536_delta_gorilla_corruption.sql b/tests/queries/0_stateless/02536_delta_gorilla_corruption.sql new file mode 100644 index 00000000000..94ee6c03c5c --- /dev/null +++ b/tests/queries/0_stateless/02536_delta_gorilla_corruption.sql @@ -0,0 +1,34 @@ +select 'Original bug: the same query executed multiple times yielded different results.'; +select 'For unclear reasons this happened only in Release builds, not in Debug builds.'; + +drop table if exists bug_delta_gorilla; + +create table bug_delta_gorilla +(value_bug UInt64 codec (Delta, Gorilla)) +engine = MergeTree +order by tuple() +as (select 0 from numbers(30000000)); + +select count(*) +from bug_delta_gorilla +where 0 <> value_bug; + +select count(*) +from bug_delta_gorilla +where 0 <> value_bug; + +select count(*) +from bug_delta_gorilla +where 0 <> value_bug; + +drop table if exists bug_delta_gorilla; + +select 'The same issue in a much smaller repro happens also in Debug builds'; + +create table bug_delta_gorilla (val UInt64 codec (Delta, Gorilla)) +engine = MergeTree +order by val; +insert into bug_delta_gorilla values (0)(1)(3); +select * from bug_delta_gorilla; + +drop table if exists bug_delta_gorilla;