aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/MySQL/ASTDropQuery.h
blob: 742cf6ba421b9228afb224028bce25ff620c7a73 (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
54
55
56
57
58
59
60
61
62
63
64
#pragma once

#include <Parsers/IParserBase.h>
#include <Parsers/MySQL/ASTDeclareIndex.h>
#include <Parsers/MySQL/ASTDeclareColumn.h>
#include <Parsers/MySQL/ASTDeclareTableOptions.h>

namespace DB
{

namespace ErrorCodes
{
    extern const int NOT_IMPLEMENTED;
}

namespace MySQLParser
{

class ASTDropQuery : public IAST
{
public:
    enum Kind
    {
        Table,
        View,
        Database,
        Index,
        /// TRIGGER,FUNCTION,EVENT and so on, No need for support
        Other,
    };
    Kind kind;
    struct QualifiedName
    {
        String schema;
        String shortName;
    };

    using QualifiedNames = std::vector<QualifiedName>;
    QualifiedNames names;
    bool if_exists{false};
    //drop or truncate
    bool is_truncate{false};

    ASTPtr clone() const override;
    String getID(char /*delim*/) const override {return "ASTDropQuery" ;}

protected:
    void formatImpl(const FormatSettings & /*settings*/, FormatState & /*state*/, FormatStateStacked /*frame*/) const override
    {
        throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method formatImpl is not supported by MySQLParser::ASTDropQuery.");
    }
};

class ParserDropQuery : public IParserBase
{
protected:
    const char * getName() const override { return "DROP query"; }

    bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};

}

}