2011-10-30 11:30:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
#include <DataStreams/BlockIO.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Interpreters/IInterpreter.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTInsertQuery.h>
|
2011-10-30 11:30:52 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** Interprets the INSERT query.
|
2011-10-30 11:30:52 +00:00
|
|
|
*/
|
2015-06-18 02:11:05 +00:00
|
|
|
class InterpreterInsertQuery : public IInterpreter
|
2011-10-30 11:30:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-03-29 14:50:48 +00:00
|
|
|
InterpreterInsertQuery(const ASTPtr & query_ptr_, const Context & context_, bool allow_materialized_ = false);
|
2011-10-30 11:30:52 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** Prepare a request for execution. Return block streams
|
|
|
|
* - the stream into which you can write data to execute the query, if INSERT;
|
|
|
|
* - the stream from which you can read the result of the query, if SELECT and similar;
|
|
|
|
* Or nothing if the request INSERT SELECT (self-sufficient query - does not accept the input data, does not return the result).
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
BlockIO execute() override;
|
2012-03-19 12:57:56 +00:00
|
|
|
|
2018-11-15 15:03:13 +00:00
|
|
|
std::pair<String, String> getDatabaseTable() const;
|
2018-07-16 14:52:02 +00:00
|
|
|
|
2011-10-30 11:30:52 +00:00
|
|
|
private:
|
2018-02-19 00:45:32 +00:00
|
|
|
StoragePtr getTable(const ASTInsertQuery & query);
|
|
|
|
Block getSampleBlock(const ASTInsertQuery & query, const StoragePtr & table);
|
2017-12-20 07:39:52 +00:00
|
|
|
void checkAccess(const ASTInsertQuery & query);
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr query_ptr;
|
2019-03-29 14:50:48 +00:00
|
|
|
const Context & context;
|
2018-01-12 13:03:19 +00:00
|
|
|
bool allow_materialized;
|
2011-10-30 11:30:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|