Fix compilation.

This commit is contained in:
Vitaly Baranov 2022-04-26 10:04:16 +02:00
parent 78bcb96098
commit 1c0b731ea6
8 changed files with 28 additions and 38 deletions

View File

@ -5,8 +5,6 @@
#include <IO/WriteBufferFromFileBase.h>
#include <base/logger_useful.h>
namespace fs = std::filesystem;
namespace DB
{

View File

@ -182,12 +182,12 @@ void BackupImpl::open()
if (open_mode == OpenMode::WRITE)
{
if (backup_exists)
throw Exception(ErrorCodes::BACKUP_ALREADY_EXISTS, "Backup {} already exists", getName());
throw Exception(ErrorCodes::BACKUP_ALREADY_EXISTS, "Backup {} already exists", backup_name);
}
else
{
if (!backup_exists)
throw Exception(ErrorCodes::BACKUP_NOT_FOUND, "Backup {} not found", getName());
throw Exception(ErrorCodes::BACKUP_NOT_FOUND, "Backup {} not found", backup_name);
}
if (open_mode == OpenMode::WRITE)
@ -215,7 +215,7 @@ void BackupImpl::open()
base_backup_uuid = base_backup->getUUID();
else if (base_backup_uuid != base_backup->getUUID())
throw Exception(ErrorCodes::WRONG_BASE_BACKUP, "Backup {}: The base backup {} has different UUID ({} != {})",
getName(), base_backup->getName(), toString(base_backup->getUUID()), (base_backup_uuid ? toString(*base_backup_uuid) : ""));
backup_name, base_backup->getName(), toString(base_backup->getUUID()), (base_backup_uuid ? toString(*base_backup_uuid) : ""));
}
}
@ -322,7 +322,7 @@ void BackupImpl::readBackupMetadata()
version = config->getUInt("version");
if ((version < INITIAL_BACKUP_VERSION) || (version > CURRENT_BACKUP_VERSION))
throw Exception(ErrorCodes::BACKUP_VERSION_NOT_SUPPORTED, "Backup {}: Version {} is not supported", getName(), version);
throw Exception(ErrorCodes::BACKUP_VERSION_NOT_SUPPORTED, "Backup {}: Version {} is not supported", backup_name, version);
timestamp = parse<LocalDateTime>(config->getString("timestamp")).to_time_t();
uuid = parse<UUID>(config->getString("uuid"));
@ -353,7 +353,7 @@ void BackupImpl::readBackupMetadata()
use_base = true;
if (info.base_size > info.size)
throw Exception(ErrorCodes::BACKUP_DAMAGED, "Backup {}: Base size must not be greater than the size of entry {}", getName(), quoteString(info.file_name));
throw Exception(ErrorCodes::BACKUP_DAMAGED, "Backup {}: Base size must not be greater than the size of entry {}", backup_name, quoteString(info.file_name));
if (use_base)
{
@ -402,7 +402,7 @@ UInt64 BackupImpl::getFileSize(const String & file_name) const
auto info = coordination->getFileInfo(file_name);
if (!info)
throw Exception(
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", getName(), quoteString(file_name));
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", backup_name, quoteString(file_name));
return info->size;
}
@ -412,7 +412,7 @@ UInt128 BackupImpl::getFileChecksum(const String & file_name) const
auto info = coordination->getFileInfo(file_name);
if (!info)
throw Exception(
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", getName(), quoteString(file_name));
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", backup_name, quoteString(file_name));
return info->checksum;
}
@ -422,7 +422,7 @@ SizeAndChecksum BackupImpl::getFileSizeAndChecksum(const String & file_name) con
auto info = coordination->getFileInfo(file_name);
if (!info)
throw Exception(
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", getName(), quoteString(file_name));
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", backup_name, quoteString(file_name));
return std::pair(info->size, info->checksum);
}
@ -440,7 +440,7 @@ BackupEntryPtr BackupImpl::readFile(const SizeAndChecksum & size_and_checksum) c
auto info_opt = coordination->getFileInfo(size_and_checksum);
if (!info_opt)
throw Exception(
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", getName(), formatSizeAndChecksum(size_and_checksum));
ErrorCodes::BACKUP_ENTRY_NOT_FOUND, "Backup {}: Entry {} not found in the backup", backup_name, formatSizeAndChecksum(size_and_checksum));
const auto & info = *info_opt;
if (!info.size)
@ -461,7 +461,7 @@ BackupEntryPtr BackupImpl::readFile(const SizeAndChecksum & size_and_checksum) c
throw Exception(
ErrorCodes::NO_BASE_BACKUP,
"Backup {}: Entry {} is marked to be read from a base backup, but there is no base backup specified",
getName(), formatSizeAndChecksum(size_and_checksum));
backup_name, formatSizeAndChecksum(size_and_checksum));
}
if (!base_backup->fileExists(std::pair(info.base_size, info.base_checksum)))
@ -469,7 +469,7 @@ BackupEntryPtr BackupImpl::readFile(const SizeAndChecksum & size_and_checksum) c
throw Exception(
ErrorCodes::WRONG_BASE_BACKUP,
"Backup {}: Entry {} is marked to be read from a base backup, but doesn't exist there",
getName(), formatSizeAndChecksum(size_and_checksum));
backup_name, formatSizeAndChecksum(size_and_checksum));
}
auto base_entry = base_backup->readFile(std::pair{info.base_size, info.base_checksum});
@ -497,7 +497,7 @@ void BackupImpl::writeFile(const String & file_name, BackupEntryPtr entry)
if (coordination->getFileInfo(file_name))
throw Exception(
ErrorCodes::BACKUP_ENTRY_ALREADY_EXISTS, "Backup {}: Entry {} already exists", getName(), quoteString(file_name));
ErrorCodes::BACKUP_ENTRY_ALREADY_EXISTS, "Backup {}: Entry {} already exists", backup_name, quoteString(file_name));
FileInfo info;
info.file_name = file_name;

