dbms: fixed error with possible conflict of names of parts when doing ATTACH after DROP PARTITION [#METR-18510].

This commit is contained in:
Alexey Milovidov 2016-01-29 05:24:03 +03:00
parent d5163b5060
commit 1b93d7d874

View File

@ -2856,7 +2856,8 @@ void StorageReplicatedMergeTree::attachPartition(ASTPtr query, const Field & fie
DayNum_t month = DateLUT::instance().makeDayNum(parse<UInt16>(partition.substr(0, 4)), parse<UInt8>(partition.substr(4, 2)), 1); DayNum_t month = DateLUT::instance().makeDayNum(parse<UInt16>(partition.substr(0, 4)), parse<UInt8>(partition.substr(4, 2)), 1);
{ {
auto existing_parts = data.getDataParts(); /// Немного неоптимально.
auto existing_parts = data.getAllDataParts();
for (const auto & part : existing_parts) for (const auto & part : existing_parts)
if (part->month == month) if (part->month == month)
min_used_number = std::min(min_used_number, part->left); min_used_number = std::min(min_used_number, part->left);