mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
495c6e03aa
* Replace all Context references with std::weak_ptr * Fix shared context captured by value * Fix build * Fix Context with named sessions * Fix copy context * Fix gcc build * Merge with master and fix build * Fix gcc-9 build
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
#include <DataStreams/BlockIO.h>
|
|
#include <Interpreters/IInterpreter.h>
|
|
#include <Parsers/ASTInsertQuery.h>
|
|
#include <Storages/StorageInMemoryMetadata.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Interprets the INSERT query.
|
|
*/
|
|
class InterpreterInsertQuery : public IInterpreter, WithContext
|
|
{
|
|
public:
|
|
InterpreterInsertQuery(
|
|
const ASTPtr & query_ptr_,
|
|
ContextPtr context_,
|
|
bool allow_materialized_ = false,
|
|
bool no_squash_ = false,
|
|
bool no_destination_ = false);
|
|
|
|
/** 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;
|
|
|
|
StorageID getDatabaseTable() const;
|
|
|
|
void extendQueryLogElemImpl(QueryLogElement & elem, const ASTPtr & ast, ContextPtr context_) const override;
|
|
|
|
private:
|
|
StoragePtr getTable(ASTInsertQuery & query);
|
|
Block getSampleBlock(const ASTInsertQuery & query, const StoragePtr & table, const StorageMetadataPtr & metadata_snapshot) const;
|
|
|
|
ASTPtr query_ptr;
|
|
const bool allow_materialized;
|
|
const bool no_squash;
|
|
const bool no_destination;
|
|
};
|
|
|
|
|
|
}
|