mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
fix
This commit is contained in:
parent
52e5c0aad7
commit
a57456a3fd
@ -158,6 +158,7 @@ struct MetadataTransaction
|
||||
void addOps(Coordination::Requests & other_ops)
|
||||
{
|
||||
std::move(ops.begin(), ops.end(), std::back_inserter(other_ops));
|
||||
ops.clear();
|
||||
}
|
||||
|
||||
void commit();
|
||||
|
@ -400,6 +400,12 @@ bool DDLWorker::tryExecuteQuery(const String & query, DDLTaskBase & task)
|
||||
auto query_context = task.makeQueryContext(context);
|
||||
query_scope.emplace(*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)
|
||||
{
|
||||
|
@ -800,11 +800,11 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
||||
|
||||
String current_database = context.getCurrentDatabase();
|
||||
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 (create.attach && !create.storage && !create.columns_list)
|
||||
{
|
||||
auto database = DatabaseCatalog::instance().getDatabase(database_name);
|
||||
bool if_not_exists = create.if_not_exists;
|
||||
|
||||
// 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
|
||||
DatabasePtr database;
|
||||
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")
|
||||
{
|
||||
auto guard = DatabaseCatalog::instance().getDDLGuard(create.database, create.table);
|
||||
|
Loading…
Reference in New Issue
Block a user