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

New system property h2.dropRestrict (work in progress).

上级 f1cfdd32
......@@ -18,8 +18,7 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Build tool: ability to only run one test using the -Dtest=className setting.
</li><li>Experimental feature to support case sensitive catalog names
<ul><li>Experimental feature to support case sensitive catalog names
and database names using the DATABASE() method.
To use this feature, set the system property h2.databaseToUpper to false.
The plan is to set the property to false by default in version 1.3.x.
......
......@@ -36,6 +36,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Enable h2.nestedJoins (nested joins and right outer joins).
</li><li>Enable h2.optimizeOr (convert OR conditions to IN(..) if possible).
</li><li>Disable h2.databaseToUpper (database short names are converted to uppercase).
</li><li>Enable h2.dropRestrict (default action for DROP is RESTRICT).
</li></ul>
<h2>Priority 1</h2>
......
......@@ -24,7 +24,7 @@ public class DropView extends SchemaCommand {
private String viewName;
private boolean ifExists;
private int dropAction = ConstraintReferential.RESTRICT;
private int dropAction = ConstraintReferential.CASCADE;
public DropView(Session session, Schema schema) {
super(session, schema);
......
......@@ -269,6 +269,15 @@ public class SysProperties {
*/
public static final int DELAY_WRONG_PASSWORD_MAX = getIntSetting("h2.delayWrongPasswordMax", 4000);
/**
* System property <code>h2.dropRestrict</code> (default: false).<br />
* Whether the default action for DROP TABLE and DROP VIEW is RESTRICT. For
* most databases, the default action is RESTRICT, but for compatibility
* with older versions of H2 the default action is currently CASCADE. This will
* change in a future version of H2.
*/
public static final boolean DROP_RESTRICT = getBooleanSetting("h2.dropRestrict", false);
/**
* System property <code>h2.estimatedFunctionTableRows</code> (default:
* 1000).<br />
......
......@@ -7,6 +7,7 @@
package org.h2.test.db;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase;
import java.sql.Connection;
......@@ -51,19 +52,29 @@ public class TestViewDropView extends TestBase {
createTestData();
try {
stat.execute("drop view v1"); // Should fail because have dependencies
// Should fail because have dependencies
stat.execute("drop view v1");
if (SysProperties.DROP_RESTRICT) {
fail();
}
} catch (SQLException e) {
if (!SysProperties.DROP_RESTRICT) {
assertEquals(ErrorCode.CANNOT_DROP_2, e.getErrorCode());
}
}
if (SysProperties.DROP_RESTRICT) {
checkViewRemainsValid();
}
}
private void testDropViewRestrict() throws SQLException {
createTestData();
try {
stat.execute("drop view v1 restrict"); // Should fail because have dependencies
// Should fail because have dependencies
stat.execute("drop view v1 restrict");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.CANNOT_DROP_2, e.getErrorCode());
}
......@@ -144,6 +155,7 @@ public class TestViewDropView extends TestBase {
}
private void createTestData() throws SQLException {
stat.execute("drop all objects");
stat.execute("create table test(a int, b int, c int)");
stat.execute("insert into test(a, b, c) values (1, 2, 3)");
stat.execute("create view v1 as select a as b, b as a from test");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论