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>() },
|
2021-03-08 19:05:51 +00:00
|
|
|
{ "remote", std::make_shared<DataTypeUInt8>() },
|
2020-10-28 22:00:04 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2021-03-08 19:05:51 +00:00
|
|
|
auto add_row = [&](std::string_view name, size_t code, size_t value, bool remote)
|
2020-10-28 22:00:04 +00:00
|
|
|
{
|
2020-10-29 07:07:42 +00:00
|
|
|
if (value || context.getSettingsRef().system_events_show_zero_values)
|
|
|
|
{
|
|
|
|
size_t col_num = 0;
|
|
|
|
res_columns[col_num++]->insert(name);
|
2021-03-08 19:05:51 +00:00
|
|
|
res_columns[col_num++]->insert(code);
|
2020-10-29 07:07:42 +00:00
|
|
|
res_columns[col_num++]->insert(value);
|
2021-03-08 19:05:51 +00:00
|
|
|
res_columns[col_num++]->insert(remote);
|
2020-10-29 07:07:42 +00:00
|
|
|
}
|
2021-03-08 19:05:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0, end = ErrorCodes::end(); i < end; ++i)
|
|
|
|
{
|
|
|
|
const auto & error = ErrorCodes::values[i];
|
|
|
|
std::string_view name = ErrorCodes::getName(i);
|
|
|
|
|
|
|
|
if (name.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
add_row(name, i, error.local, 0 /* remote=0 */);
|
|
|
|
add_row(name, i, error.remote, 1 /* remote=1 */);
|
2020-10-28 22:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|