1#pragma once
2
3#include <Parsers/IAST.h>
4
5
6namespace DB
7{
8
9
10/** INSERT query
11 */
12class ASTInsertQuery : public IAST
13{
14public:
15 String database;
16 String table;
17 ASTPtr columns;
18 String format;
19 ASTPtr select;
20 ASTPtr table_function;
21 ASTPtr settings_ast;
22
23 /// Data to insert
24 const char * data = nullptr;
25 const char * end = nullptr;
26
27 /// Query has additional data, which will be sent later
28 bool has_tail = false;
29
30 /// Try to find table function input() in SELECT part
31 void tryFindInputFunction(ASTPtr & input_function) const;
32
33 /** Get the text that identifies this element. */
34 String getID(char delim) const override { return "InsertQuery" + (delim + database) + delim + table; }
35
36 ASTPtr clone() const override
37 {
38 auto res = std::make_shared<ASTInsertQuery>(*this);
39 res->children.clear();
40
41 if (columns) { res->columns = columns->clone(); res->children.push_back(res->columns); }
42 if (select) { res->select = select->clone(); res->children.push_back(res->select); }
43 if (table_function) { res->table_function = table_function->clone(); res->children.push_back(res->table_function); }
44 if (settings_ast) { res->settings_ast = settings_ast->clone(); res->children.push_back(res->settings_ast); }
45
46 return res;
47 }
48
49protected:
50 void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
51};
52
53}
54