blob: bd28b42b48afc0d54b91692eb89531aa8e2a2a6a (
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
49
50
51
52
53
|
#pragma once
#include <Parsers/IAST.h>
namespace DB
{
/** Represents a user name.
* It can be a simple string or identifier or something like `name@host`.
* In the last case `host` specifies the hosts user is allowed to connect from.
* The `host` can be an ip address, ip subnet, or a host name.
* The % and _ wildcard characters are permitted in `host`.
* These have the same meaning as for pattern-matching operations performed with the LIKE operator.
*/
class ASTUserNameWithHost : public IAST
{
public:
String base_name;
String host_pattern;
String toString() const;
void concatParts();
ASTUserNameWithHost() = default;
explicit ASTUserNameWithHost(const String & name_) : base_name(name_) {}
String getID(char) const override { return "UserNameWithHost"; }
ASTPtr clone() const override { return std::make_shared<ASTUserNameWithHost>(*this); }
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
};
class ASTUserNamesWithHost : public IAST
{
public:
std::vector<std::shared_ptr<ASTUserNameWithHost>> names;
size_t size() const { return names.size(); }
auto begin() const { return names.begin(); }
auto end() const { return names.end(); }
auto front() const { return *begin(); }
void push_back(const String & name_) { names.push_back(std::make_shared<ASTUserNameWithHost>(name_)); } /// NOLINT
Strings toStrings() const;
void concatParts();
bool getHostPatternIfCommon(String & out_common_host_pattern) const;
String getID(char) const override { return "UserNamesWithHost"; }
ASTPtr clone() const override { return std::make_shared<ASTUserNamesWithHost>(*this); }
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
};
}
|