提交 a5b5cb2e 编写于 作者: C CurtizJ

fix query 'ATTACH TABLE IF NOT EXISTS'

上级 23dedcbf
......@@ -555,10 +555,12 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
// If this is a stub ATTACH query, read the query definition from the database
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
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.attach = true;
create.if_not_exists = if_not_exists;
}
String current_database = context.getCurrentDatabase();
......
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;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册