提交 761c70e8 authored 作者: sylvain-ilm's avatar sylvain-ilm

remove TestAll.stdDropTableRestrict, as requested

上级 efe8c198
...@@ -11,7 +11,6 @@ import java.util.ArrayList; ...@@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.h2.Driver; import org.h2.Driver;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.store.fs.FilePathRec; import org.h2.store.fs.FilePathRec;
...@@ -432,8 +431,6 @@ java org.h2.test.TestAll timer ...@@ -432,8 +431,6 @@ java org.h2.test.TestAll timer
/** If not null the database should be opened with the collation parameter */ /** If not null the database should be opened with the collation parameter */
public String collation; public String collation;
public boolean stdDropTableRestrict;
/** /**
* The AB-BA locking detector. * The AB-BA locking detector.
*/ */
...@@ -620,7 +617,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -620,7 +617,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
defrag = false; defrag = false;
traceLevelFile = throttle = 0; traceLevelFile = throttle = 0;
cipher = null; cipher = null;
stdDropTableRestrict = false;
// memory is a good match for multi-threaded, makes things happen // memory is a good match for multi-threaded, makes things happen
// faster, more chance of exposing race conditions // faster, more chance of exposing race conditions
...@@ -1130,7 +1126,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -1130,7 +1126,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
appendIf(buff, defrag, "defrag"); appendIf(buff, defrag, "defrag");
appendIf(buff, splitFileSystem, "split"); appendIf(buff, splitFileSystem, "split");
appendIf(buff, collation != null, collation); appendIf(buff, collation != null, collation);
appendIf(buff, stdDropTableRestrict, "stdDropTableRestrict");
return buff.toString(); return buff.toString();
} }
......
...@@ -34,7 +34,6 @@ import java.util.ArrayList; ...@@ -34,7 +34,6 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.store.fs.FilePath; import org.h2.store.fs.FilePath;
...@@ -167,8 +166,15 @@ public abstract class TestBase { ...@@ -167,8 +166,15 @@ public abstract class TestBase {
* @return the connection * @return the connection
*/ */
public Connection getConnection(String name) throws SQLException { public Connection getConnection(String name) throws SQLException {
return getConnectionInternal(getURL(name, true), getUser(), return getConnection(name, null);
getPassword()); }
public Connection getConnection(final String name, final Boolean stdDropTableRestrict) throws SQLException {
String url = getURL(name, true);
if (stdDropTableRestrict != null) {
url = addOption(url, "STANDARD_DROP_TABLE_RESTRICT", stdDropTableRestrict.toString());
}
return getConnectionInternal(url, getUser(), getPassword());
} }
/** /**
...@@ -334,9 +340,6 @@ public abstract class TestBase { ...@@ -334,9 +340,6 @@ public abstract class TestBase {
if (config.collation != null) { if (config.collation != null) {
url = addOption(url, "COLLATION", config.collation); url = addOption(url, "COLLATION", config.collation);
} }
if (config.stdDropTableRestrict) {
url = addOption(url, "STANDARD_DROP_TABLE_RESTRICT", "TRUE");
}
return "jdbc:h2:" + url; return "jdbc:h2:" + url;
} }
......
...@@ -19,7 +19,6 @@ import java.sql.Timestamp; ...@@ -19,7 +19,6 @@ import java.sql.Timestamp;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
...@@ -280,14 +279,8 @@ public class TestCases extends TestBase { ...@@ -280,14 +279,8 @@ public class TestCases extends TestBase {
} }
private void testDropTable() throws SQLException { private void testDropTable() throws SQLException {
final boolean prevVal = config.stdDropTableRestrict; for (final boolean stdDropTableRestrict : new boolean[] { true, false }) {
try { _testDropTable(stdDropTableRestrict);
for (final boolean newVal : new boolean[] { true, false }) {
config.stdDropTableRestrict = newVal;
_testDropTable();
}
} finally {
config.stdDropTableRestrict = prevVal;
} }
} }
...@@ -295,13 +288,13 @@ public class TestCases extends TestBase { ...@@ -295,13 +288,13 @@ public class TestCases extends TestBase {
NONE, VIEW, FOREIGN_KEY; NONE, VIEW, FOREIGN_KEY;
} }
private void _testDropTable() throws SQLException { private void _testDropTable(final boolean stdDropTableRestrict) throws SQLException {
trace("testDrop"); trace("testDrop");
for (final boolean restrict : new boolean[] { true, false }) { for (final boolean restrict : new boolean[] { true, false }) {
for (final DropDependent dropDep : DropDependent.values()) { for (final DropDependent dropDep : DropDependent.values()) {
deleteDb("cases"); deleteDb("cases");
Connection conn = getConnection("cases"); Connection conn = getConnection("cases", stdDropTableRestrict);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int)"); stat.execute("create table test(id int)");
if (dropDep == DropDependent.VIEW) { if (dropDep == DropDependent.VIEW) {
...@@ -314,9 +307,7 @@ public class TestCases extends TestBase { ...@@ -314,9 +307,7 @@ public class TestCases extends TestBase {
// drop allowed if no references or cascade // drop allowed if no references or cascade
final boolean expectedDropSuccess = dropDep == DropDependent.NONE final boolean expectedDropSuccess = dropDep == DropDependent.NONE
|| (!config.stdDropTableRestrict || (!stdDropTableRestrict && dropDep == DropDependent.FOREIGN_KEY) || !restrict;
&& dropDep == DropDependent.FOREIGN_KEY)
|| !restrict;
assertThrows(expectedDropSuccess ? 0 : ErrorCode.CANNOT_DROP_2, stat).execute("drop table test " + (restrict ? "restrict" : "cascade")); assertThrows(expectedDropSuccess ? 0 : ErrorCode.CANNOT_DROP_2, stat).execute("drop table test " + (restrict ? "restrict" : "cascade"));
assertThrows(expectedDropSuccess ? ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1 : 0, stat).execute("select * from test"); assertThrows(expectedDropSuccess ? ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1 : 0, stat).execute("select * from test");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论