StorageSystemViews bug fix

This commit is contained in:
zhongyuankai 2021-08-26 20:54:04 +08:00
parent 042d17531c
commit 15cbd7470a
3 changed files with 15 additions and 11 deletions

View File

@ -2,6 +2,10 @@
#include <DataTypes/DataTypeString.h>
#include <Access/ContextAccess.h>
#include <Interpreters/Context.h>
#include <Interpreters/QueryViewsLog.h>
#include <DataTypes/DataTypeEnum.h>
#include <Storages/StorageMaterializedView.h>
#include <Storages/LiveView/StorageLiveView.h>
namespace DB
{
@ -11,22 +15,22 @@ class Context;
NamesAndTypesList StorageSystemViews::getNamesAndTypes()
{
auto view_type_datatype = std::make_shared<DataTypeEnum8>(DataTypeEnum8::Values{
{"Default", static_cast<Int8>(ViewType::DEFAULT)},
{"Materialized", static_cast<Int8>(ViewType::MATERIALIZED)},
{"Live", static_cast<Int8>(ViewType::LIVE)}});
{"Default", static_cast<Int8>(QueryViewsLogElement::ViewType::DEFAULT)},
{"Materialized", static_cast<Int8>(QueryViewsLogElement::ViewType::MATERIALIZED)},
{"Live", static_cast<Int8>(QueryViewsLogElement::ViewType::LIVE)}});
return {
{"database", std::make_shared<DataTypeString>()},
{"name", std::make_shared<DataTypeString>()},
{"table", std::make_shared<DataTypeString>()},
{"table_database", std::make_shared<DataTypeString>()},
{"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())

View File

@ -1,18 +1,18 @@
#pragma once
#include <ext/shared_ptr_helper.h>
#include <common/shared_ptr_helper.h>
#include <Storages/System/IStorageSystemOneBlock.h>
namespace DB
{
class StorageSystemViews final : public ext::shared_ptr_helper<StorageSystemViews>, public IStorageSystemOneBlock<StorageSystemViews>
class StorageSystemViews final : public shared_ptr_helper<StorageSystemViews>, public IStorageSystemOneBlock<StorageSystemViews>
{
friend struct ext::shared_ptr_helper<StorageSystemViews>;
friend struct shared_ptr_helper<StorageSystemViews>;
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"; }

View File

@ -1 +1 @@
default views_test default views_test_view
default views_test default views_test_view MATERIALIZED