ClickHouse/src/QueryPipeline/BlockIO.h
Azat Khuzhin d82f2ff162 Set is_all_data_sent on exceptions too
This will avoid clickhouse-test complains about left queries after the
test, like in [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/36258/9646487c093a75dc31e3e818417cfad83580b40f/stateful_tests__memory__actions_.html

Follow-up for: #36649
2022-04-30 13:00:44 +03:00

59 lines
1.1 KiB
C++

#pragma once
#include <functional>
#include <QueryPipeline/QueryPipeline.h>
namespace DB
{
class ProcessListEntry;
struct BlockIO
{
BlockIO() = default;
BlockIO(BlockIO &&) = default;
BlockIO & operator= (BlockIO && rhs) noexcept;
~BlockIO();
BlockIO(const BlockIO &) = delete;
BlockIO & operator= (const BlockIO & rhs) = delete;
std::shared_ptr<ProcessListEntry> process_list_entry;
QueryPipeline pipeline;
/// Callbacks for query logging could be set here.
std::function<void(QueryPipeline &)> finish_callback;
std::function<void()> exception_callback;
/// When it is true, don't bother sending any non-empty blocks to the out stream
bool null_format = false;
void onFinish()
{
if (finish_callback)
{
finish_callback(pipeline);
}
pipeline.reset();
}
void onException()
{
if (exception_callback)
exception_callback();
pipeline.reset();
}
/// Set is_all_data_sent in system.processes for this query.
void setAllDataSent() const;
private:
void reset();
};
}