mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
dbms: ignore missing files [#METR-10242]
This commit is contained in:
parent
774206e517
commit
5bc75d93b5
@ -1304,6 +1304,9 @@ void StorageMergeTree::alter(const ASTAlterQuery::Parameters & params)
|
||||
DEFAULT_MERGE_BLOCK_SIZE, column_name, *this, part, ranges, StoragePtr(), false, NULL, ""), expr);
|
||||
MergedColumnOnlyOutputStream out(*this, full_path + part->name + '/', true);
|
||||
out.writePrefix();
|
||||
|
||||
try
|
||||
{
|
||||
while(DB::Block b = in.read())
|
||||
{
|
||||
/// оставляем только столбец с результатом
|
||||
@ -1313,39 +1316,54 @@ void StorageMergeTree::alter(const ASTAlterQuery::Parameters & params)
|
||||
LOG_TRACE(log, "Write Suffix");
|
||||
out.writeSuffix();
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
if (e.code() != ErrorCodes::ALL_REQUESTED_COLUMNS_ARE_MISSING)
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// переименовываем файлы
|
||||
/// переименовываем старые столбцы, добавляя расширение .old
|
||||
for (DataPartPtr & part : parts)
|
||||
{
|
||||
std::string path = full_path + part->name + '/' + escapeForFileName(name_type.name);
|
||||
if (Poco::File(path + ".bin").exists())
|
||||
{
|
||||
LOG_TRACE(log, "Renaming " << path + ".bin" << " to " << path + ".bin" + ".old");
|
||||
Poco::File(path + ".bin").renameTo(path + ".bin" + ".old");
|
||||
LOG_TRACE(log, "Renaming " << path + ".mrk" << " to " << path + ".mrk" + ".old");
|
||||
Poco::File(path + ".mrk").renameTo(path + ".mrk" + ".old");
|
||||
}
|
||||
}
|
||||
|
||||
/// переименовываем временные столбцы
|
||||
for (DataPartPtr & part : parts)
|
||||
{
|
||||
std::string path = full_path + part->name + '/' + escapeForFileName(out_column);
|
||||
std::string new_path = full_path + part->name + '/' + escapeForFileName(name_type.name);
|
||||
if (Poco::File(path + ".bin").exists())
|
||||
{
|
||||
LOG_TRACE(log, "Renaming " << path + ".bin" << " to " << new_path + ".bin");
|
||||
Poco::File(path + ".bin").renameTo(new_path + ".bin");
|
||||
LOG_TRACE(log, "Renaming " << path + ".mrk" << " to " << new_path + ".mrk");
|
||||
Poco::File(path + ".mrk").renameTo(new_path + ".mrk");
|
||||
}
|
||||
}
|
||||
|
||||
// удаляем старые столбцы
|
||||
for (DataPartPtr & part : parts)
|
||||
{
|
||||
std::string path = full_path + part->name + '/' + escapeForFileName(name_type.name);
|
||||
if (Poco::File(path + ".bin" + ".old").exists())
|
||||
{
|
||||
LOG_TRACE(log, "Removing old column " << path + ".bin" + ".old");
|
||||
Poco::File(path + ".bin" + ".old").remove();
|
||||
LOG_TRACE(log, "Removing old column " << path + ".mrk" + ".old");
|
||||
Poco::File(path + ".mrk" + ".old").remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
context.getUncompressedCache()->reset();
|
||||
context.getMarkCache()->reset();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user