2021-10-15 20:18:20 +00:00
|
|
|
#include <QueryPipeline/BlockIO.h>
|
2020-02-27 15:40:11 +00:00
|
|
|
#include <Interpreters/ProcessList.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-05-18 13:55:07 +00:00
|
|
|
|
2020-02-27 15:40:11 +00:00
|
|
|
void BlockIO::reset()
|
|
|
|
{
|
|
|
|
/** process_list_entry should be destroyed after in, after out and after pipeline,
|
|
|
|
* since in, out and pipeline contain pointer to objects inside process_list_entry (query-level MemoryTracker for example),
|
|
|
|
* which could be used before destroying of in and out.
|
|
|
|
*
|
|
|
|
* However, QueryStatus inside process_list_entry holds shared pointers to streams for some reason.
|
|
|
|
* Streams must be destroyed before storage locks, storages and contexts inside pipeline,
|
|
|
|
* so releaseQueryStreams() is required.
|
|
|
|
*/
|
|
|
|
/// TODO simplify it all
|
|
|
|
|
2020-08-06 12:24:05 +00:00
|
|
|
pipeline.reset();
|
2020-02-27 15:40:11 +00:00
|
|
|
process_list_entry.reset();
|
|
|
|
|
|
|
|
/// TODO Do we need also reset callbacks? In which order?
|
|
|
|
}
|
|
|
|
|
2022-02-17 15:56:42 +00:00
|
|
|
BlockIO & BlockIO::operator= (BlockIO && rhs) noexcept
|
2020-02-27 15:40:11 +00:00
|
|
|
{
|
|
|
|
if (this == &rhs)
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
/// Explicitly reset fields, so everything is destructed in right order
|
|
|
|
reset();
|
|
|
|
|
|
|
|
process_list_entry = std::move(rhs.process_list_entry);
|
|
|
|
pipeline = std::move(rhs.pipeline);
|
|
|
|
|
|
|
|
finish_callback = std::move(rhs.finish_callback);
|
|
|
|
exception_callback = std::move(rhs.exception_callback);
|
|
|
|
|
2022-05-03 01:46:34 +00:00
|
|
|
null_format = rhs.null_format;
|
2020-02-27 15:40:11 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockIO::~BlockIO()
|
|
|
|
{
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
2022-04-30 00:04:12 +00:00
|
|
|
void BlockIO::setAllDataSent() const
|
|
|
|
{
|
|
|
|
/// The following queries does not have process_list_entry:
|
|
|
|
/// - internal
|
|
|
|
/// - SHOW PROCESSLIST
|
|
|
|
if (process_list_entry)
|
|
|
|
(*process_list_entry)->setAllDataSent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-27 15:40:11 +00:00
|
|
|
}
|
|
|
|
|