mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
add limit option to rmr command
This commit is contained in:
parent
2fe6991124
commit
6309f36232
@ -506,14 +506,23 @@ bool RMRCommand::parse(IParser::Pos & pos, std::shared_ptr<ASTKeeperQuery> & nod
|
|||||||
return false;
|
return false;
|
||||||
node->args.push_back(std::move(path));
|
node->args.push_back(std::move(path));
|
||||||
|
|
||||||
|
ASTPtr remove_nodes_limit;
|
||||||
|
if (ParserUnsignedInteger{}.parse(pos, remove_nodes_limit, expected))
|
||||||
|
node->args.push_back(remove_nodes_limit->as<ASTLiteral &>().value);
|
||||||
|
else
|
||||||
|
node->args.push_back(UInt64(100));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RMRCommand::execute(const ASTKeeperQuery * query, KeeperClient * client) const
|
void RMRCommand::execute(const ASTKeeperQuery * query, KeeperClient * client) const
|
||||||
{
|
{
|
||||||
String path = client->getAbsolutePath(query->args[0].safeGet<String>());
|
String path = client->getAbsolutePath(query->args[0].safeGet<String>());
|
||||||
|
UInt64 remove_nodes_limit = query->args[1].safeGet<UInt64>();
|
||||||
|
|
||||||
client->askConfirmation(
|
client->askConfirmation(
|
||||||
"You are going to recursively delete path " + path, [client, path] { client->zookeeper->removeRecursive(path); });
|
"You are going to recursively delete path " + path,
|
||||||
|
[client, path, remove_nodes_limit] { client->zookeeper->removeRecursive(path, static_cast<UInt32>(remove_nodes_limit)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReconfigCommand::parse(IParser::Pos & pos, std::shared_ptr<ASTKeeperQuery> & node, DB::Expected & expected) const
|
bool ReconfigCommand::parse(IParser::Pos & pos, std::shared_ptr<ASTKeeperQuery> & node, DB::Expected & expected) const
|
||||||
|
@ -184,7 +184,7 @@ class RMRCommand : public IKeeperClientCommand
|
|||||||
|
|
||||||
void execute(const ASTKeeperQuery * query, KeeperClient * client) const override;
|
void execute(const ASTKeeperQuery * query, KeeperClient * client) const override;
|
||||||
|
|
||||||
String getHelpMessage() const override { return "{} <path> -- Recursively deletes path. Confirmation required"; }
|
String getHelpMessage() const override { return "{} <path> [limit] -- Recursively deletes path if the subtree size is smaller than the limit. Confirmation required (default limit = 100)"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReconfigCommand : public IKeeperClientCommand
|
class ReconfigCommand : public IKeeperClientCommand
|
||||||
|
Loading…
Reference in New Issue
Block a user