提交 4fc52e91 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 9d35faf1
...@@ -108,10 +108,10 @@ That is not easy to say. It is still a quite new product. A lot of tests have be ...@@ -108,10 +108,10 @@ That is not easy to say. It is still a quite new product. A lot of tests have be
and the code coverage of these tests is very high. Randomized stress tests and the code coverage of these tests is very high. Randomized stress tests
are run regularly. But as this is a relatively new product, there are probably are run regularly. But as this is a relatively new product, there are probably
some problems that have not yet been found. some problems that have not yet been found.
Areas that are not completely tested: Areas that are not 100% tested:
</p> </p>
<ul> <ul>
<li>Platforms other than Windows XP and the Sun JVM 1.4 <li>Platforms other than Windows XP and the Sun JVM 1.4 and 1.5
</li><li>Data types BLOB, CLOB, VARCHAR_IGNORECASE, OTHER </li><li>Data types BLOB, CLOB, VARCHAR_IGNORECASE, OTHER
</li><li>Cluster mode, 2-Phase Commit, Savepoints </li><li>Cluster mode, 2-Phase Commit, Savepoints
</li><li>Server mode (well tested, but not as well as Embedded mode) </li><li>Server mode (well tested, but not as well as Embedded mode)
......
...@@ -280,6 +280,9 @@ It looks like the development of this database has stopped. The last release was ...@@ -280,6 +280,9 @@ It looks like the development of this database has stopped. The last release was
</tr><tr> </tr><tr>
<td><a href="http://www.shellbook.com">Shellbook</a></td> <td><a href="http://www.shellbook.com">Shellbook</a></td>
<td>Desktop publishing application.</td> <td>Desktop publishing application.</td>
</tr><tr>
<td><a href="http://www.intellibo.com">Signsoft intelliBO</a></td>
<td>Persistence middleware supporting the JDO specification.</td>
</tr><tr> </tr><tr>
<td><a href="http://sql-workbench.net">SQL Workbench/J</a></td> <td><a href="http://sql-workbench.net">SQL Workbench/J</a></td>
<td>Free DBMS-independent SQL tool.</td> <td>Free DBMS-independent SQL tool.</td>
......
...@@ -162,7 +162,6 @@ public class Parser { ...@@ -162,7 +162,6 @@ public class Parser {
private boolean rightsChecked; private boolean rightsChecked;
private boolean recompileAlways; private boolean recompileAlways;
private ObjectArray indexedParameterList; private ObjectArray indexedParameterList;
private int tempViewId;
public Parser(Session session) { public Parser(Session session) {
this.session = session; this.session = session;
...@@ -741,8 +740,14 @@ public class Parser { ...@@ -741,8 +740,14 @@ public class Parser {
if(isToken("SELECT") || isToken("FROM")) { if(isToken("SELECT") || isToken("FROM")) {
Query query = parseQueryWithParams(); Query query = parseQueryWithParams();
String querySQL = query.getSQL(); String querySQL = query.getSQL();
int id = tempViewId++; String tempViewName = session.getNextTempViewName();
table = new TableView(mainSchema, 0, "TEMP_VIEW_" + id, querySQL, query.getParameters(), null, session, false); table = new TableView(mainSchema, 0, tempViewName, querySQL, query.getParameters(), null, session, false);
int testing;
table.setOnCommitDrop(true);
//this.recompileAlways = true;
session.addLocalTempTable(table);
read(")"); read(")");
} else { } else {
TableFilter top = readTableFilter(fromOuter); TableFilter top = readTableFilter(fromOuter);
......
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.command;
import org.h2.engine.Session;
public class ParserInt extends Parser {
public ParserInt(Session session) {
super(session);
}
}
...@@ -8,6 +8,7 @@ import java.sql.SQLException; ...@@ -8,6 +8,7 @@ import java.sql.SQLException;
import org.h2.command.Parser; import org.h2.command.Parser;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.Parameter; import org.h2.expression.Parameter;
...@@ -281,7 +282,12 @@ public class ConstraintReferential extends Constraint { ...@@ -281,7 +282,12 @@ public class ConstraintReferential extends Constraint {
private boolean found(Session session, Index index, SearchRow check) throws SQLException { private boolean found(Session session, Index index, SearchRow check) throws SQLException {
Cursor cursor = index.find(session, check, check); Cursor cursor = index.find(session, check, check);
while(cursor.next()) { while(cursor.next()) {
Row found = cursor.get(); SearchRow found;
if(Constants.INDEX_LOOKUP_NEW) {
found = cursor.getSearchRow();
} else {
found = cursor.get();
}
Column[] cols = index.getColumns(); Column[] cols = index.getColumns();
boolean allEqual = true; boolean allEqual = true;
for(int i=0; i<columns.length && i<cols.length; i++) { for(int i=0; i<columns.length && i<cols.length; i++) {
......
...@@ -18,13 +18,13 @@ package org.h2.engine; ...@@ -18,13 +18,13 @@ package org.h2.engine;
* - Compile with JDK 1.3, 1.4, 1.5 and 1.6: * - Compile with JDK 1.3, 1.4, 1.5 and 1.6:
* set path=C:\jdk1.3.1_19\bin;%PATH% * set path=C:\jdk1.3.1_19\bin;%PATH%
* set JAVA_HOME=C:\jdk1.3.1_19 * set JAVA_HOME=C:\jdk1.3.1_19
* ant codeswitch_jdk13 * ant codeswitchJdk13
* ant compile * ant compile
* set path=C:\Programme\Java\jdk1.6.0\bin;%PATH% * set path=C:\Programme\Java\jdk1.6.0\bin;%PATH%
* set JAVA_HOME=C:\Programme\Java\jdk1.6.0 * set JAVA_HOME=C:\Programme\Java\jdk1.6.0
* ant codeswitch_jdk16 * ant codeswitchJdk16
* ant compile * ant compile
* ant codeswitch_jdk14 * ant codeswitchJdk14
* *
* - Change FAQ (next release planned, known bugs) * - Change FAQ (next release planned, known bugs)
* - Check version, change build number in Constants.java and ant-build.properties * - Check version, change build number in Constants.java and ant-build.properties
...@@ -245,8 +245,9 @@ public class Constants { ...@@ -245,8 +245,9 @@ public class Constants {
public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096); public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = getIntSetting("h2.objectCacheMaxPerElementSize", 4096);
public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/"); public static final String CLIENT_TRACE_DIRECTORY = getStringSetting("h2.clientTraceDirectory", "trace.db/");
public static int MAX_FILE_RETRY = Math.max(1, getIntSetting("h2.maxFileRetry", 16)); public static int MAX_FILE_RETRY = Math.max(1, getIntSetting("h2.maxFileRetry", 16));
public static boolean INDEX_NEW = getBooleanSetting("h2.indexNew", false);
public static boolean LOB_CLOSE_BETWEEN_READS = getBooleanSetting("h2.lobCloseBetweenReads", false); public static boolean LOB_CLOSE_BETWEEN_READS = getBooleanSetting("h2.lobCloseBetweenReads", false);
public static boolean INDEX_OLD = getBooleanSetting("h2.indexOld", false);
public static final boolean INDEX_LOOKUP_NEW = getBooleanSetting("h2.indexLookupNew", true);
public static boolean getBooleanSetting(String name, boolean defaultValue) { public static boolean getBooleanSetting(String name, boolean defaultValue) {
String s = System.getProperty(name); String s = System.getProperty(name);
......
...@@ -832,6 +832,16 @@ public class Database implements DataHandler { ...@@ -832,6 +832,16 @@ public class Database implements DataHandler {
} }
private void closeOpenFilesAndUnlock() throws SQLException { private void closeOpenFilesAndUnlock() throws SQLException {
int testing;
if (persistent && lock == null && fileLockMethod != FileLock.LOCK_NO) {
// everything already closed (maybe in checkPowerOff)
// don't delete temp files in this case because
// the database could be open now (even from within another process)
System.out.println("lock = null!");
// return;
}
if (log != null) { if (log != null) {
stopWriter(); stopWriter();
log.close(); log.close();
...@@ -843,7 +853,7 @@ public class Database implements DataHandler { ...@@ -843,7 +853,7 @@ public class Database implements DataHandler {
systemSession.close(); systemSession.close();
systemSession = null; systemSession = null;
} }
if (lock != null) { if(lock != null) {
lock.unlock(); lock.unlock();
lock = null; lock = null;
} }
......
...@@ -60,6 +60,7 @@ public class Session implements SessionInterface { ...@@ -60,6 +60,7 @@ public class Session implements SessionInterface {
private String currentSchemaName; private String currentSchemaName;
private String traceModuleName; private String traceModuleName;
private HashSet unlinkSet; private HashSet unlinkSet;
private int tempViewIndex;
public Table findLocalTempTable(String name) { public Table findLocalTempTable(String name) {
Table t = null; Table t = null;
...@@ -89,7 +90,6 @@ public class Session implements SessionInterface { ...@@ -89,7 +90,6 @@ public class Session implements SessionInterface {
} }
public void addLocalTempTable(Table table) throws SQLException { public void addLocalTempTable(Table table) throws SQLException {
cleanTempTables(false);
if(localTempTables == null) { if(localTempTables == null) {
localTempTables = new HashMap(); localTempTables = new HashMap();
} }
...@@ -481,4 +481,8 @@ public class Session implements SessionInterface { ...@@ -481,4 +481,8 @@ public class Session implements SessionInterface {
} }
} }
public String getNextTempViewName() {
return "TEMP_VIEW_" + tempViewIndex++;
}
} }
...@@ -17,7 +17,8 @@ import org.h2.result.SearchRow; ...@@ -17,7 +17,8 @@ import org.h2.result.SearchRow;
public class BtreeCursor implements Cursor { public class BtreeCursor implements Cursor {
private BtreeIndex index; private BtreeIndex index;
private BtreePosition top; private BtreePosition top;
private Row current; private SearchRow currentSearchRow;
private Row currentRow;
private boolean first; private boolean first;
private SearchRow last; private SearchRow last;
...@@ -47,30 +48,39 @@ public class BtreeCursor implements Cursor { ...@@ -47,30 +48,39 @@ public class BtreeCursor implements Cursor {
return t; return t;
} }
void setCurrentRow(int pos) throws SQLException { void setCurrentRow(SearchRow searchRow) throws SQLException {
current = pos == POS_NO_ROW ? null : index.getRow(pos); this.currentSearchRow = searchRow;
currentRow = null;
} }
public Row get() throws SQLException { public Row get() throws SQLException {
return current; if(currentRow == null && currentSearchRow != null) {
currentRow = index.getRow(currentSearchRow.getPos());
}
return currentRow;
}
public SearchRow getSearchRow() throws SQLException {
return currentSearchRow;
} }
public int getPos() { public int getPos() {
return current.getPos(); return currentSearchRow.getPos();
} }
public boolean next() throws SQLException { public boolean next() throws SQLException {
if (first) { if (first) {
first = false; first = false;
return current != null; return currentSearchRow != null;
} }
top.page.next(this, top.position); top.page.next(this, top.position);
if(current != null && last != null) { if(currentSearchRow != null && last != null) {
if (index.compareRows(current, last) > 0) { if (index.compareRows(currentSearchRow, last) > 0) {
current = null; currentSearchRow = null;
currentRow = null;
} }
} }
return current != null; return currentSearchRow != null;
} }
} }
...@@ -183,7 +183,7 @@ public class BtreeIndex extends Index implements RecordReader { ...@@ -183,7 +183,7 @@ public class BtreeIndex extends Index implements RecordReader {
} else { } else {
BtreeCursor cursor = new BtreeCursor(this, last); BtreeCursor cursor = new BtreeCursor(this, last);
if (!root.findFirst(cursor, first)) { if (!root.findFirst(cursor, first)) {
cursor.setCurrentRow(Cursor.POS_NO_ROW); cursor.setCurrentRow(null);
} }
return cursor; return cursor;
} }
......
...@@ -160,7 +160,7 @@ public class BtreeLeaf extends BtreePage { ...@@ -160,7 +160,7 @@ public class BtreeLeaf extends BtreePage {
} }
cursor.push(this, l); cursor.push(this, l);
SearchRow row = (SearchRow) pageData.get(l); SearchRow row = (SearchRow) pageData.get(l);
cursor.setCurrentRow(row.getPos()); cursor.setCurrentRow(row);
return true; return true;
} }
...@@ -168,7 +168,7 @@ public class BtreeLeaf extends BtreePage { ...@@ -168,7 +168,7 @@ public class BtreeLeaf extends BtreePage {
i++; i++;
if (i < pageData.size()) { if (i < pageData.size()) {
SearchRow r = (SearchRow) pageData.get(i); SearchRow r = (SearchRow) pageData.get(i);
cursor.setCurrentRow(r.getPos()); cursor.setCurrentRow(r);
cursor.setStackPosition(i); cursor.setStackPosition(i);
return; return;
} }
...@@ -186,13 +186,13 @@ public class BtreeLeaf extends BtreePage { ...@@ -186,13 +186,13 @@ public class BtreeLeaf extends BtreePage {
} }
cursor.push(this, 0); cursor.push(this, 0);
SearchRow row = (SearchRow) pageData.get(0); SearchRow row = (SearchRow) pageData.get(0);
cursor.setCurrentRow(row.getPos()); cursor.setCurrentRow(row);
} }
private void nextUpper(BtreeCursor cursor) throws SQLException { private void nextUpper(BtreeCursor cursor) throws SQLException {
BtreePosition upper = cursor.pop(); BtreePosition upper = cursor.pop();
if (upper == null) { if (upper == null) {
cursor.setCurrentRow(Cursor.POS_NO_ROW); cursor.setCurrentRow(null);
} else { } else {
cursor.push(upper.page, upper.position); cursor.push(upper.page, upper.position);
upper.page.next(cursor, upper.position); upper.page.next(cursor, upper.position);
......
...@@ -268,7 +268,7 @@ public class BtreeNode extends BtreePage { ...@@ -268,7 +268,7 @@ public class BtreeNode extends BtreePage {
cursor.pop(); cursor.pop();
BtreePosition upper = cursor.pop(); BtreePosition upper = cursor.pop();
if (upper == null) { if (upper == null) {
cursor.setCurrentRow(Cursor.POS_NO_ROW); cursor.setCurrentRow(null);
} else { } else {
cursor.push(upper.page, upper.position); cursor.push(upper.page, upper.position);
upper.page.next(cursor, upper.position); upper.page.next(cursor, upper.position);
......
...@@ -7,6 +7,7 @@ package org.h2.index; ...@@ -7,6 +7,7 @@ package org.h2.index;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
public interface Cursor { public interface Cursor {
...@@ -14,6 +15,7 @@ public interface Cursor { ...@@ -14,6 +15,7 @@ public interface Cursor {
int POS_NO_ROW = -1; int POS_NO_ROW = -1;
Row get() throws SQLException; Row get() throws SQLException;
SearchRow getSearchRow() throws SQLException;
int getPos(); int getPos();
boolean next() throws SQLException; boolean next() throws SQLException;
......
...@@ -9,6 +9,7 @@ import java.sql.SQLException; ...@@ -9,6 +9,7 @@ import java.sql.SQLException;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
public class FunctionCursor implements Cursor { public class FunctionCursor implements Cursor {
...@@ -23,6 +24,10 @@ public class FunctionCursor implements Cursor { ...@@ -23,6 +24,10 @@ public class FunctionCursor implements Cursor {
return row; return row;
} }
public SearchRow getSearchRow() throws SQLException {
return row;
}
public int getPos() { public int getPos() {
throw Message.getInternalError(); throw Message.getInternalError();
} }
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
*/ */
package org.h2.index; package org.h2.index;
import java.sql.SQLException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
/** /**
* @author Thomas * @author Thomas
...@@ -21,6 +24,10 @@ public class HashCursor implements Cursor { ...@@ -21,6 +24,10 @@ public class HashCursor implements Cursor {
return row; return row;
} }
public SearchRow getSearchRow() throws SQLException {
return row;
}
public int getPos() { public int getPos() {
return row == null ? -1 : row.getPos(); return row == null ? -1 : row.getPos();
} }
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
*/ */
package org.h2.index; package org.h2.index;
import java.sql.SQLException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
/** /**
* @author Thomas * @author Thomas
...@@ -21,6 +24,10 @@ public class LinearHashCursor implements Cursor { ...@@ -21,6 +24,10 @@ public class LinearHashCursor implements Cursor {
return row; return row;
} }
public SearchRow getSearchRow() throws SQLException {
return row;
}
public int getPos() { public int getPos() {
return row == null ? -1 : row.getPos(); return row == null ? -1 : row.getPos();
} }
......
...@@ -10,6 +10,7 @@ import java.sql.SQLException; ...@@ -10,6 +10,7 @@ import java.sql.SQLException;
import org.h2.engine.Session; import org.h2.engine.Session;
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.table.Column; import org.h2.table.Column;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.value.DataType; import org.h2.value.DataType;
...@@ -36,6 +37,10 @@ public class LinkedCursor implements Cursor { ...@@ -36,6 +37,10 @@ public class LinkedCursor implements Cursor {
return current; return current;
} }
public SearchRow getSearchRow() throws SQLException {
return current;
}
public int getPos() { public int getPos() {
throw Message.getInternalError(); throw Message.getInternalError();
} }
......
...@@ -8,6 +8,7 @@ import java.sql.SQLException; ...@@ -8,6 +8,7 @@ import java.sql.SQLException;
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.util.ObjectArray; import org.h2.util.ObjectArray;
...@@ -29,6 +30,10 @@ public class MetaCursor implements Cursor { ...@@ -29,6 +30,10 @@ public class MetaCursor implements Cursor {
return current; return current;
} }
public SearchRow getSearchRow() throws SQLException {
return current;
}
public int getPos() { public int getPos() {
throw Message.getInternalError(); throw Message.getInternalError();
} }
......
...@@ -8,6 +8,7 @@ import java.sql.SQLException; ...@@ -8,6 +8,7 @@ import java.sql.SQLException;
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.value.Value; import org.h2.value.Value;
import org.h2.value.ValueLong; import org.h2.value.ValueLong;
...@@ -28,6 +29,10 @@ public class RangeCursor implements Cursor { ...@@ -28,6 +29,10 @@ public class RangeCursor implements Cursor {
return currentRow; return currentRow;
} }
public SearchRow getSearchRow() throws SQLException {
return currentRow;
}
public int getPos() { public int getPos() {
throw Message.getInternalError(); throw Message.getInternalError();
} }
......
...@@ -7,6 +7,7 @@ package org.h2.index; ...@@ -7,6 +7,7 @@ package org.h2.index;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
/** /**
...@@ -25,6 +26,10 @@ public class ScanCursor implements Cursor { ...@@ -25,6 +26,10 @@ public class ScanCursor implements Cursor {
return row; return row;
} }
public SearchRow getSearchRow() {
return row;
}
public int getPos() { public int getPos() {
return row == null ? -1 : row.getPos(); return row == null ? -1 : row.getPos();
} }
......
...@@ -28,6 +28,10 @@ public class TreeCursor implements Cursor { ...@@ -28,6 +28,10 @@ public class TreeCursor implements Cursor {
return node == null ? null : node.row; return node == null ? null : node.row;
} }
public SearchRow getSearchRow() {
return get();
}
public int getPos() { public int getPos() {
return node == null ? -1 : node.row.getPos(); return node == null ? -1 : node.row.getPos();
} }
......
...@@ -9,6 +9,7 @@ import java.sql.SQLException; ...@@ -9,6 +9,7 @@ import java.sql.SQLException;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.result.SearchRow;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
...@@ -28,6 +29,10 @@ public class ViewCursor implements Cursor { ...@@ -28,6 +29,10 @@ public class ViewCursor implements Cursor {
return current; return current;
} }
public SearchRow getSearchRow() {
return current;
}
public int getPos() { public int getPos() {
throw Message.getInternalError(); throw Message.getInternalError();
} }
......
...@@ -1273,8 +1273,8 @@ A ...@@ -1273,8 +1273,8 @@ A
"Other Grammar","Quoted Name"," "Other Grammar","Quoted Name","
""anythingExceptDoubleQuote"" ""anythingExceptDoubleQuote""
"," ","
Quoted names are case sensitive, and can contain spaces. Quoted names are case sensitive, and can contain spaces. There is no maximum name length.
There is no maximum name length. Two double quotes can be used to create a single double quote inside an identifier.
"," ","
""FirstName"" ""FirstName""
" "
...@@ -1284,7 +1284,7 @@ There is no maximum name length. ...@@ -1284,7 +1284,7 @@ There is no maximum name length.
A string starts and ends with a single quote. A string starts and ends with a single quote.
Two single quotes can be used to create a single quote inside a string. Two single quotes can be used to create a single quote inside a string.
"," ","
'Jon''s car' 'John''s car'
" "
"Other Grammar","Int"," "Other Grammar","Int","
[- | +] digit [...] [- | +] digit [...]
......
...@@ -9,6 +9,7 @@ import org.h2.value.Value; ...@@ -9,6 +9,7 @@ import org.h2.value.Value;
public class SimpleRowValue implements SearchRow { public class SimpleRowValue implements SearchRow {
private int pos; private int pos;
private int index;
private int virtualColumnCount; private int virtualColumnCount;
private Value data; private Value data;
...@@ -22,14 +23,15 @@ public class SimpleRowValue implements SearchRow { ...@@ -22,14 +23,15 @@ public class SimpleRowValue implements SearchRow {
public int getPos() { public int getPos() {
return pos; return pos;
} }
public Value getValue(int index) { public Value getValue(int idx) {
return data; return idx == index ? data : null;
} }
public void setPos(int pos) { public void setPos(int pos) {
this.pos = pos; this.pos = pos;
} }
public void setValue(int idx, Value v) { public void setValue(int idx, Value v) {
index = idx;
data = v; data = v;
} }
......
...@@ -59,7 +59,6 @@ public class FileStore { ...@@ -59,7 +59,6 @@ public class FileStore {
this.mode = mode; this.mode = mode;
try { try {
FileUtils.createDirs(name); FileUtils.createDirs(name);
// File f = new File(name);
if(FileUtils.exists(name) && !FileUtils.canWrite(name)) { if(FileUtils.exists(name) && !FileUtils.canWrite(name)) {
mode = "r"; mode = "r";
this.mode = mode; this.mode = mode;
......
...@@ -247,11 +247,11 @@ public class Storage { ...@@ -247,11 +247,11 @@ public class Storage {
this.recordCount = recordCount; this.recordCount = recordCount;
} }
public void addPage(int i) { void addPage(int i) {
pages.addValueSorted(i); pages.addValueSorted(i);
} }
public void removePage(int i) { void removePage(int i) {
pages.removeValue(i); pages.removeValue(i);
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
*/ */
package org.h2.table; package org.h2.table;
import java.sql.SQLException;
import org.h2.command.dml.Select; import org.h2.command.dml.Select;
import org.h2.value.Value; import org.h2.value.Value;
...@@ -12,7 +14,7 @@ public interface ColumnResolver { ...@@ -12,7 +14,7 @@ public interface ColumnResolver {
String getTableAlias(); String getTableAlias();
Column[] getColumns(); Column[] getColumns();
String getSchemaName(); String getSchemaName();
Value getValue(Column column); Value getValue(Column column) throws SQLException;
TableFilter getTableFilter(); TableFilter getTableFilter();
Select getSelect(); Select getSelect();
......
...@@ -299,11 +299,13 @@ public abstract class Table extends SchemaObject { ...@@ -299,11 +299,13 @@ public abstract class Table extends SchemaObject {
} }
private void remove(ObjectArray list, DbObject obj) { private void remove(ObjectArray list, DbObject obj) {
if(list != null) {
int i = list.indexOf(obj); int i = list.indexOf(obj);
if(i>=0) { if(i>=0) {
list.remove(i); list.remove(i);
} }
} }
}
public void removeIndex(Index index) { public void removeIndex(Index index) {
ObjectArray indexes = getIndexes(); ObjectArray indexes = getIndexes();
......
...@@ -44,6 +44,7 @@ public class TableFilter implements ColumnResolver { ...@@ -44,6 +44,7 @@ public class TableFilter implements ColumnResolver {
// the complete join condition // the complete join condition
private Expression joinCondition; private Expression joinCondition;
private SearchRow currentSearchRow;
private Row current; private Row current;
private int state; private int state;
...@@ -244,7 +245,9 @@ public class TableFilter implements ColumnResolver { ...@@ -244,7 +245,9 @@ public class TableFilter implements ColumnResolver {
} else { } else {
scanCount++; scanCount++;
if(cursor.next()) { if(cursor.next()) {
current = cursor.get(); currentSearchRow = cursor.getSearchRow();
current = null;
// cursor.get();
state = FOUND; state = FOUND;
} else { } else {
state = AFTER_LAST; state = AFTER_LAST;
...@@ -255,6 +258,7 @@ public class TableFilter implements ColumnResolver { ...@@ -255,6 +258,7 @@ public class TableFilter implements ColumnResolver {
if(outerJoin && !foundOne) { if(outerJoin && !foundOne) {
state = NULL_ROW; state = NULL_ROW;
current = table.getNullRow(); current = table.getNullRow();
currentSearchRow = current;
} else { } else {
break; break;
} }
...@@ -296,13 +300,17 @@ public class TableFilter implements ColumnResolver { ...@@ -296,13 +300,17 @@ public class TableFilter implements ColumnResolver {
return Boolean.TRUE.equals(condition.getBooleanValue(session)); return Boolean.TRUE.equals(condition.getBooleanValue(session));
} }
public Row get() { public Row get() throws SQLException {
if(current == null && currentSearchRow != null) {
current = cursor.get();
}
return current; return current;
} }
public void set(Row current) { public void set(Row current) {
// this is currently only used so that check constraints work - to set the current (new) row // this is currently only used so that check constraints work - to set the current (new) row
this.current = current; this.current = current;
this.currentSearchRow = current;
} }
public String getTableAlias() { public String getTableAlias() {
...@@ -506,8 +514,30 @@ public class TableFilter implements ColumnResolver { ...@@ -506,8 +514,30 @@ public class TableFilter implements ColumnResolver {
return table.getColumns(); return table.getColumns();
} }
public Value getValue(Column column) { public Value getValue(Column column) throws SQLException {
return current == null ? null : current.getValue(column.getColumnId()); if(Constants.INDEX_LOOKUP_NEW) {
if(currentSearchRow == null) {
return null;
}
int columnId = column.getColumnId();
if(current == null) {
Value v = currentSearchRow.getValue(columnId);
if(v != null) {
return v;
}
current = cursor.get();
}
return current.getValue(columnId);
} else {
if(currentSearchRow == null) {
return null;
}
if(current == null) {
current = cursor.get();
}
int columnId = column.getColumnId();
return current.getValue(columnId);
}
} }
public TableFilter getTableFilter() { public TableFilter getTableFilter() {
......
...@@ -13,8 +13,8 @@ import org.h2.engine.Session; ...@@ -13,8 +13,8 @@ import org.h2.engine.Session;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.index.Index; import org.h2.index.Index;
import org.h2.index.IndexType; import org.h2.index.IndexType;
import org.h2.index.ViewIndexOld;
import org.h2.index.ViewIndex; import org.h2.index.ViewIndex;
import org.h2.index.ViewIndexNew;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.schema.Schema; import org.h2.schema.Schema;
...@@ -28,8 +28,8 @@ public class TableView extends Table { ...@@ -28,8 +28,8 @@ public class TableView extends Table {
private ObjectArray tables; private ObjectArray tables;
private String[] columnNames; private String[] columnNames;
private Query viewQuery; private Query viewQuery;
private ViewIndex indexOld; private ViewIndexOld indexOld;
private ViewIndexNew indexNew; private ViewIndex indexNew;
private boolean recursive; private boolean recursive;
private SQLException createException; private SQLException createException;
...@@ -39,10 +39,10 @@ public class TableView extends Table { ...@@ -39,10 +39,10 @@ public class TableView extends Table {
this.columnNames = columnNames; this.columnNames = columnNames;
this.recursive = recursive; this.recursive = recursive;
int todoRemoveIndexOld; int todoRemoveIndexOld;
if(Constants.INDEX_NEW) { if(Constants.INDEX_OLD) {
indexNew = new ViewIndexNew(this, querySQL, params, recursive); indexOld = new ViewIndexOld(this, querySQL, params, recursive);
} else { } else {
indexOld = new ViewIndex(this, querySQL, params, recursive); indexNew = new ViewIndex(this, querySQL, params, recursive);
} }
initColumnsAndTables(session); initColumnsAndTables(session);
} }
...@@ -95,10 +95,10 @@ public class TableView extends Table { ...@@ -95,10 +95,10 @@ public class TableView extends Table {
for(int i=0; i<columnNames.length; i++) { for(int i=0; i<columnNames.length; i++) {
cols[i] = new Column(columnNames[i], Value.STRING, 255, 0); cols[i] = new Column(columnNames[i], Value.STRING, 255, 0);
} }
if(Constants.INDEX_NEW) { if(Constants.INDEX_OLD) {
indexNew.setRecursive(true);
} else {
indexOld.setRecursive(true); indexOld.setRecursive(true);
} else {
indexNew.setRecursive(true);
} }
recursive = true; recursive = true;
createException = null; createException = null;
...@@ -115,12 +115,12 @@ public class TableView extends Table { ...@@ -115,12 +115,12 @@ public class TableView extends Table {
public PlanItem getBestPlanItem(Session session, int[] masks) throws SQLException { public PlanItem getBestPlanItem(Session session, int[] masks) throws SQLException {
PlanItem item = new PlanItem(); PlanItem item = new PlanItem();
Index i2; Index i2;
if(Constants.INDEX_NEW) { if(Constants.INDEX_OLD) {
item.cost = indexNew.getCost(session, masks);
i2 = new ViewIndexNew(this, indexNew, session, masks);
} else {
item.cost = indexOld.getCost(session, masks); item.cost = indexOld.getCost(session, masks);
i2 = new ViewIndex(this, indexOld, session, masks); i2 = new ViewIndexOld(this, indexOld, session, masks);
} else {
item.cost = indexNew.getCost(session, masks);
i2 = new ViewIndex(this, indexNew, session, masks);
} }
item.setIndex(i2); item.setIndex(i2);
return item; return item;
......
...@@ -132,10 +132,10 @@ public class FileUtils { ...@@ -132,10 +132,10 @@ public class FileUtils {
throw Message.getInternalError("rename file old=new"); throw Message.getInternalError("rename file old=new");
} }
if(!oldFile.exists()) { if(!oldFile.exists()) {
throw Message.getSQLException(Message.FILE_RENAME_FAILED_2, new String[]{oldName, newName}, null); throw Message.getSQLException(Message.FILE_RENAME_FAILED_2, new String[]{oldName + " (not found)", newName}, null);
} }
if(newFile.exists()) { if(newFile.exists()) {
throw Message.getSQLException(Message.FILE_RENAME_FAILED_2, new String[]{oldName, newName}, null); throw Message.getSQLException(Message.FILE_RENAME_FAILED_2, new String[]{oldName, newName + " (exists)"}, null);
} }
for(int i=0; i<Constants.MAX_FILE_RETRY; i++) { for(int i=0; i<Constants.MAX_FILE_RETRY; i++) {
boolean ok = oldFile.renameTo(newFile); boolean ok = oldFile.renameTo(newFile);
...@@ -401,20 +401,6 @@ public class FileUtils { ...@@ -401,20 +401,6 @@ public class FileUtils {
} catch (IOException e) { } catch (IOException e) {
throw Message.convertIOException(e, path); throw Message.convertIOException(e, path);
} }
// try {
// File[] files = new File(path).listFiles();
// if(files == null) {
// return new String[0];
// }
// String[] list = new String[files.length];
// for(int i=0; i<files.length; i++) {
// list[i] = files[i].getCanonicalPath();
// }
// return list;
// } catch (IOException e) {
// throw Message.convert(e);
// }
} }
public static boolean isDirectory(String fileName) { public static boolean isDirectory(String fileName) {
......
...@@ -96,25 +96,6 @@ public class ValueLob extends Value { ...@@ -96,25 +96,6 @@ public class ValueLob extends Value {
return new ValueLob(type, handler, fileName, tableId, objectId, true, precision, compression); return new ValueLob(type, handler, fileName, tableId, objectId, true, precision, compression);
} }
// public static ValueLob createClobFromReader(Reader in, long length) throws SQLException {
// try {
// String s = IOUtils.readStringAndClose(in, (int)length);
// byte[] buff = StringUtils.utf8Encode(s);
// return new ValueLob(CLOB, buff);
// } catch (IOException e) {
// throw Message.convert(e);
// }
// }
// public static ValueLob createBlobFromInputStream(InputStream in, long length) throws SQLException {
// try {
// byte[] buff = IOUtils.readBytesAndClose(in, (int)length);
// return new ValueLob(BLOB, buff);
// } catch (IOException e) {
// throw Message.convert(e);
// }
// }
public static ValueLob createClob(Reader in, long length, DataHandler handler) throws SQLException { public static ValueLob createClob(Reader in, long length, DataHandler handler) throws SQLException {
try { try {
boolean compress = handler.getLobCompressionAlgorithm(Value.CLOB) != null; boolean compress = handler.getLobCompressionAlgorithm(Value.CLOB) != null;
...@@ -533,11 +514,6 @@ public class ValueLob extends Value { ...@@ -533,11 +514,6 @@ public class ValueLob extends Value {
return small; return small;
} }
// public String getJavaString() {
// // TODO value: maybe use another trick (at least the size should be ok?)
// return StringUtils.quoteJavaString(getSQL());
// }
public int getDisplaySize() { public int getDisplaySize() {
// TODO display size of lob? // TODO display size of lob?
return 40; return 40;
......
...@@ -228,7 +228,7 @@ INSERT INTO ITEM VALUES(20, ...@@ -228,7 +228,7 @@ INSERT INTO ITEM VALUES(20,
<ul> <ul>
<li>The Console is now translated to Japanese thanks to <li>The Console is now translated to Japanese thanks to
IKEMOTO, Masahiro (ikeyan (at) arizona (dot) ne (dot) jp). IKEMOTO, Masahiro (ikeyan (at) arizona (dot) ne (dot) jp).
</li><li>The database engine can now be compiled with JDK 1.3 using ant codeswitch_jdk13. </li><li>The database engine can now be compiled with JDK 1.3 using ant codeswitch.
There are still some limitations, and the ant script to build the jar does not work yet. There are still some limitations, and the ant script to build the jar does not work yet.
</li><li>SCRIPT NODATA now writes the row count for each table. </li><li>SCRIPT NODATA now writes the row count for each table.
</li><li>Timestamps with timezone information (Z or +/-hh:mm) and dates before year 1 </li><li>Timestamps with timezone information (Z or +/-hh:mm) and dates before year 1
...@@ -273,7 +273,7 @@ INSERT INTO ITEM VALUES(19, ...@@ -273,7 +273,7 @@ INSERT INTO ITEM VALUES(19,
longer the application directory. This can be changed using the system longer the application directory. This can be changed using the system
property h2.clientTraceDirectory. property h2.clientTraceDirectory.
</li><li>Build: Now using ant-build.properties. The JDK is automatically updated </li><li>Build: Now using ant-build.properties. The JDK is automatically updated
when using ant codeswitch_... when using ant codeswitch...
</li><li>Cluster: Now the server can detect if a query is read-only, and in this </li><li>Cluster: Now the server can detect if a query is read-only, and in this
case the result is only read from the first cluster node. However, there case the result is only read from the first cluster node. However, there
is currently no load balancing made to avoid problems with transactions is currently no load balancing made to avoid problems with transactions
......
...@@ -93,6 +93,42 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2 ...@@ -93,6 +93,42 @@ java -Xmx512m -Xrunhprof:cpu=samples,depth=8 org.h2.tools.RunScript -url jdbc:h2
test.printSystem(); test.printSystem();
/* /*
create local temporary table a(id int) on commit drop;
select * from a;
create local temporary table b(id int) on commit drop;
select * from a;
select * from b;
commit;
dropping session temp views doesn't work, why?
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
select a.i from t1 a inner join (select a.i from t2 a inner join (select i from t3) b on a.i=b.i) b on a.i=b.i;
SELECT A.I FROM T2 A INNER JOIN TEMP_VIEW_0 B WHERE (A.I = B.I) AND (A.I = 1)
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
select a.i
from t1 a
inner join (
select a.i
from t2 a
inner join (
select i
from t3) b on a.i=b.i
) b on a.i=b.i;
Wre es nicht besser, unabhngig von DB_CLOSE_DELAY eine Datenbank offen
zu halten, solange dafr offene PooledConnections vorhanden sind?
Change documentation and default database for H2 Console: jdbc:h2:~/test
public static final boolean INDEX_LOOKUP_NEW = getBooleanSetting("h2.indexLookupNew", false);
"com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details." "com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details."
set new console to be the default (still support old) set new console to be the default (still support old)
......
...@@ -13,8 +13,8 @@ public class TestBigResult extends TestBase { ...@@ -13,8 +13,8 @@ public class TestBigResult extends TestBase {
if(config.memory) { if(config.memory) {
return; return;
} }
testLimitBufferedResult();
testOrderGroup(); testOrderGroup();
testLimitBufferedResult();
} }
private void testLimitBufferedResult() throws Exception { private void testLimitBufferedResult() throws Exception {
......
...@@ -35,23 +35,23 @@ public class TestLob extends TestBase { ...@@ -35,23 +35,23 @@ public class TestLob extends TestBase {
if(config.memory) { if(config.memory) {
return; return;
} }
testLobNoClose(); // testLobNoClose();
testLobTransactions(10); // testLobTransactions(10);
testLobTransactions(10000); testLobTransactions(10000);
testLobRollbackStop(); // testLobRollbackStop();
testLobCopy(); // testLobCopy();
testLobHibernate(); // testLobHibernate();
testLobCopy(false); // testLobCopy(false);
testLobCopy(true); // testLobCopy(true);
testLobCompression(false); // testLobCompression(false);
testLobCompression(true); // testLobCompression(true);
testManyLobs(); // testManyLobs();
testClob(); // testClob();
testUpdateLob(); // testUpdateLob();
testLobReconnect(); // testLobReconnect();
testLob(false); // testLob(false);
testLob(true); // testLob(true);
testJavaObject(); // testJavaObject();
} }
private void testLobNoClose() throws Exception { private void testLobNoClose() throws Exception {
...@@ -90,6 +90,9 @@ public class TestLob extends TestBase { ...@@ -90,6 +90,9 @@ public class TestLob extends TestBase {
if(config.logMode == 0) { if(config.logMode == 0) {
return; return;
} }
int testing;
Constants.LOB_CLOSE_BETWEEN_READS = true;
deleteDb("lob"); deleteDb("lob");
Connection conn = reconnect(null); Connection conn = reconnect(null);
conn.createStatement().execute("CREATE TABLE TEST(ID IDENTITY, DATA CLOB, DATA2 VARCHAR)"); conn.createStatement().execute("CREATE TABLE TEST(ID IDENTITY, DATA CLOB, DATA2 VARCHAR)");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论