From 278099e663ff95cecd0dfe67a3d39d982b3eac6f Mon Sep 17 00:00:00 2001 From: Artur <613623@mail.ru> Date: Mon, 12 Jul 2021 12:21:18 +0000 Subject: [PATCH] correct code style --- src/Interpreters/Context.h | 2 +- src/Storages/System/StorageSystemWarnings.cpp | 9 ++--- src/Storages/System/StorageSystemWarnings.h | 6 ++-- .../0_stateless/01945_system_warnings.expect | 34 +++++++++++++++++++ .../01945_system_warnings.reference | 0 5 files changed, 42 insertions(+), 9 deletions(-) create mode 100755 tests/queries/0_stateless/01945_system_warnings.expect create mode 100644 tests/queries/0_stateless/01945_system_warnings.reference diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index a15151b64cf..eecc61bbd1b 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -326,7 +326,7 @@ public: void setFlagsPath(const String & path); void setUserFilesPath(const String & path); void setDictionariesLibPath(const String & path); - + void addWarningMessage(const String & msg); VolumePtr setTemporaryStorage(const String & path, const String & policy_name = ""); diff --git a/src/Storages/System/StorageSystemWarnings.cpp b/src/Storages/System/StorageSystemWarnings.cpp index 55005736890..c281ed69704 100644 --- a/src/Storages/System/StorageSystemWarnings.cpp +++ b/src/Storages/System/StorageSystemWarnings.cpp @@ -1,10 +1,8 @@ -#include -#include #include +#include -namespace DB +namespace DB { - NamesAndTypesList StorageSystemWarnings::getNamesAndTypes() { return { @@ -14,9 +12,8 @@ NamesAndTypesList StorageSystemWarnings::getNamesAndTypes() void StorageSystemWarnings::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { - for (auto& warning : context->getWarnings()) { + for (const auto & warning : context->getWarnings()) res_columns[0]->insert(warning); - } } } diff --git a/src/Storages/System/StorageSystemWarnings.h b/src/Storages/System/StorageSystemWarnings.h index b1e57e4b2c5..1606ed892e3 100644 --- a/src/Storages/System/StorageSystemWarnings.h +++ b/src/Storages/System/StorageSystemWarnings.h @@ -2,11 +2,13 @@ #include -namespace DB { +namespace DB +{ class Context; -class StorageSystemWarnings final : public shared_ptr_helper, public IStorageSystemOneBlock { +class StorageSystemWarnings final : public shared_ptr_helper, + public IStorageSystemOneBlock { public: std::string getName() const override { return "SystemWarnings"; } diff --git a/tests/queries/0_stateless/01945_system_warnings.expect b/tests/queries/0_stateless/01945_system_warnings.expect new file mode 100755 index 00000000000..6d55c792810 --- /dev/null +++ b/tests/queries/0_stateless/01945_system_warnings.expect @@ -0,0 +1,34 @@ +#!/usr/bin/expect -f + +# This is a test for system.warnings. Testing in interactive mode is necessary, +# as we want to see certain warnings from client + +log_user 0 +set timeout 60 +match_max 100000 + +# A default timeout action is to do nothing, change it to fail +expect_after { + timeout { + exit 1 + } +} + +set basedir [file dirname $argv0] +spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT --disable_suggestion" +expect ":) " + + +send -- "SELECT value FROM system.build_options WHERE name='BUILD_TYPE'" +expect { + "Debug" { + send -- "SELECT message FROM system.warnings WHERE message='Server was built in debug mode. It will work slowly.'" + expect "Server was built in debug mode. It will work slowly." + expect ":) " + } + "RelWithDebInfo" +} + +# Finish test +send -- "\4" +expect eof diff --git a/tests/queries/0_stateless/01945_system_warnings.reference b/tests/queries/0_stateless/01945_system_warnings.reference new file mode 100644 index 00000000000..e69de29bb2d