提交 238a2f58 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 16198b6d
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<fileset dir="src/main"/> <fileset dir="src/main"/>
</copy> </copy>
<java classname="org.h2.test.coverage.Coverage" classpath="bin" dir="bin" fork="true"> <java classname="org.h2.test.coverage.Coverage" classpath="bin" dir="bin" fork="true">
<arg line="-e org/h2/web -e org/h2/jdbcx -e org/h2/bnf -r org/h2"/> <arg line="-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -r org/h2"/>
</java> </java>
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/**"/> <javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/**"/>
</target> </target>
......
...@@ -235,6 +235,7 @@ For a list of applications that work with or use H2, see: ...@@ -235,6 +235,7 @@ For a list of applications that work with or use H2, see:
<a href="http://groups.google.com/group/h2-database/web/h2-in-use"> <a href="http://groups.google.com/group/h2-database/web/h2-in-use">
http://groups.google.com/group/h2-database/web/h2-in-use http://groups.google.com/group/h2-database/web/h2-in-use
</a> </a>
</p>
<br /><a name="connection_modes"></a> <br /><a name="connection_modes"></a>
<h2>Connection Modes</h2> <h2>Connection Modes</h2>
......
...@@ -36,19 +36,21 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch. ...@@ -36,19 +36,21 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<br /><a name="changelog"></a> <br /><a name="changelog"></a>
<h2>Change Log</h2> <h2>Change Log</h2>
<p>
The up-to-date change log is available here: The up-to-date change log is available here:
<a href="http://groups.google.com/group/h2-database/web/change-log"> <a href="http://groups.google.com/group/h2-database/web/change-log">
http://groups.google.com/group/h2-database/web/change-log http://groups.google.com/group/h2-database/web/change-log
</a> </a>
</p>
<br /><a name="roadmap"></a> <br /><a name="roadmap"></a>
<h2>Roadmap</h2> <h2>Roadmap</h2>
<p>
The current roadmap is available here: The current roadmap is available here:
<a href="http://groups.google.com/group/h2-database/web/roadmap"> <a href="http://groups.google.com/group/h2-database/web/roadmap">
http://groups.google.com/group/h2-database/web/roadmap http://groups.google.com/group/h2-database/web/roadmap
</a> </a>
</p>
<h3>Not Planned</h3> <h3>Not Planned</h3>
<ul> <ul>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -7,7 +7,7 @@ package org.h2.engine; ...@@ -7,7 +7,7 @@ package org.h2.engine;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
/** /**
* This class is reponsible to close a database if the application did not close a connection. * This class is responsible to close a database if the application did not close a connection.
*/ */
public class DatabaseCloser extends Thread { public class DatabaseCloser extends Thread {
......
...@@ -206,11 +206,11 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index { ...@@ -206,11 +206,11 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
public String getColumnListSQL() { public String getColumnListSQL() {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < indexColumns.length; i++) {
if (i > 0) { if (i > 0) {
buff.append(", "); buff.append(", ");
} }
buff.append(columns[i].getSQL()); buff.append(indexColumns[i].getSQL());
} }
return buff.toString(); return buff.toString();
} }
......
...@@ -258,7 +258,7 @@ public class MultiVersionIndex implements Index { ...@@ -258,7 +258,7 @@ public class MultiVersionIndex implements Index {
} }
void debug(String s, Session session, SearchRow row) throws SQLException { void debug(String s, Session session, SearchRow row) throws SQLException {
// System.out.println(this + " " + s + " sess:" + (session == null ? -1: session.getId()) + " " + (row == null ? "" : row.getValue(0).getString())); // System.out.println(this + " " + s + " session:" + (session == null ? -1: session.getId()) + " " + (row == null ? "" : row.getValue(0).getString()));
} }
} }
...@@ -252,6 +252,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -252,6 +252,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* </li><li>11 CARDINALITY (int) numbers of unique values * </li><li>11 CARDINALITY (int) numbers of unique values
* </li><li>12 PAGES (int) number of pages use (always 0) * </li><li>12 PAGES (int) number of pages use (always 0)
* </li><li>13 FILTER_CONDITION (String) filter condition (always empty) * </li><li>13 FILTER_CONDITION (String) filter condition (always empty)
* </li><li>14 SORT_TYPE (int) the sort type bit map: 1=DESCENDING, 2=NULLS_FIRST, 4=NULLS_LAST
* </li></ul> * </li></ul>
* *
* @param catalog null (to get all objects) or the catalog name * @param catalog null (to get all objects) or the catalog name
...@@ -289,7 +290,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -289,7 +290,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+ "ASC_OR_DESC, " + "ASC_OR_DESC, "
+ "CARDINALITY, " // TODO meta data for number of unique values in an index + "CARDINALITY, " // TODO meta data for number of unique values in an index
+ "PAGES, " + "PAGES, "
+ "FILTER_CONDITION " + "FILTER_CONDITION, "
+ "SORT_TYPE "
+ "FROM INFORMATION_SCHEMA.INDEXES " + "FROM INFORMATION_SCHEMA.INDEXES "
+ "WHERE TABLE_CATALOG LIKE ? " + "WHERE TABLE_CATALOG LIKE ? "
+ "AND TABLE_SCHEMA LIKE ? " + "AND TABLE_SCHEMA LIKE ? "
......
...@@ -4,55 +4,44 @@ ...@@ -4,55 +4,44 @@
*/ */
package org.h2.security; package org.h2.security;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.SQLException;
//#ifdef JDK14
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.security.Key; import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Enumeration; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import javax.net.ServerSocketFactory; import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
//#endif
/** /**
* * A factory to create encrypted sockets. To generate new keystore, use the
* keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass * SecureKeyStoreBuilder tool.
*
*
*
* @author Thomas
*/ */
public class SecureSocketFactory { public class SecureSocketFactory {
private static final String KEYSTORE = ".h2.keystore"; private static final String KEYSTORE = ".h2.keystore";
private static final String KEYSTORE_KEY = "javax.net.ssl.keyStore"; private static final String KEYSTORE_KEY = "javax.net.ssl.keyStore";
private static final String KEYSTORE_PASSWORD_KEY = "javax.net.ssl.keyStorePassword"; private static final String KEYSTORE_PASSWORD_KEY = "javax.net.ssl.keyStorePassword";
private static final String KEYSTORE_PASSWORD = "h2pass"; public static final String KEYSTORE_PASSWORD = "h2pass";
// TODO security / SSL: need a way to disable anonymous ssl // TODO security / SSL: need a way to disable anonymous ssl
private static final boolean ENABLE_ANONYMOUS_SSL = true; private static final boolean ENABLE_ANONYMOUS_SSL = true;
...@@ -107,7 +96,7 @@ public class SecureSocketFactory { ...@@ -107,7 +96,7 @@ public class SecureSocketFactory {
return ByteUtils.convertStringToBytes(hex); return ByteUtils.convertStringToBytes(hex);
} }
private byte[] getKeyStoreBytes(KeyStore store, String password) throws SQLException { private static byte[] getKeyStoreBytes(KeyStore store, String password) throws SQLException {
try { try {
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
store.store(bout, KEYSTORE_PASSWORD.toCharArray()); store.store(bout, KEYSTORE_PASSWORD.toCharArray());
...@@ -117,16 +106,7 @@ public class SecureSocketFactory { ...@@ -117,16 +106,7 @@ public class SecureSocketFactory {
} }
} }
public static void main(String[] a) throws Exception { public static KeyStore getKeyStore(String password) throws SQLException {
// first, create a keystore using:
// keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass
// then run this application to generate the source code
// then replace the code in the function getKeyStore as specified
KeyStore store = getKeyStore(KEYSTORE_PASSWORD);
printKeystore(store, KEYSTORE_PASSWORD);
}
private static KeyStore getKeyStore(String password) throws SQLException {
try { try {
// The following source code can be re-generated when you have a keystore file. // The following source code can be re-generated when you have a keystore file.
// This code is (hopefully) more Java version independent than using keystores directly. // This code is (hopefully) more Java version independent than using keystores directly.
...@@ -154,38 +134,6 @@ public class SecureSocketFactory { ...@@ -154,38 +134,6 @@ public class SecureSocketFactory {
} }
} }
private static void printKeystore(KeyStore store, String password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, CertificateEncodingException {
System.out.println("KeyStore store = KeyStore.getInstance(\""+store.getType()+"\");");
System.out.println("store.load(null, password.toCharArray());");
//System.out.println("keystore provider="+store.getProvider().getName());
Enumeration en = store.aliases();
while (en.hasMoreElements()) {
String alias = (String) en.nextElement();
Key key = store.getKey(alias, password.toCharArray());
System.out.println("KeyFactory keyFactory = KeyFactory.getInstance(\"" + key.getAlgorithm() + "\");");
System.out.println("store.load(null, password.toCharArray());");
String pkFormat = key.getFormat();
String encoded = ByteUtils.convertBytesToString(key.getEncoded());
System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));");
System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = new Certificate[]{");
Certificate[] certs = store.getCertificateChain(alias);
for (int i = 0; i < certs.length; i++) {
Certificate cert = certs[i];
System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = ByteUtils.convertBytesToString(cert.getEncoded());
System.out.println(" generateCertificate(new ByteArrayInputStream(getBytes(\""+enc+"\"))),");
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" publicKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" publicKey format="+pubKey.getFormat());
// System.out.println(" publicKey format="+ByteUtils.convertBytesToString(pubKey.getEncoded()));
}
System.out.println("};");
System.out.println("store.setKeyEntry(\""+alias+"\", privateKey, password.toCharArray(), certs);");
}
}
private void setKeystore() throws IOException, SQLException { private void setKeystore() throws IOException, SQLException {
Properties p = System.getProperties(); Properties p = System.getProperties();
if (p.getProperty(KEYSTORE_KEY) == null) { if (p.getProperty(KEYSTORE_KEY) == null) {
...@@ -220,16 +168,6 @@ public class SecureSocketFactory { ...@@ -220,16 +168,6 @@ public class SecureSocketFactory {
return newList; return newList;
} }
// private void listCipherSuites(SSLServerSocketFactory f) {
// String[] def = f.getDefaultCipherSuites();
// for(int i=0; i<def.length; i++) {
// System.out.println("default = " + def[i]);
// }
// String[] sup = f.getSupportedCipherSuites();
// for(int i=0; i<sup.length; i++) {
// System.out.println("supported = " + sup[i]);
// }
// }
//#endif //#endif
} }
...@@ -40,6 +40,7 @@ import org.h2.log.InDoubtTransaction; ...@@ -40,6 +40,7 @@ import org.h2.log.InDoubtTransaction;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow; import org.h2.result.SearchRow;
import org.h2.result.SortOrder;
import org.h2.schema.Constant; import org.h2.schema.Constant;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.schema.Sequence; import org.h2.schema.Sequence;
...@@ -143,7 +144,8 @@ public class MetaTable extends Table { ...@@ -143,7 +144,8 @@ public class MetaTable extends Table {
"FILTER_CONDITION", "FILTER_CONDITION",
"REMARKS", "REMARKS",
"SQL", "SQL",
"ID INT" "ID INT",
"SORT_TYPE INT"
}); });
indexColumnName = "TABLE_NAME"; indexColumnName = "TABLE_NAME";
break; break;
...@@ -614,9 +616,10 @@ public class MetaTable extends Table { ...@@ -614,9 +616,10 @@ public class MetaTable extends Table {
if (index.getCreateSQL() == null) { if (index.getCreateSQL() == null) {
continue; continue;
} }
Column[] cols = index.getColumns(); IndexColumn[] cols = index.getIndexColumns();
for (int k = 0; k < cols.length; k++) { for (int k = 0; k < cols.length; k++) {
Column column = cols[k]; IndexColumn idxCol = cols[k];
Column column = idxCol.column;
add(rows, new String[] { add(rows, new String[] {
catalog, // TABLE_CATALOG catalog, // TABLE_CATALOG
identifier(table.getSchema().getName()), // TABLE_SCHEMA identifier(table.getSchema().getName()), // TABLE_SCHEMA
...@@ -630,12 +633,13 @@ public class MetaTable extends Table { ...@@ -630,12 +633,13 @@ public class MetaTable extends Table {
index.getIndexType().getSQL(), // INDEX_TYPE_NAME index.getIndexType().getSQL(), // INDEX_TYPE_NAME
index.getIndexType().belongsToConstraint() ? "TRUE" : "FALSE", // IS_GENERATED index.getIndexType().belongsToConstraint() ? "TRUE" : "FALSE", // IS_GENERATED
"" + DatabaseMetaData.tableIndexOther, // INDEX_TYPE "" + DatabaseMetaData.tableIndexOther, // INDEX_TYPE
"A", // ASC_OR_DESC (idxCol.sortType & SortOrder.DESCENDING) != 0 ? "D" : "A", // ASC_OR_DESC
"0", // PAGES "0", // PAGES
"", // FILTER_CONDITION "", // FILTER_CONDITION
replaceNullWithEmpty(index.getComment()), // REMARKS replaceNullWithEmpty(index.getComment()), // REMARKS
index.getSQL(), // SQL index.getSQL(), // SQL
"" + index.getId() // ID "" + index.getId(), // ID
"" + idxCol.sortType, // SORT_TYPE
}); });
} }
} }
......
...@@ -15,15 +15,12 @@ import java.sql.DriverManager; ...@@ -15,15 +15,12 @@ import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.HashMap;
import java.util.Iterator;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.util.ClassUtils; import org.h2.util.ClassUtils;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -36,8 +33,6 @@ import org.h2.util.StringUtils; ...@@ -36,8 +33,6 @@ import org.h2.util.StringUtils;
*/ */
public class RunScript { public class RunScript {
private static final boolean MULTI_THREAD = false;
private void showUsage() { private void showUsage() {
System.out.println("java " + getClass().getName() + " -url <url> -user <user> [-password <pwd>] [-script <file>] [-driver <driver] [-options <option> ...]"); System.out.println("java " + getClass().getName() + " -url <url> -user <user> [-password <pwd>] [-script <file>] [-driver <driver] [-options <option> ...]");
} }
...@@ -156,19 +151,19 @@ public class RunScript { ...@@ -156,19 +151,19 @@ public class RunScript {
return rs; return rs;
} }
private static void execute(Connection conn, HashMap threadMap, String fileName, boolean continueOnError, String charsetName) throws SQLException, IOException { private static void execute(Connection conn, String fileName, boolean continueOnError, String charsetName) throws SQLException, IOException {
InputStream in = FileUtils.openFileInputStream(fileName); InputStream in = FileUtils.openFileInputStream(fileName);
String path = FileUtils.getParent(fileName); String path = FileUtils.getParent(fileName);
try { try {
in = new BufferedInputStream(in, Constants.IO_BUFFER_SIZE); in = new BufferedInputStream(in, Constants.IO_BUFFER_SIZE);
InputStreamReader reader = new InputStreamReader(in, charsetName); InputStreamReader reader = new InputStreamReader(in, charsetName);
execute(conn, threadMap, continueOnError, path, reader, charsetName); execute(conn, continueOnError, path, reader, charsetName);
} finally { } finally {
IOUtils.closeSilently(in); IOUtils.closeSilently(in);
} }
} }
private static void execute(Connection conn, HashMap threadMap, boolean continueOnError, String path, Reader reader, String charsetName) throws SQLException, IOException { private static void execute(Connection conn, boolean continueOnError, String path, Reader reader, String charsetName) throws SQLException, IOException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ScriptReader r = new ScriptReader(reader); ScriptReader r = new ScriptReader(reader);
while (true) { while (true) {
...@@ -182,24 +177,7 @@ public class RunScript { ...@@ -182,24 +177,7 @@ public class RunScript {
if (!FileUtils.isAbsolute(sql)) { if (!FileUtils.isAbsolute(sql)) {
sql = path + File.separator + sql; sql = path + File.separator + sql;
} }
execute(conn, threadMap, sql, continueOnError, charsetName); execute(conn, sql, continueOnError, charsetName);
} else if (MULTI_THREAD && sql.startsWith("/*")) {
int idx = sql.indexOf(']');
Integer id = ObjectUtils.getInteger(Integer.parseInt(sql.substring("/*".length(), idx)));
RunScriptThread thread = (RunScriptThread) threadMap.get(id);
if (thread == null) {
Connection c = DriverManager.getConnection(conn.getMetaData().getURL());
thread = new RunScriptThread(id.intValue(), c);
threadMap.put(id, thread);
thread.start();
}
sql = sql.substring(sql.indexOf("*/") + 2).trim();
String up = StringUtils.toUpperEnglish(sql);
thread.addStatement(sql);
if (up.startsWith("CREATE") || up.startsWith("DROP") || up.startsWith("ALTER")) {
thread.executeAll();
} else {
}
} else { } else {
try { try {
if (sql.trim().length() > 0) { if (sql.trim().length() > 0) {
...@@ -214,15 +192,6 @@ public class RunScript { ...@@ -214,15 +192,6 @@ public class RunScript {
} }
} }
} }
Iterator it = threadMap.values().iterator();
while (it.hasNext()) {
RunScriptThread thread = (RunScriptThread) it.next();
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} }
private static void executeRunscript(String url, String user, String password, String fileName, String options) throws SQLException { private static void executeRunscript(String url, String user, String password, String fileName, String options) throws SQLException {
...@@ -258,9 +227,8 @@ public class RunScript { ...@@ -258,9 +227,8 @@ public class RunScript {
if (charsetName == null) { if (charsetName == null) {
charsetName = Constants.UTF8; charsetName = Constants.UTF8;
} }
HashMap threadMap = new HashMap();
try { try {
execute(conn, threadMap, fileName, continueOnError, charsetName); execute(conn, fileName, continueOnError, charsetName);
} finally { } finally {
conn.close(); conn.close();
} }
......
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.tools;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;
import org.h2.constant.ErrorCode;
class RunScriptThread extends Thread {
private int id;
private volatile boolean stop;
private Connection conn;
private LinkedList queue = new LinkedList();
RunScriptThread(int id, Connection conn) {
this.id = id;
this.conn = conn;
}
void stopThread() {
this.stop = true;
}
void addStatement(String sql) {
synchronized (queue) {
queue.add(sql);
queue.notifyAll();
}
}
void executeAll() {
while (true) {
synchronized (queue) {
if (queue.size() == 0) {
return;
}
try {
queue.wait();
} catch (InterruptedException e) {
// ignore
}
}
}
}
public void run() {
while (!stop) {
String sql;
synchronized (queue) {
while (queue.size() == 0) {
try {
queue.wait();
} catch (InterruptedException e) {
// ignore
}
}
sql = (String) queue.removeFirst();
queue.notifyAll();
}
if (sql == null) {
continue;
}
try {
conn.createStatement().execute("/*" + id + "*/" + sql);
} catch (SQLException e) {
switch (e.getErrorCode()) {
case ErrorCode.LOCK_TIMEOUT_1:
case ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1:
break;
default:
e.printStackTrace();
}
}
}
}
}
...@@ -24,30 +24,6 @@ public class IntArray { ...@@ -24,30 +24,6 @@ public class IntArray {
this.data = data; this.data = data;
size = data.length; size = data.length;
} }
public static int[] clone(int[] array) {
if (array == null) {
return null;
}
int[] copy = new int[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return copy;
}
public static boolean equals(int[] a, int[] b) {
if (a == null || b == null) {
return a == b;
}
if (a.length != b.length) {
return false;
}
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
public void add(int value) { public void add(int value) {
checkCapacity(); checkCapacity();
......
...@@ -28,11 +28,6 @@ public class ObjectArray { ...@@ -28,11 +28,6 @@ public class ObjectArray {
data = new Object[size > 1 ? size : 1]; data = new Object[size > 1 ? size : 1];
} }
public ObjectArray(Object[] data) {
this.data = data;
size = data.length;
}
public ObjectArray(Collection collection) { public ObjectArray(Collection collection) {
// TODO lib: Collection should not be required // TODO lib: Collection should not be required
size = collection.size(); size = collection.size();
......
...@@ -146,9 +146,6 @@ java org.h2.test.TestAll timer ...@@ -146,9 +146,6 @@ java org.h2.test.TestAll timer
A file is sent although the Japanese translation has not been completed yet. A file is sent although the Japanese translation has not been completed yet.
---- ----
reverse index
Code coverage
At startup, when corrupted, say if LOG=0 was used before At startup, when corrupted, say if LOG=0 was used before
add more MVCC tests add more MVCC tests
......
...@@ -148,7 +148,7 @@ public class TestCases extends TestBase { ...@@ -148,7 +148,7 @@ public class TestCases extends TestBase {
} }
private void testDisconnect() throws Exception { private void testDisconnect() throws Exception {
if (config.networked) { if (config.networked || config.codeCoverage) {
return; return;
} }
deleteDb("cases"); deleteDb("cases");
......
...@@ -10,6 +10,7 @@ import java.sql.ResultSet; ...@@ -10,6 +10,7 @@ import java.sql.ResultSet;
import java.sql.Statement; import java.sql.Statement;
import java.util.Random; import java.util.Random;
import org.h2.result.SortOrder;
import org.h2.test.TestBase; import org.h2.test.TestBase;
public class TestIndex extends TestBase { public class TestIndex extends TestBase {
...@@ -28,6 +29,8 @@ public class TestIndex extends TestBase { ...@@ -28,6 +29,8 @@ public class TestIndex extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testDescIndex();
if (config.networked && config.big) { if (config.networked && config.big) {
return; return;
} }
...@@ -67,6 +70,33 @@ public class TestIndex extends TestBase { ...@@ -67,6 +70,33 @@ public class TestIndex extends TestBase {
conn.close(); conn.close();
} }
void testDescIndex() throws Exception {
if (config.memory) {
return;
}
ResultSet rs;
reconnect();
stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("CREATE INDEX IDX_ND ON TEST(ID DESC)");
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next();
check(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
stat.execute("INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1, 30)");
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next();
check(rs.getInt(1), 11);
reconnect();
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next();
check(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next();
check(rs.getInt(1), 11);
stat.execute("DROP TABLE TEST");
}
String getRandomString(int len) { String getRandomString(int len) {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
......
...@@ -235,7 +235,7 @@ public class TestLob extends TestBase { ...@@ -235,7 +235,7 @@ public class TestLob extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int, data clob)"); stat.execute("create table test(id int, data clob)");
stat.execute("insert into test values(1, space(1000));"); stat.execute("insert into test values(1, space(1000));");
stat.execute("insert into test values(2, space(1000));"); stat.execute("insert into test values(2, space(10000));");
stat.execute("create table test2(id int, data clob);"); stat.execute("create table test2(id int, data clob);");
stat.execute("insert into test2 select * from test;"); stat.execute("insert into test2 select * from test;");
stat.execute("drop table test;"); stat.execute("drop table test;");
......
...@@ -24,20 +24,20 @@ public class TestSequence extends TestBase { ...@@ -24,20 +24,20 @@ public class TestSequence extends TestBase {
deleteDb("sequence"); deleteDb("sequence");
Connection conn = getConnection("sequence"); Connection conn = getConnection("sequence");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create sequence testSequence"); stat.execute("create sequence test_Sequence");
stat.execute("create sequence testSequence3 cache 3"); stat.execute("create sequence test_Sequence3 cache 3");
conn.close(); conn.close();
conn = getConnection("sequence"); conn = getConnection("sequence");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("call next value for testSequence"); stat.execute("call next value for test_Sequence");
stat.execute("call next value for testSequence3"); stat.execute("call next value for test_Sequence3");
ResultSet rs = stat.executeQuery("select * from information_schema.sequences"); ResultSet rs = stat.executeQuery("select * from information_schema.sequences");
rs.next(); rs.next();
check(rs.getString("SEQUENCE_NAME"), "TESTSEQUENCE3"); check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE");
check(rs.getString("CACHE"), "3");
rs.next();
check(rs.getString("SEQUENCE_NAME"), "TESTSEQUENCE");
check(rs.getString("CACHE"), "32"); check(rs.getString("CACHE"), "32");
rs.next();
check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE3");
check(rs.getString("CACHE"), "3");
checkFalse(rs.next()); checkFalse(rs.next());
conn.close(); conn.close();
} }
......
...@@ -569,11 +569,11 @@ public class TestMetaData extends TestBase { ...@@ -569,11 +569,11 @@ public class TestMetaData extends TestBase {
stat.executeUpdate("CREATE INDEX IDX_TEXT_DEC ON TEST(TEXT_V,DEC_V)"); stat.executeUpdate("CREATE INDEX IDX_TEXT_DEC ON TEST(TEXT_V,DEC_V)");
stat.executeUpdate("CREATE UNIQUE INDEX IDX_DATE ON TEST(DATE_V)"); stat.executeUpdate("CREATE UNIQUE INDEX IDX_DATE ON TEST(DATE_V)");
rs = meta.getIndexInfo(null, null, "TEST", false, false); rs = meta.getIndexInfo(null, null, "TEST", false, false);
testResultSetMeta(rs, 13, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", testResultSetMeta(rs, 14, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
"INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC",
"CARDINALITY", "PAGES", "FILTER_CONDITION" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, "CARDINALITY", "PAGES", "FILTER_CONDITION", "SORT_TYPE"}, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR, DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR }, null, null); Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER}, null, null);
testResultSetOrdered(rs, new String[][] { testResultSetOrdered(rs, new String[][] {
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "IDX_DATE", { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "IDX_DATE",
"" + DatabaseMetaData.tableIndexOther, "1", "DATE_V", "A", "0", "0", "" }, "" + DatabaseMetaData.tableIndexOther, "1", "DATE_V", "A", "0", "0", "" },
...@@ -586,11 +586,11 @@ public class TestMetaData extends TestBase { ...@@ -586,11 +586,11 @@ public class TestMetaData extends TestBase {
stat.executeUpdate("DROP INDEX IDX_TEXT_DEC"); stat.executeUpdate("DROP INDEX IDX_TEXT_DEC");
stat.executeUpdate("DROP INDEX IDX_DATE"); stat.executeUpdate("DROP INDEX IDX_DATE");
rs = meta.getIndexInfo(null, null, "TEST", false, false); rs = meta.getIndexInfo(null, null, "TEST", false, false);
testResultSetMeta(rs, 13, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", testResultSetMeta(rs, 14, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
"INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC",
"CARDINALITY", "PAGES", "FILTER_CONDITION" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, "CARDINALITY", "PAGES", "FILTER_CONDITION", "SORT_TYPE" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR, DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR }, null, null); Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER }, null, null);
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog,
"PRIMARY_KEY_1", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } }); "PRIMARY_KEY_1", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } });
trace("getPrimaryKeys"); trace("getPrimaryKeys");
......
CREATE TABLE TEST(ID INT); CREATE TABLE TEST(ID INT);
INSERT INTO TEST VALUES(1), (2), (3); INSERT INTO TEST VALUES(1), (2), (3);
create index idxdesc on test(id desc); create index idx_desc on test(id desc);
select * from test where id between 0 and 1; select * from test where id between 0 and 1;
> 1; > 1;
select * from test where id between 3 and 4; select * from test where id between 3 and 4;
......
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.security;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.Enumeration;
import org.h2.util.ByteUtils;
/**
* Tool to generate source code for the SecureSocketFactory.
* First, create a keystore using:
* <pre>
* keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass
* </pre>
* Then run this application to generate the source code.
* Then replace the code in the function SecureSocketFactory.getKeyStore as specified
*/
public class SecureKeyStoreBuilder {
public static void main(String[] a) throws Exception {
String password = SecureSocketFactory.KEYSTORE_PASSWORD;
KeyStore store = SecureSocketFactory.getKeyStore(password);
printKeystore(store, password);
}
private static void printKeystore(KeyStore store, String password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, CertificateEncodingException {
System.out.println("KeyStore store = KeyStore.getInstance(\""+store.getType()+"\");");
System.out.println("store.load(null, password.toCharArray());");
//System.out.println("keystore provider="+store.getProvider().getName());
Enumeration en = store.aliases();
while (en.hasMoreElements()) {
String alias = (String) en.nextElement();
Key key = store.getKey(alias, password.toCharArray());
System.out.println("KeyFactory keyFactory = KeyFactory.getInstance(\"" + key.getAlgorithm() + "\");");
System.out.println("store.load(null, password.toCharArray());");
String pkFormat = key.getFormat();
String encoded = ByteUtils.convertBytesToString(key.getEncoded());
System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));");
System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = new Certificate[]{");
Certificate[] certs = store.getCertificateChain(alias);
for (int i = 0; i < certs.length; i++) {
Certificate cert = certs[i];
System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = ByteUtils.convertBytesToString(cert.getEncoded());
System.out.println(" generateCertificate(new ByteArrayInputStream(getBytes(\""+enc+"\"))),");
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" publicKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" publicKey format="+pubKey.getFormat());
// System.out.println(" publicKey format="+ByteUtils.convertBytesToString(pubKey.getEncoded()));
}
System.out.println("};");
System.out.println("store.setKeyEntry(\""+alias+"\", privateKey, password.toCharArray(), certs);");
}
}
// private void listCipherSuites(SSLServerSocketFactory f) {
// String[] def = f.getDefaultCipherSuites();
// for (int i = 0; i < def.length; i++) {
// System.out.println("default = " + def[i]);
// }
// String[] sup = f.getSupportedCipherSuites();
// for (int i = 0; i < sup.length; i++) {
// System.out.println("supported = " + sup[i]);
// }
// }
}
...@@ -511,4 +511,5 @@ lumber thus taking repositories ago delegated mention leaks pgsql seeded felt ef ...@@ -511,4 +511,5 @@ lumber thus taking repositories ago delegated mention leaks pgsql seeded felt ef
spfile svr pkey synced semicolon terminating spfile svr pkey synced semicolon terminating
framework constructing architectural jmatter workgroup upgraded naked stopper skipping assumed framework constructing architectural jmatter workgroup upgraded naked stopper skipping assumed
opensource atlassian hhh establish pawel nice italiano ucchino paolo italian pier shorter although opensource atlassian hhh establish pawel nice italiano ucchino paolo italian pier shorter although
uklinux credential crypt kerberos redferni routine
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论