Avoid incorrect warning during update of DiskSelector disks

This commit is contained in:
kssenii 2022-09-30 17:47:58 +02:00
parent 229414ed09
commit 7fbc77eacc
4 changed files with 19 additions and 11 deletions

View File

@ -73,12 +73,12 @@ DiskSelectorPtr DiskSelector::updateFromConfig(
std::shared_ptr<DiskSelector> result = std::make_shared<DiskSelector>(*this);
constexpr auto default_disk_name = "default";
DisksMap old_disks_minus_new_disks (result->getDisksMap());
DisksMap old_disks_minus_new_disks(result->getDisksMap());
for (const auto & disk_name : keys)
{
if (!std::all_of(disk_name.begin(), disk_name.end(), isWordCharASCII))
throw Exception("Disk name can contain only alphanumeric and '_' (" + disk_name + ")", ErrorCodes::EXCESSIVE_ELEMENT_IN_CONFIG);
throw Exception(ErrorCodes::EXCESSIVE_ELEMENT_IN_CONFIG, "Disk name can contain only alphanumeric and '_' ({})", disk_name);
auto disk_config_prefix = config_prefix + "." + disk_name;
if (!result->getDisksMap().contains(disk_name))
@ -106,10 +106,15 @@ DiskSelectorPtr DiskSelector::updateFromConfig(
writeString("Disks ", warning);
int index = 0;
for (const auto & [name, _] : old_disks_minus_new_disks)
for (const auto & [name, disk] : old_disks_minus_new_disks)
{
/// Custom disks are not present in config.
if (disk->isCustomDisk())
continue;
if (index++ > 0)
writeString(", ", warning);
writeBackQuotedString(name, warning);
}

View File

@ -34,13 +34,13 @@ void ASTSetQuery::formatImpl(const FormatSettings & format, FormatState & state,
first = false;
formatSettingName(change.name, format.ostr);
if (it->value_ast)
if (change.value_ast)
{
format.ostr << " = ";
it->value_ast->formatImpl(format, state, stacked);
change.value_ast->formatImpl(format, state, stacked);
}
else
format.ostr << " = " << applyVisitor(FieldVisitorToString(), it->value);
format.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
}
for (const auto & [name, value] : query_parameters)

View File

@ -11,11 +11,6 @@
namespace DB
{
namespace ErrorCodes
{
extern const int BAD_ARGUMENTS;
}
bool isDiskFunction(ASTPtr ast)
{
if (!ast)

View File

@ -238,6 +238,14 @@ def test_merge_tree_custom_disk_setting(start_cluster):
node1.query(f"INSERT INTO {TABLE_NAME} SELECT number FROM numbers(100)")
assert int(node1.query(f"SELECT count() FROM {TABLE_NAME}")) == 300
# check reload config does not wipe custom disk
node1.query("SYSTEM RELOAD CONFIG")
assert not node1.contains_in_log(
"disappeared from configuration, this change will be applied after restart of ClickHouse"
)
assert int(node1.query(f"SELECT count() FROM {TABLE_NAME}")) == 300
# check replicated merge tree on cluster
replica = "{replica}"