mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 17:20:50 +00:00
Adding system.warnings
This commit is contained in:
parent
e231f6ce5c
commit
146a45a8b3
@ -1,3 +1,4 @@
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <optional>
|
||||
@ -6,6 +7,7 @@
|
||||
#include <Poco/UUID.h>
|
||||
#include <Poco/Net/IPAddress.h>
|
||||
#include <Poco/Util/Application.h>
|
||||
#include "common/types.h"
|
||||
#include <Common/Macros.h>
|
||||
#include <Common/escapeForFileName.h>
|
||||
#include <Common/setThreadName.h>
|
||||
@ -77,6 +79,7 @@
|
||||
#include <Storages/MergeTree/BackgroundJobsExecutor.h>
|
||||
#include <Storages/MergeTree/MergeTreeDataPartUUID.h>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@ -386,6 +389,7 @@ struct ContextSharedPart
|
||||
ActionLocksManagerPtr action_locks_manager; /// Set of storages' action lockers
|
||||
std::unique_ptr<SystemLogs> system_logs; /// Used to log queries and operations on parts
|
||||
std::optional<StorageS3Settings> storage_s3_settings; /// Settings of S3 storage
|
||||
std::vector<String> warnings_logs; /// Store warning messages
|
||||
|
||||
RemoteHostFilter remote_host_filter; /// Allowed URL from config.xml
|
||||
|
||||
@ -514,6 +518,12 @@ struct ContextSharedPart
|
||||
|
||||
trace_collector.emplace(std::move(trace_log));
|
||||
}
|
||||
|
||||
void addWarningMessage(const String& message)
|
||||
{
|
||||
log->warning(message);
|
||||
warnings_logs.push_back(message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -635,6 +645,12 @@ String Context::getDictionariesLibPath() const
|
||||
return shared->dictionaries_lib_path;
|
||||
}
|
||||
|
||||
std::vector<String> Context::getWarnings() const
|
||||
{
|
||||
auto lock = getLock();
|
||||
return shared->warnings_logs;
|
||||
}
|
||||
|
||||
VolumePtr Context::getTemporaryVolume() const
|
||||
{
|
||||
auto lock = getLock();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <Access/RowPolicy.h>
|
||||
#include <Core/Block.h>
|
||||
#include <Core/NamesAndTypes.h>
|
||||
@ -318,6 +319,7 @@ public:
|
||||
String getFlagsPath() const;
|
||||
String getUserFilesPath() const;
|
||||
String getDictionariesLibPath() const;
|
||||
std::vector<String> getWarnings() const;
|
||||
|
||||
VolumePtr getTemporaryVolume() const;
|
||||
|
||||
|
22
src/Storages/System/StorageSystemWarnings.cpp
Normal file
22
src/Storages/System/StorageSystemWarnings.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <memory>
|
||||
#include <Storages/System/StorageSystemWarnings.h>
|
||||
#include <Interpreters/Context.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
NamesAndTypesList StorageSystemWarnings::getNamesAndTypes()
|
||||
{
|
||||
return {
|
||||
{"description", std::make_shared<DataTypeString>()},
|
||||
};
|
||||
}
|
||||
|
||||
void StorageSystemWarnings::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
|
||||
{
|
||||
for (auto& warning : context->getWarnings()) {
|
||||
res_columns[0]->insert(warning);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
21
src/Storages/System/StorageSystemWarnings.h
Normal file
21
src/Storages/System/StorageSystemWarnings.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <Storages/System/IStorageSystemOneBlock.h>
|
||||
|
||||
namespace DB {
|
||||
|
||||
class Context;
|
||||
|
||||
class StorageSystemWarnings final : public shared_ptr_helper<StorageSystemWarnings>, public IStorageSystemOneBlock<StorageSystemWarnings> {
|
||||
public:
|
||||
std::string getName() const override { return "SystemWarnings"; }
|
||||
|
||||
static NamesAndTypesList getNamesAndTypes();
|
||||
|
||||
protected:
|
||||
friend struct shared_ptr_helper<StorageSystemWarnings>;
|
||||
using IStorageSystemOneBlock::IStorageSystemOneBlock;
|
||||
|
||||
void fillData(MutableColumns & res_columns, ContextPtr, const SelectQueryInfo &) const override;
|
||||
};
|
||||
}
|
@ -43,6 +43,7 @@
|
||||
#include <Storages/System/StorageSystemZooKeeper.h>
|
||||
#include <Storages/System/StorageSystemContributors.h>
|
||||
#include <Storages/System/StorageSystemErrors.h>
|
||||
#include <Storages/System/StorageSystemWarnings.h>
|
||||
#include <Storages/System/StorageSystemDDLWorkerQueue.h>
|
||||
|
||||
#if !defined(ARCADIA_BUILD)
|
||||
@ -116,6 +117,7 @@ void attachSystemTablesLocal(IDatabase & system_database)
|
||||
attach<StorageSystemUserDirectories>(system_database, "user_directories");
|
||||
attach<StorageSystemPrivileges>(system_database, "privileges");
|
||||
attach<StorageSystemErrors>(system_database, "errors");
|
||||
attach<StorageSystemWarnings>(system_database, "warnings");
|
||||
attach<StorageSystemDataSkippingIndices>(system_database, "data_skipping_indices");
|
||||
#if !defined(ARCADIA_BUILD)
|
||||
attach<StorageSystemLicenses>(system_database, "licenses");
|
||||
|
Loading…
Reference in New Issue
Block a user