提交 0be7f72f authored 作者: Thomas Mueller's avatar Thomas Mueller

Remove unused code.

上级 6e0619e9
...@@ -18,7 +18,8 @@ Change Log ...@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>The Windows service wrapper now detects if multiple versions of H2 are installed. <ul><li>The translated resources are now stored in UTF-8 format.
</li><li>The Windows service wrapper now detects if multiple versions of H2 are installed.
</li></ul> </li></ul>
<h2>Version 1.2.128 (2010-01-30)</h2> <h2>Version 1.2.128 (2010-01-30)</h2>
......
...@@ -20,16 +20,13 @@ import org.h2.engine.Constants; ...@@ -20,16 +20,13 @@ import org.h2.engine.Constants;
import org.h2.engine.Database; import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.log.LogFile;
import org.h2.log.LogSystem; import org.h2.log.LogSystem;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.store.DiskFile;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.store.PageStore; import org.h2.store.PageStore;
import org.h2.util.FileUtils; import org.h2.util.FileUtils;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.ObjectArray;
/** /**
* This class represents the statement * This class represents the statement
...@@ -65,33 +62,14 @@ public class BackupCommand extends Prepared { ...@@ -65,33 +62,14 @@ public class BackupCommand extends Prepared {
OutputStream zip = FileUtils.openFileOutputStream(fileName, false); OutputStream zip = FileUtils.openFileOutputStream(fileName, false);
ZipOutputStream out = new ZipOutputStream(zip); ZipOutputStream out = new ZipOutputStream(zip);
LogSystem log = db.getLog(); LogSystem log = db.getLog();
try {
log.flush(); log.flush();
log.updateKeepFiles(1);
String fn; String fn;
if (db.isPageStoreEnabled()) {
fn = db.getName() + Constants.SUFFIX_PAGE_FILE; fn = db.getName() + Constants.SUFFIX_PAGE_FILE;
backupPageStore(out, fn, db.getPageStore()); backupPageStore(out, fn, db.getPageStore());
} else {
fn = db.getName() + Constants.SUFFIX_DATA_FILE;
backupDiskFile(out, fn, db.getDataFile());
fn = db.getName() + Constants.SUFFIX_INDEX_FILE;
backupDiskFile(out, fn, db.getIndexFile());
}
// synchronize on the database, to avoid concurrent temp file // synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup // creation / deletion / backup
String base = FileUtils.getParent(fn); String base = FileUtils.getParent(fn);
synchronized (db.getLobSyncObject()) { synchronized (db.getLobSyncObject()) {
if (!db.isPageStoreEnabled()) {
ObjectArray<LogFile> list = log.getActiveLogFiles();
int max = list.size();
for (int i = 0; i < list.size(); i++) {
LogFile lf = list.get(i);
fn = lf.getFileName();
backupFile(out, base, fn);
db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, name, i, max);
}
}
String prefix = db.getDatabasePath(); String prefix = db.getDatabasePath();
String dir = FileUtils.getParent(prefix); String dir = FileUtils.getParent(prefix);
ArrayList<String> fileList = FileLister.getDatabaseFiles(dir, name, true); ArrayList<String> fileList = FileLister.getDatabaseFiles(dir, name, true);
...@@ -103,9 +81,6 @@ public class BackupCommand extends Prepared { ...@@ -103,9 +81,6 @@ public class BackupCommand extends Prepared {
} }
out.close(); out.close();
zip.close(); zip.close();
} finally {
log.updateKeepFiles(-1);
}
} catch (IOException e) { } catch (IOException e) {
throw Message.convertIOException(e, fileName); throw Message.convertIOException(e, fileName);
} }
...@@ -127,22 +102,6 @@ public class BackupCommand extends Prepared { ...@@ -127,22 +102,6 @@ public class BackupCommand extends Prepared {
out.closeEntry(); out.closeEntry();
} }
private void backupDiskFile(ZipOutputStream out, String fileName, DiskFile file) throws SQLException, IOException {
Database db = session.getDatabase();
fileName = FileUtils.getFileName(fileName);
out.putNextEntry(new ZipEntry(fileName));
int pos = -1;
int max = file.getReadCount();
while (true) {
pos = file.copyDirect(pos, out);
if (pos < 0) {
break;
}
db.setProgress(DatabaseEventListener.STATE_BACKUP_FILE, fileName, pos, max);
}
out.closeEntry();
}
private void backupFile(ZipOutputStream out, String base, String fn) throws IOException { private void backupFile(ZipOutputStream out, String base, String fn) throws IOException {
String f = FileUtils.getAbsolutePath(fn); String f = FileUtils.getAbsolutePath(fn);
base = FileUtils.getAbsolutePath(base); base = FileUtils.getAbsolutePath(base);
......
...@@ -74,7 +74,7 @@ public class Insert extends Prepared { ...@@ -74,7 +74,7 @@ public class Insert extends Prepared {
public int update() throws SQLException { public int update() throws SQLException {
Database db = session.getDatabase(); Database db = session.getDatabase();
PageIndex index = null; PageIndex index = null;
if (sortedInsertMode && db.isPageStoreEnabled() && db.isPersistent()) { if (sortedInsertMode && db.isPersistent()) {
index = (PageIndex) table.getScanIndex(session); index = (PageIndex) table.getScanIndex(session);
index.setSortedInsertMode(true); index.setSortedInsertMode(true);
} }
......
...@@ -247,8 +247,4 @@ public abstract class ScriptBase extends Prepared implements DataHandler { ...@@ -247,8 +247,4 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
return null; return null;
} }
public Trace getTrace() {
return session.getDatabase().getTrace(Trace.DATABASE);
}
} }
...@@ -182,9 +182,6 @@ public class TransactionCommand extends Prepared { ...@@ -182,9 +182,6 @@ public class TransactionCommand extends Prepared {
s.close(); s.close();
} }
} }
LogSystem log = db.getLog();
log.setDisabled(false);
log.checkpoint();
session.close(); session.close();
break; break;
} }
......
...@@ -28,22 +28,22 @@ public class SysProperties { ...@@ -28,22 +28,22 @@ public class SysProperties {
/** /**
* INTERNAL * INTERNAL
*/ */
public static final String H2_MAX_QUERY_TIMEOUT = "h2.maxQueryTimeout"; public static final String H2_SCRIPT_DIRECTORY = "h2.scriptDirectory";
/** /**
* INTERNAL * INTERNAL
*/ */
public static final String H2_LOG_DELETE_DELAY = "h2.logDeleteDelay"; public static final String H2_MAX_QUERY_TIMEOUT = "h2.maxQueryTimeout";
/** /**
* INTERNAL * INTERNAL
*/ */
public static final String H2_COLLATOR_CACHE_SIZE = "h2.collatorCacheSize"; public static final String H2_LOG_DELETE_DELAY = "h2.logDeleteDelay";
/** /**
* INTERNAL * INTERNAL
*/ */
public static final String H2_PAGE_STORE = "h2.pageStore"; public static final String H2_COLLATOR_CACHE_SIZE = "h2.collatorCacheSize";
/** /**
* System property <code>file.encoding</code> (default: Cp1252).<br /> * System property <code>file.encoding</code> (default: Cp1252).<br />
...@@ -554,17 +554,6 @@ public class SysProperties { ...@@ -554,17 +554,6 @@ public class SysProperties {
*/ */
public static final int PAGE_SIZE = getIntSetting("h2.pageSize", 2048); public static final int PAGE_SIZE = getIntSetting("h2.pageSize", 2048);
/**
* System property <code>h2.pageStore</code>.<br />
* Use the 'page store' database file format for new databases.
* <p>
* In version 1.1, it is disabled by default.
* </p><p>
* In version 1.2, it is enabled by default.
* </p>
*/
public static final boolean PAGE_STORE = getBooleanSetting(H2_PAGE_STORE, Constants.VERSION >= 1.2);
/** /**
* System property <code>h2.pageStoreTrim</code> (default: true).<br /> * System property <code>h2.pageStoreTrim</code> (default: true).<br />
* Trim the database size when closing. * Trim the database size when closing.
...@@ -798,14 +787,7 @@ public class SysProperties { ...@@ -798,14 +787,7 @@ public class SysProperties {
* read from. * read from.
*/ */
public static String getScriptDirectory() { public static String getScriptDirectory() {
return getStringSetting("h2.scriptDirectory", ""); return getStringSetting(H2_SCRIPT_DIRECTORY, "");
}
/**
* INTERNAL
*/
public static void setScriptDirectory(String dir) {
System.setProperty("h2.scriptDirectory", dir);
} }
/** /**
...@@ -829,11 +811,4 @@ public class SysProperties { ...@@ -829,11 +811,4 @@ public class SysProperties {
return getIntSetting(H2_COLLATOR_CACHE_SIZE, 32000); return getIntSetting(H2_COLLATOR_CACHE_SIZE, 32000);
} }
/**
* INTERNAL
*/
public static boolean getPageStore() {
return getBooleanSetting(H2_PAGE_STORE, PAGE_STORE);
}
} }
...@@ -81,7 +81,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -81,7 +81,7 @@ public class ConnectionInfo implements Cloneable {
String[] connectionTime = new String[] { "ACCESS_MODE_LOG", "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER", String[] connectionTime = new String[] { "ACCESS_MODE_LOG", "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "DB_CLOSE_ON_EXIT", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "IFEXISTS", "CREATE", "CACHE_TYPE", "DB_CLOSE_ON_EXIT", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "IFEXISTS",
"PASSWORD", "RECOVER", "USER", "DATABASE_EVENT_LISTENER_OBJECT", "AUTO_SERVER", "PASSWORD", "RECOVER", "USER", "DATABASE_EVENT_LISTENER_OBJECT", "AUTO_SERVER",
"AUTO_RECONNECT", "OPEN_NEW", "PAGE_STORE" }; "AUTO_RECONNECT", "OPEN_NEW" };
for (String key : connectionTime) { for (String key : connectionTime) {
if (SysProperties.CHECK && set.contains(key)) { if (SysProperties.CHECK && set.contains(key)) {
Message.throwInternalError(key); Message.throwInternalError(key);
...@@ -326,12 +326,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -326,12 +326,7 @@ public class ConnectionInfo implements Cloneable {
*/ */
String getName() throws SQLException { String getName() throws SQLException {
if (persistent) { if (persistent) {
String suffix; String suffix = Constants.SUFFIX_PAGE_FILE;
if (SysProperties.getPageStore()) {
suffix = Constants.SUFFIX_PAGE_FILE;
} else {
suffix = Constants.SUFFIX_DATA_FILE;
}
String n = FileUtils.normalize(name + suffix); String n = FileUtils.normalize(name + suffix);
String fileName = FileUtils.getFileName(n); String fileName = FileUtils.getFileName(n);
if (fileName.length() < suffix.length() + 1) { if (fileName.length() < suffix.length() + 1) {
......
...@@ -235,11 +235,6 @@ public class Constants { ...@@ -235,11 +235,6 @@ public class Constants {
*/ */
public static final int FILE_PAGE_SIZE = 8 * 1024; public static final int FILE_PAGE_SIZE = 8 * 1024;
/**
* The default delay to flush indexes. 0 means indexes are not flushed.
*/
public static final long FLUSH_INDEX_DELAY = 0;
/** /**
* For testing, the lock timeout is smaller than for interactive use cases. * For testing, the lock timeout is smaller than for interactive use cases.
* This value could be increased to about 5 or 10 seconds. * This value could be increased to about 5 or 10 seconds.
...@@ -520,7 +515,7 @@ public class Constants { ...@@ -520,7 +515,7 @@ public class Constants {
* @return the version number * @return the version number
*/ */
public static Object getVersionStable() { public static Object getVersionStable() {
return "1.1." + BUILD_ID_STABLE; return "1.2." + BUILD_ID_STABLE;
} }
/** /**
......
...@@ -96,7 +96,6 @@ public class Session extends SessionWithState { ...@@ -96,7 +96,6 @@ public class Session extends SessionWithState {
private HashMap<String, Value> variables; private HashMap<String, Value> variables;
private HashSet<ResultInterface> temporaryResults; private HashSet<ResultInterface> temporaryResults;
private int queryTimeout = SysProperties.getMaxQueryTimeout(); private int queryTimeout = SysProperties.getMaxQueryTimeout();
private int lastUncommittedDelete;
private boolean commitOrRollbackDisabled; private boolean commitOrRollbackDisabled;
private Table waitForLock; private Table waitForLock;
private int modificationId; private int modificationId;
...@@ -429,14 +428,6 @@ public class Session extends SessionWithState { ...@@ -429,14 +428,6 @@ public class Session extends SessionWithState {
database.setPowerOffCount(count); database.setPowerOffCount(count);
} }
public int getLastUncommittedDelete() {
return lastUncommittedDelete;
}
public void setLastUncommittedDelete(int deleteId) {
lastUncommittedDelete = deleteId;
}
/** /**
* Commit the current transaction. If the statement was not a data * Commit the current transaction. If the statement was not a data
* definition statement, and if there are temporary tables that should be * definition statement, and if there are temporary tables that should be
...@@ -446,7 +437,6 @@ public class Session extends SessionWithState { ...@@ -446,7 +437,6 @@ public class Session extends SessionWithState {
*/ */
public void commit(boolean ddl) throws SQLException { public void commit(boolean ddl) throws SQLException {
checkCommitRollback(); checkCommitRollback();
lastUncommittedDelete = 0;
currentTransactionName = null; currentTransactionName = null;
if (containsUncommitted()) { if (containsUncommitted()) {
// need to commit even if rollback is not possible // need to commit even if rollback is not possible
......
...@@ -910,7 +910,7 @@ public class FullText { ...@@ -910,7 +910,7 @@ public class FullText {
prepInsertRow.setInt(2, index.id); prepInsertRow.setInt(2, index.id);
prepInsertRow.setString(3, key); prepInsertRow.setString(3, key);
prepInsertRow.execute(); prepInsertRow.execute();
ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertRow); ResultSet rs = prepInsertRow.getGeneratedKeys();
rs.next(); rs.next();
int rowId = rs.getInt(1); int rowId = rs.getInt(1);
prepInsertMap.setInt(1, rowId); prepInsertMap.setInt(1, rowId);
...@@ -977,7 +977,7 @@ public class FullText { ...@@ -977,7 +977,7 @@ public class FullText {
if (wId == null) { if (wId == null) {
prepInsertWord.setString(1, word); prepInsertWord.setString(1, word);
prepInsertWord.execute(); prepInsertWord.execute();
ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertWord); ResultSet rs = prepInsertWord.getGeneratedKeys();
rs.next(); rs.next();
wordId = rs.getInt(1); wordId = rs.getInt(1);
allWords.put(word, wordId); allWords.put(word, wordId);
......
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.index;
import java.sql.SQLException;
import org.h2.constant.SysProperties;
import org.h2.engine.Session;
import org.h2.message.Message;
import org.h2.result.Row;
import org.h2.result.SearchRow;
/**
* The cursor implementation for the b tree index.
*/
public class BtreeCursor implements Cursor {
private final Session session;
private final BtreeIndex index;
private final SearchRow last;
private BtreePosition top;
private SearchRow currentSearchRow;
private Row currentRow;
private boolean first;
BtreeCursor(Session session, BtreeIndex index, SearchRow last) {
this.session = session;
this.index = index;
this.last = last;
first = true;
}
Session getSession() {
return session;
}
void setStackPosition(int position) {
top.position = position;
}
/**
* Put this b-tree position on top of the stack.
*
* @param page the b-tree page to add
* @param position the index in the row list in this page
*/
void push(BtreePage page, int position) {
if (SysProperties.CHECK && (top != null && top.page == page)) {
Message.throwInternalError();
}
top = new BtreePosition(page, position, top);
}
/**
* Get the next b-tree position from the stack.
*
* @return the next position or null
*/
BtreePosition pop() {
BtreePosition t = top;
if (t == null) {
return null;
}
top = top.next;
return t;
}
void setCurrentRow(SearchRow searchRow) {
this.currentSearchRow = searchRow;
currentRow = null;
}
public Row get() throws SQLException {
if (currentRow == null && currentSearchRow != null) {
currentRow = index.getRow(session, currentSearchRow.getKey());
}
return currentRow;
}
public SearchRow getSearchRow() {
return currentSearchRow;
}
public long getKey() {
return currentSearchRow.getKey();
}
public boolean next() throws SQLException {
if (first) {
first = false;
} else {
top.page.next(this, top.position);
}
if (currentSearchRow != null && last != null) {
if (index.compareRows(currentSearchRow, last) > 0) {
currentSearchRow = null;
currentRow = null;
}
}
return currentSearchRow != null;
}
public boolean previous() throws SQLException {
if (currentSearchRow != null) {
top.page.previous(this, top.position);
}
return currentSearchRow != null;
}
}
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.index;
import org.h2.store.DataPage;
import org.h2.store.Record;
/**
* The head page of a b-tree index. There is exactly one head page for each such
* index, and it contains meta data such as the location of the root page.
* Unlike the root page of a b-tree index, the head page always stays at the
* same place.
*/
public class BtreeHead extends Record {
private int rootPosition;
private boolean consistent;
public BtreeHead() {
// nothing to do
}
public BtreeHead(DataPage s) {
rootPosition = s.readInt();
consistent = s.readInt() == 1;
}
boolean getConsistent() {
return consistent;
}
void setConsistent(boolean b) {
this.consistent = b;
}
public int getByteCount(DataPage dummy) {
return 1 + DataPage.LENGTH_INT;
}
public void write(DataPage buff) {
buff.writeByte((byte) 'H');
buff.writeInt(rootPosition);
buff.writeInt(consistent ? 1 : 0);
}
void setRootPosition(int rootPosition) {
this.rootPosition = rootPosition;
}
int getRootPosition() {
return rootPosition;
}
public boolean isPinned() {
return true;
}
}
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.index;
/**
* Represents a position of a b-tree index.
*/
class BtreePosition {
/**
* The index in the row list.
*/
int position;
/**
* The b-tree page.
*/
BtreePage page;
/**
* The next upper b-tree position.
*/
BtreePosition next;
BtreePosition(BtreePage page, int position, BtreePosition next) {
this.page = page;
this.position = position;
this.next = next;
}
}
...@@ -38,13 +38,6 @@ public interface Cursor { ...@@ -38,13 +38,6 @@ public interface Cursor {
*/ */
SearchRow getSearchRow() throws SQLException; SearchRow getSearchRow() throws SQLException;
/**
* Get the unique key of the current row.
*
* @return the key
*/
long getKey();
/** /**
* Skip to the next row if one is available. * Skip to the next row if one is available.
* *
......
...@@ -40,10 +40,6 @@ public class FunctionCursor implements Cursor { ...@@ -40,10 +40,6 @@ public class FunctionCursor implements Cursor {
return get(); return get();
} }
public long getKey() {
throw Message.throwInternalError();
}
public boolean next() throws SQLException { public boolean next() throws SQLException {
row = null; row = null;
if (result.next()) { if (result.next()) {
......
...@@ -30,10 +30,6 @@ public class HashCursor implements Cursor { ...@@ -30,10 +30,6 @@ public class HashCursor implements Cursor {
return row; return row;
} }
public long getKey() {
return row.getKey();
}
public boolean next() { public boolean next() {
if (row == null || end) { if (row == null || end) {
row = null; row = null;
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论