mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
fix
This commit is contained in:
parent
52e5c0aad7
commit
a57456a3fd
@ -158,6 +158,7 @@ struct MetadataTransaction
|
|||||||
void addOps(Coordination::Requests & other_ops)
|
void addOps(Coordination::Requests & other_ops)
|
||||||
{
|
{
|
||||||
std::move(ops.begin(), ops.end(), std::back_inserter(other_ops));
|
std::move(ops.begin(), ops.end(), std::back_inserter(other_ops));
|
||||||
|
ops.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void commit();
|
void commit();
|
||||||
|
@ -400,6 +400,12 @@ bool DDLWorker::tryExecuteQuery(const String & query, DDLTaskBase & task)
|
|||||||
auto query_context = task.makeQueryContext(context);
|
auto query_context = task.makeQueryContext(context);
|
||||||
query_scope.emplace(*query_context);
|
query_scope.emplace(*query_context);
|
||||||
executeQuery(istr, ostr, false, *query_context, {});
|
executeQuery(istr, ostr, false, *query_context, {});
|
||||||
|
|
||||||
|
if (auto txn = query_context->getMetadataTransaction())
|
||||||
|
{
|
||||||
|
if (txn->state == MetadataTransaction::CREATED)
|
||||||
|
txn->commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const DB::Exception & e)
|
catch (const DB::Exception & e)
|
||||||
{
|
{
|
||||||
|
@ -800,11 +800,11 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
|||||||
|
|
||||||
String current_database = context.getCurrentDatabase();
|
String current_database = context.getCurrentDatabase();
|
||||||
auto database_name = create.database.empty() ? current_database : create.database;
|
auto database_name = create.database.empty() ? current_database : create.database;
|
||||||
auto database = DatabaseCatalog::instance().getDatabase(database_name);
|
|
||||||
|
|
||||||
// If this is a stub ATTACH query, read the query definition from the database
|
// If this is a stub ATTACH query, read the query definition from the database
|
||||||
if (create.attach && !create.storage && !create.columns_list)
|
if (create.attach && !create.storage && !create.columns_list)
|
||||||
{
|
{
|
||||||
|
auto database = DatabaseCatalog::instance().getDatabase(database_name);
|
||||||
bool if_not_exists = create.if_not_exists;
|
bool if_not_exists = create.if_not_exists;
|
||||||
|
|
||||||
// Table SQL definition is available even if the table is detached (even permanently)
|
// Table SQL definition is available even if the table is detached (even permanently)
|
||||||
@ -869,7 +869,11 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO make code better if possible
|
//TODO make code better if possible
|
||||||
|
DatabasePtr database;
|
||||||
bool need_add_to_database = !create.temporary;
|
bool need_add_to_database = !create.temporary;
|
||||||
|
if (need_add_to_database)
|
||||||
|
database = DatabaseCatalog::instance().getDatabase(database_name);
|
||||||
|
|
||||||
if (need_add_to_database && database->getEngineName() == "Replicated")
|
if (need_add_to_database && database->getEngineName() == "Replicated")
|
||||||
{
|
{
|
||||||
auto guard = DatabaseCatalog::instance().getDDLGuard(create.database, create.table);
|
auto guard = DatabaseCatalog::instance().getDDLGuard(create.database, create.table);
|
||||||
|
Loading…
Reference in New Issue
Block a user