Update tests and system.settings

This commit is contained in:
Antonio Andelic 2023-02-03 18:26:31 +00:00
parent a58653820e
commit 3a8ba689f2
4 changed files with 46 additions and 7 deletions

View File

@ -87,9 +87,7 @@ void Settings::addProgramOptions(boost::program_options::options_description & o
// we can have multiple aliases to the same setting
std::unordered_map<std::string_view, std::vector<std::string_view>> setting_to_alias_mapping;
for (const auto & [alias, destination] : SettingsTraits::settings_aliases)
{
setting_to_alias_mapping[destination].push_back(alias);
}
for (const auto & field : all())
{
@ -109,9 +107,7 @@ void Settings::addProgramOptionsAsMultitokens(boost::program_options::options_de
// we can have multiple aliases to the same setting
std::unordered_map<std::string_view, std::vector<std::string_view>> setting_to_alias_mapping;
for (const auto & [alias, destination] : SettingsTraits::settings_aliases)
{
setting_to_alias_mapping[destination].push_back(alias);
}
for (const auto & field : all())
{

View File

@ -19,6 +19,7 @@ NamesAndTypesList StorageSystemSettings::getNamesAndTypes()
{"max", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>())},
{"readonly", std::make_shared<DataTypeUInt8>()},
{"type", std::make_shared<DataTypeString>()},
{"alias_for", std::make_shared<DataTypeString>()},
};
}
@ -31,10 +32,9 @@ void StorageSystemSettings::fillData(MutableColumns & res_columns, ContextPtr co
const Settings & settings = context->getSettingsRef();
auto constraints_and_current_profiles = context->getSettingsConstraintsAndCurrentProfiles();
const auto & constraints = constraints_and_current_profiles->constraints;
for (const auto & setting : settings.all())
const auto fill_data_for_setting = [&](std::string_view setting_name, const auto & setting)
{
const auto & setting_name = setting.getName();
res_columns[0]->insert(setting_name);
res_columns[1]->insert(setting.getValueString());
res_columns[2]->insert(setting.isValueChanged());
res_columns[3]->insert(setting.getDescription());
@ -53,6 +53,30 @@ void StorageSystemSettings::fillData(MutableColumns & res_columns, ContextPtr co
res_columns[5]->insert(max);
res_columns[6]->insert(writability == SettingConstraintWritability::CONST);
res_columns[7]->insert(setting.getTypeName());
};
// we can have multiple aliases to the same setting
std::unordered_map<std::string_view, std::vector<std::string_view>> setting_to_alias_mapping;
for (const auto & [alias, destination] : SettingsTraits::settings_aliases)
setting_to_alias_mapping[destination].push_back(alias);
for (const auto & setting : settings.all())
{
const auto & setting_name = setting.getName();
res_columns[0]->insert(setting_name);
fill_data_for_setting(setting_name, setting);
res_columns[8]->insert("");
if (auto it = setting_to_alias_mapping.find(setting_name); it != setting_to_alias_mapping.end())
{
for (const auto alias : it->second)
{
res_columns[0]->insert(alias);
fill_data_for_setting(alias, setting);
res_columns[8]->insert(setting_name);
}
}
}
}

View File

@ -18,3 +18,8 @@ Using HTTP with query params
Using client options
0
2
CREATE VIEW default.`02539_settings_alias_view`\n(\n `1` UInt8\n) AS\nSELECT 1\nSETTINGS replication_alter_partitions_sync = 2
replication_alter_partitions_sync 0 1 alter_sync
replication_alter_partitions_sync 2 1 alter_sync
alter_sync 0 1
alter_sync 2 1

View File

@ -26,3 +26,17 @@ for check_query in "SELECT value FROM system.settings WHERE name = 'alter_sync';
$CLICKHOUSE_CLIENT --replication_alter_partitions_sync=0 -q "$check_query"
$CLICKHOUSE_CLIENT --replication_alter_partitions_sync=2 -q "$check_query"
done
$CLICKHOUSE_CLIENT -mn -q """
DROP VIEW IF EXISTS 02539_settings_alias_view;
CREATE VIEW 02539_settings_alias_view AS SELECT 1 SETTINGS replication_alter_partitions_sync = 2;
SHOW CREATE TABLE 02539_settings_alias_view;
DROP VIEW 02539_settings_alias_view;
"""
for setting_name in "replication_alter_partitions_sync" "alter_sync"; do
query="SELECT name, value, changed, alias_for FROM system.settings WHERE name = '$setting_name'"
$CLICKHOUSE_CLIENT --replication_alter_partitions_sync=0 -q "$query"
$CLICKHOUSE_CLIENT --replication_alter_partitions_sync=2 -q "$query"
done