提交 326ed1ff authored 作者: Thomas Mueller's avatar Thomas Mueller

Small changes.

上级 b1858d05
......@@ -58,15 +58,14 @@ public class RuleList implements Rule {
}
}
return false;
} else {
for (Rule r : list) {
if (!r.autoComplete(sentence)) {
sentence.setQuery(old);
return false;
}
}
for (Rule r : list) {
if (!r.autoComplete(sentence)) {
sentence.setQuery(old);
return false;
}
return true;
}
return true;
}
}
......@@ -4770,14 +4770,13 @@ public class Parser {
if (readIf("NO")) {
read("ACTION");
return ConstraintReferential.RESTRICT;
} else {
read("SET");
if (readIf("NULL")) {
return ConstraintReferential.SET_NULL;
}
read("DEFAULT");
return ConstraintReferential.SET_DEFAULT;
}
read("SET");
if (readIf("NULL")) {
return ConstraintReferential.SET_NULL;
}
read("DEFAULT");
return ConstraintReferential.SET_DEFAULT;
}
private Integer parseCascadeOrRestrict() {
......
......@@ -278,13 +278,12 @@ public class ConnectionInfo implements Cloneable {
private byte[] hashPassword(boolean passwordHash, String userName, char[] password) {
if (passwordHash) {
return StringUtils.convertStringToBytes(new String(password));
} else {
if (userName.length() == 0 && password.length == 0 && SysProperties.EMPTY_PASSWORD) {
return new byte[0];
}
SHA256 sha = new SHA256();
return sha.getKeyPasswordHash(userName, password);
}
if (userName.length() == 0 && password.length == 0 && SysProperties.EMPTY_PASSWORD) {
return new byte[0];
}
SHA256 sha = new SHA256();
return sha.getKeyPasswordHash(userName, password);
}
/**
......
......@@ -41,9 +41,8 @@ public class FunctionIndex extends BaseIndex {
public Cursor find(Session session, SearchRow first, SearchRow last) {
if (functionTable.isFast()) {
return new FunctionCursorResultSet(session, functionTable.getResultSet(session));
} else {
return new FunctionCursor(functionTable.getResult(session));
}
return new FunctionCursor(functionTable.getResult(session));
}
public double getCost(Session session, int[] masks) {
......
......@@ -68,9 +68,8 @@ public class DocumentedMBean extends StandardMBean {
protected int getImpact(MBeanOperationInfo info) {
if (info.getName().startsWith("list")) {
return MBeanOperationInfo.INFO;
} else {
return MBeanOperationInfo.ACTION;
}
return MBeanOperationInfo.ACTION;
}
}
......@@ -162,7 +162,7 @@ public class Trace {
*/
public void error(Throwable t, String s, Object... params) {
if (isEnabled(TraceSystem.ERROR)) {
s = MessageFormat.format(s, (Object[]) params);
s = MessageFormat.format(s, params);
traceWriter.write(TraceSystem.ERROR, module, s, t);
}
}
......@@ -186,7 +186,7 @@ public class Trace {
*/
public void info(String s, Object... params) {
if (isEnabled(TraceSystem.INFO)) {
s = MessageFormat.format(s, (Object[]) params);
s = MessageFormat.format(s, params);
traceWriter.write(TraceSystem.INFO, module, s, null);
}
}
......@@ -255,7 +255,7 @@ public class Trace {
*/
public void debug(String s, Object... params) {
if (isEnabled(TraceSystem.DEBUG)) {
s = MessageFormat.format(s, (Object[]) params);
s = MessageFormat.format(s, params);
traceWriter.write(TraceSystem.DEBUG, module, s, null);
}
}
......
......@@ -422,7 +422,7 @@ public class LobStorage {
private long getHashCacheBlock(int hash) {
if (HASH_CACHE_SIZE > 0) {
int index = (int) (hash & (HASH_CACHE_SIZE - 1));
int index = hash & (HASH_CACHE_SIZE - 1);
long oldHash = hashBlocks[index];
if (oldHash == hash) {
return hashBlocks[index + HASH_CACHE_SIZE];
......@@ -433,7 +433,7 @@ public class LobStorage {
private void setHashCacheBlock(int hash, long block) {
if (HASH_CACHE_SIZE > 0) {
int index = (int) (hash & (HASH_CACHE_SIZE - 1));
int index = hash & (HASH_CACHE_SIZE - 1);
hashBlocks[index] = hash;
hashBlocks[index + HASH_CACHE_SIZE] = block;
}
......
......@@ -1492,7 +1492,7 @@ public class PageStore implements CacheWriter {
if (add) {
addMeta(row, systemSession, true);
} else {
removeMeta(logPos, row);
removeMeta(row);
}
}
Index index = metaObjects.get(tableId);
......@@ -1565,7 +1565,7 @@ public class PageStore implements CacheWriter {
}
}
private void removeMeta(int logPos, Row row) {
private void removeMeta(Row row) {
int id = row.getValue(0).getInt();
PageIndex index = metaObjects.get(id);
index.getTable().removeIndex(index);
......
......@@ -621,7 +621,7 @@ public class TableFilter implements ColumnResolver {
do {
buffNested.append(n.getPlanSQL(n != nestedJoin));
buffNested.append("\n");
n = (TableFilter) n.getJoin();
n = n.getJoin();
} while (n != null);
buff.append("(\n");
......@@ -943,7 +943,7 @@ public class TableFilter implements ColumnResolver {
if (n != null) {
n.visit(visitor);
}
f = (TableFilter) f.join;
f = f.join;
} while (f != null);
}
......
......@@ -1622,7 +1622,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
private void checkColumnIndex(int columnIndex) throws SQLException {
if (columnIndex < 0 || columnIndex >= columns.size()) {
throw DbException.getInvalidValueException("columnIndex", columnIndex).getSQLException();
throw DbException.getInvalidValueException("columnIndex", columnIndex + 1).getSQLException();
}
}
......
......@@ -114,9 +114,8 @@ public class CacheTQ implements Cache {
public CacheObject update(int pos, CacheObject record) {
if (lru.find(pos) != null) {
return lru.update(pos, record);
} else {
return fifo.update(pos, record);
}
return fifo.update(pos, record);
}
}
......@@ -455,9 +455,8 @@ public class Utils {
in = Utils.class.getResourceAsStream(name);
if (in == null) {
return null;
} else {
return IOUtils.readBytesAndClose(in, 0);
}
return IOUtils.readBytesAndClose(in, 0);
}
ZipInputStream zipIn = new ZipInputStream(in);
try {
......@@ -475,9 +474,8 @@ public class Utils {
IOUtils.copy(zipIn, out);
zipIn.closeEntry();
return out.toByteArray();
} else {
zipIn.closeEntry();
}
zipIn.closeEntry();
}
} catch (IOException e) {
// if this happens we have a real problem
......
......@@ -326,7 +326,6 @@ java org.h2.test.TestAll timer
System.setProperty("h2.maxMemoryRowsDistinct", "128");
System.setProperty("h2.check2", "true");
int initialTest;
// System.setProperty("h2.lobInDatabase", "true");
// test.nestedJoins = true;
// System.setProperty("h2.largeTransactions", "true");
......@@ -335,7 +334,7 @@ java org.h2.test.TestAll timer
// System.setProperty("h2.queryCacheSize", "100");
// System.setProperty("h2.dropRestrict", "true");
int speedup;
// speedup
// System.setProperty("h2.syncMethod", "");
/*
......@@ -524,159 +523,159 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
beforeTest();
// db
new TestScriptSimple().runTest(this);
new TestScript().runTest(this);
new TestAlter().runTest(this);
new TestAlterSchemaRename().runTest(this);
new TestAutoRecompile().runTest(this);
new TestBitField().runTest(this);
new TestBackup().runTest(this);
new TestBigDb().runTest(this);
new TestBigResult().runTest(this);
new TestCases().runTest(this);
new TestCheckpoint().runTest(this);
new TestCluster().runTest(this);
new TestCompatibility().runTest(this);
new TestCsv().runTest(this);
new TestDeadlock().runTest(this);
new TestEncryptedDb().runTest(this);
new TestExclusive().runTest(this);
new TestFullText().runTest(this);
new TestFunctionOverload().runTest(this);
new TestFunctions().runTest(this);
new TestInit().runTest(this);
new TestIndex().runTest(this);
new TestLargeBlob().runTest(this);
new TestLinkedTable().runTest(this);
new TestListener().runTest(this);
new TestLob().runTest(this);
new TestMemoryUsage().runTest(this);
new TestMultiConn().runTest(this);
new TestMultiDimension().runTest(this);
new TestMultiThread().runTest(this);
new TestMultiThreadedKernel().runTest(this);
// new TestScriptSimple().runTest(this);
// new TestScript().runTest(this);
// new TestAlter().runTest(this);
// new TestAlterSchemaRename().runTest(this);
// new TestAutoRecompile().runTest(this);
// new TestBitField().runTest(this);
// new TestBackup().runTest(this);
// new TestBigDb().runTest(this);
// new TestBigResult().runTest(this);
// new TestCases().runTest(this);
// new TestCheckpoint().runTest(this);
// new TestCluster().runTest(this);
// new TestCompatibility().runTest(this);
// new TestCsv().runTest(this);
// new TestDeadlock().runTest(this);
// new TestEncryptedDb().runTest(this);
// new TestExclusive().runTest(this);
// new TestFullText().runTest(this);
// new TestFunctionOverload().runTest(this);
// new TestFunctions().runTest(this);
// new TestInit().runTest(this);
// new TestIndex().runTest(this);
// new TestLargeBlob().runTest(this);
// new TestLinkedTable().runTest(this);
// new TestListener().runTest(this);
// new TestLob().runTest(this);
// new TestMemoryUsage().runTest(this);
// new TestMultiConn().runTest(this);
// new TestMultiDimension().runTest(this);
// new TestMultiThread().runTest(this);
// new TestMultiThreadedKernel().runTest(this);
new TestOpenClose().runTest(this);
new TestOptimizations().runTest(this);
new TestOutOfMemory().runTest(this);
new TestPowerOff().runTest(this);
new TestQueryCache().runTest(this);
new TestReadOnly().runTest(this);
new TestRecursiveQueries().runTest(this);
new TestRights().runTest(this);
new TestRunscript().runTest(this);
new TestSQLInjection().runTest(this);
new TestSessionsLocks().runTest(this);
new TestSequence().runTest(this);
new TestSpaceReuse().runTest(this);
new TestSpeed().runTest(this);
new TestTableEngines().runTest(this);
new TestTempTables().runTest(this);
new TestTransaction().runTest(this);
new TestTriggersConstraints().runTest(this);
new TestTwoPhaseCommit().runTest(this);
new TestView().runTest(this);
new TestViewAlterTable().runTest(this);
new TestViewDropView().runTest(this);
// jaqu
new AliasMapTest().runTest(this);
new SamplesTest().runTest(this);
new UpdateTest().runTest(this);
// jdbc
new TestBatchUpdates().runTest(this);
new TestCallableStatement().runTest(this);
new TestCancel().runTest(this);
new TestDatabaseEventListener().runTest(this);
new TestDriver().runTest(this);
new TestLobApi().runTest(this);
new TestManyJdbcObjects().runTest(this);
new TestMetaData().runTest(this);
new TestNativeSQL().runTest(this);
new TestPreparedStatement().runTest(this);
new TestResultSet().runTest(this);
new TestStatement().runTest(this);
new TestTransactionIsolation().runTest(this);
new TestUpdatableResultSet().runTest(this);
new TestZloty().runTest(this);
// jdbcx
new TestConnectionPool().runTest(this);
new TestDataSource().runTest(this);
new TestXA().runTest(this);
new TestXASimple().runTest(this);
// server
new TestAutoServer().runTest(this);
new TestNestedLoop().runTest(this);
new TestWeb().runTest(this);
// mvcc & row level locking
new TestMvcc1().runTest(this);
new TestMvcc2().runTest(this);
new TestMvcc3().runTest(this);
new TestMvccMultiThreaded().runTest(this);
new TestRowLocks().runTest(this);
// synth
new TestBtreeIndex().runTest(this);
new TestCrashAPI().runTest(this);
new TestFuzzOptimizations().runTest(this);
new TestRandomSQL().runTest(this);
new TestRandomCompare().runTest(this);
new TestKillRestart().runTest(this);
new TestKillRestartMulti().runTest(this);
new TestMultiThreaded().runTest(this);
new TestOuterJoins().runTest(this);
new TestNestedJoins().runTest(this);
// new TestOptimizations().runTest(this);
// new TestOutOfMemory().runTest(this);
// new TestPowerOff().runTest(this);
// new TestQueryCache().runTest(this);
// new TestReadOnly().runTest(this);
// new TestRecursiveQueries().runTest(this);
// new TestRights().runTest(this);
// new TestRunscript().runTest(this);
// new TestSQLInjection().runTest(this);
// new TestSessionsLocks().runTest(this);
// new TestSequence().runTest(this);
// new TestSpaceReuse().runTest(this);
// new TestSpeed().runTest(this);
// new TestTableEngines().runTest(this);
// new TestTempTables().runTest(this);
// new TestTransaction().runTest(this);
// new TestTriggersConstraints().runTest(this);
// new TestTwoPhaseCommit().runTest(this);
// new TestView().runTest(this);
// new TestViewAlterTable().runTest(this);
// new TestViewDropView().runTest(this);
//
// // jaqu
// new AliasMapTest().runTest(this);
// new SamplesTest().runTest(this);
// new UpdateTest().runTest(this);
//
// // jdbc
// new TestBatchUpdates().runTest(this);
// new TestCallableStatement().runTest(this);
// new TestCancel().runTest(this);
// new TestDatabaseEventListener().runTest(this);
// new TestDriver().runTest(this);
// new TestLobApi().runTest(this);
// new TestManyJdbcObjects().runTest(this);
// new TestMetaData().runTest(this);
// new TestNativeSQL().runTest(this);
// new TestPreparedStatement().runTest(this);
// new TestResultSet().runTest(this);
// new TestStatement().runTest(this);
// new TestTransactionIsolation().runTest(this);
// new TestUpdatableResultSet().runTest(this);
// new TestZloty().runTest(this);
//
// // jdbcx
// new TestConnectionPool().runTest(this);
// new TestDataSource().runTest(this);
// new TestXA().runTest(this);
// new TestXASimple().runTest(this);
//
// // server
// new TestAutoServer().runTest(this);
// new TestNestedLoop().runTest(this);
// new TestWeb().runTest(this);
//
// // mvcc & row level locking
// new TestMvcc1().runTest(this);
// new TestMvcc2().runTest(this);
// new TestMvcc3().runTest(this);
// new TestMvccMultiThreaded().runTest(this);
// new TestRowLocks().runTest(this);
//
// // synth
// new TestBtreeIndex().runTest(this);
// new TestCrashAPI().runTest(this);
// new TestFuzzOptimizations().runTest(this);
// new TestRandomSQL().runTest(this);
// new TestRandomCompare().runTest(this);
// new TestKillRestart().runTest(this);
// new TestKillRestartMulti().runTest(this);
// new TestMultiThreaded().runTest(this);
// new TestOuterJoins().runTest(this);
// new TestNestedJoins().runTest(this);
afterTest();
}
private void testUnit() {
new TestAutoReconnect().runTest(this);
new TestCache().runTest(this);
new TestClearReferences().runTest(this);
new TestCompress().runTest(this);
new TestConnectionInfo().runTest(this);
new TestDataPage().runTest(this);
new TestDate().runTest(this);
new TestDateIso8601().runTest(this);
new TestExit().runTest(this);
new TestFile().runTest(this);
new TestFileLock().runTest(this);
new TestFileLockSerialized().runTest(this);
new TestFtp().runTest(this);
new TestFileSystem().runTest(this);
new TestIntArray().runTest(this);
new TestIntIntHashMap().runTest(this);
new TestJmx().runTest(this);
new TestMathUtils().runTest(this);
new TestOldVersion().runTest(this);
new TestNetUtils().runTest(this);
new TestMultiThreadedKernel().runTest(this);
new TestOverflow().runTest(this);
new TestPageStore().runTest(this);
new TestPageStoreCoverage().runTest(this);
new TestPattern().runTest(this);
new TestPgServer().runTest(this);
new TestReader().runTest(this);
new TestRecovery().runTest(this);
new TestSampleApps().runTest(this);
new TestScriptReader().runTest(this);
runTest("org.h2.test.unit.TestServlet");
new TestSecurity().runTest(this);
new TestShell().runTest(this);
new TestStreams().runTest(this);
new TestStringCache().runTest(this);
new TestStringUtils().runTest(this);
new TestTools().runTest(this);
new TestTraceSystem().runTest(this);
new TestUpgrade().runTest(this);
new TestUtils().runTest(this);
new TestValue().runTest(this);
new TestValueHashMap().runTest(this);
new TestValueMemory().runTest(this);
// new TestAutoReconnect().runTest(this);
// new TestCache().runTest(this);
// new TestClearReferences().runTest(this);
// new TestCompress().runTest(this);
// new TestConnectionInfo().runTest(this);
// new TestDataPage().runTest(this);
// new TestDate().runTest(this);
// new TestDateIso8601().runTest(this);
// new TestExit().runTest(this);
// new TestFile().runTest(this);
// new TestFileLock().runTest(this);
// new TestFileLockSerialized().runTest(this);
// new TestFtp().runTest(this);
// new TestFileSystem().runTest(this);
// new TestIntArray().runTest(this);
// new TestIntIntHashMap().runTest(this);
// new TestJmx().runTest(this);
// new TestMathUtils().runTest(this);
// new TestOldVersion().runTest(this);
// new TestNetUtils().runTest(this);
// new TestMultiThreadedKernel().runTest(this);
// new TestOverflow().runTest(this);
// new TestPageStore().runTest(this);
// new TestPageStoreCoverage().runTest(this);
// new TestPattern().runTest(this);
// new TestPgServer().runTest(this);
// new TestReader().runTest(this);
// new TestRecovery().runTest(this);
// new TestSampleApps().runTest(this);
// new TestScriptReader().runTest(this);
// runTest("org.h2.test.unit.TestServlet");
// new TestSecurity().runTest(this);
// new TestShell().runTest(this);
// new TestStreams().runTest(this);
// new TestStringCache().runTest(this);
// new TestStringUtils().runTest(this);
// new TestTools().runTest(this);
// new TestTraceSystem().runTest(this);
// new TestUpgrade().runTest(this);
// new TestUtils().runTest(this);
// new TestValue().runTest(this);
// new TestValueHashMap().runTest(this);
// new TestValueMemory().runTest(this);
}
private void runTest(String className) {
......
......@@ -53,7 +53,7 @@ public class TestMultiDimension extends TestBase {
assertEquals(5, m.interleave(new int[]{3, 0}));
assertEquals(10, m.interleave(0, 3));
assertEquals(10, m.interleave(new int[] { 0, 3 }));
long v = (long) Integer.MAX_VALUE | ((long) Integer.MAX_VALUE << 31L);
long v = Integer.MAX_VALUE | ((long) Integer.MAX_VALUE << 31L);
assertEquals(v, m.interleave(Integer.MAX_VALUE, Integer.MAX_VALUE));
assertEquals(v, m.interleave(new int[] { Integer.MAX_VALUE, Integer.MAX_VALUE }));
Random random = new Random(1);
......
......@@ -73,9 +73,8 @@ public class TestLobApi extends TestBase {
if (pos > 100001) {
if (ioException) {
throw new IOException("");
} else {
throw new IllegalStateException();
}
throw new IllegalStateException();
}
return len;
}
......@@ -99,9 +98,8 @@ public class TestLobApi extends TestBase {
if (pos > 100001) {
if (ioException) {
throw new IOException("");
} else {
throw new IllegalStateException();
}
throw new IllegalStateException();
}
return 0;
}
......
......@@ -127,11 +127,9 @@ public class TestNestedJoins extends TestBase {
// System.out.println(se);
// System.out.println(" " + sql);
}
if (e != null) {
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
}
}
......@@ -338,7 +336,7 @@ public class TestNestedJoins extends TestBase {
stat.execute("insert into t4 values(1,1), (2,2), (3,3), (4,4)");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) ON T1.B = T3.A ) ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
// expected: 1 1 1; null 2 null
......@@ -372,7 +370,7 @@ public class TestNestedJoins extends TestBase {
stat.execute("insert into c values(1), (2)");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN ( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
// expected result: 1 1 1; null null 2
......@@ -414,7 +412,7 @@ public class TestNestedJoins extends TestBase {
"on b.x = c.y) " +
"on a.x = c.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X, C.Y FROM PUBLIC.A " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"LEFT OUTER JOIN PUBLIC.C " +
......@@ -495,7 +493,7 @@ public class TestNestedJoins extends TestBase {
"left outer join (b " +
"inner join c on c.x = 1) on a.x = b.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.A " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"INNER JOIN PUBLIC.C ON C.X = 1 ) ON A.X = B.X", sql);
......@@ -541,7 +539,7 @@ public class TestNestedJoins extends TestBase {
"left outer join (b inner join base b_base " +
"on b.pk = b_base.pk and b_base.deleted = 0) on 1=1");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.PK, A_BASE.PK, B.PK, B_BASE.PK FROM PUBLIC.BASE A_BASE " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"INNER JOIN PUBLIC.BASE B_BASE " +
......@@ -571,7 +569,7 @@ public class TestNestedJoins extends TestBase {
deleteDb("nestedJoins");
}
private String cleanRemarks(Connection conn, String sql) throws SQLException {
private String cleanRemarks(String sql) throws SQLException {
ScriptReader r = new ScriptReader(new StringReader(sql));
r.setSkipRemarks(true);
sql = r.readStatement();
......
......@@ -118,11 +118,9 @@ public class TestOuterJoins extends TestBase {
// SQLException se = (SQLException) e;
// System.out.println(se);
}
if (e != null) {
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
}
}
......@@ -330,7 +328,7 @@ public class TestOuterJoins extends TestBase {
stat.execute("insert into t4 values(1,1), (2,2), (3,3), (4,4)");
rs = stat.executeQuery("explain select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT DISTINCT T1.A, T2.A, T3.A FROM PUBLIC.T2 LEFT OUTER JOIN ( PUBLIC.T3 LEFT OUTER JOIN ( PUBLIC.T1 ) ON T1.B = T3.A ) ON T2.B = T1.A", sql);
rs = stat.executeQuery("select distinct t1.a, t2.a, t3.a from t1 right outer join t3 on t1.b=t3.a right outer join t2 on t2.b=t1.a");
// expected: 1 1 1; null 2 null
......@@ -364,7 +362,7 @@ public class TestOuterJoins extends TestBase {
stat.execute("insert into c values(1), (2)");
rs = stat.executeQuery("explain select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.C LEFT OUTER JOIN ( PUBLIC.A INNER JOIN PUBLIC.B ON A.X = B.X ) ON C.X = A.X", sql);
rs = stat.executeQuery("select a.x, b.x, c.x from a inner join b on a.x = b.x right outer join c on c.x = a.x");
// expected result: 1 1 1; null null 2
......@@ -406,7 +404,7 @@ public class TestOuterJoins extends TestBase {
"on b.x = c.y) " +
"on a.x = c.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X, C.Y FROM PUBLIC.A " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"LEFT OUTER JOIN PUBLIC.C " +
......@@ -487,7 +485,7 @@ public class TestOuterJoins extends TestBase {
"left outer join (b " +
"inner join c on c.x = 1) on a.x = b.x");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.X, B.X, C.X FROM PUBLIC.A " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"INNER JOIN PUBLIC.C ON C.X = 1 ) ON A.X = B.X", sql);
......@@ -533,7 +531,7 @@ public class TestOuterJoins extends TestBase {
"left outer join (b inner join base b_base " +
"on b.pk = b_base.pk and b_base.deleted = 0) on 1=1");
assertTrue(rs.next());
sql = cleanRemarks(conn, rs.getString(1));
sql = cleanRemarks(rs.getString(1));
assertEquals("SELECT A.PK, A_BASE.PK, B.PK, B_BASE.PK FROM PUBLIC.BASE A_BASE " +
"LEFT OUTER JOIN ( PUBLIC.B " +
"INNER JOIN PUBLIC.BASE B_BASE " +
......@@ -563,7 +561,7 @@ public class TestOuterJoins extends TestBase {
deleteDb("nestedJoins");
}
private String cleanRemarks(Connection conn, String sql) throws SQLException {
private String cleanRemarks(String sql) throws SQLException {
ScriptReader r = new ScriptReader(new StringReader(sql));
r.setSkipRemarks(true);
sql = r.readStatement();
......
......@@ -104,11 +104,9 @@ public class TestRandomCompare extends TestBase {
// System.out.println(se);
// System.out.println(" " + sql);
}
if (e != null) {
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
if (shortest == null || sql.length() < shortest.length()) {
shortest = sql;
shortestEx = e;
}
}
}
......
......@@ -165,7 +165,6 @@ public class TestCache extends TestBase implements CacheWriter {
conn.close();
stat = null;
conn = null;
rs = null;
long afterClose = getRealMemory();
trace("Used memory: " + (afterInsert - afterClose) + " calculated cache size: " + calculated);
trace("Before: " + before + " after: " + afterInsert + " after closing: " + afterClose);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论