View File

@ -9,7 +9,7 @@ namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_SETTING;
extern const int CANNOT_PARSE_BACKUP_SETTINGS;
}
/// List of backup settings except base_backup_name.
@ -44,7 +44,7 @@ BackupSettings BackupSettings::fromBackupQuery(const ASTBackupQuery & query)
else
LIST_OF_BACKUP_SETTINGS(GET_SETTINGS_FROM_BACKUP_QUERY_HELPER)
throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting {}", setting.name);
throw Exception(ErrorCodes::CANNOT_PARSE_BACKUP_SETTINGS, "Unknown setting {}", setting.name);
}
}
@ -61,7 +61,7 @@ void BackupSettings::copySettingsToBackupQuery(ASTBackupQuery & query) const
static const BackupSettings default_settings;
#define SET_SETTINGS_IN_BACKUP_QUERY_HELPER(TYPE, NAME) \
if (NAME != default_settings.NAME) \
if ((NAME) != default_settings.NAME) \
query_settings->changes.emplace_back(#NAME, static_cast<Field>(SettingField##TYPE{NAME}));
LIST_OF_BACKUP_SETTINGS(SET_SETTINGS_IN_BACKUP_QUERY_HELPER)

View File

@ -16,10 +16,7 @@ BackupsWorker & BackupsWorker::instance()
return the_instance;
}
BackupsWorker::BackupsWorker()
{
}
BackupsWorker::BackupsWorker() = default;
size_t BackupsWorker::add(const String & backup_name, BackupStatus status, const String & error)
{

View File

@ -11,8 +11,8 @@ namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_SETTING;
extern const int CANNOT_PARSE_RESTORE_TABLE_CREATION_MODE;
extern const int CANNOT_PARSE_BACKUP_SETTINGS;
extern const int LOGICAL_ERROR;
}
namespace
@ -25,7 +25,7 @@ namespace
{
if (field.getType() == Field::Types::String)
{
String str = field.get<String>();
const String & str = field.get<const String &>();
if (str == "1" || boost::iequals(str, "true"))
value = RestoreTableCreationMode::kCreate;
else if (str == "0" || boost::iequals(str, "false"))
@ -33,7 +33,7 @@ namespace
else if (boost::iequals(str, "if not exists"))
value = RestoreTableCreationMode::kCreateIfNotExists;
else throw Exception("Cannot parse creation mode from string '" + str + "'",
ErrorCodes::CANNOT_PARSE_RESTORE_TABLE_CREATION_MODE);
ErrorCodes::CANNOT_PARSE_BACKUP_SETTINGS);
}
else
{
@ -52,6 +52,7 @@ namespace
case RestoreTableCreationMode::kMustExist: return Field{false};
case RestoreTableCreationMode::kCreateIfNotExists: return Field{"if not exists"};
}
throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected value of enum RestoreTableCreationMode: {}", static_cast<int>(value));
}
operator RestoreTableCreationMode() const { return value; }
@ -94,7 +95,7 @@ RestoreSettings RestoreSettings::fromRestoreQuery(const ASTBackupQuery & query)
else
LIST_OF_RESTORE_SETTINGS(GET_SETTINGS_FROM_RESTORE_QUERY_HELPER)
throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting {}", setting.name);
throw Exception(ErrorCodes::CANNOT_PARSE_BACKUP_SETTINGS, "Unknown setting {}", setting.name);
}
}
@ -111,7 +112,7 @@ void RestoreSettings::copySettingsToRestoreQuery(ASTBackupQuery & query) const
static const RestoreSettings default_settings;
#define SET_SETTINGS_IN_RESTORE_QUERY_HELPER(TYPE, NAME) \
if (NAME != default_settings.NAME) \
if ((NAME) != default_settings.NAME) \
query_settings->changes.emplace_back(#NAME, static_cast<Field>(SettingField##TYPE{NAME}));
LIST_OF_RESTORE_SETTINGS(SET_SETTINGS_IN_RESTORE_QUERY_HELPER)

View File

@ -22,14 +22,11 @@
#include <Storages/IStorage.h>
#include <base/chrono_io.h>
#include <base/insertAtEnd.h>
#include <base/sleep.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm_ext/erase.hpp>
#include <filesystem>
#include <base/sleep.h>
namespace fs = std::filesystem;
namespace DB
{
@ -45,7 +42,7 @@ namespace
class PathsInBackup
{
public:
PathsInBackup(const IBackup & backup_) : backup(backup_) {}
explicit PathsInBackup(const IBackup & backup_) : backup(backup_) {}
std::vector<size_t> getShards() const
{
@ -312,10 +309,7 @@ namespace
use_coordination_for_table_creation = true;
replicated_database_zookeeper_path = replicated_db->getZooKeeperPath();
if (restore_coordination->acquireZkPathAndName(replicated_database_zookeeper_path, table_name.second))
return true;
return false;
return restore_coordination->acquireZkPathAndName(replicated_database_zookeeper_path, table_name.second);
}
void setTableCreationResult(IRestoreCoordination::Result res)

View File

@ -621,7 +621,7 @@
M(650, SERIALIZATION_ERROR) \
M(651, CAPN_PROTO_BAD_TYPE) \
M(652, ONLY_NULLS_WHILE_READING_SCHEMA) \
M(653, CANNOT_PARSE_RESTORE_TABLE_CREATION_MODE) \
M(653, CANNOT_PARSE_BACKUP_SETTINGS) \
\
M(999, KEEPER_EXCEPTION) \
M(1000, POCO_EXCEPTION) \

View File

@ -174,7 +174,7 @@ namespace
changes.emplace_back("shard_num", params.shard_index);
changes.emplace_back("replica_num", params.replica_index);
auto out_settings = std::shared_ptr<ASTSetQuery>();
auto out_settings = std::make_shared<ASTSetQuery>();
out_settings->changes = std::move(changes);
out_settings->is_standalone = false;
return out_settings;