aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/ASTKillQueryQuery.cpp
blob: a3c0f48f28aacdbdc169ecc7e668857e6a342fcc (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
#include <Parsers/ASTKillQueryQuery.h>
#include <IO/Operators.h>

namespace DB
{

String ASTKillQueryQuery::getID(char delim) const
{
    return String("KillQueryQuery") + delim + (where_expression ? where_expression->getID() : "") + delim + String(sync ? "SYNC" : "ASYNC");
}

void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
    settings.ostr << (settings.hilite ? hilite_keyword : "") << "KILL ";

    switch (type)
    {
        case Type::Query:
            settings.ostr << "QUERY";
            break;
        case Type::Mutation:
            settings.ostr << "MUTATION";
            break;
        case Type::PartMoveToShard:
            settings.ostr << "PART_MOVE_TO_SHARD";
            break;
        case Type::Transaction:
            settings.ostr << "TRANSACTION";
            break;
    }

    settings.ostr << (settings.hilite ? hilite_none : "");

    formatOnCluster(settings);

    if (where_expression)
    {
        settings.ostr << (settings.hilite ? hilite_keyword : "") << " WHERE " << (settings.hilite ? hilite_none : "");
        where_expression->formatImpl(settings, state, frame);
    }

    settings.ostr << " " << (settings.hilite ? hilite_keyword : "") << (test ? "TEST" : (sync ? "SYNC" : "ASYNC")) << (settings.hilite ? hilite_none : "");
}

}