提交 844cb01c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix used schema in CreateSynonym.update()

上级 e6c38059
......@@ -56,7 +56,7 @@ public class CreateSynonym extends SchemaCommand {
data.session = session;
db.lockMeta(session);
if (data.synonymForSchema.findTableOrView(session, data.synonymName) != null) {
if (getSchema().findTableOrView(session, data.synonymName) != null) {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, data.synonymName);
}
......
......@@ -111,7 +111,7 @@ public class TestScript extends TestBase {
testScript("datatypes/" + s + ".sql");
}
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn",
"createAlias", "createView", "createTable", "createTrigger",
"createAlias", "createSynonym", "createView", "createTable", "createTrigger",
"dropSchema" }) {
testScript("ddl/" + s + ".sql");
}
......
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE SCHEMA SCHEMA1;
> ok
CREATE SCHEMA SCHEMA2;
> ok
CREATE TABLE SCHEMA1.T1(K BIGINT PRIMARY KEY, V VARCHAR);
> ok
CREATE SYNONYM SCHEMA1.T1 FOR SCHEMA1.T1;
> exception TABLE_OR_VIEW_ALREADY_EXISTS_1
CREATE SYNONYM SCHEMA2.T1 FOR SCHEMA1.T1;
> ok
DROP SYNONYM SCHEMA2.T1;
> ok
SET SCHEMA SCHEMA2;
> ok
CREATE SYNONYM T1 FOR SCHEMA1.T1;
> ok
DROP SYNONYM T1;
> ok
SET SCHEMA SCHEMA1;
> ok
CREATE SYNONYM T1 FOR T1;
> exception TABLE_OR_VIEW_ALREADY_EXISTS_1
CREATE SYNONYM SCHEMA2.T1 FOR T1;
> ok
DROP SYNONYM SCHEMA2.T1;
> ok
SET SCHEMA PUBLIC;
> ok
DROP SCHEMA SCHEMA2 CASCADE;
> ok
DROP SCHEMA SCHEMA1 CASCADE;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论