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

Remove unused code.

上级 90819f31
......@@ -34,7 +34,6 @@ public class CreateView extends SchemaCommand {
private String selectSQL;
private String[] columnNames;
private String comment;
private boolean recursive;
private boolean orReplace;
private boolean force;
......@@ -46,10 +45,6 @@ public class CreateView extends SchemaCommand {
viewName = name;
}
public void setRecursive(boolean recursive) {
this.recursive = recursive;
}
public void setSelect(Query select) {
this.select = select;
}
......@@ -113,7 +108,7 @@ public class CreateView extends SchemaCommand {
try {
Schema schema = session.getDatabase().getSchema(session.getCurrentSchemaName());
sysSession.setCurrentSchema(schema);
view = new TableView(getSchema(), id, viewName, querySQL, null, columnNames, sysSession, recursive);
view = new TableView(getSchema(), id, viewName, querySQL, null, columnNames, sysSession, false);
} finally {
sysSession.setCurrentSchema(db.getSchema(Constants.SCHEMA_MAIN));
}
......
......@@ -139,8 +139,8 @@ public interface DbObject {
String getName();
/**
* Construct a CREATE ... SQL statement for this object when creating a copy
* of it.
* Build a SQL statement to re-create the object, or to create a copy of the
* object with a different name or referencing a different table
*
* @param table the new table
* @param quotedName the quoted name
......
......@@ -9,7 +9,6 @@ package org.h2.engine;
import java.util.ArrayList;
import org.h2.command.Parser;
import org.h2.message.Trace;
import org.h2.table.Table;
/**
* The base class for all database objects.
......@@ -52,18 +51,6 @@ public abstract class DbObjectBase implements DbObject {
this.modificationId = db.getModificationMetaId();
}
/**
* Build a SQL statement to re-create the object, or to create a copy of the
* object with a different name or referencing a different table
*
* @param table
* the new table name
* @param quotedName
* the new quoted name
* @return the SQL statement
*/
public abstract String getCreateSQLForCopy(Table table, String quotedName);
/**
* Build a SQL statement to re-create this object.
*
......@@ -78,13 +65,6 @@ public abstract class DbObjectBase implements DbObject {
*/
public abstract String getDropSQL();
/**
* Get the object type.
*
* @return the object type
*/
public abstract int getType();
/**
* Remove all dependent objects and free all resources (files, blocks in
* files) of this object.
......
......@@ -636,10 +636,6 @@ public class SessionRemote extends SessionWithState implements DataHandler {
return null;
}
public int getClientVersion() {
return clientVersion;
}
public int getLastReconnect() {
return lastReconnect;
}
......
......@@ -65,95 +65,16 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
}
}
public int getRootPageId() {
return 0;
public String getDropSQL() {
return null;
}
/**
* Close this index.
*
* @param session the session
*/
public abstract void close(Session session);
/**
* Add a row to this index.
*
* @param session the session
* @param row the row to add
*/
public abstract void add(Session session, Row row);
/**
* Remove a row from the index.
*
* @param session the session
* @param row the row
*/
public abstract void remove(Session session, Row row);
/**
* Create a cursor to iterate over a number of rows.
*
* @param session the session
* @param first the first row to return (null if no limit)
* @param last the last row to return (null if no limit)
* @return the cursor to iterate over the results
*/
public abstract Cursor find(Session session, SearchRow first, SearchRow last);
/**
* Calculate the cost to find rows.
*
* @param session the session
* @param masks the condition mask
* @return the cost
*/
public abstract double getCost(Session session, int[] masks);
/**
* Remove the index.
* Create a duplicate key exception with a message that contains the index name
*
* @param session the session
* @return the exception
*/
public abstract void remove(Session session);
/**
* Truncate the index.
*
* @param session the session
*/
public abstract void truncate(Session session);
/**
* Check if this index can quickly find the first or last value.
*
* @return true if it can
*/
public abstract boolean canGetFirstOrLast();
/**
* Find the first (or last) value of this index. The cursor returned is
* positioned on the correct row, or on null if no row has been found.
*
* @param session the session
* @param first true for the first value, false for the last
* @return a cursor (never null)
*/
public abstract Cursor findFirstOrLast(Session session, boolean first);
/**
* Check if this index needs to be re-built.
*
* @return true if it must be re-built.
*/
public abstract boolean needRebuild();
public String getDropSQL() {
return null;
}
public DbException getDuplicateKeyException() {
DbException getDuplicateKeyException() {
String sql = getName() + " ON " + table.getSQL() + "(" + getColumnListSQL() + ")";
return DbException.get(ErrorCode.DUPLICATE_KEY_1, sql);
}
......@@ -186,19 +107,16 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
throw DbException.throwInternalError();
}
public int getLookupCost(long rowCount) {
return 2;
}
/**
* Calculate the cost for the given mask as if this index was a typical
* b-tree range index.
* b-tree range index. This is the estimated cost required to search one row, and then iterate over the
* given number of rows.
*
* @param masks the search mask
* @param rowCount the number of rows in the index
* @return the calculated cost
* @return the estimated cost
*/
public long getCostRangeIndex(int[] masks, long rowCount) {
long getCostRangeIndex(int[] masks, long rowCount) {
rowCount += Constants.COST_ROW_OFFSET;
long cost = rowCount;
long rows = rowCount;
......@@ -212,7 +130,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
int mask = masks[index];
if ((mask & IndexCondition.EQUALITY) == IndexCondition.EQUALITY) {
if (i == columns.length - 1 && getIndexType().isUnique()) {
cost = getLookupCost(rowCount) + 1;
cost = 3;
break;
}
totalSelectivity = 100 - ((100 - totalSelectivity) * (100 - column.getSelectivity()) / 100);
......@@ -221,12 +139,12 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
distinctRows = 1;
}
rows = Math.max(rowCount / distinctRows, 1);
cost = getLookupCost(rowCount) + rows;
cost = 2 + rows;
} else if ((mask & IndexCondition.RANGE) == IndexCondition.RANGE) {
cost = getLookupCost(rowCount) + rows / 4;
cost = 2 + rows / 4;
break;
} else if ((mask & IndexCondition.START) == IndexCondition.START) {
cost = getLookupCost(rowCount) + rows / 3;
cost = 2 + rows / 3;
break;
} else if ((mask & IndexCondition.END) == IndexCondition.END) {
cost = rows / 3;
......@@ -254,7 +172,16 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
return 0;
}
public boolean containsNullAndAllowMultipleNull(SearchRow newRow) {
/**
* Check if one of the columns is NULL and multiple rows with NULL are
* allowed using the current compatibility mode for unique indexes. Note:
* NULL behavior is complicated in SQL.
*
* @param newRow the row to check
* @return true if one of the columns is null and multiple nulls in unique
* indexes are allowed
*/
boolean containsNullAndAllowMultipleNull(SearchRow newRow) {
Mode mode = database.getMode();
if (mode.uniqueIndexSingleNull) {
return false;
......@@ -276,7 +203,14 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
return false;
}
public int compareKeys(SearchRow rowData, SearchRow compare) {
/**
* Compare the positions of two rows.
*
* @param rowData the first row
* @param compare the second row
* @return 0 if both rows are equal, -1 if the first row is smaller, otherwise 1
*/
int compareKeys(SearchRow rowData, SearchRow compare) {
long k1 = rowData.getKey();
long k2 = compare.getKey();
if (k1 == k2) {
......@@ -314,7 +248,12 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
return -1;
}
public String getColumnListSQL() {
/**
* Get the list of columns as a string.
*
* @return the list of columns
*/
private String getColumnListSQL() {
StatementBuilder buff = new StatementBuilder();
for (IndexColumn c : indexColumns) {
buff.appendExceptFirst(", ");
......
......@@ -7,7 +7,6 @@
package org.h2.index;
import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.Row;
import org.h2.result.SearchRow;
import org.h2.schema.SchemaObject;
......@@ -20,13 +19,6 @@ import org.h2.table.Table;
*/
public interface Index extends SchemaObject {
/**
* Create a duplicate key exception with a message that contains the index name
*
* @return the exception
*/
DbException getDuplicateKeyException();
/**
* Get the message to show in a EXPLAIN statement.
*
......@@ -45,7 +37,7 @@ public interface Index extends SchemaObject {
* Add a row to the index.
*
* @param session the session to use
* @param row the data
* @param row the row to add
*/
void add(Session session, Row row);
......@@ -53,7 +45,7 @@ public interface Index extends SchemaObject {
* Remove a row from the index.
*
* @param session the session
* @param row the data
* @param row the row
*/
void remove(Session session, Row row);
......@@ -63,7 +55,7 @@ public interface Index extends SchemaObject {
* @param session the session
* @param first the first row, or null for no limit
* @param last the last row, or null for no limit
* @return the cursor
* @return the cursor to iterate over the results
*/
Cursor find(Session session, SearchRow first, SearchRow last);
......@@ -119,12 +111,13 @@ public interface Index extends SchemaObject {
Cursor findNext(Session session, SearchRow higherThan, SearchRow last);
/**
* Find the lowest or highest value of a column.
* Find the first (or last) value of this index. The cursor returned is
* positioned on the correct row, or on null if no row has been found.
*
* @param session the session
* @param first true if the first (lowest for ascending indexes) or last
* value should be returned
* @return a cursor or null
* @return a cursor (never null)
*/
Cursor findFirstOrLast(Session session, boolean first);
......@@ -151,24 +144,6 @@ public interface Index extends SchemaObject {
*/
long getRowCountApproximation();
/**
* Estimate the cost required to search a number of rows.
*
* @param rowCount the row count
* @return the estimated cost
*/
int getLookupCost(long rowCount);
/**
* Estimate the cost required to search one row, and then iterate over the
* given number of rows.
*
* @param masks the search mask
* @param rowCount the row count
* @return the estimated cost
*/
long getCostRangeIndex(int[] masks, long rowCount);
/**
* Compare two rows.
*
......@@ -178,26 +153,6 @@ public interface Index extends SchemaObject {
*/
int compareRows(SearchRow rowData, SearchRow compare);
/**
* Check if one of the columns is NULL and multiple rows with NULL are
* allowed using the current compatibility mode for unique indexes. Note:
* NULL behavior is complicated in SQL.
*
* @param newRow the row to check
* @return true if one of the columns is null and multiple nulls in unique
* indexes are allowed
*/
boolean containsNullAndAllowMultipleNull(SearchRow newRow);
/**
* Compare the positions of two rows.
*
* @param rowData the first row
* @param compare the second row
* @return 0 if both rows are equal, -1 if the first row is smaller, otherwise 1
*/
int compareKeys(SearchRow rowData, SearchRow compare);
/**
* Get the index of a column in the list of index columns
*
......@@ -206,13 +161,6 @@ public interface Index extends SchemaObject {
*/
int getColumnIndex(Column col);
/**
* Get the list of columns as a string.
*
* @return the list of columns
*/
String getColumnListSQL();
/**
* Get the indexed columns as index columns (with ordering information).
*
......@@ -250,14 +198,6 @@ public interface Index extends SchemaObject {
*/
void commit(int operation, Row row);
/**
* Get the root page of this index.
*
* @return the root page id
*/
int getRootPageId();
/**
* Get the row with the given key.
*
......
......@@ -56,10 +56,6 @@ public class MultiVersionIndex implements Index {
}
}
public int getRootPageId() {
return base.getRootPageId();
}
public void close(Session session) {
synchronized (sync) {
base.close(session);
......@@ -190,10 +186,6 @@ public class MultiVersionIndex implements Index {
}
}
public int compareKeys(SearchRow rowData, SearchRow compare) {
return base.compareKeys(rowData, compare);
}
public int compareRows(SearchRow rowData, SearchRow compare) {
return base.compareRows(rowData, compare);
}
......@@ -202,10 +194,6 @@ public class MultiVersionIndex implements Index {
return base.getColumnIndex(col);
}
public String getColumnListSQL() {
return base.getColumnListSQL();
}
public Column[] getColumns() {
return base.getColumns();
}
......@@ -214,10 +202,6 @@ public class MultiVersionIndex implements Index {
return base.getIndexColumns();
}
public long getCostRangeIndex(int[] masks, long rowCount) {
return base.getCostRangeIndex(masks, rowCount);
}
public String getCreateSQL() {
return base.getCreateSQL();
}
......@@ -230,18 +214,10 @@ public class MultiVersionIndex implements Index {
return base.getDropSQL();
}
public DbException getDuplicateKeyException() {
return base.getDuplicateKeyException();
}
public IndexType getIndexType() {
return base.getIndexType();
}
public int getLookupCost(long rowCount) {
return base.getLookupCost(rowCount);
}
public String getPlanSQL() {
return base.getPlanSQL();
}
......@@ -258,10 +234,6 @@ public class MultiVersionIndex implements Index {
return base.getType();
}
public boolean containsNullAndAllowMultipleNull(SearchRow newRow) {
return base.containsNullAndAllowMultipleNull(newRow);
}
public void removeChildrenAndResources(Session session) {
synchronized (sync) {
table.removeIndex(this);
......
......@@ -19,6 +19,11 @@ public abstract class PageIndex extends BaseIndex {
private boolean sortedInsertMode;
/**
* Get the root page of this index.
*
* @return the root page id
*/
public int getRootPageId() {
return rootPageId;
}
......
......@@ -1369,7 +1369,7 @@ public class JdbcConnection extends TraceObject implements Connection {
trace.debug("reconnect");
closePreparedCommands();
session = session.reconnect(write);
setTrace(session.getTrace());
trace = session.getTrace();
}
}
......
......@@ -910,7 +910,7 @@ public class JdbcStatement extends TraceObject implements Statement {
SessionInterface s = conn.getSession();
if (s != session) {
session = s;
setTrace(session.getTrace());
trace = session.getTrace();
return true;
}
return false;
......
......@@ -108,7 +108,8 @@ public class TraceObject {
"ds", "xads", "xares", "xid", "ar"
};
private Trace trace;
protected Trace trace;
private int traceType;
private int id;
......@@ -125,15 +126,6 @@ public class TraceObject {
this.id = id;
}
/**
* Update the trace object.
*
* @param trace the trace object
*/
protected void setTrace(Trace trace) {
this.trace = trace;
}
/**
* Get the trace object.
*
......
......@@ -506,15 +506,6 @@ public class Schema extends DbObjectBase {
return New.arrayList(tablesAndViews.values());
}
/**
* Get all functions.
*
* @return a (possible empty) list of all objects
*/
public ArrayList<FunctionAlias> getAllFunctionAliases() {
return New.arrayList(functions.values());
}
/**
* Remove an object from this schema.
*
......
......@@ -25,20 +25,6 @@ public class FileLister {
// utility class
}
/**
* Extract the name of the database from a given file name.
* Only files ending with .data.db are considered, all others return null.
*
* @param fileName the file name (without directory)
* @return the database name or null
*/
public static String getDatabaseNameFromFileName(String fileName) {
if (fileName.endsWith(Constants.SUFFIX_PAGE_FILE)) {
return fileName.substring(0, fileName.length() - Constants.SUFFIX_PAGE_FILE.length());
}
return null;
}
/**
* Try to lock the database, and then unlock it. If this worked, the
* .lock.db file will be removed.
......
......@@ -14,8 +14,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.DbException;
import org.h2.store.FileLister;
import org.h2.util.IOUtils;
import org.h2.util.Tool;
......@@ -85,7 +85,7 @@ public class Restore extends Tool {
}
String entryName = entry.getName();
zipIn.closeEntry();
String name = FileLister.getDatabaseNameFromFileName(entryName);
String name = getDatabaseNameFromFileName(entryName);
if (name != null) {
if (db.equals(name)) {
originalDbName = name;
......@@ -111,6 +111,20 @@ public class Restore extends Tool {
}
}
/**
* Extract the name of the database from a given file name.
* Only files ending with .h2.db are considered, all others return null.
*
* @param fileName the file name (without directory)
* @return the database name or null
*/
private static String getDatabaseNameFromFileName(String fileName) {
if (fileName.endsWith(Constants.SUFFIX_PAGE_FILE)) {
return fileName.substring(0, fileName.length() - Constants.SUFFIX_PAGE_FILE.length());
}
return null;
}
/**
* Restores database files.
*
......
......@@ -14,7 +14,6 @@ import java.sql.Statement;
import java.util.Properties;
import javax.naming.Context;
import javax.sql.DataSource;
import javax.sql.XAConnection;
import org.h2.message.DbException;
/**
......@@ -99,23 +98,6 @@ public class JdbcUtils {
}
}
/**
* Close an XA connection set without throwing an exception.
*
* @param conn the XA connection or null
*/
//## Java 1.4 begin ##
public static void closeSilently(XAConnection conn) {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// ignore
}
}
}
//## Java 1.4 end ##
/**
* Open a new database connection with the given settings.
*
......
......@@ -102,7 +102,6 @@ public class StringUtils {
return s.substring(0, start.length()).equalsIgnoreCase(start);
}
/**
* Convert a string to a SQL literal. Null is converted to NULL. The text is
* enclosed in single quotes. If there are any special characters, the method
......
......@@ -587,11 +587,11 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// jaqu
new AliasMapTest().runTest(this);
new AnnotationsTest().runTest(this);
new ClobTest().runTest(this);
new ModelsTest().runTest(this);
new SamplesTest().runTest(this);
new UpdateTest().runTest(this);
new AnnotationsTest().runTest(this);
new ModelsTest().runTest(this);
// jdbc
new TestBatchUpdates().runTest(this);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论