mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix bug with uncompressed checksums in CHECK TABLE query
This commit is contained in:
parent
0fb6cf0a4c
commit
c17fa34fa5
@ -99,19 +99,6 @@ IMergeTreeDataPart::Checksums checkDataPart(
|
||||
throw Exception("Unknown type in part " + path, ErrorCodes::UNKNOWN_PART_TYPE);
|
||||
}
|
||||
|
||||
for (auto it = disk->iterateDirectory(path); it->isValid(); it->next())
|
||||
{
|
||||
const String & file_name = it->name();
|
||||
auto checksum_it = checksums_data.files.find(file_name);
|
||||
if (checksum_it == checksums_data.files.end() && file_name != "checksums.txt" && file_name != "columns.txt")
|
||||
{
|
||||
auto file_buf = disk->readFile(it->path());
|
||||
HashingReadBuffer hashing_buf(*file_buf);
|
||||
hashing_buf.tryIgnore(std::numeric_limits<size_t>::max());
|
||||
checksums_data.files[file_name] = IMergeTreeDataPart::Checksums::Checksum(hashing_buf.count(), hashing_buf.getHash());
|
||||
}
|
||||
}
|
||||
|
||||
/// Checksums from file checksums.txt. May be absent. If present, they are subsequently compared with the actual data checksums.
|
||||
IMergeTreeDataPart::Checksums checksums_txt;
|
||||
|
||||
@ -122,6 +109,28 @@ IMergeTreeDataPart::Checksums checkDataPart(
|
||||
assertEOF(*buf);
|
||||
}
|
||||
|
||||
const auto & checksum_files_txt = checksums_txt.files;
|
||||
for (auto it = disk->iterateDirectory(path); it->isValid(); it->next())
|
||||
{
|
||||
const String & file_name = it->name();
|
||||
auto checksum_it = checksums_data.files.find(file_name);
|
||||
if (checksum_it == checksums_data.files.end() && file_name != "checksums.txt" && file_name != "columns.txt")
|
||||
{
|
||||
auto txt_checksum_it = checksum_files_txt.find(file_name);
|
||||
if (txt_checksum_it == checksum_files_txt.end() || txt_checksum_it->second.uncompressed_size == 0)
|
||||
{
|
||||
auto file_buf = disk->readFile(it->path());
|
||||
HashingReadBuffer hashing_buf(*file_buf);
|
||||
hashing_buf.tryIgnore(std::numeric_limits<size_t>::max());
|
||||
checksums_data.files[file_name] = IMergeTreeDataPart::Checksums::Checksum(hashing_buf.count(), hashing_buf.getHash());
|
||||
}
|
||||
else /// If we have both compressed and uncompressed in txt, than calculate them
|
||||
{
|
||||
checksums_data.files[file_name] = checksum_compressed_file(disk, it->path());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_cancelled())
|
||||
return {};
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
all_1_1_0 1
|
15
tests/queries/0_stateless/01112_check_table_with_index.sql
Normal file
15
tests/queries/0_stateless/01112_check_table_with_index.sql
Normal file
@ -0,0 +1,15 @@
|
||||
SET check_query_single_value_result = 'false';
|
||||
|
||||
DROP TABLE IF EXISTS check_table_with_indices;
|
||||
|
||||
CREATE TABLE check_table_with_indices (
|
||||
id UInt64,
|
||||
data String,
|
||||
INDEX a (id) type minmax GRANULARITY 3
|
||||
) ENGINE = MergeTree() ORDER BY id;
|
||||
|
||||
INSERT INTO check_table_with_indices VALUES (0, 'test'), (1, 'test2');
|
||||
|
||||
CHECK TABLE check_table_with_indices;
|
||||
|
||||
DROP TABLE check_table_with_indices;
|
Loading…
Reference in New Issue
Block a user