aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/Access/ASTSettingsProfileElement.h
blob: 13c1926d9b0d95edcec30d7506064191669f57cb (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
43
44
45
46
47
48
#pragma once

#include <Parsers/IAST.h>
#include <Core/Field.h>
#include <Common/SettingConstraintWritability.h>

namespace DB
{
/** Represents a settings profile's element like the following
  * {variable [= value] [MIN [=] min_value] [MAX [=] max_value] [CONST|READONLY|WRITABLE|CHANGEABLE_IN_READONLY]} | PROFILE 'profile_name'
  */
class ASTSettingsProfileElement : public IAST
{
public:
    String parent_profile;
    String setting_name;
    std::optional<Field> value;
    std::optional<Field> min_value;
    std::optional<Field> max_value;
    std::optional<SettingConstraintWritability> writability;
    bool id_mode = false;  /// If true then `parent_profile` keeps UUID, not a name.
    bool use_inherit_keyword = false;  /// If true then this element is a part of ASTCreateSettingsProfileQuery.

    bool empty() const { return parent_profile.empty() && setting_name.empty(); }

    String getID(char) const override { return "SettingsProfileElement"; }
    ASTPtr clone() const override { return std::make_shared<ASTSettingsProfileElement>(*this); }
    void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
};


/** Represents settings profile's elements like the following
  * {{variable [= value] [MIN [=] min_value] [MAX [=] max_value] [CONST|READONLY|WRITABLE|CHANGEABLE_IN_READONLY]} | PROFILE 'profile_name'} [,...]
  */
class ASTSettingsProfileElements : public IAST
{
public:
    std::vector<std::shared_ptr<ASTSettingsProfileElement>> elements;

    bool empty() const;

    String getID(char) const override { return "SettingsProfileElements"; }
    ASTPtr clone() const override { return std::make_shared<ASTSettingsProfileElements>(*this); }
    void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;

    void setUseInheritKeyword(bool use_inherit_keyword_);
};
}