提交 96cf5428 authored 作者: Thomas Mueller's avatar Thomas Mueller

Remove unused code.

上级 39fbde49
......@@ -1747,9 +1747,6 @@ public class Parser {
read("NULL");
r = new Comparison(session, type, r, null);
} else if (readIf("IN")) {
if (SysProperties.OPTIMIZE_IN && !SysProperties.OPTIMIZE_IN_LIST) {
recompileAlways = true;
}
read("(");
if (readIf(")")) {
r = ValueExpression.get(ValueBoolean.get(false));
......@@ -2901,7 +2898,7 @@ public class Parser {
}
break;
case '$':
if (SysProperties.DOLLAR_QUOTING && command[i + 1] == '$' && (i == 0 || command[i - 1] <= ' ')) {
if (command[i + 1] == '$' && (i == 0 || command[i - 1] <= ' ')) {
// dollar quoted string
changed = true;
command[i] = ' ';
......@@ -3867,7 +3864,7 @@ public class Parser {
columns.add(new Column(c, Value.STRING));
}
CreateTableData data = new CreateTableData();
data.id = database.allocateObjectId(true, true);
data.id = database.allocateObjectId();
data.tableName = tempViewName;
data.temporary = true;
data.persistData = true;
......@@ -3881,7 +3878,7 @@ public class Parser {
Query withQuery = parseSelect();
withQuery.prepare();
session.removeLocalTempTable(recursiveTable);
int id = database.allocateObjectId(true, true);
int id = database.allocateObjectId();
TableView view = new TableView(schema, id, tempViewName, querySQL, null, cols, session, true);
view.setTemporary(true);
// view.setOnCommitDrop(true);
......@@ -4167,10 +4164,6 @@ public class Parser {
readIfEqualOrTo();
read();
return new NoOperation(session);
} else if (readIf("ACCESS_MODE_LOG")) {
readIfEqualOrTo();
read();
return new NoOperation(session);
} else if (readIf("AUTO_SERVER")) {
readIfEqualOrTo();
read();
......
......@@ -238,17 +238,15 @@ public abstract class Prepared {
* Get the current object id, or get a new id from the database. The object
* id is used when creating new database object (CREATE statement).
*
* @param needFresh if a fresh id is required
* @param dataFile if the object id is used for the
* @return the object id
*/
protected int getObjectId(boolean needFresh, boolean dataFile) {
Database db = session.getDatabase();
protected int getObjectId() {
int id = objectId;
if (id == 0) {
id = db.allocateObjectId(needFresh, dataFile);
id = session.getDatabase().allocateObjectId();
} else {
objectId = 0;
}
objectId = 0;
return id;
}
......
......@@ -137,7 +137,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
if (index == null) {
IndexType indexType = IndexType.createPrimaryKey(table.isPersistIndexes(), primaryKeyHash);
String indexName = table.getSchema().getUniqueIndexName(session, table, Constants.PREFIX_PRIMARY_KEY);
int id = getObjectId(true, false);
int id = getObjectId();
try {
index = table.addIndex(session, indexName, id, indexColumns, indexType, Index.EMPTY_HEAD, null);
} finally {
......@@ -145,7 +145,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
}
index.getIndexType().setBelongsToConstraint(true);
int constraintId = getObjectId(true, true);
int constraintId = getObjectId();
String name = generateConstraintName(table);
ConstraintUnique pk = new ConstraintUnique(getSchema(), constraintId, name, table, true);
pk.setColumns(indexColumns);
......@@ -166,7 +166,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
isOwner = true;
}
}
int id = getObjectId(true, true);
int id = getObjectId();
String name = generateConstraintName(table);
ConstraintUnique unique = new ConstraintUnique(getSchema(), id, name, table, false);
unique.setColumns(indexColumns);
......@@ -175,7 +175,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
break;
}
case CHECK: {
int id = getObjectId(true, true);
int id = getObjectId();
String name = generateConstraintName(table);
ConstraintCheck check = new ConstraintCheck(getSchema(), id, name, table);
TableFilter filter = new TableFilter(session, table, null, false, null);
......@@ -227,7 +227,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
isRefOwner = true;
}
}
int id = getObjectId(true, true);
int id = getObjectId();
String name = generateConstraintName(table);
ConstraintReferential ref = new ConstraintReferential(getSchema(), id, name, table);
ref.setColumns(indexColumns);
......@@ -259,7 +259,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private Index createIndex(Table t, IndexColumn[] cols, boolean unique) throws SQLException {
int indexId = getObjectId(true, false);
int indexId = getObjectId();
IndexType indexType;
if (unique) {
// for unique constraints
......
......@@ -186,7 +186,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
if (c.isPrimaryKey()) {
c.setOriginalSQL("IDENTITY");
} else {
int objId = getObjectId(true, true);
int objId = getObjectId();
c.convertAutoIncrementToSequence(session, getSchema(), objId, table.isTemporary());
}
}
......@@ -274,7 +274,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
// with the old table
// still need a new id because using 0 would mean: the new table tries
// to use the rows of the table 0 (the meta table)
int id = db.allocateObjectId(true, true);
int id = db.allocateObjectId();
CreateTableData data = new CreateTableData();
data.tableName = tempName;
data.id = id;
......
......@@ -38,7 +38,7 @@ public class CreateAggregate extends DefineCommand {
throw Message.getSQLException(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, name);
}
} else {
int id = getObjectId(false, true);
int id = getObjectId();
UserAggregate aggregate = new UserAggregate(db, id, name, javaClassMethod, force);
db.addDatabaseObject(session, aggregate);
}
......
......@@ -45,7 +45,7 @@ public class CreateConstant extends SchemaCommand {
}
throw Message.getSQLException(ErrorCode.CONSTANT_ALREADY_EXISTS_1, constantName);
}
int id = getObjectId(false, true);
int id = getObjectId();
Constant constant = new Constant(getSchema(), id, constantName);
expression = expression.optimize(session);
Value value = expression.getValue(session);
......
......@@ -40,7 +40,7 @@ public class CreateFunctionAlias extends DefineCommand {
throw Message.getSQLException(ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, aliasName);
}
} else {
int id = getObjectId(false, true);
int id = getObjectId();
FunctionAlias functionAlias;
if (javaClassMethod != null) {
functionAlias = FunctionAlias.newInstance(db, id, aliasName, javaClassMethod, force);
......
......@@ -62,7 +62,7 @@ public class CreateIndex extends SchemaCommand {
if (!table.isPersistIndexes()) {
persistent = false;
}
int id = getObjectId(true, false);
int id = getObjectId();
if (indexName == null) {
if (primaryKey) {
indexName = table.getSchema().getUniqueIndexName(session, table, Constants.PREFIX_PRIMARY_KEY);
......
......@@ -74,7 +74,7 @@ public class CreateLinkedTable extends SchemaCommand {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1,
tableName);
}
int id = getObjectId(false, true);
int id = getObjectId();
TableLink table = getSchema().createTableLink(id, tableName, driver, url, user, password, originalSchema, originalTable, emitUpdates, force);
table.setTemporary(temporary);
table.setGlobalTemporary(globalTemporary);
......
......@@ -48,7 +48,7 @@ public class CreateRole extends DefineCommand {
}
throw Message.getSQLException(ErrorCode.ROLE_ALREADY_EXISTS_1, roleName);
}
int id = getObjectId(false, true);
int id = getObjectId();
Role role = new Role(db, id, roleName, false);
db.addDatabaseObject(session, role);
return 0;
......
......@@ -45,7 +45,7 @@ public class CreateSchema extends DefineCommand {
}
throw Message.getSQLException(ErrorCode.SCHEMA_ALREADY_EXISTS_1, schemaName);
}
int id = getObjectId(true, true);
int id = getObjectId();
Schema schema = new Schema(db, id, schemaName, user, false);
db.addDatabaseObject(session, schema);
return 0;
......
......@@ -50,7 +50,7 @@ public class CreateSequence extends SchemaCommand {
}
throw Message.getSQLException(ErrorCode.SEQUENCE_ALREADY_EXISTS_1, sequenceName);
}
int id = getObjectId(false, true);
int id = getObjectId();
Sequence sequence = new Sequence(getSchema(), id, sequenceName, belongsToTable);
sequence.setStartValue(getLong(start, 1));
sequence.setIncrement(getLong(increment, 1));
......
......@@ -126,7 +126,7 @@ public class CreateTable extends SchemaCommand {
ObjectArray<Sequence> sequences = ObjectArray.newInstance();
for (Column c : data.columns) {
if (c.isAutoIncrement()) {
int objId = getObjectId(true, true);
int objId = getObjectId();
c.convertAutoIncrementToSequence(session, getSchema(), objId, data.temporary);
}
Sequence seq = c.getSequence();
......@@ -134,7 +134,7 @@ public class CreateTable extends SchemaCommand {
sequences.add(seq);
}
}
data.id = getObjectId(true, true);
data.id = getObjectId();
data.headPos = headPos;
data.session = session;
TableData table = getSchema().createTable(data);
......
......@@ -89,7 +89,7 @@ public class CreateTrigger extends SchemaCommand {
}
throw Message.getSQLException(ErrorCode.TRIGGER_ALREADY_EXISTS_1, triggerName);
}
int id = getObjectId(false, true);
int id = getObjectId();
Table table = getSchema().getTableOrView(session, tableName);
TriggerObject trigger = new TriggerObject(getSchema(), id, triggerName, table);
trigger.setInsteadOf(insteadOf);
......
......@@ -68,7 +68,7 @@ public class CreateUser extends DefineCommand {
}
throw Message.getSQLException(ErrorCode.USER_ALREADY_EXISTS_1, userName);
}
int id = getObjectId(false, true);
int id = getObjectId();
User user = new User(db, id, userName, false);
user.setAdmin(admin);
user.setComment(comment);
......
......@@ -64,7 +64,7 @@ public class CreateUserDataType extends DefineCommand {
throw Message.getSQLException(ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1, typeName + " (" + table.getSQL() + ")");
}
}
int id = getObjectId(false, true);
int id = getObjectId();
UserDataType type = new UserDataType(db, id, typeName);
type.setColumn(column);
db.addDatabaseObject(session, type);
......
......@@ -56,7 +56,7 @@ public class CreateView extends SchemaCommand {
}
throw Message.getSQLException(ErrorCode.VIEW_ALREADY_EXISTS_1, viewName);
}
int id = getObjectId(true, true);
int id = getObjectId();
String querySQL;
if (select == null) {
querySQL = selectSQL;
......
......@@ -118,7 +118,7 @@ public class GrantRevoke extends DefineCommand {
for (Table table : tables) {
Right right = grantee.getRightForTable(table);
if (right == null) {
int id = getObjectId(true, true);
int id = getObjectId();
right = new Right(db, id, grantee, rightMask, table);
grantee.grantRight(table, right);
db.addDatabaseObject(session, right);
......@@ -140,7 +140,7 @@ public class GrantRevoke extends DefineCommand {
}
}
Database db = session.getDatabase();
int id = getObjectId(true, true);
int id = getObjectId();
Right right = new Right(db, id, grantee, grantedRole);
db.addDatabaseObject(session, right);
grantee.grantRole(grantedRole, right);
......
......@@ -107,7 +107,7 @@ public class SetComment extends DefineCommand {
if (text == null) {
// reset a non-existing comment - nothing to do
} else {
int id = getObjectId(false, false);
int id = getObjectId();
comment = new Comment(db, id, object);
comment.setCommentText(text);
db.addDatabaseObject(session, comment);
......
......@@ -202,10 +202,6 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
session.getDatabase().freeUpDiskSpace();
}
public void handleInvalidChecksum() throws SQLException {
session.getDatabase().handleInvalidChecksum();
}
public int compareTypeSave(Value a, Value b) {
throw Message.throwInternalError();
}
......@@ -214,14 +210,6 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
return session.getDatabase().getMaxLengthInplaceLob();
}
public int allocateObjectId(boolean b, boolean c) {
return session.getDatabase().allocateObjectId(b, c);
}
public String createTempFile() throws SQLException {
return session.getDatabase().createTempFile();
}
public TempFileDeleter getTempFileDeleter() {
return session.getDatabase().getTempFileDeleter();
}
......@@ -238,10 +226,6 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
return this;
}
public boolean getLobFilesInDirectories() {
return session.getDatabase().getLobFilesInDirectories();
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return null;
}
......
......@@ -718,9 +718,6 @@ public class Select extends Query {
}
if (condition != null) {
condition = condition.optimize(session);
if (SysProperties.optimizeInJoin) {
condition = condition.optimizeInJoin(session, this);
}
for (TableFilter f : filters) {
condition.createIndexConditions(session, f);
}
......@@ -769,7 +766,7 @@ public class Select extends Query {
}
}
}
if (SysProperties.OPTIMIZE_GROUP_SORTED && !isQuickAggregateQuery && isGroupQuery && getGroupByExpressionCount() > 0) {
if (!isQuickAggregateQuery && isGroupQuery && getGroupByExpressionCount() > 0) {
Index index = getGroupSortedIndex();
Index current = topTableFilter.getIndex();
if (index != null && (current.getIndexType().isScan() || current == index)) {
......
......@@ -178,7 +178,7 @@ public class Set extends Prepared {
if (value == 0) {
session.getUser().checkAdmin();
}
database.setLog(value);
// currently no effect
break;
}
case SetTypes.MAX_LENGTH_INPLACE_LOB: {
......@@ -349,7 +349,7 @@ public class Set extends Prepared {
boolean addNew = false;
if (setting == null) {
addNew = true;
int id = getObjectId(false, true);
int id = getObjectId();
setting = new Setting(database, id, name);
}
if (s != null) {
......
......@@ -1052,7 +1052,7 @@ public class ErrorCode {
* the connection properties.
* Example:
* <pre>
* jdbc:h2:~/test;LOG=0;LOG=1
* jdbc:h2:~/test;LOCK_TIMEOUT=0;LOCK_TIMEOUT=1
* </pre>
*/
public static final int DUPLICATE_PROPERTY_1 = 90066;
......
......@@ -78,7 +78,7 @@ public class ConnectionInfo implements Cloneable {
ArrayList<String> list = SetTypes.getTypes();
HashSet<String> set = KNOWN_SETTINGS;
set.addAll(list);
String[] connectionTime = new String[] { "ACCESS_MODE_LOG", "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
String[] connectionTime = new String[] { "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" };
......
......@@ -127,28 +127,25 @@ public class Database implements DataHandler {
private int maxMemoryRows = Constants.DEFAULT_MAX_MEMORY_ROWS;
private int maxMemoryUndo = SysProperties.DEFAULT_MAX_MEMORY_UNDO;
private int lockMode = SysProperties.DEFAULT_LOCK_MODE;
private int logLevel = 1;
private int maxLengthInplaceLob = SysProperties.DEFAULT_MAX_LENGTH_INPLACE_LOB;
private int allowLiterals = Constants.DEFAULT_ALLOW_LITERALS;
private int powerOffCount = initialPowerOffCount;
private int closeDelay;
private DatabaseCloser delayedCloser;
private boolean recovery;
private volatile boolean closing;
private boolean ignoreCase;
private boolean deleteFilesOnDisconnect;
private String lobCompressionAlgorithm;
private boolean optimizeReuseResults = true;
private String cacheType;
private String accessModeLog, accessModeData;
private String accessModeData;
private boolean referentialIntegrity = true;
private boolean multiVersion;
private DatabaseCloser closeOnExit;
private Mode mode = Mode.getInstance(Mode.REGULAR);
private boolean multiThreaded;
private int maxOperationMemory = SysProperties.DEFAULT_MAX_OPERATION_MEMORY;
private boolean lobFilesInDirectories = SysProperties.LOB_FILES_IN_DIRECTORIES;
private SmallLRUCache<String, String[]> lobFileListCache = SmallLRUCache.newInstance(128);
private boolean autoServerMode;
private Server server;
......@@ -174,13 +171,11 @@ public class Database implements DataHandler {
this.databaseShortName = parseDatabaseShortName();
this.cipher = cipher;
String lockMethodName = ci.getProperty("FILE_LOCK", null);
this.accessModeLog = ci.getProperty("ACCESS_MODE_LOG", "rw").toLowerCase();
this.accessModeData = ci.getProperty("ACCESS_MODE_DATA", "rw").toLowerCase();
this.autoServerMode = ci.getProperty("AUTO_SERVER", false);
this.cacheSize = ci.getProperty("CACHE_SIZE", SysProperties.CACHE_SIZE_DEFAULT);
if ("r".equals(accessModeData)) {
readOnly = true;
accessModeLog = "r";
}
this.fileLockMethod = FileLock.getFileLockMethod(lockMethodName);
this.databaseURL = ci.getURL();
......@@ -193,11 +188,6 @@ public class Database implements DataHandler {
setEventListenerClass(listener);
}
}
String logSetting = ci.getProperty(SetTypes.LOG, null);
String ignoreSummary = ci.getProperty("RECOVER", null);
if (ignoreSummary != null) {
this.recovery = true;
}
this.multiVersion = ci.getProperty("MVCC", false);
boolean closeAtVmShutdown = ci.getProperty("DB_CLOSE_ON_EXIT", true);
int traceLevelFile = ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE, TraceSystem.DEFAULT_TRACE_LEVEL_FILE);
......@@ -514,7 +504,6 @@ public class Database implements DataHandler {
// if it is already read-only because ACCESS_MODE_DATA=r
readOnly = readOnly | FileUtils.isReadOnly(pageFileName);
}
boolean exists = existsPage;
if (readOnly) {
traceSystem = new TraceSystem(null);
} else {
......@@ -547,10 +536,6 @@ public class Database implements DataHandler {
// wait until others stopped writing and
// until we can write (file are not open - no need to re-connect)
}
if (exists) {
lobFilesInDirectories &= !ValueLob.existsLobFile(getDatabasePath());
lobFilesInDirectories |= FileUtils.exists(databaseName + Constants.SUFFIX_LOBS_DIRECTORY);
}
deleteOldTempFiles();
starting = true;
getPageStore();
......@@ -688,7 +673,7 @@ public class Database implements DataHandler {
}
String name = SetTypes.getTypeName(type);
if (settings.get(name) == null) {
Setting setting = new Setting(this, allocateObjectId(false, true), name);
Setting setting = new Setting(this, allocateObjectId(), name);
if (stringValue == null) {
setting.setIntValue(intValue);
} else {
......@@ -1198,22 +1183,8 @@ public class Database implements DataHandler {
}
}
public synchronized int allocateObjectId(boolean needFresh, boolean dataFile) {
int todo;
// TODO refactor: use hash map instead of bit field for object ids
needFresh = true;
int i;
if (needFresh) {
i = objectIds.getLastSetBit() + 1;
if ((i & 1) != (dataFile ? 1 : 0)) {
i++;
}
} else {
i = objectIds.nextClearBit(0);
}
if (SysProperties.CHECK && objectIds.get(i)) {
Message.throwInternalError();
}
public synchronized int allocateObjectId() {
int i = objectIds.nextClearBit(0);
objectIds.set(i);
return i;
}
......@@ -1542,19 +1513,6 @@ public class Database implements DataHandler {
return null;
}
private String getFirstInvalidTable(Session session) {
String conflict = null;
try {
for (Table t : getAllTablesAndViews(false)) {
conflict = t.getSQL();
session.prepare(t.getCreateSQL());
}
} catch (SQLException e) {
return conflict;
}
return null;
}
/**
* Remove an object from the system table.
*
......@@ -1591,16 +1549,10 @@ public class Database implements DataHandler {
}
obj.getSchema().remove(obj);
if (!starting) {
String invalid;
if (SysProperties.OPTIMIZE_DROP_DEPENDENCIES) {
Table t = getDependentTable(obj, null);
invalid = t == null ? null : t.getSQL();
} else {
invalid = getFirstInvalidTable(session);
}
if (invalid != null) {
Table t = getDependentTable(obj, null);
if (t != null) {
obj.getSchema().add(obj);
throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, obj.getSQL(), invalid);
throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, obj.getSQL(), t.getSQL());
}
obj.removeChildrenAndResources(session);
}
......@@ -1798,46 +1750,10 @@ public class Database implements DataHandler {
this.closeDelay = value;
}
public synchronized void setLog(int level) throws SQLException {
if (logLevel == level) {
return;
}
boolean logData;
boolean logIndex;
switch (level) {
case 0:
logData = false;
logIndex = false;
break;
case 1:
logData = true;
logIndex = false;
break;
case 2:
logData = true;
logIndex = true;
break;
default:
throw Message.throwInternalError("level=" + level);
}
if (level == 0) {
traceSystem.getTrace(Trace.DATABASE).error("SET LOG " + level, null);
}
logLevel = level;
}
public Session getSystemSession() {
return systemSession;
}
public void handleInvalidChecksum() throws SQLException {
SQLException e = Message.getSQLException(ErrorCode.FILE_CORRUPTED_1, "wrong checksum");
if (!recovery) {
throw e;
}
traceSystem.getTrace(Trace.DATABASE).error("recover", e);
}
/**
* Check if the database is in the process of closing.
*
......@@ -1987,10 +1903,6 @@ public class Database implements DataHandler {
this.exclusiveSession = session;
}
public boolean getLobFilesInDirectories() {
return lobFilesInDirectories;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return lobFileListCache;
}
......
......@@ -60,7 +60,7 @@ public class Engine {
if (database.getAllUsers().size() == 0) {
// users is the last thing we add, so if no user is around,
// the database is not initialized correctly
user = new User(database, database.allocateObjectId(false, true), ci.getUserName(), false);
user = new User(database, database.allocateObjectId(), ci.getUserName(), false);
user.setAdmin(true);
user.setUserPasswordHash(ci.getUserPasswordHash());
database.setMasterUser(user);
......
......@@ -107,7 +107,7 @@ public class Mode {
static {
Mode mode = new Mode(REGULAR);
mode.aliasColumnName = SysProperties.ALIAS_COLUMN_NAME;
mode.nullConcatIsNull = SysProperties.NULL_CONCAT_IS_NULL;
mode.nullConcatIsNull = true;
add(mode);
mode = new Mode("DB2");
......
......@@ -71,7 +71,6 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
private boolean autoCommit = true;
private CommandInterface switchOffAutoCommit;
private ConnectionInfo connectionInfo;
private int objectId;
private String databaseName;
private String cipher;
private byte[] fileEncryptionKey;
......@@ -556,10 +555,6 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
}
}
public int allocateObjectId(boolean needFresh, boolean dataFile) {
return objectId++;
}
public void checkPowerOff() {
// ok
}
......@@ -572,15 +567,6 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
throw Message.throwInternalError();
}
public String createTempFile() throws SQLException {
try {
String prefix = getFilePrefix(System.getProperty("java.io.tmpdir"));
return FileUtils.createTempFile(prefix, Constants.SUFFIX_TEMP_FILE, true, false);
} catch (IOException e) {
throw Message.convertIOException(e, databaseName);
}
}
public void freeUpDiskSpace() {
// nothing to do
}
......@@ -601,10 +587,6 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
return Constants.DEFAULT_MAX_LENGTH_CLIENTSIDE_LOB;
}
public void handleInvalidChecksum() throws SQLException {
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1, "wrong checksum");
}
public FileStore openFile(String name, String mode, boolean mustExist) throws SQLException {
if (mustExist && !FileUtils.exists(name)) {
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1, name);
......@@ -633,10 +615,6 @@ public class SessionRemote extends SessionWithState implements SessionFactory, D
return lobSyncObject;
}
public boolean getLobFilesInDirectories() {
return false;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return null;
}
......
......@@ -12,7 +12,6 @@ import java.util.HashMap;
import org.h2.command.dml.Select;
import org.h2.command.dml.SelectOrderBy;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Session;
import org.h2.index.Cursor;
import org.h2.index.Index;
......@@ -544,9 +543,6 @@ public class Aggregate extends Expression {
return visitor.getTable().canGetRowCount();
case MIN:
case MAX:
if (!SysProperties.OPTIMIZE_MIN_MAX) {
return false;
}
boolean first = type == MIN;
Index index = getColumnIndex(first);
return index != null;
......
......@@ -7,8 +7,6 @@
package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.dml.Select;
import org.h2.constant.SysProperties;
import org.h2.engine.Session;
import org.h2.message.Message;
......@@ -140,7 +138,7 @@ public class ConditionAndOr extends Condition {
// INSERT INTO TEST VALUES(1, NULL);
// SELECT * FROM TEST WHERE NOT (B=A AND B=0); // no rows
// SELECT * FROM TEST WHERE NOT (B=A AND B=0 AND A=0); // 1, NULL
if (SysProperties.OPTIMIZE_TWO_EQUALS && SysProperties.OPTIMIZE_NOT && andOrType == AND) {
if (SysProperties.OPTIMIZE_TWO_EQUALS && andOrType == AND) {
// try to add conditions (A=B AND B=1: add A=1)
if (left instanceof Comparison && right instanceof Comparison) {
Comparison compLeft = (Comparison) left;
......@@ -254,21 +252,6 @@ public class ConditionAndOr extends Condition {
return left.getCost() + right.getCost();
}
public Expression optimizeInJoin(Session session, Select select) throws SQLException {
if (andOrType == AND) {
Expression l = left.optimizeInJoin(session, select);
Expression r = right.optimizeInJoin(session, select);
if (l != left || r != right) {
left = l;
right = r;
// only optimize again if there was some change
// otherwise some expressions are 'over-optimized'
return optimize(session);
}
}
return this;
}
/**
* Get the left or the right sub-expression of this condition.
*
......
......@@ -7,21 +7,14 @@
package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.dml.Select;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.index.Index;
import org.h2.index.IndexCondition;
import org.h2.schema.Schema;
import org.h2.table.Column;
import org.h2.table.ColumnResolver;
import org.h2.table.FunctionTable;
import org.h2.table.TableFilter;
import org.h2.util.ObjectArray;
import org.h2.util.StatementBuilder;
import org.h2.value.CompareMode;
import org.h2.value.Value;
import org.h2.value.ValueBoolean;
import org.h2.value.ValueNull;
......@@ -34,7 +27,6 @@ public class ConditionIn extends Condition {
private final Database database;
private Expression left;
private final ObjectArray<Expression> valueList;
private Value min, max;
private int queryLevel;
/**
......@@ -107,32 +99,6 @@ public class ConditionIn extends Condition {
expr = expr.optimize(session);
return expr;
}
if (SysProperties.OPTIMIZE_IN && !SysProperties.OPTIMIZE_IN_LIST) {
int dataType = left.getType();
ExpressionVisitor independent = ExpressionVisitor.get(ExpressionVisitor.INDEPENDENT);
independent.setQueryLevel(queryLevel);
if (areAllValues(independent)) {
if (left instanceof ExpressionColumn) {
Column column = ((ExpressionColumn) left).getColumn();
boolean nullable = column.isNullable();
CompareMode mode = session.getDatabase().getCompareMode();
for (int i = 0; i < valueList.size(); i++) {
Expression e = valueList.get(i);
Value v = e.getValue(session);
v = v.convertTo(dataType);
valueList.set(i, ValueExpression.get(v));
if (min == null || min.compareTo(v, mode) > 0) {
if (v != ValueNull.INSTANCE || nullable) {
min = v;
}
}
if (max == null || max.compareTo(v, mode) < 0) {
max = v;
}
}
}
}
}
return this;
}
......@@ -155,14 +121,6 @@ public class ConditionIn extends Condition {
filter.addIndexCondition(IndexCondition.getInList(l, valueList));
return;
}
if (!SysProperties.OPTIMIZE_IN) {
return;
}
if (min == null && max == null) {
return;
}
filter.addIndexCondition(IndexCondition.get(Comparison.BIGGER_EQUAL, l, ValueExpression.get(min)));
filter.addIndexCondition(IndexCondition.get(Comparison.SMALLER_EQUAL, l, ValueExpression.get(max)));
}
public void setEvaluatable(TableFilter tableFilter, boolean b) {
......@@ -213,53 +171,6 @@ public class ConditionIn extends Condition {
return cost;
}
public Expression optimizeInJoin(Session session, Select select) throws SQLException {
if (SysProperties.OPTIMIZE_IN_LIST) {
return this;
}
if (!areAllValues(ExpressionVisitor.get(ExpressionVisitor.EVALUATABLE))) {
return this;
}
if (!areAllValues(ExpressionVisitor.get(ExpressionVisitor.INDEPENDENT))) {
return this;
}
if (!(left instanceof ExpressionColumn)) {
return this;
}
ExpressionColumn ec = (ExpressionColumn) left;
Index index = ec.getTableFilter().getTable().getIndexForColumn(ec.getColumn(), false);
if (index == null) {
return this;
}
Database db = session.getDatabase();
Schema mainSchema = db.getSchema(Constants.SCHEMA_MAIN);
int rowCount = valueList.size();
TableFunction function = new TableFunction(database, Function.getFunctionInfo("TABLE_DISTINCT"), rowCount);
Expression[] array = new Expression[rowCount];
for (int i = 0; i < rowCount; i++) {
Expression e = valueList.get(i);
array[i] = e;
}
ExpressionList list = new ExpressionList(array);
function.setParameter(0, list);
function.doneWithParameters();
ObjectArray<Column> columns = ObjectArray.newInstance();
int dataType = left.getType();
String columnName = session.getNextSystemIdentifier(select.getSQL());
Column col = new Column(columnName, dataType);
columns.add(col);
function.setColumns(columns);
FunctionTable table = new FunctionTable(mainSchema, session, function, function);
String viewName = session.getNextSystemIdentifier(select.getSQL());
TableFilter filter = new TableFilter(session, table, viewName, false, select);
select.addTableFilter(filter, true);
ExpressionColumn column = new ExpressionColumn(db, null, viewName, columnName);
Expression on = new Comparison(session, Comparison.EQUAL, left, column);
on.mapColumns(filter, 0);
on = on.optimize(session);
return new ConditionAndOr(ConditionAndOr.AND, this, on);
}
/**
* Add an additional element if possible. Example: given two conditions
* A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3).
......
......@@ -8,18 +8,15 @@ package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.dml.Query;
import org.h2.command.dml.Select;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Database;
import org.h2.engine.Session;
import org.h2.index.Index;
import org.h2.index.IndexCondition;
import org.h2.message.Message;
import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.table.TableView;
import org.h2.value.Value;
import org.h2.value.ValueBoolean;
import org.h2.value.ValueNull;
......@@ -91,6 +88,7 @@ public class ConditionInSelect extends Condition {
public Expression optimize(Session session) throws SQLException {
left = left.optimize(session);
query.setDistinct(true);
query.prepare();
if (query.getColumnCount() != 1) {
throw Message.getSQLException(ErrorCode.SUBQUERY_IS_NOT_SINGLE_COLUMN);
......@@ -123,43 +121,6 @@ public class ConditionInSelect extends Condition {
return left.getCost() + 10 + (int) (10 * query.getCost());
}
public Expression optimizeInJoin(Session session, Select select) throws SQLException {
query.setDistinct(true);
if (SysProperties.OPTIMIZE_IN_LIST) {
return this;
}
if (all || compareType != Comparison.EQUAL) {
return this;
}
if (!query.isEverything(ExpressionVisitor.EVALUATABLE)) {
return this;
}
if (!query.isEverything(ExpressionVisitor.INDEPENDENT)) {
return this;
}
String alias = query.getFirstColumnAlias(session);
if (alias == null) {
return this;
}
if (!(left instanceof ExpressionColumn)) {
return this;
}
ExpressionColumn ec = (ExpressionColumn) left;
Index index = ec.getTableFilter().getTable().getIndexForColumn(ec.getColumn(), false);
if (index == null) {
return this;
}
String name = session.getNextSystemIdentifier(select.getSQL());
TableView view = TableView.createTempView(session, session.getUser(), name, query, select);
TableFilter filter = new TableFilter(session, view, name, false, select);
select.addTableFilter(filter, true);
ExpressionColumn column = new ExpressionColumn(session.getDatabase(), null, view.getName(), alias);
Expression on = new Comparison(session, Comparison.EQUAL, left, column);
on.mapColumns(filter, 0);
on = on.optimize(session);
return on;
}
public void createIndexConditions(Session session, TableFilter filter) {
if (!SysProperties.OPTIMIZE_IN_LIST) {
return;
......
......@@ -7,8 +7,6 @@
package org.h2.expression;
import java.sql.SQLException;
import org.h2.constant.SysProperties;
import org.h2.engine.Session;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
......@@ -43,10 +41,6 @@ public class ConditionNot extends Condition {
}
public Expression optimize(Session session) throws SQLException {
if (!SysProperties.OPTIMIZE_NOT) {
condition = condition.optimize(session);
return this;
}
Expression e2 = condition.getNotIfPossible(session);
if (e2 != null) {
return e2.optimize(session);
......
......@@ -8,7 +8,6 @@ package org.h2.expression;
import java.sql.SQLException;
import org.h2.command.dml.Select;
import org.h2.engine.Session;
import org.h2.table.Column;
import org.h2.table.ColumnResolver;
......@@ -295,16 +294,4 @@ public abstract class Expression {
return getSQL();
}
/**
* Optimize IN(...) expressions if possible.
*
* @param session the session
* @param select the query
* @return the optimized expression
* @throws SQLException
*/
public Expression optimizeInJoin(Session session, Select select) throws SQLException {
return this;
}
}
......@@ -1258,9 +1258,7 @@ public class JdbcConnection extends TraceObject implements Connection {
chars[i] = ' ';
break;
case '$':
if (SysProperties.DOLLAR_QUOTING) {
i = translateGetEnd(sql, i, c);
}
i = translateGetEnd(sql, i, c);
break;
default:
}
......
......@@ -378,10 +378,6 @@ Sets the lock mode."
SET LOCK_TIMEOUT int
","
Sets the lock timeout (in milliseconds) for the current session."
"Commands (Other)","SET LOG","
SET LOG int
","
Enabled or disables writing to the transaction log file."
"Commands (Other)","SET MAX_LENGTH_INPLACE_LOB","
SET MAX_LENGTH_INPLACE_LOB int
","
......
......@@ -44,7 +44,7 @@ public class ResultTempTable implements ResultExternal {
column.setNullable(false);
CreateTableData data = new CreateTableData();
data.columns.add(column);
data.id = session.getDatabase().allocateObjectId(true, true);
data.id = session.getDatabase().allocateObjectId();
data.tableName = "TEMP_RESULT_SET_" + data.id;
data.temporary = true;
data.persistIndexes = false;
......@@ -52,7 +52,7 @@ public class ResultTempTable implements ResultExternal {
data.headPos = Index.EMPTY_HEAD;
data.session = session;
table = schema.createTable(data);
int indexId = session.getDatabase().allocateObjectId(true, false);
int indexId = session.getDatabase().allocateObjectId();
IndexColumn indexColumn = new IndexColumn();
indexColumn.column = column;
indexColumn.columnName = COLUMN_NAME;
......
......@@ -21,10 +21,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.h2.Driver;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.message.TraceSystem;
......@@ -32,7 +30,6 @@ import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils;
import org.h2.util.NetUtils;
import org.h2.util.New;
import org.h2.util.Tool;
/**
* The TCP server implements the native H2 database server protocol.
......@@ -152,16 +149,8 @@ public class TcpServer implements Service {
String a = args[i];
if ("-trace".equals(a)) {
trace = true;
} else if ("-log".equals(a) && SysProperties.OLD_COMMAND_LINE_OPTIONS) {
trace = Tool.readArgBoolean(args, i) == 1;
i++;
} else if ("-tcpSSL".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
ssl = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
ssl = true;
}
ssl = true;
} else if ("-tcpPort".equals(a)) {
port = MathUtils.decodeInt(args[++i]);
} else if ("-tcpPassword".equals(a)) {
......@@ -172,19 +161,9 @@ public class TcpServer implements Service {
key = args[++i];
keyDatabase = args[++i];
} else if ("-tcpAllowOthers".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
allowOthers = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
allowOthers = true;
}
allowOthers = true;
} else if ("-ifExists".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
ifExists = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
ifExists = true;
}
ifExists = true;
}
}
org.h2.Driver.load();
......
......@@ -19,14 +19,11 @@ import java.sql.Types;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.server.Service;
import org.h2.util.MathUtils;
import org.h2.util.NetUtils;
import org.h2.util.New;
import org.h2.util.Tool;
/**
* This class implements a subset of the PostgreSQL protocol as described here:
......@@ -84,27 +81,14 @@ public class PgServer implements Service {
String a = args[i];
if ("-trace".equals(a)) {
trace = true;
} else if ("-log".equals(a) && SysProperties.OLD_COMMAND_LINE_OPTIONS) {
trace = Tool.readArgBoolean(args, i) == 1;
i++;
} else if ("-pgPort".equals(a)) {
port = MathUtils.decodeInt(args[++i]);
} else if ("-baseDir".equals(a)) {
baseDir = args[++i];
} else if ("-pgAllowOthers".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
allowOthers = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
allowOthers = true;
}
allowOthers = true;
} else if ("-ifExists".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
ifExists = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
ifExists = true;
}
ifExists = true;
}
}
org.h2.Driver.load();
......
......@@ -42,7 +42,6 @@ import org.h2.util.New;
import org.h2.util.RandomUtils;
import org.h2.util.Resources;
import org.h2.util.SortedProperties;
import org.h2.util.Tool;
/**
* The web server is a simple standalone HTTP server that implements the H2
......@@ -229,34 +228,16 @@ public class WebServer implements Service {
if ("-webPort".equals(a)) {
port = MathUtils.decodeInt(args[++i]);
} else if ("-webSSL".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
ssl = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
ssl = true;
}
ssl = true;
} else if ("-webAllowOthers".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
allowOthers = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
allowOthers = true;
}
allowOthers = true;
} else if ("-baseDir".equals(a)) {
String baseDir = args[++i];
SysProperties.setBaseDir(baseDir);
} else if ("-ifExists".equals(a)) {
if (Tool.readArgBoolean(args, i) != 0) {
ifExists = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
ifExists = true;
}
ifExists = true;
} else if ("-trace".equals(a)) {
trace = true;
} else if ("-log".equals(a) && SysProperties.OLD_COMMAND_LINE_OPTIONS) {
trace = Tool.readArgBoolean(args, i) == 1;
i++;
}
}
// if(driverList != null) {
......
......@@ -259,19 +259,6 @@ public class Data extends DataPage {
pos = 0;
}
/**
* Append the contents of the given data page to this page.
* The filler is not appended.
*
* @param page the page that will be appended
*/
public void writeDataPageNoSize(Data page) {
// don't write filler
int len = page.pos - LENGTH_FILLER;
System.arraycopy(page.data, 0, data, pos, len);
pos += len;
}
/**
* Append a number of bytes to this data page.
*
......
......@@ -68,13 +68,6 @@ public interface DataHandler {
*/
void freeUpDiskSpace() throws SQLException;
/**
* Called when the checksum was invalid.
*
* @throws SQLException if this should not be ignored
*/
void handleInvalidChecksum() throws SQLException;
/**
* Compare two values.
*
......@@ -99,23 +92,6 @@ public interface DataHandler {
*/
String getLobCompressionAlgorithm(int type);
/**
* Get the next object id.
* This method is not required if LOB_FILES_IN_DIRECTORIES is enabled.
*
* @param needFresh if a fresh id is required
* @param dataFile true if the id is for the data file
* @return the new id
*/
int allocateObjectId(boolean needFresh, boolean dataFile);
/**
* Create a temporary file and return the file name.
*
* @return the file name
*/
String createTempFile() throws SQLException;
/**
* Get the temp file deleter mechanism.
*
......@@ -130,13 +106,6 @@ public interface DataHandler {
*/
Object getLobSyncObject();
/**
* Checks if the lob files stored in directories.
*
* @return true if lob files are stored in directories.
*/
boolean getLobFilesInDirectories();
/**
* Get the lob file list cache if it is used.
*
......
......@@ -12,6 +12,7 @@ import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.Message;
......@@ -108,7 +109,7 @@ public class DataPage {
if (data[len - 2] == (byte) x) {
return;
}
handler.handleInvalidChecksum();
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1, "Invalid checksum");
}
}
......
......@@ -839,7 +839,6 @@ public class MetaTable extends Table {
add(rows, "MVCC", database.isMultiVersion() ? "TRUE" : "FALSE");
add(rows, "QUERY_TIMEOUT", "" + session.getQueryTimeout());
// the setting for the current database
add(rows, "LOB_FILES_IN_DIRECTORIES", "" + database.getLobFilesInDirectories());
add(rows, "h2.allowBigDecimalExtensions", "" + SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS);
add(rows, "h2.baseDir", "" + SysProperties.getBaseDir());
add(rows, "h2.check", "" + SysProperties.CHECK);
......@@ -847,7 +846,6 @@ public class MetaTable extends Table {
add(rows, "h2.clientTraceDirectory", SysProperties.CLIENT_TRACE_DIRECTORY);
add(rows, SysProperties.H2_COLLATOR_CACHE_SIZE, "" + SysProperties.getCollatorCacheSize());
add(rows, "h2.defaultMaxMemoryUndo", "" + SysProperties.DEFAULT_MAX_MEMORY_UNDO);
add(rows, "h2.lobFilesInDirectories", "" + SysProperties.LOB_FILES_IN_DIRECTORIES);
add(rows, "h2.lobFilesPerDirectory", "" + SysProperties.LOB_FILES_PER_DIRECTORY);
add(rows, "h2.logAllErrors", "" + SysProperties.LOG_ALL_ERRORS);
add(rows, "h2.logAllErrorsFile", "" + SysProperties.LOG_ALL_ERRORS_FILE);
......@@ -857,10 +855,7 @@ public class MetaTable extends Table {
add(rows, "h2.objectCache", "" + SysProperties.OBJECT_CACHE);
add(rows, "h2.objectCacheSize", "" + SysProperties.OBJECT_CACHE_SIZE);
add(rows, "h2.objectCacheMaxPerElementSize", "" + SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE);
add(rows, "h2.optimizeIn", "" + SysProperties.OPTIMIZE_IN);
add(rows, "h2.optimizeInJoin", "" + SysProperties.optimizeInJoin);
add(rows, "h2.optimizeInList", "" + SysProperties.OPTIMIZE_IN_LIST);
add(rows, "h2.optimizeMinMax", "" + SysProperties.OPTIMIZE_MIN_MAX);
add(rows, "h2.optimizeSubqueryCache", "" + SysProperties.OPTIMIZE_SUBQUERY_CACHE);
add(rows, "h2.overflowExceptions", "" + SysProperties.OVERFLOW_EXCEPTIONS);
add(rows, "h2.recompileAlways", "" + SysProperties.RECOMPILE_ALWAYS);
......
......@@ -85,7 +85,6 @@ public class Recover extends Tool implements DataHandler {
private int recordLength;
private int valueId;
private boolean trace;
private boolean lobFilesInDirectories;
private ObjectArray<MetaRecord> schema;
private HashSet<Integer> objectIdSet;
private HashMap<Integer, String> tableMap;
......@@ -482,7 +481,6 @@ public class Recover extends Tool implements DataHandler {
private void setDatabaseName(String name) {
databaseName = name;
lobFilesInDirectories = FileUtils.exists(databaseName + Constants.SUFFIX_LOBS_DIRECTORY);
}
private void dumpLog(String fileName, boolean onlySetSessionState) {
......@@ -1790,13 +1788,6 @@ public class Recover extends Tool implements DataHandler {
// nothing to do
}
/**
* INTERNAL
*/
public void handleInvalidChecksum() throws SQLException {
throw new SQLException("Invalid Checksum");
}
/**
* INTERNAL
*/
......@@ -1811,20 +1802,6 @@ public class Recover extends Tool implements DataHandler {
throw Message.throwInternalError();
}
/**
* INTERNAL
*/
public int allocateObjectId(boolean b, boolean c) {
throw Message.throwInternalError();
}
/**
* INTERNAL
*/
public String createTempFile() {
throw Message.throwInternalError();
}
/**
* INTERNAL
*/
......@@ -1839,13 +1816,6 @@ public class Recover extends Tool implements DataHandler {
return this;
}
/**
* INTERNAL
*/
public boolean getLobFilesInDirectories() {
return lobFilesInDirectories;
}
/**
* INTERNAL
*/
......
......@@ -8,9 +8,7 @@ package org.h2.tools;
import java.sql.Connection;
import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.message.Message;
import org.h2.message.TraceSystem;
import org.h2.server.Service;
......@@ -124,13 +122,9 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
startDefaultServers = false;
webStart = true;
} else if ("-webAllowOthers".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-webSSL".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-webPort".equals(arg)) {
i++;
} else if ("-webScript".equals(arg)) {
......@@ -146,13 +140,9 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
startDefaultServers = false;
tcpStart = true;
} else if ("-tcpAllowOthers".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-tcpSSL".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-tcpPort".equals(arg)) {
i++;
} else if ("-tcpPassword".equals(arg)) {
......@@ -162,12 +152,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
tcpShutdown = true;
tcpShutdownServer = args[++i];
} else if ("-tcpShutdownForce".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
tcpShutdownForce = Tool.readArgBoolean(args, i) == 1;
i++;
} else {
tcpShutdownForce = true;
}
tcpShutdownForce = true;
} else {
throwUnsupportedOption(arg);
}
......@@ -176,9 +161,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
startDefaultServers = false;
pgStart = true;
} else if ("-pgAllowOthers".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-pgPort".equals(arg)) {
i++;
} else {
......@@ -186,12 +169,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
}
} else if ("-trace".equals(arg)) {
// no parameters
} else if ("-log".equals(arg) && SysProperties.OLD_COMMAND_LINE_OPTIONS) {
i++;
} else if ("-ifExists".equals(arg)) {
if (Tool.readArgBoolean(args, i) != 0) {
i++;
}
// no parameters
} else if ("-baseDir".equals(arg)) {
i++;
} else {
......
......@@ -10,8 +10,6 @@ import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.Arrays;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.Message;
......@@ -86,7 +84,7 @@ public class ScriptReader {
switch (c) {
case '$': {
c = read();
if (c == '$' && SysProperties.DOLLAR_QUOTING && (bufferPos - bufferStart < 3 || buffer[bufferPos - 3] <= ' ')) {
if (c == '$' && (bufferPos - bufferStart < 3 || buffer[bufferPos - 3] <= ' ')) {
// dollar quoted string
while (true) {
c = read();
......
......@@ -11,7 +11,6 @@ import java.io.IOException;
import java.io.PrintStream;
import java.sql.SQLException;
import java.util.Properties;
import org.h2.constant.SysProperties;
/**
* Command line tools implement the tool interface so that they can be used in
......@@ -94,27 +93,4 @@ public abstract class Tool {
out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html");
}
/**
* Read an argument and check if it is true (1), false (-1), or not (0).
* This method is used for compatibility with older versions only.
*
* @param args the list of arguments
* @param i the index - 1
* @return 1 for true, -1 for false, or 0 for not read
*/
public static int readArgBoolean(String[] args, int i) {
if (!SysProperties.OLD_COMMAND_LINE_OPTIONS) {
return 0;
}
if (i + 1 < args.length) {
String a = args[++i];
if ("true".equals(a)) {
return 1;
} else if ("false".equals(a)) {
return -1;
}
}
return 0;
}
}
......@@ -121,11 +121,8 @@ public class ValueLob extends Value {
if (SysProperties.CHECK && tableId == 0 && objectId == 0) {
Message.throwInternalError("0 LOB");
}
if (handler.getLobFilesInDirectories()) {
String table = tableId < 0 ? ".temp" : ".t" + tableId;
return getFileNamePrefix(handler.getDatabasePath(), objectId) + table + Constants.SUFFIX_LOB_FILE;
}
return handler.getDatabasePath() + "." + tableId + "." + objectId + Constants.SUFFIX_LOB_FILE;
String table = tableId < 0 ? ".temp" : ".t" + tableId;
return getFileNamePrefix(handler.getDatabasePath(), objectId) + table + Constants.SUFFIX_LOB_FILE;
}
/**
......@@ -388,13 +385,8 @@ public class ValueLob extends Value {
String compressionAlgorithm = h.getLobCompressionAlgorithm(type);
this.compression = compressionAlgorithm != null;
synchronized (h) {
if (h.getLobFilesInDirectories()) {
objectId = getNewObjectId(h);
fileName = getFileNamePrefix(h.getDatabasePath(), objectId) + Constants.SUFFIX_TEMP_FILE;
} else {
objectId = h.allocateObjectId(false, true);
fileName = h.createTempFile();
}
objectId = getNewObjectId(h);
fileName = getFileNamePrefix(h.getDatabasePath(), objectId) + Constants.SUFFIX_TEMP_FILE;
tempFile = h.openFile(fileName, "rw", false);
tempFile.autoDelete();
}
......@@ -477,12 +469,7 @@ public class ValueLob extends Value {
// synchronize on the database, to avoid concurrent temp file
// creation / deletion / backup
synchronized (handler) {
if (handler.getLobFilesInDirectories()) {
temp = getFileName(handler, -1, objectId);
} else {
// just to get a filename - an empty file will be created
temp = handler.createTempFile();
}
temp = getFileName(handler, -1, objectId);
deleteFile(handler, temp);
renameFile(handler, fileName, temp);
tempFile = FileStore.open(handler, temp, "rw");
......@@ -501,11 +488,7 @@ public class ValueLob extends Value {
}
if (linked) {
ValueLob copy = ValueLob.copy(this);
if (h.getLobFilesInDirectories()) {
copy.objectId = getNewObjectId(h);
} else {
copy.objectId = h.allocateObjectId(false, true);
}
copy.objectId = getNewObjectId(h);
copy.tableId = tabId;
String live = getFileName(h, copy.tableId, copy.objectId);
copyFileTo(h, fileName, live);
......@@ -749,36 +732,8 @@ public class ValueLob extends Value {
* @param tableId the table id
*/
public static void removeAllForTable(DataHandler handler, int tableId) throws SQLException {
if (handler.getLobFilesInDirectories()) {
String dir = getFileNamePrefix(handler.getDatabasePath(), 0);
removeAllForTable(handler, dir, tableId);
} else {
String prefix = handler.getDatabasePath();
String dir = FileUtils.getParent(prefix);
String[] list = FileUtils.listFiles(dir);
for (String name : list) {
if (name.startsWith(prefix + "." + tableId + ".") && name.endsWith(Constants.SUFFIX_LOB_FILE)) {
deleteFile(handler, name);
}
}
}
}
/**
* Check if a lob file exists for this database.
*
* @param prefix the file name prefix
* @return true if a lob file exists
*/
public static boolean existsLobFile(String prefix) throws SQLException {
String dir = FileUtils.getParent(prefix);
String[] list = FileUtils.listFiles(dir);
for (String name: list) {
if (name.startsWith(prefix + ".") && name.endsWith(Constants.SUFFIX_LOB_FILE)) {
return true;
}
}
return false;
String dir = getFileNamePrefix(handler.getDatabasePath(), 0);
removeAllForTable(handler, dir, tableId);
}
private static void removeAllForTable(DataHandler handler, String dir, int tableId) throws SQLException {
......
......@@ -46,7 +46,7 @@ public class ShowProgress implements DatabaseEventListener {
*/
void test() throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:test;LOG=2", "sa", "");
Connection conn = DriverManager.getConnection("jdbc:h2:test", "sa", "");
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
......@@ -77,7 +77,7 @@ public class ShowProgress implements DatabaseEventListener {
System.out.println("Open connection...");
time = System.currentTimeMillis();
conn = DriverManager.getConnection("jdbc:h2:test;LOG=2;DATABASE_EVENT_LISTENER='" + getClass().getName() + "'", "sa", "");
conn = DriverManager.getConnection("jdbc:h2:test;DATABASE_EVENT_LISTENER='" + getClass().getName() + "'", "sa", "");
time = System.currentTimeMillis() - time;
System.out.println("Done after " + time + " ms");
conn.close();
......
......@@ -33,7 +33,6 @@ import org.h2.test.db.TestLargeBlob;
import org.h2.test.db.TestLinkedTable;
import org.h2.test.db.TestListener;
import org.h2.test.db.TestLob;
import org.h2.test.db.TestLogFile;
import org.h2.test.db.TestMemoryUsage;
import org.h2.test.db.TestMultiConn;
import org.h2.test.db.TestMultiDimension;
......@@ -198,11 +197,6 @@ java org.h2.test.TestAll timer
*/
public boolean mvcc;
/**
* The log mode to use.
*/
public int logMode = 1;
/**
* The cipher to use (null for unencrypted).
*/
......@@ -292,7 +286,13 @@ java org.h2.test.TestAll timer
System.setProperty("h2.check2", "true");
/*
DataHandler.getLobFilesInDirectories
document in performance section:
PreparedStatement prep = conn.prepareStatement(
"select * from table(x int = ?) t inner join test on t.x = test.id");
prep.setObject(1, new Object[] { "1", "2" });
ResultSet rs = prep.executeQuery();
remove Record class; or at least fix javadoc
remove links from Row - Record - Page - DataPage
cleanup SortedProperties
......@@ -300,11 +300,9 @@ remove unused methods
change test case for migration (download old h2.jar).
move migration to separate classes.
direct link to javadoc doesn't open method; cannot copy & paste
TestAll deleteIndex
remove DiskFile
SET LOG 2 noop
Database.accessModeLog, accessModeData
move upgrade code from Recover to a separate class
FileStore.sync, Database.sync() (CHECKPOINT SYNC)
data page > buffer
......@@ -393,8 +391,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
ssl = (a & 16) != 0;
diskResult = (a & 32) != 0;
deleteIndex = (a & 64) != 0;
for (logMode = 0; logMode < 3; logMode++) {
traceLevelFile = logMode;
for (int trace = 0; trace < 3; trace++) {
traceLevelFile = trace;
test();
}
}
......@@ -410,7 +408,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
diskResult = deleteIndex = traceSystemOut = diskUndo = false;
mvcc = traceTest = stopOnError = false;
traceLevelFile = throttle = 0;
logMode = 1;
cipher = null;
test();
testUnit();
......@@ -421,10 +418,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
networked = false;
memory = false;
logMode = 2;
test();
logMode = 1;
diskUndo = true;
diskResult = true;
deleteIndex = true;
......@@ -446,24 +441,20 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
smallLog = true;
networked = true;
ssl = true;
logMode = 2;
test();
smallLog = false;
networked = false;
ssl = false;
logMode = 1;
traceLevelFile = 0;
test();
big = false;
logMode = 0;
cipher = "AES";
test();
mvcc = true;
cipher = null;
logMode = 1;
test();
memory = true;
......@@ -502,7 +493,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new TestLinkedTable().runTest(this);
new TestListener().runTest(this);
new TestLob().runTest(this);
new TestLogFile().runTest(this);
new TestMemoryUsage().runTest(this);
new TestMultiConn().runTest(this);
new TestMultiDimension().runTest(this);
......@@ -689,7 +679,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
appendIf(buff, memory, "memory");
appendIf(buff, codeCoverage, "codeCoverage");
appendIf(buff, mvcc, "mvcc");
appendIf(buff, logMode != 1, "logMode:" + logMode);
appendIf(buff, cipher != null, cipher);
appendIf(buff, jdk14, "jdk14");
appendIf(buff, smallLog, "smallLog");
......
......@@ -236,9 +236,6 @@ public abstract class TestBase {
url = name;
}
if (!config.memory) {
if (admin) {
url += ";LOG=" + config.logMode;
}
if (config.smallLog && admin) {
url += ";MAX_LOG_SIZE=1";
}
......
......@@ -30,7 +30,7 @@ public class TestBackup extends TestBase {
}
public void test() throws SQLException {
if (config.memory || config.logMode == 0) {
if (config.memory) {
return;
}
testBackupRestoreLobStatement();
......
......@@ -46,7 +46,7 @@ public class TestCases extends TestBase {
testDeleteGroup();
testDisconnect();
testExecuteTrace();
if (config.memory || config.logMode == 0) {
if (config.memory) {
return;
}
testDeleteAndDropTableWithLobs(true);
......
......@@ -53,7 +53,7 @@ public class TestIndex extends TestBase {
testWideIndex(979);
testWideIndex(1200);
testWideIndex(2400);
if (config.big && config.logMode == 2) {
if (config.big) {
for (int i = 0; i < 2000; i++) {
if ((i % 100) == 0) {
System.out.println("width: " + i);
......
......@@ -217,7 +217,7 @@ public class TestLob extends TestBase {
}
private void testLobDrop() throws SQLException {
if (config.logMode == 0 || config.networked) {
if (config.networked) {
return;
}
deleteDb("lob");
......@@ -239,7 +239,7 @@ public class TestLob extends TestBase {
}
private void testLobNoClose() throws Exception {
if (config.logMode == 0 || config.networked) {
if (config.networked) {
return;
}
deleteDb("lob");
......@@ -289,11 +289,6 @@ public class TestLob extends TestBase {
}
private void testLobTransactions(int spaceLen) throws SQLException {
if (config.logMode == 0) {
return;
}
// Constants.LOB_CLOSE_BETWEEN_READS = true;
deleteDb("lob");
Connection conn = reconnect(null);
conn.createStatement().execute("CREATE TABLE TEST(ID IDENTITY, DATA CLOB, DATA2 VARCHAR)");
......@@ -373,9 +368,6 @@ public class TestLob extends TestBase {
}
private void testLobRollbackStop() throws SQLException {
if (config.logMode == 0) {
return;
}
deleteDb("lob");
Connection conn = reconnect(null);
conn.createStatement().execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA CLOB)");
......
/*
* 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.test.db;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import org.h2.constant.SysProperties;
import org.h2.store.FileLister;
import org.h2.test.TestBase;
import org.h2.util.FileUtils;
/**
* Tests the database transaction log file.
*/
public class TestLogFile extends TestBase {
private static final int MAX_LOG_SIZE = 1;
private Connection conn;
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
private long reconnect(int maxFiles) throws SQLException {
if (conn != null) {
conn.close();
}
long length = 0;
ArrayList<String> files = FileLister.getDatabaseFiles(baseDir, "logfile", false);
assertSmaller(files.size(), maxFiles + 2);
for (String fileName : files) {
long len = new File(fileName).length();
length += len;
}
conn = getConnection("logfile");
return length;
}
public void test() throws SQLException {
if (config.memory) {
return;
}
deleteDb("logfile");
int old = SysProperties.getLogFileDeleteDelay();
System.setProperty(SysProperties.H2_LOG_DELETE_DELAY, "0");
try {
reconnect(0);
insert();
// data, index, log
int maxFiles = 3;
for (int i = 0; i < 3; i++) {
long length = reconnect(maxFiles);
insert();
long l2 = reconnect(maxFiles);
trace("length:" + length + " l2:" + l2);
assertTrue(l2 <= length * 2);
}
conn.close();
} finally {
System.setProperty(SysProperties.H2_LOG_DELETE_DELAY, "" + old);
}
deleteDb("logfile");
}
private void checkLogSize() throws SQLException {
for (String name : FileUtils.listFiles(getTestDir(""))) {
if (name.startsWith("logfile") && name.endsWith(".log.db")) {
long length = FileUtils.length(name);
assertSmaller(length, MAX_LOG_SIZE * 1024 * 1024 * 2);
}
}
}
private void insert() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("SET LOGSIZE 200");
stat.execute("SET MAX_LOG_SIZE " + MAX_LOG_SIZE);
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, 'Hello' || ?)");
int len = getSize(1, 10000);
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
prep.setInt(2, i);
prep.execute();
if (i > 0 && (i % 2000) == 0) {
checkLogSize();
}
}
checkLogSize();
// stat.execute("TRUNCATE TABLE TEST");
}
}
......@@ -60,10 +60,9 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
private void testBackup() throws SQLException {
if (config.memory || config.logMode == 0) {
if (config.memory) {
return;
}
deleteDb("openClose");
String url = getURL("openClose", true);
org.h2.Driver.load();
......
......@@ -16,8 +16,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.TreeSet;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase;
import org.h2.tools.SimpleResultSet;
import org.h2.util.New;
......@@ -169,9 +167,6 @@ public class TestOptimizations extends TestBase {
assertTrue(rs.next());
assertFalse(rs.next());
boolean old = SysProperties.optimizeInJoin;
SysProperties.optimizeInJoin = true;
prep = conn.prepareStatement(
"select 2 from test a where a=? and b in(" +
"select b.c from test b where b.d=?)");
......@@ -181,15 +176,10 @@ public class TestOptimizations extends TestBase {
assertTrue(rs.next());
assertFalse(rs.next());
conn.close();
SysProperties.optimizeInJoin = old;
}
private void testOptimizeInJoinSelect() throws SQLException {
boolean old = SysProperties.optimizeInJoin;
SysProperties.optimizeInJoin = true;
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -205,9 +195,6 @@ public class TestOptimizations extends TestBase {
assertEquals(1, rs.getInt(1));
assertFalse(rs.next());
conn.close();
SysProperties.optimizeInJoin = old;
}
/**
......@@ -223,9 +210,6 @@ public class TestOptimizations extends TestBase {
}
private void testOptimizeInJoin() throws SQLException {
boolean old = SysProperties.optimizeInJoin;
SysProperties.optimizeInJoin = true;
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -239,8 +223,6 @@ public class TestOptimizations extends TestBase {
fail("Expected using the primary key, got: " + plan);
}
conn.close();
SysProperties.optimizeInJoin = old;
}
private void testMinMaxNullOptimization() throws SQLException {
......@@ -391,11 +373,6 @@ public class TestOptimizations extends TestBase {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
// if h2.optimizeInJoin is enabled, the following query can not be improved
if (!SysProperties.optimizeInJoin) {
testQuerySpeed(stat,
"select sum(x) from system_range(1, 10000) a where a.x in (select b.x from system_range(1, 30) b)");
}
testQuerySpeed(stat,
"select sum(a.n), sum(b.x) from system_range(1, 100) b, (select sum(x) n from system_range(1, 4000)) a");
conn.close();
......
......@@ -30,7 +30,7 @@ public class TestOutOfMemory extends TestBase {
}
public void test() throws SQLException {
if (config.memory || config.mvcc || config.logMode == 0) {
if (config.memory || config.mvcc) {
return;
}
for (int i = 0; i < 5; i++) {
......
......@@ -39,7 +39,7 @@ public class TestPowerOff extends TestBase {
}
public void test() throws SQLException {
if (config.memory || config.logMode == 0) {
if (config.memory) {
return;
}
if (config.big || config.googleAppEngine) {
......
......@@ -55,7 +55,7 @@ public class TestReadOnly extends TestBase {
deleteDb("readonly");
Connection conn = getConnection("readonly");
conn.close();
conn = getConnection("readonly;ACCESS_MODE_LOG=r;ACCESS_MODE_DATA=r");
conn = getConnection("readonly;ACCESS_MODE_DATA=r");
Statement stat = conn.createStatement();
try {
stat.execute("CREATE TABLE TEST(ID INT)");
......@@ -165,7 +165,7 @@ public class TestReadOnly extends TestBase {
stat.execute("create table test(id identity)");
stat.execute("insert into test select x from system_range(1, 11)");
try {
getConnection("readonly;ACCESS_MODE_LOG=r;ACCESS_MODE_DATA=r;OPEN_NEW=TRUE");
getConnection("readonly;ACCESS_MODE_DATA=r;OPEN_NEW=TRUE");
} catch (SQLException e) {
assertEquals(ErrorCode.DATABASE_ALREADY_OPEN_1, e.getErrorCode());
}
......
......@@ -30,7 +30,7 @@ public class TestTwoPhaseCommit extends TestBase {
}
public void test() throws SQLException {
if (config.memory || config.networked || config.logMode == 0) {
if (config.memory || config.networked) {
return;
}
......
......@@ -125,7 +125,6 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
p.setProperty("password", password);
Connection conn = DriverManager.getConnection(url, p);
Statement stat = conn.createStatement();
stat.execute("set log 0");
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("insert into test select x, space(1000) from system_range(1,1000)");
if (shutdown) {
......
......@@ -116,7 +116,7 @@ public class TestCrashAPI extends TestBase {
recoverAll();
return;
}
if (config.mvcc || config.networked || config.logMode == 0) {
if (config.mvcc || config.networked) {
return;
}
int len = getSize(2, 6);
......@@ -151,7 +151,6 @@ public class TestCrashAPI extends TestBase {
// Runtime.getRuntime().halt(0);
// System.exit(1);
// }
// add = ";LOG=2";
// System.out.println("now open " + openCount);
// add += ";TRACE_LEVEL_FILE=3";
// config.logMode = 2;
......@@ -468,7 +467,7 @@ public class TestCrashAPI extends TestBase {
public TestBase init(TestAll conf) throws Exception {
super.init(conf);
if (config.mvcc || config.networked || config.logMode == 0) {
if (config.mvcc || config.networked) {
return this;
}
baseDir = TestBase.getTestDir("crash");
......
......@@ -10,7 +10,6 @@ import java.sql.Connection;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.test.TestBase;
import org.h2.test.db.Db;
import org.h2.test.db.Db.Prepared;
......@@ -42,7 +41,6 @@ public class TestFuzzOptimizations extends TestBase {
}
private void testInSelect() {
boolean old = SysProperties.optimizeInJoin;
Db db = new Db(conn);
db.execute("CREATE TABLE TEST(A INT, B INT)");
db.execute("CREATE INDEX IDX ON TEST(A)");
......@@ -53,22 +51,19 @@ public class TestFuzzOptimizations extends TestBase {
long seed = random.nextLong();
println("seed: " + seed);
for (int i = 0; i < 100; i++) {
String sql = "SELECT * FROM TEST T WHERE ";
sql += random.nextBoolean() ? "A" : "B";
sql += " IN(SELECT ";
sql += new String[] { "NULL", "0", "A", "B" }[random.nextInt(4)];
sql += " FROM TEST I WHERE I.";
sql += random.nextBoolean() ? "A" : "B";
sql += "=?) ORDER BY 1, 2";
int v = random.nextInt(3);
SysProperties.optimizeInJoin = false;
List<Map<String, Object>> a = db.prepare(sql).set(v).query();
SysProperties.optimizeInJoin = true;
List<Map<String, Object>> b = db.prepare(sql).set(v).query();
String column = random.nextBoolean() ? "A" : "B";
String value = new String[] { "NULL", "0", "A", "B" }[random.nextInt(4)];
String compare = random.nextBoolean() ? "A" : "B";
int x = random.nextInt(3);
String sql1 = "SELECT * FROM TEST T WHERE " + column + "+0 " +
"IN(SELECT " + value + " FROM TEST I WHERE I." + compare + "=?) ORDER BY 1, 2";
String sql2 = "SELECT * FROM TEST T WHERE " + column + " " +
"IN(SELECT " + value + " FROM TEST I WHERE I." + compare + "=?) ORDER BY 1, 2";
List<Map<String, Object>> a = db.prepare(sql1).set(x).query();
List<Map<String, Object>> b = db.prepare(sql2).set(x).query();
assertTrue(a.equals(b));
}
db.execute("DROP TABLE TEST");
SysProperties.optimizeInJoin = old;
}
private void testGroupSorted() {
......
差异被折叠。
......@@ -5699,8 +5699,8 @@ EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE ID IN(SELECT ID FROM TEST);
EXPLAIN PLAN FOR SELECT * FROM TEST T1 WHERE ID NOT IN(SELECT ID FROM TEST);
> PLAN
> -------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM PUBLIC.TEST T1 /* PUBLIC.TEST_DATA */ WHERE NOT (ID IN(SELECT ID FROM PUBLIC.TEST /* PUBLIC.TEST_DATA */))
> ----------------------------------------------------------------------------------------------------------------------------------------------
> SELECT T1.ID, T1.NAME FROM PUBLIC.TEST T1 /* PUBLIC.TEST_DATA */ WHERE NOT (ID IN(SELECT DISTINCT ID FROM PUBLIC.TEST /* PUBLIC.TEST_DATA */))
> rows: 1
EXPLAIN PLAN FOR SELECT CAST(ID AS VARCHAR(255)) FROM TEST;
......
......@@ -11,7 +11,6 @@ import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import org.h2.constant.SysProperties;
import org.h2.store.Data;
import org.h2.store.DataHandler;
import org.h2.store.DataPage;
......@@ -288,10 +287,6 @@ public class TestDataPage extends TestBase implements DataHandler {
// nothing to do
}
public void handleInvalidChecksum() throws SQLException {
throw new SQLException();
}
public int compareTypeSave(Value a, Value b) throws SQLException {
throw new SQLException();
}
......@@ -300,14 +295,6 @@ public class TestDataPage extends TestBase implements DataHandler {
throw new AssertionError();
}
public int allocateObjectId(boolean b, boolean c) {
throw new AssertionError();
}
public String createTempFile() throws SQLException {
throw new SQLException();
}
public String getLobCompressionAlgorithm(int type) {
throw new AssertionError();
}
......@@ -316,10 +303,6 @@ public class TestDataPage extends TestBase implements DataHandler {
return this;
}
public boolean getLobFilesInDirectories() {
return SysProperties.LOB_FILES_IN_DIRECTORIES;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return null;
}
......
......@@ -7,7 +7,6 @@
package org.h2.test.unit;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.store.DataHandler;
import org.h2.store.FileStore;
import org.h2.test.TestBase;
......@@ -131,10 +130,6 @@ public class TestFile extends TestBase implements DataHandler {
FileUtils.delete("~/testFile");
}
public int allocateObjectId(boolean needFresh, boolean dataFile) {
return 0;
}
public void checkPowerOff() {
// nothing to do
}
......@@ -147,10 +142,6 @@ public class TestFile extends TestBase implements DataHandler {
return 0;
}
public String createTempFile() {
return null;
}
public void freeUpDiskSpace() {
// nothing to do
}
......@@ -175,18 +166,10 @@ public class TestFile extends TestBase implements DataHandler {
return 0;
}
public void handleInvalidChecksum() {
// nothing to do
}
public FileStore openFile(String name, String mode, boolean mustExist) {
return null;
}
public boolean getLobFilesInDirectories() {
return SysProperties.LOB_FILES_IN_DIRECTORIES;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return null;
}
......
......@@ -255,7 +255,7 @@ public class TestFileLockSerialized extends TestBase {
String url = "jdbc:h2:" + baseDir + "/fileLockSerialized";
String writeUrl = url + ";FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE";
// ;TRACE_LEVEL_SYSTEM_OUT=3
// String readUrl = writeUrl + ";ACCESS_MODE_LOG=R;ACCESS_MODE_DATA=R";
// String readUrl = writeUrl + ";ACCESS_MODE_DATA=R";
trace(" create database");
Class.forName("org.h2.Driver");
......@@ -327,7 +327,7 @@ public class TestFileLockSerialized extends TestBase {
println("testAutoIncrement waitTime: " + waitTime + " howManyThreads: " + howManyThreads + " runTime: " + runTime);
deleteDb("fileLockSerialized");
final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;" +
"AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;LOG=2;CACHE_SIZE=65536";
"AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;CACHE_SIZE=65536";
Connection conn = DriverManager.getConnection(url);
conn.createStatement().execute("create table test(id int auto_increment, id2 int)");
......@@ -394,7 +394,7 @@ public class TestFileLockSerialized extends TestBase {
println("testConcurrentUpdates waitTime: " + waitTime + " howManyThreads: " + howManyThreads + " runTime: " + runTime);
deleteDb("fileLockSerialized");
final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;" +
"AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;LOG=2;CACHE_SIZE=65536";
"AUTO_RECONNECT=TRUE;MAX_LENGTH_INPLACE_LOB=8192;COMPRESS_LOB=DEFLATE;CACHE_SIZE=65536";
Connection conn = DriverManager.getConnection(url);
conn.createStatement().execute("create table test(id int)");
......
......@@ -10,7 +10,6 @@ import java.sql.SQLException;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.store.DataHandler;
import org.h2.store.FileStore;
import org.h2.test.TestBase;
......@@ -136,10 +135,6 @@ public class TestValueHashMap extends TestBase implements DataHandler {
// nothing to do
}
public void handleInvalidChecksum() {
// nothing to do
}
public int compareTypeSave(Value a, Value b) throws SQLException {
return a.compareTo(b, compareMode);
}
......@@ -148,14 +143,6 @@ public class TestValueHashMap extends TestBase implements DataHandler {
return 0;
}
public int allocateObjectId(boolean b, boolean c) {
return 0;
}
public String createTempFile() {
return null;
}
public String getLobCompressionAlgorithm(int type) {
return null;
}
......@@ -164,10 +151,6 @@ public class TestValueHashMap extends TestBase implements DataHandler {
return this;
}
public boolean getLobFilesInDirectories() {
return SysProperties.LOB_FILES_IN_DIRECTORIES;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return null;
}
......
......@@ -7,20 +7,15 @@
package org.h2.test.unit;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.store.DataHandler;
import org.h2.store.FileStore;
import org.h2.test.TestBase;
import org.h2.util.FileUtils;
import org.h2.util.MemoryUtils;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
......@@ -183,10 +178,6 @@ public class TestValueMemory extends TestBase implements DataHandler {
return new String(chars);
}
public int allocateObjectId(boolean needFresh, boolean dataFile) {
return 0;
}
public void checkPowerOff() {
// nothing to do
}
......@@ -199,15 +190,6 @@ public class TestValueMemory extends TestBase implements DataHandler {
return 0;
}
public String createTempFile() throws SQLException {
String name = baseDir + "/valueMemory/data";
try {
return FileUtils.createTempFile(name, Constants.SUFFIX_TEMP_FILE, true, false);
} catch (IOException e) {
throw Message.convertIOException(e, name);
}
}
public void freeUpDiskSpace() {
// nothing to do
}
......@@ -232,18 +214,10 @@ public class TestValueMemory extends TestBase implements DataHandler {
return 100;
}
public void handleInvalidChecksum() {
// nothing to do
}
public FileStore openFile(String name, String mode, boolean mustExist) throws SQLException {
return FileStore.open(this, name, mode);
}
public boolean getLobFilesInDirectories() {
return SysProperties.LOB_FILES_IN_DIRECTORIES;
}
public SmallLRUCache<String, String[]> getLobFileListCache() {
return lobFileListCache;
}
......
......@@ -288,6 +288,7 @@ public class Build extends BuildBase {
FileList files = files("temp").
exclude("temp/org/h2/build/*").
exclude("temp/org/h2/dev/*").
exclude("temp/org/h2/jcr/*").
exclude("temp/org/h2/jaqu/*").
exclude("temp/org/h2/mode/*").
exclude("temp/org/h2/samples/*").
......
......@@ -18,7 +18,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Properties;
import org.h2.constant.SysProperties;
import org.h2.server.Service;
import org.h2.store.fs.FileSystem;
import org.h2.tools.Server;
......@@ -340,9 +339,6 @@ public class FtpServer extends Tool implements Service {
writePassword = args[++i];
} else if ("-trace".equals(a)) {
trace = true;
} else if ("-log".equals(a) && SysProperties.OLD_COMMAND_LINE_OPTIONS) {
trace = Tool.readArgBoolean(args, i) == 1;
i++;
} else if ("-ftpTask".equals(a)) {
allowTask = true;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论