mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
fix after rebase
This commit is contained in:
parent
c1c132502c
commit
0d392bbb34
@ -1,4 +1,5 @@
|
||||
#include <Databases/DatabaseAtomic.h>
|
||||
#include <Databases/DatabaseReplicated.h>
|
||||
#include <Databases/DatabaseDictionary.h>
|
||||
#include <Databases/DatabaseFactory.h>
|
||||
#include <Databases/DatabaseLazy.h>
|
||||
@ -69,7 +70,7 @@ DatabasePtr DatabaseFactory::getImpl(
|
||||
{
|
||||
String engine_name = engine_define->engine->name;
|
||||
|
||||
if (engine_name != "MySQL" && engine_name != "Lazy" && engine_define->engine->arguments)
|
||||
if (engine_name != "MySQL" && engine_name != "Lazy" && engine_name != "Replicated" && engine_define->engine->arguments)
|
||||
throw Exception("Database engine " + engine_name + " cannot have arguments", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
if (engine_define->engine->parameters || engine_define->partition_by || engine_define->primary_key || engine_define->order_by ||
|
||||
@ -138,6 +139,20 @@ DatabasePtr DatabaseFactory::getImpl(
|
||||
return std::make_shared<DatabaseLazy>(database_name, metadata_path, cache_expiration_time_seconds, context);
|
||||
}
|
||||
|
||||
else if (engine_name == "Replicated")
|
||||
{
|
||||
const ASTFunction * engine = engine_define->engine;
|
||||
|
||||
if (!engine->arguments || engine->arguments->children.size() != 2)
|
||||
throw Exception("Replicated database requires zoo_path and replica_name arguments", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
const auto & arguments = engine->arguments->children;
|
||||
|
||||
const auto zoo_path = arguments[0]->as<ASTLiteral>()->value.safeGet<String>();
|
||||
const auto replica_name = arguments[1]->as<ASTLiteral>()->value.safeGet<String>();
|
||||
return std::make_shared<DatabaseReplicated>(database_name, metadata_path, zoo_path, replica_name, context);
|
||||
}
|
||||
|
||||
throw Exception("Unknown database engine: " + engine_name, ErrorCodes::UNKNOWN_DATABASE_ENGINE);
|
||||
}
|
||||
|
||||
|
@ -125,8 +125,8 @@ void DatabaseReplicated::createTable(
|
||||
Coordination::Requests ops;
|
||||
ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path, "",
|
||||
zkutil::CreateMode::Persistent));
|
||||
ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path + "/metadata", metadata,
|
||||
zkutil::CreateMode::Persistent));
|
||||
//ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path + "/metadata", metadata,
|
||||
//zkutil::CreateMode::Persistent));
|
||||
// ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path + "/columns", getColumns().toString(),
|
||||
// zkutil::CreateMode::Persistent));
|
||||
ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path + "/log", "",
|
||||
@ -160,23 +160,24 @@ void DatabaseReplicated::renameTable(
|
||||
const String & table_name,
|
||||
IDatabase & to_database,
|
||||
const String & to_table_name,
|
||||
TableStructureWriteLockHolder & lock)
|
||||
bool exchange)
|
||||
{
|
||||
// try
|
||||
DatabaseOnDisk::renameTable(context, table_name, to_database, to_table_name, lock);
|
||||
// replicated stuff
|
||||
String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
DatabaseOnDisk::renameTable(context, table_name, to_database, to_table_name, exchange);
|
||||
// replicated stuff; what to put to a znode
|
||||
// String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
// this one is fairly more complex
|
||||
}
|
||||
|
||||
void DatabaseReplicated::removeTable(
|
||||
void DatabaseReplicated::dropTable(
|
||||
const Context & context,
|
||||
const String & table_name)
|
||||
const String & table_name,
|
||||
bool no_delay)
|
||||
{
|
||||
// try
|
||||
DatabaseOnDisk::removeTable(context, table_name);
|
||||
DatabaseOnDisk::dropTable(context, table_name, no_delay);
|
||||
// replicated stuff
|
||||
String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
//String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
// ...
|
||||
}
|
||||
|
||||
@ -184,13 +185,26 @@ void DatabaseReplicated::drop(const Context & context)
|
||||
{
|
||||
DatabaseOnDisk::drop(context);
|
||||
// replicated stuff
|
||||
String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
//String statement = getObjectDefinitionFromCreateQuery(query);
|
||||
// should it be possible to recover after a drop.
|
||||
// if not, we can just delete all the zookeeper nodes starting from
|
||||
// zookeeper path. does it work recursively? hope so...
|
||||
}
|
||||
|
||||
void DatabaseOrdinary::loadStoredObjects(
|
||||
// sync replica's zookeeper metadata
|
||||
void DatabaseReplicated::syncReplicaState(Context & context) {
|
||||
auto c = context; // fixes unuser parameter error
|
||||
return;
|
||||
}
|
||||
|
||||
// get the up to date metadata from zookeeper to local metadata dir
|
||||
// for replicated (only?) tables
|
||||
void DatabaseReplicated::updateMetadata(Context & context) {
|
||||
auto c = context; // fixes unuser parameter error
|
||||
return;
|
||||
}
|
||||
|
||||
void DatabaseReplicated::loadStoredObjects(
|
||||
Context & context,
|
||||
bool has_force_restore_data_flag)
|
||||
{
|
||||
@ -201,15 +215,6 @@ void DatabaseOrdinary::loadStoredObjects(
|
||||
|
||||
}
|
||||
|
||||
// sync replica's zookeeper metadata
|
||||
void syncReplicaState(Context & context) {
|
||||
|
||||
}
|
||||
|
||||
// get the up to date metadata from zookeeper to local metadata dir
|
||||
// for replicated (only?) tables
|
||||
void updateMetadata(Context & context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,16 +24,17 @@ public:
|
||||
const StoragePtr & table,
|
||||
const ASTPtr & query) override;
|
||||
|
||||
void removeTable(
|
||||
void dropTable(
|
||||
const Context & context,
|
||||
const String & table_name) override;
|
||||
const String & table_name,
|
||||
bool no_delay) override;
|
||||
|
||||
void renameTable(
|
||||
const Context & context,
|
||||
const String & table_name,
|
||||
IDatabase & to_database,
|
||||
const String & to_table_name,
|
||||
TableStructureWriteLockHolder & lock) override;
|
||||
bool exchange) override;
|
||||
|
||||
void drop(const Context & context) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user