mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Add database_replicated_allow_only_replicated_engine setting.
This commit is contained in:
parent
5869afcedd
commit
cdc529fa2a
@ -506,6 +506,7 @@ class IColumn;
|
||||
M(UInt64, database_replicated_initial_query_timeout_sec, 300, "How long initial DDL query should wait for Replicated database to precess previous DDL queue entries", 0) \
|
||||
M(UInt64, max_distributed_depth, 5, "Maximum distributed query depth", 0) \
|
||||
M(Bool, database_replicated_always_detach_permanently, false, "Execute DETACH TABLE as DETACH TABLE PERMANENTLY if database engine is Replicated", 0) \
|
||||
M(Bool, database_replicated_allow_only_replicated_engine, false, "Allow to create only Replicated tables in database with engine Replicated", 0) \
|
||||
M(DistributedDDLOutputMode, distributed_ddl_output_mode, DistributedDDLOutputMode::THROW, "Format of distributed DDL query result", 0) \
|
||||
M(UInt64, distributed_ddl_entry_format_version, 1, "Version of DDL entry to write into ZooKeeper", 0) \
|
||||
\
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <Storages/StorageFactory.h>
|
||||
#include <Storages/StorageInMemoryMetadata.h>
|
||||
#include <Storages/StorageReplicatedMergeTree.h>
|
||||
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Interpreters/executeDDLQueryOnCluster.h>
|
||||
@ -94,6 +95,7 @@ namespace ErrorCodes
|
||||
extern const int PATH_ACCESS_DENIED;
|
||||
extern const int NOT_IMPLEMENTED;
|
||||
extern const int ENGINE_REQUIRED;
|
||||
extern const int UNKNOWN_STORAGE;
|
||||
}
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@ -1195,6 +1197,14 @@ bool InterpreterCreateQuery::doCreateTable(ASTCreateQuery & create,
|
||||
addColumnsDescriptionToCreateQueryIfNecessary(query_ptr->as<ASTCreateQuery &>(), res);
|
||||
}
|
||||
|
||||
if (!create.attach && getContext()->getSettingsRef().database_replicated_allow_only_replicated_engine)
|
||||
{
|
||||
bool is_replicated_storage = typeid_cast<const StorageReplicatedMergeTree *>(res.get()) != nullptr;
|
||||
if (!is_replicated_storage && database && database->getEngineName() != "Replicated")
|
||||
throw Exception(ErrorCodes::UNKNOWN_STORAGE,
|
||||
"Only Replicated tables are allowed in database engine is Replicated");
|
||||
}
|
||||
|
||||
if (from_path && !res->storesDataOnDisk())
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
|
||||
"ATTACH ... FROM ... query is not supported for {} table engine, "
|
||||
|
Loading…
Reference in New Issue
Block a user