Unverified 提交 82ffee2e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1104 from katzyn/ddl

Fix CREATE SYNONYM with the same name in different schema
...@@ -21,6 +21,16 @@ Change Log ...@@ -21,6 +21,16 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1102: CREATE SYNONYM rejects valid definition
</li>
<li>Issue #1048: 1.4.197 regression. org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "SYS"
</li>
<li>PR #1101: Move some tests in better place and add an additional test for 2PC
</li>
<li>PR #1100: Fix Insert.prepareUpdateCondition() for PageStore
</li>
<li>PR #1098: Fix some issues with NULLS FIRST / LAST
</li>
<li>Issue #1089: Parser does not quote words INTERSECTS, DUAL, TOP <li>Issue #1089: Parser does not quote words INTERSECTS, DUAL, TOP
</li> </li>
<li>Issue #230: Renaming a column does not update foreign key constraint <li>Issue #230: Renaming a column does not update foreign key constraint
......
...@@ -56,7 +56,7 @@ public class CreateSynonym extends SchemaCommand { ...@@ -56,7 +56,7 @@ public class CreateSynonym extends SchemaCommand {
data.session = session; data.session = session;
db.lockMeta(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); throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, data.synonymName);
} }
......
...@@ -111,7 +111,7 @@ public class TestScript extends TestBase { ...@@ -111,7 +111,7 @@ public class TestScript extends TestBase {
testScript("datatypes/" + s + ".sql"); testScript("datatypes/" + s + ".sql");
} }
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn", for (String s : new String[] { "alterTableAdd", "alterTableDropColumn",
"createAlias", "createView", "createTable", "createTrigger", "createAlias", "createSynonym", "createView", "createTable", "createTrigger",
"dropSchema" }) { "dropSchema" }) {
testScript("ddl/" + s + ".sql"); 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论