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>
|
2019-10-30 21:37:28 +00:00
|
|
|
#include <Access/SettingsConstraints.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>()},
|
2018-07-24 14:28:56 +00:00
|
|
|
};
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 01:42:55 +00:00
|
|
|
#ifndef __clang__
|
|
|
|
#pragma GCC optimize("-fno-var-tracking-assignments")
|
|
|
|
#endif
|
|
|
|
|
2018-07-24 14:28:56 +00:00
|
|
|
void StorageSystemSettings::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const
|
2014-10-06 03:49:56 +00:00
|
|
|
{
|
2019-10-30 21:37:28 +00:00
|
|
|
const Settings & settings = context.getSettingsRef();
|
|
|
|
auto settings_constraints = context.getSettingsConstraints();
|
|
|
|
for (const auto & setting : settings)
|
2019-04-25 14:08:20 +00:00
|
|
|
{
|
2020-07-19 14:59:07 +00:00
|
|
|
std::string_view setting_name{setting.getName()};
|
|
|
|
res_columns[0]->insert(setting_name);
|
2019-04-25 14:08:20 +00:00
|
|
|
res_columns[1]->insert(setting.getValueAsString());
|
|
|
|
res_columns[2]->insert(setting.isChanged());
|
|
|
|
res_columns[3]->insert(setting.getDescription().toString());
|
2019-10-30 21:37:28 +00:00
|
|
|
|
|
|
|
Field min, max;
|
|
|
|
bool read_only = false;
|
|
|
|
if (settings_constraints)
|
|
|
|
settings_constraints->get(setting_name, min, max, read_only);
|
|
|
|
|
|
|
|
/// These two columns can accept strings only.
|
|
|
|
if (!min.isNull())
|
|
|
|
min = Settings::valueToString(setting_name, min);
|
|
|
|
if (!max.isNull())
|
|
|
|
max = Settings::valueToString(setting_name, max);
|
|
|
|
|
|
|
|
if (!read_only)
|
|
|
|
{
|
|
|
|
if ((settings.readonly == 1)
|
|
|
|
|| ((settings.readonly > 1) && (setting_name == "readonly"))
|
|
|
|
|| ((!settings.allow_ddl) && (setting_name == "allow_ddl")))
|
|
|
|
read_only = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
res_columns[4]->insert(min);
|
|
|
|
res_columns[5]->insert(max);
|
|
|
|
res_columns[6]->insert(read_only);
|
2020-03-28 08:11:49 +00:00
|
|
|
res_columns[7]->insert(setting.getType().toString());
|
2019-04-25 14:08:20 +00:00
|
|
|
}
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|