aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/KnownObjectNames.cpp
blob: 0862c52d892d7eaa5b0b9424f2ba3190d7de87f0 (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
#include <Common/KnownObjectNames.h>
#include <Poco/String.h>


namespace DB
{

bool KnownObjectNames::exists(const String & name) const
{
    std::lock_guard lock{mutex};
    if (names.contains(name))
        return true;

    if (!case_insensitive_names.empty())
    {
        String lower_name = Poco::toLower(name);
        if (case_insensitive_names.contains(lower_name))
            return true;
    }

    return false;
}


void KnownObjectNames::add(const String & name, bool case_insensitive)
{
    std::lock_guard lock{mutex};
    if (case_insensitive)
        case_insensitive_names.emplace(Poco::toLower(name));
    else
        names.emplace(name);
}


KnownTableFunctionNames & KnownTableFunctionNames::instance()
{
    static KnownTableFunctionNames the_instance;
    return the_instance;
}


KnownFormatNames & KnownFormatNames::instance()
{
    static KnownFormatNames the_instance;
    return the_instance;
}

}