提交 8c20d4bd authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 bff6f9c0
......@@ -171,12 +171,8 @@
<echo message="build-jdk:${java.specification.version} ant-build.properties/jdk:${jdk}"></echo>
</target>
<target name="jar" depends="compile, compileServlet">
<mkdir dir="bin/META-INF"/>
<manifest file="bin/META-INF/MANIFEST.MF">
<!--
<attribute name="Bundle-Activator" value="org.h2.osgi.Activator"/>
-->
<target name="jar" depends="compile, compileServlet, manifest">
<manifest file="bin/META-INF/MANIFEST.MF" mode="update">
<attribute name="Main-Class" value="org.h2.tools.Console"/>
</manifest>
<jar jarfile="bin/h2.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
......@@ -192,26 +188,26 @@
</jar>
</target>
<target name="jarClient" depends="compileResources">
<target name="jarClient" depends="compileResources, manifest">
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/main" destdir="bin" debug="true">
<include name="org/h2/*" />
<include name="org/h2/jdbc/**" />
<include name="org/h2/jdbcx/**" />
</javac>
<jar jarfile="bin/h2client.jar" basedir="bin">
<jar jarfile="bin/h2client.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
<include name="**/*.*"/>
<exclude name="**/*.bat"/>
</jar>
</target>
<target name="jarDb" depends="compileResources">
<target name="jarDb" depends="compileResources, manifest">
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/main" destdir="bin" debug="true">
<include name="org/h2/*" />
<include name="org/h2/engine/**" />
<include name="org/h2/jdbc/**" />
<include name="org/h2/jdbcx/**" />
</javac>
<jar jarfile="bin/h2db.jar" basedir="bin">
<jar jarfile="bin/h2db.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
<include name="**/*.*"/>
<exclude name="**/*.bat"/>
</jar>
......@@ -231,7 +227,20 @@
<fileset dir="src/docsrc/javadoc" includes="**/*"/>
</copy>
</target>
<target name="manifest">
<mkdir dir="bin/META-INF"/>
<manifest file="bin/META-INF/MANIFEST.MF">
<!--
<attribute name="Bundle-Activator" value="org.h2.osgi.Activator"/>
-->
<attribute name="Implementation-Title" value="H2 Database Engine"/>
<attribute name="Implementation-URL" value="http://www.h2database.com"/>
<attribute name="Implementation-Version" value="${version.name.maven}"/>
<attribute name="Build-Jdk" value="${jdk}"/>
</manifest>
</target>
<target name="mavenBuildCentral">
<copy tofile="bin/h2-${version.name.maven}.jar" file="bin/h2.jar" />
<copy tofile="bin/pom.xml" filtering="true" file="src/installer/pom.xml">
......
......@@ -316,6 +316,9 @@ It looks like the development of this database has stopped. The last release was
</tr><tr>
<td><a href="http://www.tamava.com">Tamava</a></td>
<td>Newsgroups Reader.</td>
</tr><tr>
<td><a href="http://www.gabealbert.info/tunebackup">Tune Backup</a></td>
<td>Easy-to-use backup solution for your iTunes library.</td>
</tr><tr>
<td><a href="http://www.webofweb.net">Web of Web</a></td>
<td>Collaborative and realtime interactive media platform for the web.</td>
......
......@@ -40,7 +40,11 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.x (2007-09-x)</h3><ul>
<li>The database file sizes are now increased at most 32 MB at any time.
<li>Using spaces in column and table aliases was not supported when used inside a view or temporary view.
</li><li>The version (build) number is now included in the manifest file.
</li><li>In some systems, SecureRandom.generateSeed is very slow (taking one minute or more).
For those cases, an alternative method is used that takes less than one second.
</li><li>The database file sizes are now increased at most 32 MB at any time.
</li><li>New method DatabaseEventListener.opened that is called just after opening a database.
</li><li>When using the Console with Internet Explorer 6.0 or 7.0, a Javascript error was thrown after clearing the query.
</li><li>A database can now be opened even if class of a user defined function is not in the classpath.
......
......@@ -350,6 +350,8 @@ public class Parser {
c = parseGrantRevoke(GrantRevoke.REVOKE);
} else if (readIf("RUNSCRIPT")) {
c = parseRunScript();
} else if (readIf("RELEASE")) {
c = parseReleaseSavepoint();
}
break;
case 'S':
......@@ -540,6 +542,13 @@ public class Parser {
command.setSavepointName(readUniqueIdentifier());
return command;
}
private Prepared parseReleaseSavepoint() throws SQLException {
Prepared command = new NoOperation(session);
readIf("SAVEPOINT");
readUniqueIdentifier();
return command;
}
private Schema getSchema() throws SQLException {
if (schemaName == null) {
......
......@@ -151,26 +151,26 @@ public class CompressLZF implements Compressor {
} else {
// back reference
int len = ctrl >> 5;
int ref = -((ctrl & 0x1f) << 8) - 1;
ctrl = -((ctrl & 0x1f) << 8) - 1;
if (len == 7) {
len += in[inPos++] & 255;
}
ref -= in[inPos++] & 255;
ctrl -= in[inPos++] & 255;
len += outPos + 2;
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
while (outPos < len - 8) {
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ctrl];
}
while (outPos < len) {
out[outPos] = out[outPos++ + ref];
out[outPos] = out[outPos++ + ctrl];
}
}
} while (outPos < outLen);
......
......@@ -1271,7 +1271,11 @@ public class Database implements DataHandler {
} else {
try {
eventListener = (DatabaseEventListener) loadClass(className).newInstance();
eventListener.init(databaseURL);
String url = databaseURL;
if (cipher != null) {
url += ";CIPHER=" + cipher;
}
eventListener.init(url);
} catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, new String[] {
className, e.toString() }, e);
......
......@@ -6,6 +6,7 @@ package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.Parser;
import org.h2.engine.Session;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
......@@ -64,7 +65,7 @@ public class Alias extends Expression {
}
public String getSQL() {
return expr.getSQL() + " AS " + alias;
return expr.getSQL() + " AS " + Parser.quoteIdentifier(alias);
}
public void updateAggregate(Session session) throws SQLException {
......
......@@ -10,6 +10,7 @@ import org.h2.constant.SysProperties;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.index.IndexCondition;
import org.h2.table.Column;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.util.ObjectArray;
......@@ -88,8 +89,7 @@ public class ConditionIn extends Condition {
if (constant && allValuesConstant) {
return ValueExpression.get(getValue(session));
}
// TODO optimization: could use index in some cases (sort, use min and
// max)
// TODO optimization: could use index in some cases (sort, use min and max)
if (values.size() == 1) {
Expression right = (Expression) values.get(0);
Expression expr = new Comparison(session, Comparison.EQUAL, left, right);
......@@ -102,6 +102,8 @@ public class ConditionIn extends Condition {
independent.queryLevel = queryLevel;
if (areAllValues(independent)) {
if (left instanceof ExpressionColumn) {
Column column = ((ExpressionColumn) left).getColumn();
boolean nullable = column.getNullable();
CompareMode mode = session.getDatabase().getCompareMode();
for (int i = 0; i < values.size(); i++) {
Expression e = (Expression) values.get(i);
......@@ -109,7 +111,9 @@ public class ConditionIn extends Condition {
v = v.convertTo(dataType);
values.set(i, ValueExpression.get(v));
if (min == null || min.compareTo(v, mode) > 0) {
min = v;
if (v != ValueNull.INSTANCE || nullable) {
min = v;
}
}
if (max == null || max.compareTo(v, mode) < 0) {
max = v;
......
......@@ -42,8 +42,6 @@ public class ConditionNot extends Condition {
condition = condition.optimize(session);
return this;
}
// TODO optimization: some cases are maybe possible to optimize further:
// (NOT ID >= 5)
Expression e2 = condition.getNotIfPossible(session);
if (e2 != null) {
return e2.optimize(session);
......
......@@ -240,25 +240,27 @@ public class JdbcConnection extends TraceObject implements Connection {
if (session == null) {
return;
}
try {
if (!session.isClosed()) {
try {
rollbackInternal();
commit = closeAndSetNull(commit);
rollback = closeAndSetNull(rollback);
setAutoCommitTrue = closeAndSetNull(setAutoCommitTrue);
setAutoCommitFalse = closeAndSetNull(setAutoCommitFalse);
getAutoCommit = closeAndSetNull(getAutoCommit);
getReadOnly = closeAndSetNull(getReadOnly);
getGeneratedKeys = closeAndSetNull(getGeneratedKeys);
getLockMode = closeAndSetNull(getLockMode);
setLockMode = closeAndSetNull(setLockMode);
} finally {
session.close();
synchronized (session) {
try {
if (!session.isClosed()) {
try {
rollbackInternal();
commit = closeAndSetNull(commit);
rollback = closeAndSetNull(rollback);
setAutoCommitTrue = closeAndSetNull(setAutoCommitTrue);
setAutoCommitFalse = closeAndSetNull(setAutoCommitFalse);
getAutoCommit = closeAndSetNull(getAutoCommit);
getReadOnly = closeAndSetNull(getReadOnly);
getGeneratedKeys = closeAndSetNull(getGeneratedKeys);
getLockMode = closeAndSetNull(getLockMode);
setLockMode = closeAndSetNull(setLockMode);
} finally {
session.close();
}
}
} finally {
session = null;
}
} finally {
session = null;
}
} catch (Throwable e) {
throw logAndConvert(e);
......
......@@ -59,19 +59,19 @@ public class JdbcStatement extends TraceObject implements Statement {
if (escapeProcessing) {
sql = conn.translateSQL(sql);
}
CommandInterface command = conn.prepareCommand(sql);
ResultInterface result;
boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY;
synchronized (session) {
CommandInterface command = conn.prepareCommand(sql);
ResultInterface result;
boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY;
setExecutingStatement(command);
try {
result = command.executeQuery(maxRows, scrollable);
} finally {
setExecutingStatement(null);
}
command.close();
resultSet = new JdbcResultSet(session, conn, this, result, id, closedByResultSet, scrollable);
}
command.close();
resultSet = new JdbcResultSet(session, conn, this, result, id, closedByResultSet, scrollable);
return resultSet;
} catch (Throwable e) {
throw logAndConvert(e);
......
......@@ -56,7 +56,9 @@ public class PgServer implements Service {
}
org.h2.Driver.load();
url = "pg://localhost:" + port;
// log = true;
// int testing;
// log = true;
}
boolean getLog() {
......
......@@ -5,6 +5,8 @@
package org.h2.table;
import java.sql.SQLException;
import org.h2.command.Parser;
import org.h2.command.dml.Select;
import org.h2.constant.SysProperties;
import org.h2.engine.Mode;
......@@ -403,7 +405,7 @@ public class TableFilter implements ColumnResolver {
buff.append(table.getSQL());
if (alias != null && !table.getName().equals(alias)) {
buff.append(' ');
buff.append(alias);
buff.append(Parser.quoteIdentifier(alias));
}
buff.append(" /* ");
StringBuffer planBuff = new StringBuffer();
......
......@@ -133,9 +133,7 @@ public class MemoryFile {
long end = MathUtils.roundUpLong(l, BLOCK_SIZE);
if (end != l) {
int lastBlock = (int) (l >>> BLOCK_SIZE_SHIFT);
if (compress) {
expand(data, lastBlock);
}
expand(data, lastBlock);
byte[] d = data[lastBlock];
for (int i = (int) (l & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
d[i] = 0;
......@@ -161,11 +159,7 @@ public class MemoryFile {
byte[][] n = new byte[blocks][];
System.arraycopy(data, 0, n, 0, Math.min(data.length, n.length));
for (int i = data.length; i < blocks; i++) {
if (compress) {
n[i] = COMPRESSED_BLOCK;
} else {
n[i] = new byte[BLOCK_SIZE];
}
n[i] = COMPRESSED_BLOCK;
}
data = n;
}
......@@ -187,9 +181,7 @@ public class MemoryFile {
while (len > 0) {
int l = (int) Math.min(len, BLOCK_SIZE - (pos & BLOCK_SIZE_MASK));
int id = (int) (pos >>> BLOCK_SIZE_SHIFT);
if (compress) {
expand(data, id);
}
expand(data, id);
byte[] block = data[id];
int blockOffset = (int) (pos & BLOCK_SIZE_MASK);
if (write) {
......
......@@ -4,49 +4,155 @@
*/
package org.h2.util;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Random;
public class RandomUtils {
private static SecureRandom secureRandom;
private static Random random;
private static Random random = new Random();
private static volatile boolean seeded;
static {
private static synchronized SecureRandom getSecureRandom() {
if (secureRandom != null) {
return secureRandom;
}
try {
secureRandom = SecureRandom.getInstance("SHA1PRNG");
byte[] seed = secureRandom.generateSeed(64);
secureRandom.setSeed(seed);
random = new Random(secureRandom.nextLong());
// On some systems, secureRandom.generateSeed() is very slow.
// In this case it is initialized using our own seed implementation
// and afterwards (in the thread) using the regular algorithm.
Runnable runnable = new Runnable() {
public void run() {
try {
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
byte[] seed = sr.generateSeed(20);
synchronized (secureRandom) {
secureRandom.setSeed(seed);
seeded = true;
}
} catch (NoSuchAlgorithmException e) {
warn("SecureRandom", e);
}
}
};
Thread t = new Thread(runnable);
t.start();
Thread.yield();
try {
// normally, generateSeed takes less than 200 ms
t.join(400);
} catch (InterruptedException e) {
warn("InterruptedException", e);
}
if (!seeded) {
byte[] seed = generateAlternativeSeed();
// this never reduces randomness
synchronized (secureRandom) {
secureRandom.setSeed(seed);
}
}
} catch (NoSuchAlgorithmException e) {
// random is null if the algorithm is not found
// TODO log exception
random = new Random();
warn("SecureRandom", e);
secureRandom = new SecureRandom();
}
return secureRandom;
}
private static byte[] generateAlternativeSeed() {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bout);
// milliseconds
out.writeLong(System.currentTimeMillis());
// nanoseconds if available
try {
Method m = System.class.getMethod("nanoTime", new Class[0]);
if (m != null) {
Object o = m.invoke(null, null);
out.writeUTF(o.toString());
}
} catch (Exception e) {
// nanoTime not found, this is ok (only exists for JDK 1.5 and higher)
}
// memory
out.writeInt(new Object().hashCode());
Runtime runtime = Runtime.getRuntime();
out.writeLong(runtime.freeMemory());
out.writeLong(runtime.maxMemory());
out.writeLong(runtime.totalMemory());
// environment
out.writeUTF(System.getProperties().toString());
// host name and ip addresses (if any)
try {
String hostName = InetAddress.getLocalHost().getHostName();
out.writeUTF(hostName);
InetAddress[] list = InetAddress.getAllByName(hostName);
for (int i = 0; i < list.length; i++) {
out.write(list[i].getAddress());
}
} catch (Exception e) {
warn("InetAddress", e);
}
// timing (a second thread is already running)
for (int j = 0; j < 16; j++) {
int i = 0;
long end = System.currentTimeMillis();
while (end == System.currentTimeMillis()) {
i++;
}
out.writeInt(i);
}
out.close();
return bout.toByteArray();
} catch (IOException e) {
warn("generateAlternativeSeed", e);
return new byte[1];
}
}
public static long getSecureLong() {
if (secureRandom == null) {
byte[] buff = SecureRandom.getSeed(8);
return ByteUtils.readLong(buff, 0);
SecureRandom sr = getSecureRandom();
synchronized (sr) {
return sr.nextLong();
}
return secureRandom.nextLong();
}
public static byte[] getSecureBytes(int len) {
if (secureRandom == null) {
return SecureRandom.getSeed(len);
}
if (len <= 0) {
len = 1;
}
byte[] buff = new byte[len];
secureRandom.nextBytes(buff);
SecureRandom sr = getSecureRandom();
synchronized (sr) {
sr.nextBytes(buff);
}
return buff;
}
public static int nextInt(int max) {
return random.nextInt(max);
}
private static void warn(String s, Throwable t) {
// not a fatal problem, but maybe reduced security
System.out.println("RandomUtils warning: " + s);
if (t != null) {
t.printStackTrace();
}
}
}
......@@ -148,27 +148,73 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript
/*
SYSDATE sollte CURRENT_TIMESTAMP
support Trunc(Sysdate),...
public static String chr(int code) {
return String.valueOf((char) code);
}
public static Object nvl(Object value, Object ifNull) {
return (value != null) ? value : ifNull;
}
public static Object nvl2(Object value, Object notNull, Object ifNull) {
return (value != null) ? notNull : ifNull;
}
public static Timestamp sysdate() {
return new Timestamp(System.currentTimeMillis());
}
public static String to_char(Object what, String format) {
throw new Error("not yet"); // @todo check format
}
public static Date to_date(Object what, String format) {
throw new Error("not yet"); // @todo check format
}
public static Number to_number(String str) {
return new Double(str);
}
public static java.sql.Date trunc(Timestamp tsp) {
return new java.sql.Date(tsp.getTime());
}
public static Object trunc(Object what, String format) {
System.out.println("*** trunc ***");
if (what == null)
return null;
else if (what instanceof Date) {
System.out.println("*** date-format = " + format);
return Timestamp.valueOf("1963-03-27 12:34:56.0");
} else if (what instanceof Number) {
System.out.println("*** number-format = " + format);
return new Double(123.456D);
} else
throw new ClassCastException("number or date expected");
}
slow:
Ich hatte auch schon unter Windows Probleme mit generateSeed. Eigentlich braucht es das schon. urandom ist nicht genug, siehe http://en.wikipedia.org/wiki/Urandom 'This may be used for less secure applications.' Ich muss mir berlegen wie man dieses Problem lsen kann... Ev. wie folgt: einen Thread starten, generateSeed dort aufrufen. Wenn es lnger als 1 Sekunde dauert, folgendes verwenden:
Ja. Ich knnte ausserdem Secure-Random verzgert initialisieren, d.h. in einem separaten Thread.
SHA-256 Hash von
System.currentTimeMillis() + " " +
System.identityHashCode(new Object()) + " " +
System.freeMemory() + " " +
System.maxMemory() + " " +
System.totalMemory() + " " +
Math.random() + " " +
System.getProperties().toString() + " " +
Arrays.asList(InetAddress.getAllByName(InetAddress.getLocalHost().getHostName())).toString();
Und bei JDK 1.5 zustzlich:
System.nanoTime()
I think it would be a good idea to include the version (build) number
in the Manifest file of h2.jar
Thus, one could find out the build/version number even if the rest of
the distribution is not available.
select ta.attname, ia.attnum, ic.relname
from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class ic, pg_catalog.pg_index i, pg_catalog.pg_namespace n
where ic.relname = 'dummy_pkey'
AND n.nspname = ''
AND ic.oid = i.indexrelid
AND n.oid = ic.relnamespace
AND ia.attrelid = i.indexrelid
AND ta.attrelid = i.indrelid
AND ta.attnum = i.indkey[ia.attnum-1]
AND (NOT ta.attisdropped)
AND (NOT ia.attisdropped)
order by ia.attnum;
database files grow when updating data
change default for in-memory undo
japanese topics in the javascript search
feature request: optimization for
where link_id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
with NULL and LINK_ID doesn't allow nulls
slow power off test: slow memFS?
DROP TABLE ONE;
......@@ -706,67 +752,65 @@ SELECT COUNT(*) AS A FROM TEST GROUP BY ID HAVING A>0;
beforeTest();
// db
// new TestScriptSimple().runTest(this);
// new TestScript().runTest(this);
// new TestAutoRecompile().runTest(this);
// new TestBackup().runTest(this);
// new TestBatchUpdates().runTest(this);
// new TestBigDb().runTest(this);
// new TestBigResult().runTest(this);
// new TestCache().runTest(this);
// new TestCases().runTest(this);
// new TestCheckpoint().runTest(this);
// new TestCluster().runTest(this);
// new TestCompatibility().runTest(this);
// new TestCsv().runTest(this);
// new TestFunctions().runTest(this);
// new TestIndex().runTest(this);
// if (!SysProperties.MVCC) {
// new TestLinkedTable().runTest(this);
// }
// new TestListener().runTest(this);
// new TestLob().runTest(this);
// new TestLogFile().runTest(this);
// new TestMemoryUsage().runTest(this);
// new TestMultiConn().runTest(this);
// new TestMultiDimension().runTest(this);
// if (!SysProperties.MVCC) {
// new TestMultiThread().runTest(this);
// }
// new TestOpenClose().runTest(this);
// new TestOptimizations().runTest(this);
new TestScriptSimple().runTest(this);
new TestScript().runTest(this);
new TestAutoRecompile().runTest(this);
new TestBackup().runTest(this);
new TestBatchUpdates().runTest(this);
new TestBigDb().runTest(this);
new TestBigResult().runTest(this);
new TestCache().runTest(this);
new TestCases().runTest(this);
new TestCheckpoint().runTest(this);
new TestCluster().runTest(this);
new TestCompatibility().runTest(this);
new TestCsv().runTest(this);
new TestFunctions().runTest(this);
new TestIndex().runTest(this);
if (!SysProperties.MVCC) {
new TestLinkedTable().runTest(this);
}
new TestListener().runTest(this);
new TestLob().runTest(this);
new TestLogFile().runTest(this);
new TestMemoryUsage().runTest(this);
new TestMultiConn().runTest(this);
new TestMultiDimension().runTest(this);
if (!SysProperties.MVCC) {
new TestMultiThread().runTest(this);
}
new TestOpenClose().runTest(this);
new TestOptimizations().runTest(this);
new TestPowerOff().runTest(this);
System.exit(0);
// new TestReadOnly().runTest(this);
// new TestRights().runTest(this);
// new TestRunscript().runTest(this);
// new TestSQLInjection().runTest(this);
// new TestSequence().runTest(this);
// new TestSpaceReuse().runTest(this);
// new TestSpeed().runTest(this);
// new TestTempTables().runTest(this);
// new TestTransaction().runTest(this);
// new TestTriggersConstraints().runTest(this);
// new TestTwoPhaseCommit().runTest(this);
// new TestView().runTest(this);
//
// // server
// new TestNestedLoop().runTest(this);
//
// // jdbc
// new TestCancel().runTest(this);
// new TestDataSource().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 TestXA().runTest(this);
// new TestZloty().runTest(this);
new TestReadOnly().runTest(this);
new TestRights().runTest(this);
new TestRunscript().runTest(this);
new TestSQLInjection().runTest(this);
new TestSequence().runTest(this);
new TestSpaceReuse().runTest(this);
new TestSpeed().runTest(this);
new TestTempTables().runTest(this);
new TestTransaction().runTest(this);
new TestTriggersConstraints().runTest(this);
new TestTwoPhaseCommit().runTest(this);
new TestView().runTest(this);
// server
new TestNestedLoop().runTest(this);
// jdbc
new TestCancel().runTest(this);
new TestDataSource().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 TestXA().runTest(this);
new TestZloty().runTest(this);
afterTest();
}
......
......@@ -82,6 +82,9 @@ public class TestListener extends TestBase implements DatabaseEventListener {
}
public void closingDatabase() {
if (url.toUpperCase().indexOf("CIPHER") >= 0) {
return;
}
Connection conn = null;
try {
conn = DriverManager.getConnection(url, getUser(), getPassword());
......@@ -99,6 +102,9 @@ public class TestListener extends TestBase implements DatabaseEventListener {
}
public void opened() {
if (url.toUpperCase().indexOf("CIPHER") >= 0) {
return;
}
Connection conn = null;
try {
conn = DriverManager.getConnection(url, getUser(), getPassword());
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(id int primary key);
> ok
insert into test values(1), (2), (3);
> update count: 3
explain select * from test where id in(1, 2, null);
> PLAN
> -------------------------------------------------------------------------------------------------------
> SELECT TEST.ID FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_1: ID >= 1 AND ID <= 2 */ WHERE ID IN(1, 2, NULL)
> rows: 1
drop table test;
> ok
create alias "SYSDATE" for "java.lang.Integer.parseInt(java.lang.String)";
> exception
......
SELECT X FROM (SELECT X, X AS "XY" FROM DUAL) WHERE X=1;
> 1;
SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL) WHERE X=1;
> 1;
SELECT X FROM (SELECT X, X AS "X Y" FROM DUAL AS "D Z") WHERE X=1;
> 1;
select * from (select x from dual union select convert(x, int) from dual) where x=0;
create table test(id int);
insert into scriptSimple.public.test(id) values(1), (2);
......
......@@ -10,6 +10,65 @@ import org.h2.test.TestBase;
import org.h2.tools.CompressTool;
public class TestCompress extends TestBase {
public static void main(String[] a) throws Exception {
byte[] data = new byte[1000];
long total = 0;
for (int i = 100; i < 104; i++) {
long time = System.currentTimeMillis();
for (int j = 0; j < 10000000; j++) {
// System.arraycopy(data, 0, data, 100, 11);
// for (int k = 0, n = 100; k < 11; k++) {
// data[k] = data[n++];
// }
int outPos = 0, ctrl = 100, len = i;
// do {
// switch((len - outPos) & 7) {
// case 0:
// data[outPos] = data[outPos++ + ctrl];
// case 7:
// data[outPos] = data[outPos++ + ctrl];
// case 6:
// data[outPos] = data[outPos++ + ctrl];
// case 5:
// data[outPos] = data[outPos++ + ctrl];
// case 4:
// data[outPos] = data[outPos++ + ctrl];
// case 3:
// data[outPos] = data[outPos++ + ctrl];
// case 2:
// data[outPos] = data[outPos++ + ctrl];
// case 1:
// data[outPos] = data[outPos++ + ctrl];
// }
// } while(outPos < len);
//
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
while (outPos < len - 8) {
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
data[outPos] = data[outPos++ + ctrl];
}
while (outPos < len) {
data[outPos] = data[outPos++ + ctrl];
}
}
// now: 8907/11859, switch: 9078/14782
long t = (System.currentTimeMillis() - time);
total += t;
System.out.println("i: " + i + " time: " + t);
}
System.out.println("total: " + total);
}
public void test() throws Exception {
if (config.big) {
......@@ -29,7 +88,8 @@ public class TestCompress extends TestBase {
}
void test(int len) throws Exception {
for (int pattern = 0; pattern < 3; pattern++) {
Random r = new Random(len);
for (int pattern = 0; pattern < 4; pattern++) {
byte[] buff = new byte[len];
switch (pattern) {
case 0:
......@@ -42,10 +102,22 @@ public class TestCompress extends TestBase {
break;
}
case 2: {
Random r = new Random(len);
r.nextBytes(buff);
break;
}
case 3: {
for (int x = 0; x < len; x++) {
buff[x] = (byte) (x / 10);
}
break;
}
}
if (r.nextInt(2) < 1) {
for (int x = 0; x < len; x++) {
if (r.nextInt(20) < 1) {
buff[x] = (byte) (r.nextInt(255));
}
}
}
String[] algorithm = new String[] { "LZF", "Deflate", "No" };
CompressTool utils = CompressTool.getInstance();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论