aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/Access/InterpreterShowCreateAccessEntityQuery.h
blob: 9d84e68568b095cf20cf8dd7af091694df54b1e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include <Interpreters/IInterpreter.h>
#include <Parsers/IAST_fwd.h>
#include <Core/UUID.h>


namespace DB
{
class AccessControl;
class Context;
class AccessRightsElements;
struct IAccessEntity;
using AccessEntityPtr = std::shared_ptr<const IAccessEntity>;


/** Returns a single item containing a statement which could be used to create a specified role.
  */
class InterpreterShowCreateAccessEntityQuery : public IInterpreter, WithContext
{
public:
    InterpreterShowCreateAccessEntityQuery(const ASTPtr & query_ptr_, ContextPtr context_);

    BlockIO execute() override;

    bool ignoreQuota() const override { return true; }
    bool ignoreLimits() const override { return true; }

    static ASTPtr getCreateQuery(const IAccessEntity & entity, const AccessControl & access_control);
    static ASTPtr getAttachQuery(const IAccessEntity & entity);

private:
    QueryPipeline executeImpl();
    std::vector<AccessEntityPtr> getEntities() const;
    ASTs getCreateQueries() const;
    AccessRightsElements getRequiredAccess() const;

    ASTPtr query_ptr;
};


}