提交 5c0a8e63 authored 作者: Thomas Mueller's avatar Thomas Mueller

SET SCHEMA did not work for views.

上级 d8f72099
......@@ -10,6 +10,7 @@ import java.sql.SQLException;
import org.h2.command.dml.Query;
import org.h2.constant.ErrorCode;
import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.message.Message;
......@@ -64,8 +65,20 @@ public class CreateView extends SchemaCommand {
querySQL = select.getSQL();
}
Session sysSession = db.getSystemSession();
TableView view = new TableView(getSchema(), id, viewName, querySQL, null, columnNames, sysSession, recursive);
TableView view;
try {
Schema schema = session.getDatabase().getSchema(session.getCurrentSchemaName());
sysSession.setCurrentSchema(schema);
view = new TableView(getSchema(), id, viewName, querySQL, null, columnNames, sysSession, recursive);
} finally {
sysSession.setCurrentSchema(db.getSchema(Constants.SCHEMA_MAIN));
}
view.setComment(comment);
try {
view.recompileQuery(session);
} catch (SQLException e) {
// this is not strictly required - ignore exceptions, specially when using FORCE
}
db.addSchemaObject(session, view);
return 0;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论