提交 e9b4498c authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 8bd9aeaa
#Sat Dec 01 09:41:20 CET 2007 #Mon Dec 10 07:25:40 CET 2007
javac=javac javac=javac
benchmark.drivers.dir=C\:/data/java benchmark.drivers.dir=C\:/data/java
path.servlet.jar=C\:/data/classpath/servlet-api.jar path.servlet.jar=C\:/data/classpath/servlet-api.jar
......
...@@ -14,6 +14,7 @@ import org.h2.constraint.ConstraintCheck; ...@@ -14,6 +14,7 @@ import org.h2.constraint.ConstraintCheck;
import org.h2.constraint.ConstraintReferential; import org.h2.constraint.ConstraintReferential;
import org.h2.constraint.ConstraintUnique; import org.h2.constraint.ConstraintUnique;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.DbObject;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.Expression; import org.h2.expression.Expression;
...@@ -52,9 +53,9 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -52,9 +53,9 @@ public class AlterTableAddConstraint extends SchemaCommand {
super(session, schema); super(session, schema);
} }
private String generateConstraintName(int id) throws SQLException { private String generateConstraintName(DbObject obj, int id) throws SQLException {
if (constraintName == null) { if (constraintName == null) {
constraintName = getSchema().getUniqueConstraintName(); constraintName = getSchema().getUniqueConstraintName(obj);
} }
return constraintName; return constraintName;
} }
...@@ -72,7 +73,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -72,7 +73,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
switch (type) { switch (type) {
case CHECK: { case CHECK: {
int id = getObjectId(true, true); int id = getObjectId(true, true);
String name = generateConstraintName(id); String name = generateConstraintName(table, id);
ConstraintCheck check = new ConstraintCheck(getSchema(), id, name, table); ConstraintCheck check = new ConstraintCheck(getSchema(), id, name, table);
TableFilter filter = new TableFilter(session, table, null, false, null); TableFilter filter = new TableFilter(session, table, null, false, null);
checkExpression.mapColumns(filter, 0); checkExpression.mapColumns(filter, 0);
...@@ -99,7 +100,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -99,7 +100,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
} }
int id = getObjectId(true, true); int id = getObjectId(true, true);
String name = generateConstraintName(id); String name = generateConstraintName(table, id);
ConstraintUnique unique = new ConstraintUnique(getSchema(), id, name, table); ConstraintUnique unique = new ConstraintUnique(getSchema(), id, name, table);
unique.setColumns(columns); unique.setColumns(columns);
unique.setIndex(index, isOwner); unique.setIndex(index, isOwner);
...@@ -146,7 +147,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -146,7 +147,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
} }
int id = getObjectId(true, true); int id = getObjectId(true, true);
String name = generateConstraintName(id); String name = generateConstraintName(table, id);
ConstraintReferential ref = new ConstraintReferential(getSchema(), id, name, table); ConstraintReferential ref = new ConstraintReferential(getSchema(), id, name, table);
ref.setColumns(columns); ref.setColumns(columns);
ref.setIndex(index, isOwner); ref.setIndex(index, isOwner);
...@@ -186,7 +187,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -186,7 +187,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
indexType.setBelongsToConstraint(true); indexType.setBelongsToConstraint(true);
String prefix = constraintName == null ? "CONSTRAINT" : constraintName; String prefix = constraintName == null ? "CONSTRAINT" : constraintName;
String indexName = getSchema().getUniqueIndexName(prefix + "_INDEX_"); String indexName = getSchema().getUniqueIndexName(t, prefix + "_INDEX_");
IndexColumn[] idxCols = IndexColumn.wrap(cols); IndexColumn[] idxCols = IndexColumn.wrap(cols);
return t.addIndex(session, indexName, indexId, idxCols, indexType, Index.EMPTY_HEAD, null); return t.addIndex(session, indexName, indexId, idxCols, indexType, Index.EMPTY_HEAD, null);
} }
......
...@@ -70,7 +70,7 @@ public class CreateIndex extends SchemaCommand { ...@@ -70,7 +70,7 @@ public class CreateIndex extends SchemaCommand {
} }
int id = getObjectId(true, false); int id = getObjectId(true, false);
if (indexName == null) { if (indexName == null) {
indexName = getSchema().getUniqueIndexName("INDEX_"); indexName = getSchema().getUniqueIndexName(table, "INDEX_");
} }
if (getSchema().findIndex(indexName) != null) { if (getSchema().findIndex(indexName) != null) {
if (ifNotExists) { if (ifNotExists) {
......
...@@ -56,7 +56,8 @@ import org.h2.constant.SysProperties; ...@@ -56,7 +56,8 @@ import org.h2.constant.SysProperties;
* - Make sure the build files are removed * - Make sure the build files are removed
* - ant zip * - ant zip
* - Windows installer (nsis) * - Windows installer (nsis)
* - Test * - Test Console
* - Test all languages
* - Test the windows service * - Test the windows service
* - Scan for viruses * - Scan for viruses
* - ant mavenDeployCentral * - ant mavenDeployCentral
......
...@@ -33,7 +33,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -33,7 +33,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// final static int MAX_PAGE_SIZE = 256; // final static int MAX_PAGE_SIZE = 256;
private Storage storage; private Storage storage;
private BtreePage root; private BtreePage rootPage;
private TableData tableData; private TableData tableData;
private BtreeHead head; private BtreeHead head;
private boolean needRebuild; private boolean needRebuild;
...@@ -57,7 +57,8 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -57,7 +57,8 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
head = (BtreeHead) rec; head = (BtreeHead) rec;
} }
if (head != null && head.getConsistent()) { if (head != null && head.getConsistent()) {
setRoot((BtreePage) storage.getRecord(session, head.getRootPosition())); int testing;
// setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
needRebuild = false; needRebuild = false;
rowCount = table.getRowCount(session); rowCount = table.getRowCount(session);
} else { } else {
...@@ -67,12 +68,20 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -67,12 +68,20 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
} }
} }
private void setRoot(BtreePage newRoot) { private BtreePage getRoot(Session session) throws SQLException {
if (root != null) { if (rootPage == null) {
root.setRoot(false); setRoot((BtreePage) storage.getRecord(session, head.getRootPosition()));
}
return rootPage;
}
private BtreePage setRoot(BtreePage newRoot) {
if (rootPage != null) {
rootPage.setRoot(false);
} }
newRoot.setRoot(true); newRoot.setRoot(true);
root = newRoot; rootPage = newRoot;
return rootPage;
} }
public int getHeadPos() { public int getHeadPos() {
...@@ -151,12 +160,13 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -151,12 +160,13 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
Value v = r.getValue(idx); Value v = r.getValue(idx);
row.setValue(idx, v); row.setValue(idx, v);
} }
BtreePage root = getRoot(session);
int splitPoint = root.add(row, session); int splitPoint = root.add(row, session);
if (splitPoint != 0) { if (splitPoint != 0) {
SearchRow pivot = root.getData(splitPoint); SearchRow pivot = root.getData(splitPoint);
BtreePage page1 = root; BtreePage page1 = root;
BtreePage page2 = root.split(session, splitPoint); BtreePage page2 = root.split(session, splitPoint);
setRoot(new BtreeNode(this, page1, pivot, page2)); root = setRoot(new BtreeNode(this, page1, pivot, page2));
addPage(session, root); addPage(session, root);
deletePage(session, head); deletePage(session, head);
head.setRootPosition(root.getPos()); head.setRootPosition(root.getPos());
...@@ -171,6 +181,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -171,6 +181,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
// TODO performance: maybe improve truncate performance in this case // TODO performance: maybe improve truncate performance in this case
truncate(session); truncate(session);
} else { } else {
BtreePage root = getRoot(session);
root.remove(session, row, 0); root.remove(session, row, 0);
rowCount--; rowCount--;
} }
...@@ -180,6 +191,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -180,6 +191,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
if (SysProperties.CHECK && storage == null) { if (SysProperties.CHECK && storage == null) {
throw Message.getSQLException(ErrorCode.OBJECT_CLOSED); throw Message.getSQLException(ErrorCode.OBJECT_CLOSED);
} }
BtreePage root = getRoot(session);
if (first == null) { if (first == null) {
BtreeCursor cursor = new BtreeCursor(session, this, last); BtreeCursor cursor = new BtreeCursor(session, this, last);
root.first(cursor); root.first(cursor);
...@@ -257,7 +269,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -257,7 +269,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
storage.truncate(session); storage.truncate(session);
head = new BtreeHead(); head = new BtreeHead();
addPage(session, head); addPage(session, head);
setRoot(new BtreeLeaf(this, new ObjectArray())); BtreePage root = setRoot(new BtreeLeaf(this, new ObjectArray()));
addPage(session, root); addPage(session, root);
deletePage(session, head); deletePage(session, head);
head.setRootPosition(root.getPos()); head.setRootPosition(root.getPos());
...@@ -301,7 +313,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader { ...@@ -301,7 +313,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
} }
return null; return null;
} else { } else {
return root.getLast(session); return getRoot(session).getLast(session);
} }
} }
......
...@@ -839,7 +839,8 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -839,7 +839,8 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
* Sets the value of a parameter as an input stream. * Sets the value of a parameter as an input stream.
* *
* @param parameterIndex the parameter index (1, 2, ...) * @param parameterIndex the parameter index (1, 2, ...)
* @param x the value * @throws SQLException if this object is closed * @param x the value
* @throws SQLException if this object is closed
*/ */
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
setBinaryStream(parameterIndex, x, -1); setBinaryStream(parameterIndex, x, -1);
......
...@@ -24,6 +24,14 @@ import java.util.Calendar; ...@@ -24,6 +24,14 @@ import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
//#ifdef JDK16
/*
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
*/
//#endif
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.engine.Constants; import org.h2.engine.Constants;
...@@ -2668,7 +2676,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2668,7 +2676,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Detects if the row was updated (by somebody else or the caller). * Detects if the row was updated (by somebody else or the caller).
* *
* @return false because this driver does detect this * @return false because this driver does not detect this
*/ */
public boolean rowUpdated() throws SQLException { public boolean rowUpdated() throws SQLException {
try { try {
...@@ -2682,7 +2690,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2682,7 +2690,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Detects if the row was inserted. * Detects if the row was inserted.
* *
* @return false because this driver does detect this * @return false because this driver does not detect this
*/ */
public boolean rowInserted() throws SQLException { public boolean rowInserted() throws SQLException {
try { try {
...@@ -2696,7 +2704,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2696,7 +2704,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Detects if the row was deleted (by somebody else or the caller). * Detects if the row was deleted (by somebody else or the caller).
* *
* @return false because this driver does detect this * @return false because this driver does not detect this
*/ */
public boolean rowDeleted() throws SQLException { public boolean rowDeleted() throws SQLException {
try { try {
...@@ -2928,10 +2936,6 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2928,10 +2936,6 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
return super.getTraceId(); return super.getTraceId();
} }
JdbcConnection getConnection() {
return conn;
}
private boolean nextRow() throws SQLException { private boolean nextRow() throws SQLException {
boolean next = result.next(); boolean next = result.next();
if (!next && !scrollable) { if (!next && !scrollable) {
......
...@@ -6,6 +6,7 @@ package org.h2.schema; ...@@ -6,6 +6,7 @@ package org.h2.schema;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import org.h2.constant.ErrorCode; import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties; import org.h2.constant.SysProperties;
import org.h2.constraint.Constraint; import org.h2.constraint.Constraint;
...@@ -185,7 +186,15 @@ public class Schema extends DbObjectBase { ...@@ -185,7 +186,15 @@ public class Schema extends DbObjectBase {
return (Constant) constants.get(constantName); return (Constant) constants.get(constantName);
} }
private String getUniqueName(HashMap map, String prefix) { private String getUniqueName(DbObject obj, HashMap map, String prefix) {
String hash = Integer.toHexString(obj.getName().hashCode()).toUpperCase();
for (int i = 1; i < hash.length(); i++) {
String name = prefix + hash.substring(0, i);
if (map.get(name) == null) {
return name;
}
}
prefix = prefix + hash + "_";
for (int i = 0;; i++) { for (int i = 0;; i++) {
String name = prefix + i; String name = prefix + i;
if (map.get(name) == null) { if (map.get(name) == null) {
...@@ -194,12 +203,12 @@ public class Schema extends DbObjectBase { ...@@ -194,12 +203,12 @@ public class Schema extends DbObjectBase {
} }
} }
public String getUniqueConstraintName() { public String getUniqueConstraintName(DbObject obj) {
return getUniqueName(constraints, "CONSTRAINT_"); return getUniqueName(obj, constraints, "CONSTRAINT_");
} }
public String getUniqueIndexName(String prefix) { public String getUniqueIndexName(DbObject obj, String prefix) {
return getUniqueName(indexes, prefix); return getUniqueName(obj, indexes, prefix);
} }
public Table getTableOrView(Session session, String name) throws SQLException { public Table getTableOrView(Session session, String name) throws SQLException {
......
...@@ -70,7 +70,7 @@ public class WebServer implements Service { ...@@ -70,7 +70,7 @@ public class WebServer implements Service {
"Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa", "Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa",
"Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc:db2://<host>/<db>|" , "Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc:db2://<host>/<db>|" ,
"Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc:oracle:thin:@<host>:1521:<instance>|scott" , "Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc:oracle:thin:@<host>:1521:<instance>|scott" ,
"Generic MS SQL Server|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:Microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa", "Generic MS SQL Server 2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sqlexpress|sa",
"Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc:sqlserver://localhost;DatabaseName=test|sa", "Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc:sqlserver://localhost;DatabaseName=test|sa",
"Generic PostgreSQL|org.postgresql.Driver|jdbc:postgresql:<db>|" , "Generic PostgreSQL|org.postgresql.Driver|jdbc:postgresql:<db>|" ,
"Generic MySQL|com.mysql.jdbc.Driver|jdbc:mysql://<host>:<port>/<db>|" , "Generic MySQL|com.mysql.jdbc.Driver|jdbc:mysql://<host>:<port>/<db>|" ,
......
...@@ -1429,7 +1429,8 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -1429,7 +1429,8 @@ class WebThread extends Thread implements DatabaseEventListener {
stat.close(); stat.close();
} }
return buff.toString(); return buff.toString();
} catch (Exception e) { } catch (Throwable e) {
// throwable: including OutOfMemoryError and so on
return getStackTrace(id, e); return getStackTrace(id, e);
} finally { } finally {
session.executingStatement = null; session.executingStatement = null;
......
<!-- can not use doctype --> <!-- can not use doctype -->
<!-- <!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group Initial Developer: H2 Group
--> -->
<html> <html>
...@@ -13,13 +13,14 @@ Initial Developer: H2 Group ...@@ -13,13 +13,14 @@ Initial Developer: H2 Group
var agent=navigator.userAgent.toLowerCase(); var agent=navigator.userAgent.toLowerCase();
var is_opera = agent.indexOf("opera") >= 0; var is_opera = agent.indexOf("opera") >= 0;
var autoComplete = 1; var autoComplete = 1; // 0: off, 1: normal, 2: full
var selectedRow = -1; var selectedRow = -1;
var lastList = ''; var lastList = '';
var lastQuery = null; var lastQuery = null;
var columnsByTable = new Object(); var columnsByTable = new Object();
var tableAliases = new Object(); var tableAliases = new Object();
var showAutoCompleteWait = 0; var showAutoCompleteWait = 0;
var autoCompleteManual = false;
var req; var req;
function refreshTables() { function refreshTables() {
...@@ -71,7 +72,7 @@ function splitSQL(s) { ...@@ -71,7 +72,7 @@ function splitSQL(s) {
function help() { function help() {
var input = document.h2query.sql; var input = document.h2query.sql;
setSelection(input); setSelection(input);
var pos = input.selectionStart; var pos = input.selectionStart;
if(pos > 0) { if(pos > 0) {
var s = input.value.substring(0, pos).toUpperCase(); var s = input.value.substring(0, pos).toUpperCase();
var e = pos-1; var e = pos-1;
...@@ -108,7 +109,7 @@ function setSelection(element) { ...@@ -108,7 +109,7 @@ function setSelection(element) {
} catch (e) { } catch (e) {
element.selectionEnd = element.selectionStart = 0; element.selectionEnd = element.selectionStart = 0;
} }
} }
} }
function set(field, combo) { function set(field, combo) {
...@@ -172,13 +173,6 @@ function insertText(s, isTable) { ...@@ -172,13 +173,6 @@ function insertText(s, isTable) {
field.focus(); field.focus();
} }
function keyUp() {
if(autoComplete != 0) {
showAutoComplete();
}
return true;
}
function showAutoComplete() { function showAutoComplete() {
if(showAutoCompleteWait==0) { if(showAutoCompleteWait==0) {
showAutoCompleteWait=5; showAutoCompleteWait=5;
...@@ -206,24 +200,32 @@ function keyDown(event) { ...@@ -206,24 +200,32 @@ function keyDown(event) {
return false; return false;
} }
if (key == 13 && event.ctrlKey) { if (key == 13 && event.ctrlKey) {
// ctrl + return
document.h2query.submit(); document.h2query.submit();
return false; return false;
} else if(key == 32 && event.ctrlKey) { } else if(key == 32 && event.ctrlKey) {
showAutoComplete(); // ctrl + space
autoCompleteManual = true;
lastQuery = null;
lastList = '';
showAutoCompleteNow();
return false; return false;
} else if(key == 190 && autoComplete==0) { } else if(key == 190 && autoComplete==0) {
// dot
help(); help();
return true; return true;
} }
var table = getAutoCompleteTable(); var table = getAutoCompleteTable();
if(table.rows.length > 0) { if(table.rows.length > 0) {
if(key == 27) { if(key == 27) {
// escape
while(table.rows.length > 0) { while(table.rows.length > 0) {
table.deleteRow(0); table.deleteRow(0);
} }
showOutput(''); showOutput('');
return false; return false;
} else if((key == 13 && !event.shiftKey) || (key==9 && !event.shiftKey)) { } else if((key == 13 && !event.shiftKey) || (key==9 && !event.shiftKey)) {
// enter or tab
if(table.rows.length > selectedRow) { if(table.rows.length > selectedRow) {
var row = table.rows[selectedRow]; var row = table.rows[selectedRow];
if(row.cells.length>1) { if(row.cells.length>1) {
...@@ -231,31 +233,44 @@ function keyDown(event) { ...@@ -231,31 +233,44 @@ function keyDown(event) {
} }
if(autoComplete == 0) { if(autoComplete == 0) {
setAutoComplete(0); setAutoComplete(0);
} }
return false; return false;
} }
} else if(key == 38 && !event.shiftKey) { } else if(key == 38 && !event.shiftKey) {
if(table.rows.length > selectedRow) { // up
if(table.rows.length > selectedRow) {
selectedRow = selectedRow <= 0 ? table.rows.length-1 : selectedRow-1; selectedRow = selectedRow <= 0 ? table.rows.length-1 : selectedRow-1;
highlightRow(selectedRow); highlightRow(selectedRow);
} }
return false; return false;
} else if(key == 40 && !event.shiftKey) { } else if(key == 40 && !event.shiftKey) {
if(table.rows.length > selectedRow) { // down
if(table.rows.length > selectedRow) {
selectedRow = selectedRow >= table.rows.length-1 ? 0 : selectedRow+1; selectedRow = selectedRow >= table.rows.length-1 ? 0 : selectedRow+1;
highlightRow(selectedRow); highlightRow(selectedRow);
} }
return false; return false;
} }
} }
return true; return true;
// alert('key:' + key); // alert('key:' + key);
// bs:8 ret:13 lt:37 up:38 rt:39 dn:40 tab:9 // bs:8 ret:13 lt:37 up:38 rt:39 dn:40 tab:9
// pgup:33 pgdn:34 home:36 end:35 del:46 shift:16 // pgup:33 pgdn:34 home:36 end:35 del:46 shift:16
// ctrl,alt gr:17 alt:18 caps:20 5(num):12 ins:45 // ctrl, alt gr:17 alt:18 caps:20 5(num):12 ins:45
// pause:19 f1..13:112..123 win-start:91 win-ctx:93 esc:27 // pause:19 f1..13:112..123 win-start:91 win-ctx:93 esc:27
} }
function keyUp(event) {
if(autoComplete != 0) {
var key=event == null ? 0 : (event.keyCode? event.keyCode : event.charCode);
if(key != 37 && key != 38 && key != 39 && key != 40) {
// left, right, up, down: don't show autocomplete
showAutoComplete();
}
}
return true;
}
function setAutoComplete(value) { function setAutoComplete(value) {
autoComplete = value; autoComplete = value;
if(value != 1) { if(value != 1) {
...@@ -325,7 +340,7 @@ function showList(s) { ...@@ -325,7 +340,7 @@ function showList(s) {
for(var i=0; list != null && i<list.length; i++) { for(var i=0; list != null && i<list.length; i++) {
var kv = list[i].split('#'); var kv = list[i].split('#');
var type = kv[0]; var type = kv[0];
if(type > 0 && autoComplete != 2) { if(type > 0 && autoComplete != 2 && !autoCompleteManual) {
continue; continue;
} }
var row = doc.createElement("tr"); var row = doc.createElement("tr");
...@@ -354,7 +369,7 @@ function showList(s) { ...@@ -354,7 +369,7 @@ function showList(s) {
cell = doc.createElement("td"); cell = doc.createElement("td");
cell.style.display='none'; cell.style.display='none';
text = doc.createTextNode(value); text = doc.createTextNode(value);
cell.appendChild(text); cell.appendChild(text);
row.appendChild(cell); row.appendChild(cell);
} }
if(count > 0) { if(count > 0) {
...@@ -365,6 +380,7 @@ function showList(s) { ...@@ -365,6 +380,7 @@ function showList(s) {
} }
// scroll to the top left // scroll to the top left
top.h2result.scrollTo(0, 0); top.h2result.scrollTo(0, 0);
autoCompleteManual = false;
} }
function retrieveList(s) { function retrieveList(s) {
...@@ -436,7 +452,7 @@ function processAsyncResponse() { ...@@ -436,7 +452,7 @@ function processAsyncResponse() {
<div style="display:none"> <div style="display:none">
<iframe id="h2iframeTransport" src="" onload="showList(this.contentWindow.document.body.innerHTML);"></iframe> <iframe id="h2iframeTransport" src="" onload="showList(this.contentWindow.document.body.innerHTML);"></iframe>
</div> </div>
<textarea id="sql" name="sql" cols="80" rows="5" onkeydown="return keyDown(event)" onkeyup="return keyUp()" <textarea id="sql" name="sql" cols="80" rows="5" onkeydown="return keyDown(event)" onkeyup="return keyUp(event)"
onfocus="keyUp()" onchange="return keyUp()">${query}</textarea> onfocus="keyUp()" onchange="return keyUp()">${query}</textarea>
</form> </form>
</body> </body>
......
...@@ -35,8 +35,8 @@ import org.h2.util.MathUtils; ...@@ -35,8 +35,8 @@ import org.h2.util.MathUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
/** /**
* This class represents a file that is usually written to disk. * This class represents a file that is usually written to disk.
* The two main files are .data.db and .index.db. * The two main files are .data.db and .index.db.
* For each such file, a number of {@link Storage} objects exists. * For each such file, a number of {@link Storage} objects exists.
* The disk file is responsible for caching; each object contains a {@link Cache} object. * The disk file is responsible for caching; each object contains a {@link Cache} object.
* Changes in the file are logged in a {@link LogSystem} object. * Changes in the file are logged in a {@link LogSystem} object.
...@@ -277,7 +277,7 @@ public class DiskFile implements CacheWriter { ...@@ -277,7 +277,7 @@ public class DiskFile implements CacheWriter {
} }
} }
} }
public void init() throws SQLException { public void init() throws SQLException {
synchronized (database) { synchronized (database) {
...@@ -351,6 +351,33 @@ public class DiskFile implements CacheWriter { ...@@ -351,6 +351,33 @@ public class DiskFile implements CacheWriter {
} }
} }
public void flushNew() throws SQLException {
int todoTest;
synchronized (database) {
database.checkPowerOff();
ObjectArray list = cache.getAllChanged();
CacheObject.sort(list);
int deletePos = deleted.nextSetBit(0);
int writeIndex = 0;
Record writeRecord = null;
while (true) {
if (writeRecord == null && writeIndex < list.size()) {
writeRecord = (Record) list.get(writeIndex++);
}
if (writeRecord != null && (deletePos < 0 || writeRecord.getPos() < deletePos)) {
writeBack(writeRecord);
writeRecord = null;
} else if (deletePos < fileBlockCount && deletePos >= 0) {
writeDirectDeleted(deletePos, 1);
deleted.clear(deletePos);
deletePos = deleted.nextSetBit(deletePos);
} else {
break;
}
}
}
}
public void close() throws SQLException { public void close() throws SQLException {
synchronized (database) { synchronized (database) {
SQLException closeException = null; SQLException closeException = null;
...@@ -888,8 +915,6 @@ public class DiskFile implements CacheWriter { ...@@ -888,8 +915,6 @@ public class DiskFile implements CacheWriter {
if (last != null && last.data != null) { if (last != null && last.data != null) {
writeRedoLog(last); writeRedoLog(last);
} }
redoBuffer.clear(); redoBuffer.clear();
redoBufferSize = 0; redoBufferSize = 0;
} }
...@@ -917,4 +942,8 @@ public class DiskFile implements CacheWriter { ...@@ -917,4 +942,8 @@ public class DiskFile implements CacheWriter {
} }
} }
public String toString() {
return getClass().getName() + ":" + fileName;
}
} }
...@@ -36,7 +36,7 @@ public class FileSystemDisk extends FileSystem { ...@@ -36,7 +36,7 @@ public class FileSystemDisk extends FileSystem {
return INSTANCE; return INSTANCE;
} }
private FileSystemDisk() { protected FileSystemDisk() {
} }
public long length(String fileName) { public long length(String fileName) {
......
...@@ -143,7 +143,7 @@ public class TableData extends Table implements RecordReader { ...@@ -143,7 +143,7 @@ public class TableData extends Table implements RecordReader {
public Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType, public Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType,
int headPos, String indexComment) throws SQLException { int headPos, String indexComment) throws SQLException {
if (indexType.isPrimaryKey()) { if (indexType.isPrimaryKey()) {
indexName = getSchema().getUniqueIndexName(Constants.PRIMARY_KEY_PREFIX); indexName = getSchema().getUniqueIndexName(this, Constants.PRIMARY_KEY_PREFIX);
for (int i = 0; i < cols.length; i++) { for (int i = 0; i < cols.length; i++) {
Column column = cols[i].column; Column column = cols[i].column;
if (column.getNullable()) { if (column.getNullable()) {
......
...@@ -152,24 +152,17 @@ java org.h2.test.TestAll timer ...@@ -152,24 +152,17 @@ java org.h2.test.TestAll timer
/* /*
History: History:
The performance has been improved for ResultSet methods with column name. The Ukrainian translation was not working in the last release. Fixed.
The method Trigger.init has been changed: the parameters 'before' and 'type', have been added to the init method. Creating many tables (many hundreds) was slow. Fixed.
Opening a database with many indexes (thousands) was slow. Fixed.
C:\temp\test\db
No more
@author
autocomplete only just after meaningful key (ctrl+space, space, bs, ...) C:\temp\test\db
write more tests for the command line tools
Known Problems: Web site:
link to history page, bug page link to history page, bug page
Add a link to the google code bug page Add a link to the google code bug page
implement & test: checkpoint commits running transactions
test DbStarter test DbStarter
---- ----
...@@ -203,8 +196,6 @@ shrink newsletter list (migrate to google groups) ...@@ -203,8 +196,6 @@ shrink newsletter list (migrate to google groups)
don't create @~ of not translated don't create @~ of not translated
test performance and document fulltext search
clustered tables: test, document clustered tables: test, document
extend tests that simulate power off extend tests that simulate power off
...@@ -297,6 +288,7 @@ Features of H2 ...@@ -297,6 +288,7 @@ Features of H2
if (args.length > 0) { if (args.length > 0) {
if ("crash".equals(args[0])) { if ("crash".equals(args[0])) {
test.endless = true;
new TestCrashAPI().runTest(test); new TestCrashAPI().runTest(test);
} else if ("synth".equals(args[0])) { } else if ("synth".equals(args[0])) {
new TestSynth().runTest(test); new TestSynth().runTest(test);
...@@ -620,6 +612,7 @@ Features of H2 ...@@ -620,6 +612,7 @@ Features of H2
new TestMVCC().runTest(this); new TestMVCC().runTest(this);
// synthetic // synthetic
new TestCrashAPI().runTest(this);
new TestRandomSQL().runTest(this); new TestRandomSQL().runTest(this);
new TestKillRestart().runTest(this); new TestKillRestart().runTest(this);
......
/* /*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html). * Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group * Initial Developer: H2 Group
*/ */
package org.h2.test; package org.h2.test;
...@@ -52,6 +52,9 @@ public abstract class TestBase { ...@@ -52,6 +52,9 @@ public abstract class TestBase {
} }
public void runTest(TestAll conf) { public void runTest(TestAll conf) {
if (conf.networked) {
return;
}
try { try {
init(conf); init(conf);
start = System.currentTimeMillis(); start = System.currentTimeMillis();
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
package org.h2.test.db; package org.h2.test.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Statement; import java.sql.Statement;
import java.util.StringTokenizer;
import org.h2.test.TestBase; import org.h2.test.TestBase;
...@@ -17,17 +19,59 @@ public class TestFullText extends TestBase { ...@@ -17,17 +19,59 @@ public class TestFullText extends TestBase {
return; return;
} }
test(false); test(false);
testPerformance(false);
String luceneFullTextClassName = "org.h2.fulltext.FullTextLucene"; String luceneFullTextClassName = "org.h2.fulltext.FullTextLucene";
try { try {
Class.forName(luceneFullTextClassName); Class.forName(luceneFullTextClassName);
test(true); test(true);
testPerformance(true);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
this.println("Class not found, not tested: " + luceneFullTextClassName); println("Class not found, not tested: " + luceneFullTextClassName);
// ok // ok
} }
} }
private void testPerformance(boolean lucene) throws Exception {
deleteDb("fullText");
Connection conn = getConnection("fullText");
String prefix = lucene ? "FTL" : "FT";
Statement stat = conn.createStatement();
String className = lucene ? "FullTextLucene" : "FullText";
stat.execute("CREATE ALIAS IF NOT EXISTS " + prefix + "_INIT FOR \"org.h2.fulltext." + className + ".init\"");
stat.execute("CALL " + prefix + "_INIT()");
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST AS SELECT * FROM INFORMATION_SCHEMA.HELP");
stat.execute("ALTER TABLE TEST ALTER COLUMN ID INT NOT NULL");
stat.execute("CREATE PRIMARY KEY ON TEST(ID)");
long time = System.currentTimeMillis();
stat.execute("CALL " + prefix + "_CREATE_INDEX('PUBLIC', 'TEST', NULL)");
println("Create index " + prefix + ": " + (System.currentTimeMillis() - time) + " ms");
PreparedStatement prep = conn.prepareStatement("SELECT * FROM " + prefix + "_SEARCH(?, 0, 0)");
time = System.currentTimeMillis();
ResultSet rs = stat.executeQuery("SELECT TEXT FROM TEST");
int count = 0;
while (rs.next()) {
String text = rs.getString(1);
StringTokenizer tokenizer = new StringTokenizer(text, " ()[].,;:-+*/!?=<>{}#@'\"~$_%&|");
while (tokenizer.hasMoreTokens()) {
String word = tokenizer.nextToken();
if (word.length() < 10) {
continue;
}
prep.setString(1, word);
ResultSet rs2 = prep.executeQuery();
while (rs2.next()) {
rs2.getString(1);
count++;
}
}
}
println("Search " + prefix + ": " + (System.currentTimeMillis() - time) + " ms, count: " + count);
stat.execute("CALL " + prefix + "_DROP_ALL()");
conn.close();
}
private void test(boolean lucene) throws Exception { private void test(boolean lucene) throws Exception {
deleteDb("fullText"); deleteDb("fullText");
Connection conn = getConnection("fullText"); Connection conn = getConnection("fullText");
......
...@@ -578,7 +578,7 @@ public class TestMetaData extends TestBase { ...@@ -578,7 +578,7 @@ public class TestMetaData extends TestBase {
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", "" },
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "PRIMARY_KEY_1", { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "PRIMARY_KEY_2",
"" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" }, "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" },
{ catalog, Constants.SCHEMA_MAIN, "TEST", "TRUE", catalog, "IDX_TEXT_DEC", { catalog, Constants.SCHEMA_MAIN, "TEST", "TRUE", catalog, "IDX_TEXT_DEC",
"" + DatabaseMetaData.tableIndexOther, "1", "TEXT_V", "A", "0", "0", "" }, "" + DatabaseMetaData.tableIndexOther, "1", "TEXT_V", "A", "0", "0", "" },
...@@ -593,14 +593,14 @@ public class TestMetaData extends TestBase { ...@@ -593,14 +593,14 @@ public class TestMetaData extends TestBase {
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, Types.INTEGER }, 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_2", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } });
trace("getPrimaryKeys"); trace("getPrimaryKeys");
rs = meta.getPrimaryKeys(null, null, "TEST"); rs = meta.getPrimaryKeys(null, null, "TEST");
testResultSetMeta(rs, 6, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", testResultSetMeta(rs, 6, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ",
"PK_NAME" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, "PK_NAME" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT,
Types.VARCHAR }, null, null); Types.VARCHAR }, null, null);
testResultSetOrdered(rs, testResultSetOrdered(rs,
new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "ID", "1", "PRIMARY_KEY_1" }, }); new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "ID", "1", "PRIMARY_KEY_2" }, });
trace("getTables - using a wildcard"); trace("getTables - using a wildcard");
stat.executeUpdate("CREATE TABLE T_2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"); stat.executeUpdate("CREATE TABLE T_2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))");
stat.executeUpdate("CREATE TABLE TX2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))"); stat.executeUpdate("CREATE TABLE TX2(B INT,A VARCHAR(6),C INT,PRIMARY KEY(C,A,B))");
...@@ -719,21 +719,21 @@ public class TestMetaData extends TestBase { ...@@ -719,21 +719,21 @@ public class TestMetaData extends TestBase {
* null, * null,
* null * null
*/}, */},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3", { catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "1", "C", "A" /* "" + DatabaseMetaData.tableIndexOther, "1", "C", "A" /*
* , * ,
* null, * null,
* null, * null,
* null * null
*/}, */},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3", { catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "2", "A", "A" /* "" + DatabaseMetaData.tableIndexOther, "2", "A", "A" /*
* , * ,
* null, * null,
* null, * null,
* null * null
*/}, */},
{ catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_3", { catalog, Constants.SCHEMA_MAIN, "TX2", "FALSE", catalog, "PRIMARY_KEY_146",
"" + DatabaseMetaData.tableIndexOther, "3", "B", "A"/* "" + DatabaseMetaData.tableIndexOther, "3", "B", "A"/*
* , * ,
* null, * null,
...@@ -763,9 +763,9 @@ public class TestMetaData extends TestBase { ...@@ -763,9 +763,9 @@ public class TestMetaData extends TestBase {
*/}, }); */}, });
trace("getPrimaryKeys"); trace("getPrimaryKeys");
rs = meta.getPrimaryKeys(null, null, "T_2"); rs = meta.getPrimaryKeys(null, null, "T_2");
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "T_2", "A", "2", "PRIMARY_KEY_2" }, testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "T_2", "A", "2", "PRIMARY_KEY_14" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "B", "3", "PRIMARY_KEY_2" }, { catalog, Constants.SCHEMA_MAIN, "T_2", "B", "3", "PRIMARY_KEY_14" },
{ catalog, Constants.SCHEMA_MAIN, "T_2", "C", "1", "PRIMARY_KEY_2" }, }); { catalog, Constants.SCHEMA_MAIN, "T_2", "C", "1", "PRIMARY_KEY_14" }, });
stat.executeUpdate("DROP TABLE TX2"); stat.executeUpdate("DROP TABLE TX2");
stat.executeUpdate("DROP TABLE T_2"); stat.executeUpdate("DROP TABLE T_2");
stat.executeUpdate("CREATE TABLE PARENT(ID INT PRIMARY KEY)"); stat.executeUpdate("CREATE TABLE PARENT(ID INT PRIMARY KEY)");
......
...@@ -6,11 +6,16 @@ package org.h2.test.synth; ...@@ -6,11 +6,16 @@ package org.h2.test.synth;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.BatchUpdateException; import java.sql.BatchUpdateException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
...@@ -33,7 +38,8 @@ import org.h2.util.RandomUtils; ...@@ -33,7 +38,8 @@ import org.h2.util.RandomUtils;
*/ */
public class TestCrashAPI extends TestBase { public class TestCrashAPI extends TestBase {
public static final Class[] INTERFACES = { Connection.class, PreparedStatement.class, Statement.class, public static final Class[] INTERFACES = { Connection.class, PreparedStatement.class, Statement.class,
ResultSet.class, ResultSetMetaData.class, Savepoint.class }; ResultSet.class, ResultSetMetaData.class, Savepoint.class,
ParameterMetaData.class, Clob.class, Blob.class, Array.class, CallableStatement.class };
private ArrayList objects = new ArrayList(); private ArrayList objects = new ArrayList();
private HashMap classMethods = new HashMap(); private HashMap classMethods = new HashMap();
private RandomGen random = new RandomGen(null); private RandomGen random = new RandomGen(null);
...@@ -376,7 +382,8 @@ public class TestCrashAPI extends TestBase { ...@@ -376,7 +382,8 @@ public class TestCrashAPI extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
while (true) { int len = getSize(2, 6);
for (int i = 0; i < len; i++) {
int seed = RandomUtils.nextInt(Integer.MAX_VALUE); int seed = RandomUtils.nextInt(Integer.MAX_VALUE);
testCase(seed); testCase(seed);
deleteDb(); deleteDb();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论