2011-10-30 11:30:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/QueryProcessingStage.h>
|
|
|
|
#include <DataStreams/BlockIO.h>
|
2011-10-30 11:30:52 +00:00
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
#include <Processors/QueryPipeline.h>
|
2011-10-30 11:30:52 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-05-25 14:15:22 +00:00
|
|
|
class ReadBuffer;
|
|
|
|
class WriteBuffer;
|
|
|
|
class Context;
|
|
|
|
|
2011-10-30 11:30:52 +00:00
|
|
|
|
2017-01-18 13:53:20 +00:00
|
|
|
/// Parse and execute a query.
|
2011-10-30 11:30:52 +00:00
|
|
|
void executeQuery(
|
2017-07-27 18:44:55 +00:00
|
|
|
ReadBuffer & istr, /// Where to read query from (and data for INSERT, if present).
|
|
|
|
WriteBuffer & ostr, /// Where to write query output to.
|
2017-04-01 07:20:54 +00:00
|
|
|
bool allow_into_outfile, /// If true and the query contains INTO OUTFILE section, redirect output to that file.
|
2017-07-27 18:44:55 +00:00
|
|
|
Context & context, /// DB, tables, data types, storage engines, functions, aggregate functions...
|
2019-02-02 12:24:26 +00:00
|
|
|
std::function<void(const String &)> set_content_type, /// If non-empty callback is passed, it will be called with the Content-Type of the result.
|
|
|
|
std::function<void(const String &)> set_query_id /// If non-empty callback is passed, it will be called with the query id.
|
2019-10-29 10:27:19 +00:00
|
|
|
);
|
2011-10-30 11:30:52 +00:00
|
|
|
|
2012-03-11 08:52:56 +00:00
|
|
|
|
2017-01-18 13:53:20 +00:00
|
|
|
/// More low-level function for server-to-server interaction.
|
|
|
|
/// Prepares a query for execution but doesn't execute it.
|
|
|
|
/// Returns a pair of block streams which, when used, will result in query execution.
|
|
|
|
/// This means that the caller can to the extent control the query execution pipeline.
|
|
|
|
///
|
|
|
|
/// To execute:
|
|
|
|
/// * if present, write INSERT data into BlockIO::out
|
|
|
|
/// * then read the results from BlockIO::in.
|
|
|
|
///
|
|
|
|
/// If the query doesn't involve data insertion or returning of results, out and in respectively
|
|
|
|
/// will be equal to nullptr.
|
|
|
|
///
|
|
|
|
/// Correctly formatting the results (according to INTO OUTFILE and FORMAT sections)
|
|
|
|
/// must be done separately.
|
2012-03-11 08:52:56 +00:00
|
|
|
BlockIO executeQuery(
|
2017-04-01 07:20:54 +00:00
|
|
|
const String & query, /// Query text without INSERT data. The latter must be written to BlockIO::out.
|
|
|
|
Context & context, /// DB, tables, data types, storage engines, functions, aggregate functions...
|
|
|
|
bool internal = false, /// If true, this query is caused by another query and thus needn't be registered in the ProcessList.
|
2019-02-13 11:57:47 +00:00
|
|
|
QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, /// To which stage the query must be executed.
|
2019-09-02 15:19:01 +00:00
|
|
|
bool may_have_embedded_data = false, /// If insert query may have embedded data
|
|
|
|
bool allow_processors = true /// If can use processors pipeline
|
2019-10-29 10:27:19 +00:00
|
|
|
);
|
2012-03-11 08:52:56 +00:00
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
|
|
|
|
QueryPipeline executeQueryWithProcessors(
|
|
|
|
const String & query, /// Query text without INSERT data. The latter must be written to BlockIO::out.
|
|
|
|
Context & context, /// DB, tables, data types, storage engines, functions, aggregate functions...
|
|
|
|
bool internal = false, /// If true, this query is caused by another query and thus needn't be registered in the ProcessList.
|
|
|
|
QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, /// To which stage the query must be executed.
|
|
|
|
bool may_have_embedded_data = false /// If insert query may have embedded data
|
|
|
|
);
|
|
|
|
|
2011-10-30 11:30:52 +00:00
|
|
|
}
|