#pragma once #include #include #include #include #include namespace DB { /** Interprets the INSERT query. */ class InterpreterInsertQuery : public IInterpreter { public: InterpreterInsertQuery(const ASTPtr & query_ptr_, const Context & context_); /** 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). */ BlockIO execute() override; private: /// Cache storage to avoid double table function call. StoragePtr cached_table; StoragePtr loadTable(); StoragePtr getTable(); Block getSampleBlock(); void checkAccess(const ASTInsertQuery & query); ASTPtr query_ptr; const Context & context; }; }