2017-08-04 15:54:00 +00:00
|
|
|
#pragma once
|
2019-03-11 14:01:45 +00:00
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
#include <Interpreters/IInterpreter.h>
|
2019-03-11 14:01:45 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
2019-05-17 14:34:25 +00:00
|
|
|
#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>
|
2017-08-04 15:54:00 +00:00
|
|
|
|
2017-08-06 20:26:23 +00:00
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
namespace Poco { class Logger; }
|
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
2020-01-24 16:20:36 +00:00
|
|
|
class AccessRightsElements;
|
2018-05-21 13:49:54 +00:00
|
|
|
class ASTSystemQuery;
|
2017-08-04 15:54:00 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2017-08-04 15:54:00 +00:00
|
|
|
class InterpreterSystemQuery : public IInterpreter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InterpreterSystemQuery(const ASTPtr & query_ptr_, Context & context_);
|
|
|
|
|
|
|
|
BlockIO execute() override;
|
|
|
|
|
2019-11-11 01:11:32 +00:00
|
|
|
bool ignoreQuota() const override { return true; }
|
|
|
|
bool ignoreLimits() const override { return true; }
|
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
private:
|
|
|
|
ASTPtr query_ptr;
|
|
|
|
Context & context;
|
2018-05-21 13:49:54 +00:00
|
|
|
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
|
2018-05-21 13:49:54 +00:00
|
|
|
|
|
|
|
/// Tries to get a replicated table and restart it
|
|
|
|
/// Returns pointer to a newly created table if the restart was successful
|
2020-03-30 23:36:23 +00:00
|
|
|
StoragePtr tryRestartReplica(const StorageID & replica, Context & context, bool need_ddl_guard = true);
|
2018-05-21 13:49:54 +00:00
|
|
|
|
2018-08-27 18:05:28 +00:00
|
|
|
void restartReplicas(Context & system_context);
|
2018-05-21 13:49:54 +00:00
|
|
|
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);
|
2019-05-10 04:19:02 +00:00
|
|
|
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);
|
2017-08-04 15:54:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|