ClickHouse/src/Interpreters/InterpreterSystemQuery.h

64 lines
1.9 KiB
C++
Raw Normal View History

#pragma once
2019-03-11 14:01:45 +00:00
#include <Interpreters/IInterpreter.h>
2019-03-11 14:01:45 +00:00
#include <Parsers/IAST_fwd.h>
#include <Storages/IStorage_fwd.h>
2020-03-13 10:30:55 +00:00
#include <Interpreters/StorageID.h>
2020-03-04 20:29:52 +00:00
#include <Common/ActionLock.h>
namespace Poco { class Logger; }
namespace DB
{
class Context;
2020-01-24 16:20:36 +00:00
class AccessRightsElements;
class ASTSystemQuery;
2020-06-15 23:27:22 +00:00
/** Implement various SYSTEM queries.
* Examples: SYSTEM SHUTDOWN, SYSTEM DROP MARK CACHE.
*
* Some commands are intended to stop/start background actions for tables and comes with two variants:
*
* 1. SYSTEM STOP MERGES table, SYSTEM START MERGES table
* - start/stop actions for specific table.
*
* 2. SYSTEM STOP MERGES, SYSTEM START MERGES
* - start/stop actions for all existing tables.
* Note that the actions for tables that will be created after this query will not be affected.
*/
class InterpreterSystemQuery : public IInterpreter
{
public:
InterpreterSystemQuery(const ASTPtr & query_ptr_, Context & context_);
BlockIO execute() override;
bool ignoreQuota() const override { return true; }
bool ignoreLimits() const override { return true; }
private:
ASTPtr query_ptr;
Context & context;
Poco::Logger * log = nullptr;
2020-03-04 20:29:52 +00:00
StorageID table_id = StorageID::createEmpty(); /// Will be set up if query contains table name
/// Tries to get a replicated table and restart it
/// Returns pointer to a newly created table if the restart was successful
StoragePtr tryRestartReplica(const StorageID & replica, Context & context, bool need_ddl_guard = true);
2018-08-27 18:05:28 +00:00
void restartReplicas(Context & system_context);
void syncReplica(ASTSystemQuery & query);
2020-05-17 12:44:22 +00:00
void dropReplica(ASTSystemQuery & query);
2020-06-23 12:01:51 +00:00
bool dropReplicaImpl(ASTSystemQuery & query, const StoragePtr & table);
void flushDistributed(ASTSystemQuery & query);
2020-01-24 16:20:36 +00:00
AccessRightsElements getRequiredAccessForDDLOnCluster() const;
2020-03-04 20:29:52 +00:00
void startStopAction(StorageActionBlockType action_type, bool start);
};
}