mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
DatabaseCloud: development [#METR-19998].
This commit is contained in:
parent
e8f2afe899
commit
fc99c6a3ae
@ -93,7 +93,7 @@ public:
|
||||
bool empty() const override;
|
||||
|
||||
void createTable(const String & table_name, const StoragePtr & table, const ASTPtr & query, const String & engine) override;
|
||||
StoragePtr removeTable(const String & table_name) override;
|
||||
void removeTable(const String & table_name) override;
|
||||
|
||||
void attachTable(const String & table_name, const StoragePtr & table) override;
|
||||
StoragePtr detachTable(const String & table_name) override;
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
bool empty() const override;
|
||||
|
||||
void createTable(const String & table_name, const StoragePtr & table, const ASTPtr & query, const String & engine) override;
|
||||
StoragePtr removeTable(const String & table_name) override;
|
||||
void removeTable(const String & table_name) override;
|
||||
|
||||
void attachTable(const String & table_name, const StoragePtr & table) override;
|
||||
StoragePtr detachTable(const String & table_name) override;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
virtual void createTable(const String & name, const StoragePtr & table, const ASTPtr & query, const String & engine) = 0;
|
||||
|
||||
/// Удалить таблицу из базы данных и вернуть её. Удалить метаданные.
|
||||
virtual StoragePtr removeTable(const String & name) = 0;
|
||||
virtual void removeTable(const String & name) = 0;
|
||||
|
||||
/// Добавить таблицу в базу данных, но не прописывать её в метаданных. БД может не поддерживать этот метод.
|
||||
virtual void attachTable(const String & name, const StoragePtr & table) = 0;
|
||||
|
@ -55,9 +55,10 @@ void DatabaseCloud::createZookeeperNodes()
|
||||
else
|
||||
throw zkutil::KeeperException(code);
|
||||
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/tables/" + name);
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/local_tables/" + name);
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/nodes/" + hostname);
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/tables/" + name, "");
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/local_tables/" + name, "");
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/nodes/" + hostname, "");
|
||||
zookeeper->createIfNotExists(zookeeper_path + "/nodes/" + hostname + "/datacenter", datacenter_name);
|
||||
}
|
||||
|
||||
|
||||
@ -434,7 +435,7 @@ bool DatabaseCloud::empty() const
|
||||
ASTPtr DatabaseCloud::getCreateQuery(const String & table_name) const
|
||||
{
|
||||
zkutil::ZooKeeperPtr zookeeper = context.getZooKeeper();
|
||||
String definition;
|
||||
Hash definition_hash;
|
||||
|
||||
String table_name_escaped = escapeForFileName(table_name);
|
||||
if (Poco::File(data_path + table_name_escaped).exists())
|
||||
@ -443,7 +444,7 @@ ASTPtr DatabaseCloud::getCreateQuery(const String & table_name) const
|
||||
zookeeper_path + "/local_tables/" + name + "/" + getNameOfNodeWithTables(table_name)));
|
||||
|
||||
Hash table_hash = getTableHash(table_name);
|
||||
definition = getTableDefinitionFromHash(local_tables_info.map.at(table_hash));
|
||||
definition_hash = local_tables_info.map.at(table_hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -451,12 +452,14 @@ ASTPtr DatabaseCloud::getCreateQuery(const String & table_name) const
|
||||
zookeeper_path + "/tables/" + name + "/" + getNameOfNodeWithTables(table_name)));
|
||||
|
||||
const TableDescription & description = tables_info.at(table_name);
|
||||
definition = getTableDefinitionFromHash(description.definition_hash);
|
||||
definition_hash = description.definition_hash;
|
||||
}
|
||||
|
||||
String definition = getTableDefinitionFromHash(definition_hash);
|
||||
|
||||
ParserCreateQuery parser;
|
||||
ASTPtr ast = parseQuery(parser, definition.data(), definition.data() + definition.size(),
|
||||
"in zookeeper node " + zookeeper_path + "/table_definitions/" + hashToHex(description.definition_hash));
|
||||
"in zookeeper node " + zookeeper_path + "/table_definitions/" + hashToHex(definition_hash));
|
||||
|
||||
ASTCreateQuery & ast_create_query = typeid_cast<ASTCreateQuery &>(*ast);
|
||||
ast_create_query.attach = false;
|
||||
|
@ -332,7 +332,7 @@ StoragePtr DatabaseOrdinary::detachTable(const String & table_name)
|
||||
}
|
||||
|
||||
|
||||
StoragePtr DatabaseOrdinary::removeTable(const String & table_name)
|
||||
void DatabaseOrdinary::removeTable(const String & table_name)
|
||||
{
|
||||
StoragePtr res = detachTable(table_name);
|
||||
|
||||
@ -348,8 +348,6 @@ StoragePtr DatabaseOrdinary::removeTable(const String & table_name)
|
||||
attachTable(table_name, res);
|
||||
throw;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user