2019-10-30 21:37:28 +00:00
|
|
|
#include <Storages/System/StorageSystemSettings.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataTypes/DataTypeString.h>
|
2019-10-30 21:37:28 +00:00
|
|
|
#include <DataTypes/DataTypeNullable.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
2017-05-24 21:06:29 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2021-07-22 16:07:03 +00:00
|
|
|
#include <Access/SettingsConstraintsAndProfileIDs.h>
|
2014-10-06 03:49:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2018-07-24 14:28:56 +00:00
|
|
|
NamesAndTypesList StorageSystemSettings::getNamesAndTypes()
|
2018-01-25 14:42:39 +00:00
|
|
|
{
|
2018-07-24 14:28:56 +00:00
|
|
|
return {
|
|
|
|
{"name", std::make_shared<DataTypeString>()},
|
|
|
|
{"value", std::make_shared<DataTypeString>()},
|
|
|
|
{"changed", std::make_shared<DataTypeUInt8>()},
|
|
|
|
{"description", std::make_shared<DataTypeString>()},
|
2019-10-30 21:37:28 +00:00
|
|
|
{"min", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>())},
|
|
|
|
{"max", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>())},
|
2020-03-28 08:11:49 +00:00
|
|
|
{"readonly", std::make_shared<DataTypeUInt8>()},
|
|
|
|
{"type", std::make_shared<DataTypeString>()},
|
2023-02-23 23:24:57 +00:00
|
|
|
{"default", std::make_shared<DataTypeString>()},
|
2023-02-03 18:26:31 +00:00
|
|
|
{"alias_for", std::make_shared<DataTypeString>()},
|
2023-06-10 08:26:32 +00:00
|
|
|
{"is_obsolete", std::make_shared<DataTypeUInt8>()},
|
2018-07-24 14:28:56 +00:00
|
|
|
};
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
void StorageSystemSettings::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
2014-10-06 03:49:56 +00:00
|
|
|
{
|
2021-04-10 23:33:54 +00:00
|
|
|
const Settings & settings = context->getSettingsRef();
|
2021-07-22 16:07:03 +00:00
|
|
|
auto constraints_and_current_profiles = context->getSettingsConstraintsAndCurrentProfiles();
|
|
|
|
const auto & constraints = constraints_and_current_profiles->constraints;
|
2023-02-03 18:26:31 +00:00
|
|
|
|
|
|
|
const auto fill_data_for_setting = [&](std::string_view setting_name, const auto & setting)
|
2019-04-25 14:08:20 +00:00
|
|
|
{
|
2020-07-20 09:57:17 +00:00
|
|
|
res_columns[1]->insert(setting.getValueString());
|
|
|
|
res_columns[2]->insert(setting.isValueChanged());
|
|
|
|
res_columns[3]->insert(setting.getDescription());
|
2019-10-30 21:37:28 +00:00
|
|
|
|
|
|
|
Field min, max;
|
2022-09-15 11:34:14 +00:00
|
|
|
SettingConstraintWritability writability = SettingConstraintWritability::WRITABLE;
|
2022-09-12 19:03:06 +00:00
|
|
|
constraints.get(settings, setting_name, min, max, writability);
|
2019-10-30 21:37:28 +00:00
|
|
|
|
|
|
|
/// These two columns can accept strings only.
|
|
|
|
if (!min.isNull())
|
2020-07-20 09:57:17 +00:00
|
|
|
min = Settings::valueToStringUtil(setting_name, min);
|
2019-10-30 21:37:28 +00:00
|
|
|
if (!max.isNull())
|
2020-07-20 09:57:17 +00:00
|
|
|
max = Settings::valueToStringUtil(setting_name, max);
|
2019-10-30 21:37:28 +00:00
|
|
|
|
|
|
|
res_columns[4]->insert(min);
|
|
|
|
res_columns[5]->insert(max);
|
2022-09-12 19:03:06 +00:00
|
|
|
res_columns[6]->insert(writability == SettingConstraintWritability::CONST);
|
2022-08-26 19:20:00 +00:00
|
|
|
res_columns[7]->insert(setting.getTypeName());
|
2023-02-23 23:24:57 +00:00
|
|
|
res_columns[8]->insert(setting.getDefaultValueString());
|
2023-06-10 08:26:32 +00:00
|
|
|
res_columns[10]->insert(setting.isObsolete());
|
2023-02-03 18:26:31 +00:00
|
|
|
};
|
|
|
|
|
2023-02-03 18:44:56 +00:00
|
|
|
const auto & settings_to_aliases = Settings::Traits::settingsToAliases();
|
2023-02-03 18:26:31 +00:00
|
|
|
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);
|
2023-02-23 23:24:57 +00:00
|
|
|
res_columns[9]->insert("");
|
2023-02-03 18:26:31 +00:00
|
|
|
|
2023-02-03 18:44:56 +00:00
|
|
|
if (auto it = settings_to_aliases.find(setting_name); it != settings_to_aliases.end())
|
2023-02-03 18:26:31 +00:00
|
|
|
{
|
|
|
|
for (const auto alias : it->second)
|
|
|
|
{
|
|
|
|
res_columns[0]->insert(alias);
|
|
|
|
fill_data_for_setting(alias, setting);
|
2023-02-23 23:24:57 +00:00
|
|
|
res_columns[9]->insert(setting_name);
|
2023-02-03 18:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-25 14:08:20 +00:00
|
|
|
}
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|