2020-10-28 22:00:04 +00:00
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Storages/System/StorageSystemErrors.h>
|
2020-10-29 07:07:42 +00:00
|
|
|
#include <Common/ErrorCodes.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2020-10-28 22:00:04 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
NamesAndTypesList StorageSystemErrors::getNamesAndTypes()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
{ "name", std::make_shared<DataTypeString>() },
|
|
|
|
{ "code", std::make_shared<DataTypeInt32>() },
|
|
|
|
{ "value", std::make_shared<DataTypeUInt64>() },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-29 07:07:42 +00:00
|
|
|
void StorageSystemErrors::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const
|
2020-10-28 22:00:04 +00:00
|
|
|
{
|
2020-10-29 07:07:42 +00:00
|
|
|
for (size_t i = 0, end = ErrorCodes::end(); i < end; ++i)
|
2020-10-28 22:00:04 +00:00
|
|
|
{
|
2020-10-29 07:07:42 +00:00
|
|
|
UInt64 value = ErrorCodes::values[i];
|
|
|
|
std::string_view name = ErrorCodes::getName(i);
|
|
|
|
|
2020-10-29 21:07:40 +00:00
|
|
|
if (name.empty())
|
2020-10-29 07:07:42 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (value || context.getSettingsRef().system_events_show_zero_values)
|
|
|
|
{
|
|
|
|
size_t col_num = 0;
|
|
|
|
res_columns[col_num++]->insert(name);
|
|
|
|
res_columns[col_num++]->insert(i);
|
|
|
|
res_columns[col_num++]->insert(value);
|
|
|
|
}
|
2020-10-28 22:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|