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

Remove unused code.

上级 6e0619e9
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<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>
<h2>Version 1.2.128 (2010-01-30)</h2>
......
......@@ -20,16 +20,13 @@ import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.expression.Expression;
import org.h2.log.LogFile;
import org.h2.log.LogSystem;
import org.h2.message.Message;
import org.h2.result.ResultInterface;
import org.h2.store.DiskFile;
import org.h2.store.FileLister;
import org.h2.store.PageStore;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.ObjectArray;
/**
* This class represents the statement
......@@ -65,47 +62,25 @@ public class BackupCommand extends Prepared {
OutputStream zip = FileUtils.openFileOutputStream(fileName, false);
ZipOutputStream out = new ZipOutputStream(zip);
LogSystem log = db.getLog();
try {
log.flush();
log.updateKeepFiles(1);
String fn;
if (db.isPageStoreEnabled()) {
fn = db.getName() + Constants.SUFFIX_PAGE_FILE;
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
// creation / deletion / backup
String base = FileUtils.getParent(fn);
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 dir = FileUtils.getParent(prefix);
ArrayList<String> fileList = FileLister.getDatabaseFiles(dir, name, true);
for (String n : fileList) {
if (n.endsWith(Constants.SUFFIX_LOB_FILE)) {
backupFile(out, base, n);
}
log.flush();
String fn;
fn = db.getName() + Constants.SUFFIX_PAGE_FILE;
backupPageStore(out, fn, db.getPageStore());
// synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup
String base = FileUtils.getParent(fn);
synchronized (db.getLobSyncObject()) {
String prefix = db.getDatabasePath();
String dir = FileUtils.getParent(prefix);
ArrayList<String> fileList = FileLister.getDatabaseFiles(dir, name, true);
for (String n : fileList) {
if (n.endsWith(Constants.SUFFIX_LOB_FILE)) {
backupFile(out, base, n);
}
}
out.close();
zip.close();
} finally {
log.updateKeepFiles(-1);
}
out.close();
zip.close();
} catch (IOException e) {
throw Message.convertIOException(e, fileName);
}
......@@ -127,22 +102,6 @@ public class BackupCommand extends Prepared {
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 {
String f = FileUtils.getAbsolutePath(fn);
base = FileUtils.getAbsolutePath(base);
......
......@@ -74,7 +74,7 @@ public class Insert extends Prepared {
public int update() throws SQLException {
Database db = session.getDatabase();
PageIndex index = null;
if (sortedInsertMode && db.isPageStoreEnabled() && db.isPersistent()) {
if (sortedInsertMode && db.isPersistent()) {
index = (PageIndex) table.getScanIndex(session);
index.setSortedInsertMode(true);
}
......
......@@ -247,8 +247,4 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
return null;
}
public Trace getTrace() {
return session.getDatabase().getTrace(Trace.DATABASE);
}
}
......@@ -182,9 +182,6 @@ public class TransactionCommand extends Prepared {
s.close();
}
}
LogSystem log = db.getLog();
log.setDisabled(false);
log.checkpoint();
session.close();
break;
}
......
......@@ -28,22 +28,22 @@ public class SysProperties {
/**
* INTERNAL
*/
public static final String H2_MAX_QUERY_TIMEOUT = "h2.maxQueryTimeout";
public static final String H2_SCRIPT_DIRECTORY = "h2.scriptDirectory";
/**
* INTERNAL
*/
public static final String H2_LOG_DELETE_DELAY = "h2.logDeleteDelay";
public static final String H2_MAX_QUERY_TIMEOUT = "h2.maxQueryTimeout";
/**
* INTERNAL
*/
public static final String H2_COLLATOR_CACHE_SIZE = "h2.collatorCacheSize";
public static final String H2_LOG_DELETE_DELAY = "h2.logDeleteDelay";
/**
* 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 />
......@@ -554,17 +554,6 @@ public class SysProperties {
*/
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 />
* Trim the database size when closing.
......@@ -798,14 +787,7 @@ public class SysProperties {
* read from.
*/
public static String getScriptDirectory() {
return getStringSetting("h2.scriptDirectory", "");
}
/**
* INTERNAL
*/
public static void setScriptDirectory(String dir) {
System.setProperty("h2.scriptDirectory", dir);
return getStringSetting(H2_SCRIPT_DIRECTORY, "");
}
/**
......@@ -829,11 +811,4 @@ public class SysProperties {
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 {
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",
"PASSWORD", "RECOVER", "USER", "DATABASE_EVENT_LISTENER_OBJECT", "AUTO_SERVER",
"AUTO_RECONNECT", "OPEN_NEW", "PAGE_STORE" };
"AUTO_RECONNECT", "OPEN_NEW" };
for (String key : connectionTime) {
if (SysProperties.CHECK && set.contains(key)) {
Message.throwInternalError(key);
......@@ -326,12 +326,7 @@ public class ConnectionInfo implements Cloneable {
*/
String getName() throws SQLException {
if (persistent) {
String suffix;
if (SysProperties.getPageStore()) {
suffix = Constants.SUFFIX_PAGE_FILE;
} else {
suffix = Constants.SUFFIX_DATA_FILE;
}
String suffix = Constants.SUFFIX_PAGE_FILE;
String n = FileUtils.normalize(name + suffix);
String fileName = FileUtils.getFileName(n);
if (fileName.length() < suffix.length() + 1) {
......
......@@ -235,11 +235,6 @@ public class Constants {
*/
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.
* This value could be increased to about 5 or 10 seconds.
......@@ -520,7 +515,7 @@ public class Constants {
* @return the version number
*/
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 {
private HashMap<String, Value> variables;
private HashSet<ResultInterface> temporaryResults;
private int queryTimeout = SysProperties.getMaxQueryTimeout();
private int lastUncommittedDelete;
private boolean commitOrRollbackDisabled;
private Table waitForLock;
private int modificationId;
......@@ -429,14 +428,6 @@ public class Session extends SessionWithState {
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
* definition statement, and if there are temporary tables that should be
......@@ -446,7 +437,6 @@ public class Session extends SessionWithState {
*/
public void commit(boolean ddl) throws SQLException {
checkCommitRollback();
lastUncommittedDelete = 0;
currentTransactionName = null;
if (containsUncommitted()) {
// need to commit even if rollback is not possible
......
......@@ -910,7 +910,7 @@ public class FullText {
prepInsertRow.setInt(2, index.id);
prepInsertRow.setString(3, key);
prepInsertRow.execute();
ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertRow);
ResultSet rs = prepInsertRow.getGeneratedKeys();
rs.next();
int rowId = rs.getInt(1);
prepInsertMap.setInt(1, rowId);
......@@ -977,7 +977,7 @@ public class FullText {
if (wId == null) {
prepInsertWord.setString(1, word);
prepInsertWord.execute();
ResultSet rs = JdbcUtils.getGeneratedKeys(prepInsertWord);
ResultSet rs = prepInsertWord.getGeneratedKeys();
rs.next();
wordId = rs.getInt(1);
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;
}
}
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论