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

--no commit message

--no commit message
上级 bff6f9c0
...@@ -171,12 +171,8 @@ ...@@ -171,12 +171,8 @@
<echo message="build-jdk:${java.specification.version} ant-build.properties/jdk:${jdk}"></echo> <echo message="build-jdk:${java.specification.version} ant-build.properties/jdk:${jdk}"></echo>
</target> </target>
<target name="jar" depends="compile, compileServlet"> <target name="jar" depends="compile, compileServlet, manifest">
<mkdir dir="bin/META-INF"/> <manifest file="bin/META-INF/MANIFEST.MF" mode="update">
<manifest file="bin/META-INF/MANIFEST.MF">
<!--
<attribute name="Bundle-Activator" value="org.h2.osgi.Activator"/>
-->
<attribute name="Main-Class" value="org.h2.tools.Console"/> <attribute name="Main-Class" value="org.h2.tools.Console"/>
</manifest> </manifest>
<jar jarfile="bin/h2.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF"> <jar jarfile="bin/h2.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
...@@ -192,26 +188,26 @@ ...@@ -192,26 +188,26 @@
</jar> </jar>
</target> </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"> <javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/main" destdir="bin" debug="true">
<include name="org/h2/*" /> <include name="org/h2/*" />
<include name="org/h2/jdbc/**" /> <include name="org/h2/jdbc/**" />
<include name="org/h2/jdbcx/**" /> <include name="org/h2/jdbcx/**" />
</javac> </javac>
<jar jarfile="bin/h2client.jar" basedir="bin"> <jar jarfile="bin/h2client.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
<include name="**/*.*"/> <include name="**/*.*"/>
<exclude name="**/*.bat"/> <exclude name="**/*.bat"/>
</jar> </jar>
</target> </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"> <javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="src/main" destdir="bin" debug="true">
<include name="org/h2/*" /> <include name="org/h2/*" />
<include name="org/h2/engine/**" /> <include name="org/h2/engine/**" />
<include name="org/h2/jdbc/**" /> <include name="org/h2/jdbc/**" />
<include name="org/h2/jdbcx/**" /> <include name="org/h2/jdbcx/**" />
</javac> </javac>
<jar jarfile="bin/h2db.jar" basedir="bin"> <jar jarfile="bin/h2db.jar" basedir="bin" manifest="bin/META-INF/MANIFEST.MF">
<include name="**/*.*"/> <include name="**/*.*"/>
<exclude name="**/*.bat"/> <exclude name="**/*.bat"/>
</jar> </jar>
...@@ -232,6 +228,19 @@ ...@@ -232,6 +228,19 @@
</copy> </copy>
</target> </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"> <target name="mavenBuildCentral">
<copy tofile="bin/h2-${version.name.maven}.jar" file="bin/h2.jar" /> <copy tofile="bin/h2-${version.name.maven}.jar" file="bin/h2.jar" />
<copy tofile="bin/pom.xml" filtering="true" file="src/installer/pom.xml"> <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 ...@@ -316,6 +316,9 @@ It looks like the development of this database has stopped. The last release was
</tr><tr> </tr><tr>
<td><a href="http://www.tamava.com">Tamava</a></td> <td><a href="http://www.tamava.com">Tamava</a></td>
<td>Newsgroups Reader.</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> </tr><tr>
<td><a href="http://www.webofweb.net">Web of Web</a></td> <td><a href="http://www.webofweb.net">Web of Web</a></td>
<td>Collaborative and realtime interactive media platform for the web.</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. ...@@ -40,7 +40,11 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3> <h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.x (2007-09-x)</h3><ul> <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>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>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. </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 { ...@@ -350,6 +350,8 @@ public class Parser {
c = parseGrantRevoke(GrantRevoke.REVOKE); c = parseGrantRevoke(GrantRevoke.REVOKE);
} else if (readIf("RUNSCRIPT")) { } else if (readIf("RUNSCRIPT")) {
c = parseRunScript(); c = parseRunScript();
} else if (readIf("RELEASE")) {
c = parseReleaseSavepoint();
} }
break; break;
case 'S': case 'S':
...@@ -541,6 +543,13 @@ public class Parser { ...@@ -541,6 +543,13 @@ public class Parser {
return command; return command;
} }
private Prepared parseReleaseSavepoint() throws SQLException {
Prepared command = new NoOperation(session);
readIf("SAVEPOINT");
readUniqueIdentifier();
return command;
}
private Schema getSchema() throws SQLException { private Schema getSchema() throws SQLException {
if (schemaName == null) { if (schemaName == null) {
return null; return null;
......
...@@ -151,26 +151,26 @@ public class CompressLZF implements Compressor { ...@@ -151,26 +151,26 @@ public class CompressLZF implements Compressor {
} else { } else {
// back reference // back reference
int len = ctrl >> 5; int len = ctrl >> 5;
int ref = -((ctrl & 0x1f) << 8) - 1; ctrl = -((ctrl & 0x1f) << 8) - 1;
if (len == 7) { if (len == 7) {
len += in[inPos++] & 255; len += in[inPos++] & 255;
} }
ref -= in[inPos++] & 255; ctrl -= in[inPos++] & 255;
len += outPos + 2; len += outPos + 2;
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
while (outPos < len - 8) { while (outPos < len - 8) {
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
} }
while (outPos < len) { while (outPos < len) {
out[outPos] = out[outPos++ + ref]; out[outPos] = out[outPos++ + ctrl];
} }
} }
} while (outPos < outLen); } while (outPos < outLen);
......
...@@ -1271,7 +1271,11 @@ public class Database implements DataHandler { ...@@ -1271,7 +1271,11 @@ public class Database implements DataHandler {
} else { } else {
try { try {
eventListener = (DatabaseEventListener) loadClass(className).newInstance(); eventListener = (DatabaseEventListener) loadClass(className).newInstance();
eventListener.init(databaseURL); String url = databaseURL;
if (cipher != null) {
url += ";CIPHER=" + cipher;
}
eventListener.init(url);
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, new String[] { throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, new String[] {
className, e.toString() }, e); className, e.toString() }, e);
......
...@@ -6,6 +6,7 @@ package org.h2.expression; ...@@ -6,6 +6,7 @@ package org.h2.expression;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.command.Parser;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
...@@ -64,7 +65,7 @@ public class Alias extends Expression { ...@@ -64,7 +65,7 @@ public class Alias extends Expression {
} }
public String getSQL() { public String getSQL() {
return expr.getSQL() + " AS " + alias; return expr.getSQL() + " AS " + Parser.quoteIdentifier(alias);
} }
public void updateAggregate(Session session) throws SQLException { public void updateAggregate(Session session) throws SQLException {
......
...@@ -10,6 +10,7 @@ import org.h2.constant.SysProperties; ...@@ -10,6 +10,7 @@ import org.h2.constant.SysProperties;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.index.IndexCondition; import org.h2.index.IndexCondition;
import org.h2.table.Column;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
...@@ -88,8 +89,7 @@ public class ConditionIn extends Condition { ...@@ -88,8 +89,7 @@ public class ConditionIn extends Condition {
if (constant && allValuesConstant) { if (constant && allValuesConstant) {
return ValueExpression.get(getValue(session)); return ValueExpression.get(getValue(session));
} }
// TODO optimization: could use index in some cases (sort, use min and // TODO optimization: could use index in some cases (sort, use min and max)
// max)
if (values.size() == 1) { if (values.size() == 1) {
Expression right = (Expression) values.get(0); Expression right = (Expression) values.get(0);
Expression expr = new Comparison(session, Comparison.EQUAL, left, right); Expression expr = new Comparison(session, Comparison.EQUAL, left, right);
...@@ -102,6 +102,8 @@ public class ConditionIn extends Condition { ...@@ -102,6 +102,8 @@ public class ConditionIn extends Condition {
independent.queryLevel = queryLevel; independent.queryLevel = queryLevel;
if (areAllValues(independent)) { if (areAllValues(independent)) {
if (left instanceof ExpressionColumn) { if (left instanceof ExpressionColumn) {
Column column = ((ExpressionColumn) left).getColumn();
boolean nullable = column.getNullable();
CompareMode mode = session.getDatabase().getCompareMode(); CompareMode mode = session.getDatabase().getCompareMode();
for (int i = 0; i < values.size(); i++) { for (int i = 0; i < values.size(); i++) {
Expression e = (Expression) values.get(i); Expression e = (Expression) values.get(i);
...@@ -109,8 +111,10 @@ public class ConditionIn extends Condition { ...@@ -109,8 +111,10 @@ public class ConditionIn extends Condition {
v = v.convertTo(dataType); v = v.convertTo(dataType);
values.set(i, ValueExpression.get(v)); values.set(i, ValueExpression.get(v));
if (min == null || min.compareTo(v, mode) > 0) { if (min == null || min.compareTo(v, mode) > 0) {
if (v != ValueNull.INSTANCE || nullable) {
min = v; min = v;
} }
}
if (max == null || max.compareTo(v, mode) < 0) { if (max == null || max.compareTo(v, mode) < 0) {
max = v; max = v;
} }
......
...@@ -42,8 +42,6 @@ public class ConditionNot extends Condition { ...@@ -42,8 +42,6 @@ public class ConditionNot extends Condition {
condition = condition.optimize(session); condition = condition.optimize(session);
return this; return this;
} }
// TODO optimization: some cases are maybe possible to optimize further:
// (NOT ID >= 5)
Expression e2 = condition.getNotIfPossible(session); Expression e2 = condition.getNotIfPossible(session);
if (e2 != null) { if (e2 != null) {
return e2.optimize(session); return e2.optimize(session);
......
...@@ -240,6 +240,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -240,6 +240,7 @@ public class JdbcConnection extends TraceObject implements Connection {
if (session == null) { if (session == null) {
return; return;
} }
synchronized (session) {
try { try {
if (!session.isClosed()) { if (!session.isClosed()) {
try { try {
...@@ -260,6 +261,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -260,6 +261,7 @@ public class JdbcConnection extends TraceObject implements Connection {
} finally { } finally {
session = null; session = null;
} }
}
} catch (Throwable e) { } catch (Throwable e) {
throw logAndConvert(e); throw logAndConvert(e);
} }
......
...@@ -59,19 +59,19 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -59,19 +59,19 @@ public class JdbcStatement extends TraceObject implements Statement {
if (escapeProcessing) { if (escapeProcessing) {
sql = conn.translateSQL(sql); sql = conn.translateSQL(sql);
} }
synchronized (session) {
CommandInterface command = conn.prepareCommand(sql); CommandInterface command = conn.prepareCommand(sql);
ResultInterface result; ResultInterface result;
boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY; boolean scrollable = resultSetType != ResultSet.TYPE_FORWARD_ONLY;
synchronized (session) {
setExecutingStatement(command); setExecutingStatement(command);
try { try {
result = command.executeQuery(maxRows, scrollable); result = command.executeQuery(maxRows, scrollable);
} finally { } finally {
setExecutingStatement(null); setExecutingStatement(null);
} }
}
command.close(); command.close();
resultSet = new JdbcResultSet(session, conn, this, result, id, closedByResultSet, scrollable); resultSet = new JdbcResultSet(session, conn, this, result, id, closedByResultSet, scrollable);
}
return resultSet; return resultSet;
} catch (Throwable e) { } catch (Throwable e) {
throw logAndConvert(e); throw logAndConvert(e);
......
...@@ -56,7 +56,9 @@ public class PgServer implements Service { ...@@ -56,7 +56,9 @@ public class PgServer implements Service {
} }
org.h2.Driver.load(); org.h2.Driver.load();
url = "pg://localhost:" + port; url = "pg://localhost:" + port;
// log = true;
// int testing;
// log = true;
} }
boolean getLog() { boolean getLog() {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
package org.h2.table; package org.h2.table;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.command.Parser;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Mode; import org.h2.engine.Mode;
...@@ -403,7 +405,7 @@ public class TableFilter implements ColumnResolver { ...@@ -403,7 +405,7 @@ public class TableFilter implements ColumnResolver {
buff.append(table.getSQL()); buff.append(table.getSQL());
if (alias != null && !table.getName().equals(alias)) { if (alias != null && !table.getName().equals(alias)) {
buff.append(' '); buff.append(' ');
buff.append(alias); buff.append(Parser.quoteIdentifier(alias));
} }
buff.append(" /* "); buff.append(" /* ");
StringBuffer planBuff = new StringBuffer(); StringBuffer planBuff = new StringBuffer();
......
...@@ -133,9 +133,7 @@ public class MemoryFile { ...@@ -133,9 +133,7 @@ public class MemoryFile {
long end = MathUtils.roundUpLong(l, BLOCK_SIZE); long end = MathUtils.roundUpLong(l, BLOCK_SIZE);
if (end != l) { if (end != l) {
int lastBlock = (int) (l >>> BLOCK_SIZE_SHIFT); int lastBlock = (int) (l >>> BLOCK_SIZE_SHIFT);
if (compress) {
expand(data, lastBlock); expand(data, lastBlock);
}
byte[] d = data[lastBlock]; byte[] d = data[lastBlock];
for (int i = (int) (l & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) { for (int i = (int) (l & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
d[i] = 0; d[i] = 0;
...@@ -161,11 +159,7 @@ public class MemoryFile { ...@@ -161,11 +159,7 @@ public class MemoryFile {
byte[][] n = new byte[blocks][]; byte[][] n = new byte[blocks][];
System.arraycopy(data, 0, n, 0, Math.min(data.length, n.length)); System.arraycopy(data, 0, n, 0, Math.min(data.length, n.length));
for (int i = data.length; i < blocks; i++) { for (int i = data.length; i < blocks; i++) {
if (compress) {
n[i] = COMPRESSED_BLOCK; n[i] = COMPRESSED_BLOCK;
} else {
n[i] = new byte[BLOCK_SIZE];
}
} }
data = n; data = n;
} }
...@@ -187,9 +181,7 @@ public class MemoryFile { ...@@ -187,9 +181,7 @@ public class MemoryFile {
while (len > 0) { while (len > 0) {
int l = (int) Math.min(len, BLOCK_SIZE - (pos & BLOCK_SIZE_MASK)); int l = (int) Math.min(len, BLOCK_SIZE - (pos & BLOCK_SIZE_MASK));
int id = (int) (pos >>> BLOCK_SIZE_SHIFT); int id = (int) (pos >>> BLOCK_SIZE_SHIFT);
if (compress) {
expand(data, id); expand(data, id);
}
byte[] block = data[id]; byte[] block = data[id];
int blockOffset = (int) (pos & BLOCK_SIZE_MASK); int blockOffset = (int) (pos & BLOCK_SIZE_MASK);
if (write) { if (write) {
......
...@@ -4,44 +4,142 @@ ...@@ -4,44 +4,142 @@
*/ */
package org.h2.util; 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.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Random; import java.util.Random;
public class RandomUtils { public class RandomUtils {
private static SecureRandom secureRandom; 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 { try {
secureRandom = SecureRandom.getInstance("SHA1PRNG"); secureRandom = SecureRandom.getInstance("SHA1PRNG");
byte[] seed = secureRandom.generateSeed(64); // 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); secureRandom.setSeed(seed);
random = new Random(secureRandom.nextLong()); }
}
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
// random is null if the algorithm is not found warn("SecureRandom", e);
// TODO log exception secureRandom = new SecureRandom();
random = new Random(); }
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() { public static long getSecureLong() {
if (secureRandom == null) { SecureRandom sr = getSecureRandom();
byte[] buff = SecureRandom.getSeed(8); synchronized (sr) {
return ByteUtils.readLong(buff, 0); return sr.nextLong();
} }
return secureRandom.nextLong();
} }
public static byte[] getSecureBytes(int len) { public static byte[] getSecureBytes(int len) {
if (secureRandom == null) {
return SecureRandom.getSeed(len);
}
if (len <= 0) { if (len <= 0) {
len = 1; len = 1;
} }
byte[] buff = new byte[len]; byte[] buff = new byte[len];
secureRandom.nextBytes(buff); SecureRandom sr = getSecureRandom();
synchronized (sr) {
sr.nextBytes(buff);
}
return buff; return buff;
} }
...@@ -49,4 +147,12 @@ public class RandomUtils { ...@@ -49,4 +147,12 @@ public class RandomUtils {
return random.nextInt(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 ...@@ -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: select ta.attname, ia.attnum, ic.relname
Ja. Ich knnte ausserdem Secure-Random verzgert initialisieren, d.h. in einem separaten Thread. 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
SHA-256 Hash von where ic.relname = 'dummy_pkey'
System.currentTimeMillis() + " " + AND n.nspname = ''
System.identityHashCode(new Object()) + " " + AND ic.oid = i.indexrelid
System.freeMemory() + " " + AND n.oid = ic.relnamespace
System.maxMemory() + " " + AND ia.attrelid = i.indexrelid
System.totalMemory() + " " + AND ta.attrelid = i.indrelid
Math.random() + " " + AND ta.attnum = i.indkey[ia.attnum-1]
System.getProperties().toString() + " " + AND (NOT ta.attisdropped)
Arrays.asList(InetAddress.getAllByName(InetAddress.getLocalHost().getHostName())).toString(); AND (NOT ia.attisdropped)
Und bei JDK 1.5 zustzlich: order by ia.attnum;
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.
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? slow power off test: slow memFS?
DROP TABLE ONE; DROP TABLE ONE;
...@@ -706,67 +752,65 @@ SELECT COUNT(*) AS A FROM TEST GROUP BY ID HAVING A>0; ...@@ -706,67 +752,65 @@ SELECT COUNT(*) AS A FROM TEST GROUP BY ID HAVING A>0;
beforeTest(); beforeTest();
// db // db
// new TestScriptSimple().runTest(this); new TestScriptSimple().runTest(this);
// new TestScript().runTest(this); new TestScript().runTest(this);
// new TestAutoRecompile().runTest(this); new TestAutoRecompile().runTest(this);
// new TestBackup().runTest(this); new TestBackup().runTest(this);
// new TestBatchUpdates().runTest(this); new TestBatchUpdates().runTest(this);
// new TestBigDb().runTest(this); new TestBigDb().runTest(this);
// new TestBigResult().runTest(this); new TestBigResult().runTest(this);
// new TestCache().runTest(this); new TestCache().runTest(this);
// new TestCases().runTest(this); new TestCases().runTest(this);
// new TestCheckpoint().runTest(this); new TestCheckpoint().runTest(this);
// new TestCluster().runTest(this); new TestCluster().runTest(this);
// new TestCompatibility().runTest(this); new TestCompatibility().runTest(this);
// new TestCsv().runTest(this); new TestCsv().runTest(this);
// new TestFunctions().runTest(this); new TestFunctions().runTest(this);
// new TestIndex().runTest(this); new TestIndex().runTest(this);
// if (!SysProperties.MVCC) { if (!SysProperties.MVCC) {
// new TestLinkedTable().runTest(this); new TestLinkedTable().runTest(this);
// } }
// new TestListener().runTest(this); new TestListener().runTest(this);
// new TestLob().runTest(this); new TestLob().runTest(this);
// new TestLogFile().runTest(this); new TestLogFile().runTest(this);
// new TestMemoryUsage().runTest(this); new TestMemoryUsage().runTest(this);
// new TestMultiConn().runTest(this); new TestMultiConn().runTest(this);
// new TestMultiDimension().runTest(this); new TestMultiDimension().runTest(this);
// if (!SysProperties.MVCC) { if (!SysProperties.MVCC) {
// new TestMultiThread().runTest(this); new TestMultiThread().runTest(this);
// } }
// new TestOpenClose().runTest(this); new TestOpenClose().runTest(this);
// new TestOptimizations().runTest(this); new TestOptimizations().runTest(this);
new TestPowerOff().runTest(this); new TestPowerOff().runTest(this);
System.exit(0); new TestReadOnly().runTest(this);
// new TestReadOnly().runTest(this); new TestRights().runTest(this);
// new TestRights().runTest(this); new TestRunscript().runTest(this);
// new TestRunscript().runTest(this); new TestSQLInjection().runTest(this);
// new TestSQLInjection().runTest(this); new TestSequence().runTest(this);
// new TestSequence().runTest(this); new TestSpaceReuse().runTest(this);
// new TestSpaceReuse().runTest(this); new TestSpeed().runTest(this);
// new TestSpeed().runTest(this); new TestTempTables().runTest(this);
// new TestTempTables().runTest(this); new TestTransaction().runTest(this);
// new TestTransaction().runTest(this); new TestTriggersConstraints().runTest(this);
// new TestTriggersConstraints().runTest(this); new TestTwoPhaseCommit().runTest(this);
// new TestTwoPhaseCommit().runTest(this); new TestView().runTest(this);
// new TestView().runTest(this);
// // server
// // server new TestNestedLoop().runTest(this);
// new TestNestedLoop().runTest(this);
// // jdbc
// // jdbc new TestCancel().runTest(this);
// new TestCancel().runTest(this); new TestDataSource().runTest(this);
// new TestDataSource().runTest(this); new TestManyJdbcObjects().runTest(this);
// new TestManyJdbcObjects().runTest(this); new TestMetaData().runTest(this);
// new TestMetaData().runTest(this); new TestNativeSQL().runTest(this);
// new TestNativeSQL().runTest(this); new TestPreparedStatement().runTest(this);
// new TestPreparedStatement().runTest(this); new TestResultSet().runTest(this);
// new TestResultSet().runTest(this); new TestStatement().runTest(this);
// new TestStatement().runTest(this); new TestTransactionIsolation().runTest(this);
// new TestTransactionIsolation().runTest(this); new TestUpdatableResultSet().runTest(this);
// new TestUpdatableResultSet().runTest(this); new TestXA().runTest(this);
// new TestXA().runTest(this); new TestZloty().runTest(this);
// new TestZloty().runTest(this);
afterTest(); afterTest();
} }
......
...@@ -82,6 +82,9 @@ public class TestListener extends TestBase implements DatabaseEventListener { ...@@ -82,6 +82,9 @@ public class TestListener extends TestBase implements DatabaseEventListener {
} }
public void closingDatabase() { public void closingDatabase() {
if (url.toUpperCase().indexOf("CIPHER") >= 0) {
return;
}
Connection conn = null; Connection conn = null;
try { try {
conn = DriverManager.getConnection(url, getUser(), getPassword()); conn = DriverManager.getConnection(url, getUser(), getPassword());
...@@ -99,6 +102,9 @@ public class TestListener extends TestBase implements DatabaseEventListener { ...@@ -99,6 +102,9 @@ public class TestListener extends TestBase implements DatabaseEventListener {
} }
public void opened() { public void opened() {
if (url.toUpperCase().indexOf("CIPHER") >= 0) {
return;
}
Connection conn = null; Connection conn = null;
try { try {
conn = DriverManager.getConnection(url, getUser(), getPassword()); conn = DriverManager.getConnection(url, getUser(), getPassword());
......
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- 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)"; create alias "SYSDATE" for "java.lang.Integer.parseInt(java.lang.String)";
> exception > 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; select * from (select x from dual union select convert(x, int) from dual) where x=0;
create table test(id int); create table test(id int);
insert into scriptSimple.public.test(id) values(1), (2); insert into scriptSimple.public.test(id) values(1), (2);
......
...@@ -11,6 +11,65 @@ import org.h2.tools.CompressTool; ...@@ -11,6 +11,65 @@ import org.h2.tools.CompressTool;
public class TestCompress extends TestBase { 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 { public void test() throws Exception {
if (config.big) { if (config.big) {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
...@@ -29,7 +88,8 @@ public class TestCompress extends TestBase { ...@@ -29,7 +88,8 @@ public class TestCompress extends TestBase {
} }
void test(int len) throws Exception { 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]; byte[] buff = new byte[len];
switch (pattern) { switch (pattern) {
case 0: case 0:
...@@ -42,10 +102,22 @@ public class TestCompress extends TestBase { ...@@ -42,10 +102,22 @@ public class TestCompress extends TestBase {
break; break;
} }
case 2: { case 2: {
Random r = new Random(len);
r.nextBytes(buff); r.nextBytes(buff);
break; 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" }; String[] algorithm = new String[] { "LZF", "Deflate", "No" };
CompressTool utils = CompressTool.getInstance(); CompressTool utils = CompressTool.getInstance();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论