2011-10-30 05:19:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
2011-10-30 05:19:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** INSERT query
|
2011-10-30 05:19:41 +00:00
|
|
|
*/
|
|
|
|
class ASTInsertQuery : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
String database;
|
|
|
|
String table;
|
|
|
|
ASTPtr columns;
|
|
|
|
String format;
|
|
|
|
ASTPtr select;
|
2017-05-27 17:27:16 +00:00
|
|
|
/// Data to insert
|
2017-04-01 07:20:54 +00:00
|
|
|
const char * data = nullptr;
|
|
|
|
const char * end = nullptr;
|
|
|
|
|
|
|
|
ASTInsertQuery() = default;
|
|
|
|
ASTInsertQuery(const StringRange range_) : IAST(range_) {}
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2017-04-01 07:20:54 +00:00
|
|
|
String getID() const override { return "InsertQuery_" + database + "_" + table; };
|
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTInsertQuery>(*this);
|
|
|
|
res->children.clear();
|
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
if (columns) { res->columns = columns->clone(); res->children.push_back(res->columns); }
|
|
|
|
if (select) { res->select = select->clone(); res->children.push_back(res->select); }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2011-10-30 05:19:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|