aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/Access/parseUserName.h
blob: 10c548d88263cf7a8f73e0a08ab0b46651165213 (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
#pragma once

#include <Core/Types.h>
#include <Parsers/IParser.h>
#include <Parsers/parseIdentifierOrStringLiteral.h>


namespace DB
{
/// Parses 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.
bool parseUserName(IParser::Pos & pos, Expected & expected, String & user_name);

/// Parses a comma-separated list of user names.
bool parseUserNames(IParser::Pos & pos, Expected & expected, Strings & user_names);


/// Parses either the 'CURRENT_USER' keyword (or some of its aliases).
bool parseCurrentUserTag(IParser::Pos & pos, Expected & expected);


/// Parses a role name. It follows the same rules as a user name, but allowed hosts are never checked
/// (because roles are not used to connect to server).
inline bool parseRoleName(IParser::Pos & pos, Expected & expected, String & role_name)
{
    return parseUserName(pos, expected, role_name);
}

/// Parses a comma-separated list of role names.
inline bool parseRoleNames(IParser::Pos & pos, Expected & expected, Strings & role_names)
{
    return parseUserNames(pos, expected, role_names);
}

}