2014-10-06 03:49:56 +00:00
|
|
|
#include <DB/Columns/ColumnString.h>
|
|
|
|
#include <DB/DataTypes/DataTypeString.h>
|
|
|
|
#include <DB/DataTypes/DataTypesNumberFixed.h>
|
|
|
|
#include <DB/DataStreams/OneBlockInputStream.h>
|
2015-09-24 03:50:09 +00:00
|
|
|
#include <DB/Storages/System/StorageSystemSettings.h>
|
2014-10-06 03:49:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2015-01-21 03:56:28 +00:00
|
|
|
StorageSystemSettings::StorageSystemSettings(const std::string & name_)
|
|
|
|
: name(name_)
|
2014-10-06 03:49:56 +00:00
|
|
|
, columns{
|
2016-05-28 07:48:40 +00:00
|
|
|
{ "name", std::make_shared<DataTypeString>() },
|
|
|
|
{ "value", std::make_shared<DataTypeString>() },
|
|
|
|
{ "changed", std::make_shared<DataTypeUInt8>() },
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-21 03:56:28 +00:00
|
|
|
StoragePtr StorageSystemSettings::create(const std::string & name_)
|
2014-10-06 03:49:56 +00:00
|
|
|
{
|
2015-01-21 03:56:28 +00:00
|
|
|
return (new StorageSystemSettings(name_))->thisPtr();
|
2014-10-06 03:49:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemSettings::read(
|
2014-12-17 11:53:17 +00:00
|
|
|
const Names & column_names,
|
|
|
|
ASTPtr query,
|
|
|
|
const Context & context,
|
|
|
|
const Settings & settings,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
const size_t max_block_size,
|
|
|
|
const unsigned threads)
|
2014-10-06 03:49:56 +00:00
|
|
|
{
|
|
|
|
check(column_names);
|
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
|
|
|
|
2016-05-28 07:48:40 +00:00
|
|
|
ColumnWithTypeAndName col_name{std::make_shared<ColumnString>(), std::make_shared<DataTypeString>(), "name"};
|
|
|
|
ColumnWithTypeAndName col_value{std::make_shared<ColumnString>(), std::make_shared<DataTypeString>(), "value"};
|
|
|
|
ColumnWithTypeAndName col_changed{std::make_shared<ColumnUInt8>(), std::make_shared<DataTypeUInt8>(), "changed"};
|
2014-10-06 03:49:56 +00:00
|
|
|
|
|
|
|
#define ADD_SETTING(TYPE, NAME, DEFAULT) \
|
|
|
|
col_name.column->insert(String(#NAME)); \
|
|
|
|
col_value.column->insert(settings.NAME.toString()); \
|
|
|
|
col_changed.column->insert(UInt64(settings.NAME.changed));
|
|
|
|
|
|
|
|
APPLY_FOR_SETTINGS(ADD_SETTING)
|
|
|
|
#undef ADD_SETTING
|
|
|
|
|
|
|
|
#define ADD_LIMIT(TYPE, NAME, DEFAULT) \
|
|
|
|
col_name.column->insert(String(#NAME)); \
|
|
|
|
col_value.column->insert(settings.limits.NAME.toString()); \
|
|
|
|
col_changed.column->insert(UInt64(settings.limits.NAME.changed));
|
|
|
|
|
|
|
|
APPLY_FOR_LIMITS(ADD_LIMIT)
|
|
|
|
#undef ADD_LIMIT
|
|
|
|
|
|
|
|
Block block{
|
|
|
|
col_name,
|
|
|
|
col_value,
|
|
|
|
col_changed,
|
|
|
|
};
|
|
|
|
|
|
|
|
return BlockInputStreams(1, new OneBlockInputStream(block));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|