Fix bug with segmentation fault in ATTACH PART query

This commit is contained in:
alesapin 2019-10-03 21:07:47 +03:00
parent ddf171e9df
commit 4e83f65089
3 changed files with 27 additions and 0 deletions

View File

@ -2967,6 +2967,8 @@ MergeTreeData::MutableDataPartsVector MergeTreeData::tryLoadPartsToAttach(const
String part_id = partition->as<ASTLiteral &>().value.safeGet<String>(); String part_id = partition->as<ASTLiteral &>().value.safeGet<String>();
validateDetachedPartName(part_id); validateDetachedPartName(part_id);
renamed_parts.addPart(part_id, "attaching_" + part_id); renamed_parts.addPart(part_id, "attaching_" + part_id);
if (MergeTreePartInfo::tryParsePartName(part_id, nullptr, format_version))
name_to_disk[part_id] = getDiskForPart(part_id, source_dir);
} }
else else
{ {

View File

@ -0,0 +1,3 @@
1000
0
1000

View File

@ -0,0 +1,22 @@
DROP TABLE IF EXISTS table_01;
CREATE TABLE table_01 (
date Date,
n Int32
) ENGINE = MergeTree()
PARTITION BY date
ORDER BY date;
INSERT INTO table_01 SELECT toDate('2019-10-01'), number FROM system.numbers LIMIT 1000;
SELECT COUNT() FROM table_01;
ALTER TABLE table_01 DETACH PARTITION ID '20191001';
SELECT COUNT() FROM table_01;
ALTER TABLE table_01 ATTACH PART '20191001_1_1_0';
SELECT COUNT() FROM table_01;
DROP TABLE IF EXISTS table_01;