From 15cbd7470a0b93c80aff933c7571c7336487280e Mon Sep 17 00:00:00 2001 From: zhongyuankai Date: Thu, 26 Aug 2021 20:54:04 +0800 Subject: [PATCH] StorageSystemViews bug fix --- src/Storages/System/StorageSystemViews.cpp | 16 ++++++++++------ src/Storages/System/StorageSystemViews.h | 8 ++++---- .../0_stateless/02014_add_system_views.reference | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Storages/System/StorageSystemViews.cpp b/src/Storages/System/StorageSystemViews.cpp index e0e7a75fe89..c6461fd0949 100644 --- a/src/Storages/System/StorageSystemViews.cpp +++ b/src/Storages/System/StorageSystemViews.cpp @@ -2,6 +2,10 @@ #include #include #include +#include +#include +#include +#include namespace DB { @@ -11,22 +15,22 @@ class Context; NamesAndTypesList StorageSystemViews::getNamesAndTypes() { auto view_type_datatype = std::make_shared(DataTypeEnum8::Values{ - {"Default", static_cast(ViewType::DEFAULT)}, - {"Materialized", static_cast(ViewType::MATERIALIZED)}, - {"Live", static_cast(ViewType::LIVE)}}); + {"Default", static_cast(QueryViewsLogElement::ViewType::DEFAULT)}, + {"Materialized", static_cast(QueryViewsLogElement::ViewType::MATERIALIZED)}, + {"Live", static_cast(QueryViewsLogElement::ViewType::LIVE)}}); return { {"database", std::make_shared()}, {"name", std::make_shared()}, {"table", std::make_shared()}, {"table_database", std::make_shared()}, - {"type", std::move(view_type_datatype)}, + {"view_type", std::move(view_type_datatype)}, }; } -void StorageSystemViews::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const +void StorageSystemViews::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { - const auto access = context.getAccess(); + const auto access = context->getAccess(); const bool check_access_for_databases = !access->isGranted(AccessType::SHOW_TABLES); for (const auto & [table_id, view_ids] : DatabaseCatalog::instance().getViewDependencies()) diff --git a/src/Storages/System/StorageSystemViews.h b/src/Storages/System/StorageSystemViews.h index cfcab9566f1..67fcb79067e 100644 --- a/src/Storages/System/StorageSystemViews.h +++ b/src/Storages/System/StorageSystemViews.h @@ -1,18 +1,18 @@ #pragma once -#include +#include #include namespace DB { -class StorageSystemViews final : public ext::shared_ptr_helper, public IStorageSystemOneBlock +class StorageSystemViews final : public shared_ptr_helper, public IStorageSystemOneBlock { - friend struct ext::shared_ptr_helper; + friend struct shared_ptr_helper; protected: using IStorageSystemOneBlock::IStorageSystemOneBlock; - void fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo & query_info) const override; + void fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const override; public: std::string getName() const override { return "SystemViews"; } diff --git a/tests/queries/0_stateless/02014_add_system_views.reference b/tests/queries/0_stateless/02014_add_system_views.reference index fa8a1885767..dc4e25c14e7 100644 --- a/tests/queries/0_stateless/02014_add_system_views.reference +++ b/tests/queries/0_stateless/02014_add_system_views.reference @@ -1 +1 @@ -default views_test default views_test_view +default views_test default views_test_view MATERIALIZED