2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
#include <Parsers/ASTQueryWithOutput.h>
|
2018-07-20 05:46:48 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
2016-11-30 17:31:05 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-07-20 05:46:48 +00:00
|
|
|
class ASTKillQueryQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluster
|
2016-11-30 17:31:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-02-05 13:15:11 +00:00
|
|
|
enum class Type
|
|
|
|
{
|
|
|
|
Query, /// KILL QUERY
|
|
|
|
Mutation, /// KILL MUTATION
|
|
|
|
};
|
|
|
|
|
|
|
|
Type type = Type::Query;
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr where_expression; // expression to filter processes from system.processes table
|
2017-08-03 17:00:41 +00:00
|
|
|
bool sync = false; // SYNC or ASYNC mode
|
|
|
|
bool test = false; // does it TEST mode? (doesn't cancel queries just checks and shows them)
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2018-05-17 13:33:28 +00:00
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto clone = std::make_shared<ASTKillQueryQuery>(*this);
|
2018-12-24 08:17:22 +00:00
|
|
|
if (where_expression)
|
|
|
|
{
|
|
|
|
clone->where_expression = where_expression->clone();
|
|
|
|
clone->children = {clone->where_expression};
|
|
|
|
}
|
|
|
|
|
Get rid of useless std::move to get NRVO
http://eel.is/c++draft/class.copy.elision#:constructor,copy,elision
Some quote:
> Speaking of RVO, return std::move(w); prohibits it. It means "use move constructor or fail to compile", whereas return w; means "use RVO, and if you can't, use move constructor, and if you can't, use copy constructor, and if you can't, fail to compile."
There is one exception to this rule:
```cpp
Block FilterBlockInputStream::removeFilterIfNeed(Block && block)
{
if (block && remove_filter)
block.erase(static_cast<size_t>(filter_column));
return std::move(block);
}
```
because references are not eligible for NRVO, which is another rule "always move rvalue references and forward universal references" that takes precedence.
2018-08-27 14:04:22 +00:00
|
|
|
return clone;
|
2018-05-17 13:33:28 +00:00
|
|
|
}
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override;
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
2018-07-20 05:46:48 +00:00
|
|
|
|
2018-10-24 15:31:07 +00:00
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string &) const override
|
|
|
|
{
|
|
|
|
return removeOnCluster<ASTKillQueryQuery>(clone());
|
|
|
|
}
|
2016-11-30 17:31:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|