mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
fix query 'ATTACH TABLE IF NOT EXISTS'
This commit is contained in:
parent
23dedcbfa9
commit
a5b5cb2e94
@ -555,10 +555,12 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
|
|||||||
// 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)
|
||||||
{
|
{
|
||||||
|
bool if_not_exists = create.if_not_exists;
|
||||||
// Table SQL definition is available even if the table is detached
|
// Table SQL definition is available even if the table is detached
|
||||||
auto query = context.getDatabase(create.database)->getCreateTableQuery(context, create.table);
|
auto query = context.getDatabase(create.database)->getCreateTableQuery(context, create.table);
|
||||||
create = query->as<ASTCreateQuery &>(); // Copy the saved create query, but use ATTACH instead of CREATE
|
create = query->as<ASTCreateQuery &>(); // Copy the saved create query, but use ATTACH instead of CREATE
|
||||||
create.attach = true;
|
create.attach = true;
|
||||||
|
create.if_not_exists = if_not_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
String current_database = context.getCurrentDatabase();
|
String current_database = context.getCurrentDatabase();
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
1
|
@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE t (a Int) ENGINE = Log;
|
||||||
|
ATTACH TABLE t; -- { serverError 57 }
|
||||||
|
ATTACH TABLE IF NOT EXISTS t;
|
||||||
|
DETACH TABLE t;
|
||||||
|
ATTACH TABLE IF NOT EXISTS t;
|
||||||
|
EXISTS TABLE t;
|
Loading…
Reference in New Issue
Block a user