提交 20ea18c2 authored 作者: Thomas Mueller's avatar Thomas Mueller

SET QUERY_TIMEOUT and Statement.setQueryTimeout no longer commits

        a transaction. The same applies to SET @VARIABLE, SET LOCK_TIMEOUT, 
        SET TRACE_LEVEL_*, SET THROTTLE, and SET PATH.
上级 b08ba47c
......@@ -51,6 +51,17 @@ public class Set extends Prepared {
}
public boolean isTransactional() {
switch (type) {
case SetTypes.VARIABLE:
case SetTypes.QUERY_TIMEOUT:
case SetTypes.LOCK_TIMEOUT:
case SetTypes.TRACE_LEVEL_SYSTEM_OUT:
case SetTypes.TRACE_LEVEL_FILE:
case SetTypes.THROTTLE:
case SetTypes.SCHEMA:
case SetTypes.SCHEMA_SEARCH_PATH:
return true;
}
return false;
}
......@@ -59,50 +70,14 @@ public class Set extends Prepared {
Database database = session.getDatabase();
String name = SetTypes.getTypeName(type);
switch (type) {
case SetTypes.MAX_LOG_SIZE:
session.getUser().checkAdmin();
session.getDatabase().setMaxLogSize((long) getIntValue() * 1024 * 1024);
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.LOCK_TIMEOUT:
session.setLockTimeout(getIntValue());
break;
case SetTypes.LOCK_MODE:
session.getUser().checkAdmin();
database.setLockMode(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.DEFAULT_LOCK_TIMEOUT:
session.getUser().checkAdmin();
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.DEFAULT_TABLE_TYPE:
session.getUser().checkAdmin();
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.TRACE_LEVEL_SYSTEM_OUT:
session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
database.getTraceSystem().setLevelSystemOut(getIntValue());
}
break;
case SetTypes.TRACE_LEVEL_FILE:
case SetTypes.ALLOW_LITERALS: {
session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
database.getTraceSystem().setLevelFile(getIntValue());
int value = getIntValue();
if (value < 0 || value > 2) {
throw Message.getInvalidValueException("" + getIntValue(), "ALLOW_LITERALS");
}
break;
case SetTypes.TRACE_MAX_FILE_SIZE: {
session.getUser().checkAdmin();
int size = getIntValue() * 1024 * 1024;
database.getTraceSystem().setMaxFileSize(size);
addOrUpdateSetting(name, null, getIntValue());
database.setAllowLiterals(value);
addOrUpdateSetting(name, null, value);
break;
}
case SetTypes.CACHE_SIZE:
......@@ -110,14 +85,12 @@ public class Set extends Prepared {
database.setCacheSize(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.MODE:
case SetTypes.CLUSTER: {
session.getUser().checkAdmin();
Mode mode = Mode.getInstance(stringValue);
if (mode == null) {
throw Message.getSQLException(ErrorCode.UNKNOWN_MODE_1, stringValue);
}
database.setMode(mode);
database.setCluster(StringUtils.quoteStringSQL(stringValue));
addOrUpdateSetting(name, StringUtils.quoteStringSQL(stringValue), 0);
break;
}
case SetTypes.COLLATION: {
session.getUser().checkAdmin();
ObjectArray array = database.getAllSchemaObjects(DbObject.TABLE_OR_VIEW);
......@@ -150,21 +123,21 @@ public class Set extends Prepared {
database.setCompareMode(compareMode);
break;
}
case SetTypes.IGNORECASE:
session.getUser().checkAdmin();
session.getDatabase().setIgnoreCase(getIntValue() == 1);
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.CLUSTER: {
case SetTypes.COMPRESS_LOB: {
session.getUser().checkAdmin();
database.setCluster(StringUtils.quoteStringSQL(stringValue));
addOrUpdateSetting(name, StringUtils.quoteStringSQL(stringValue), 0);
int algo = CompressTool.getInstance().getCompressAlgorithm(stringValue);
database.setLobCompressionAlgorithm(algo == Compressor.NO ? null : stringValue);
addOrUpdateSetting(name, stringValue, 0);
break;
}
case SetTypes.WRITE_DELAY: {
case SetTypes.CREATE_BUILD: {
session.getUser().checkAdmin();
database.setWriteDelay(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
if (database.isStarting()) {
// just ignore the command if not starting
// this avoids problems when running recovery scripts
int value = getIntValue();
addOrUpdateSetting(name, null, value);
}
break;
}
case SetTypes.DATABASE_EVENT_LISTENER: {
......@@ -172,23 +145,39 @@ public class Set extends Prepared {
database.setEventListenerClass(stringValue);
break;
}
case SetTypes.MAX_MEMORY_ROWS: {
case SetTypes.DB_CLOSE_DELAY: {
session.getUser().checkAdmin();
database.setMaxMemoryRows(getIntValue());
database.setCloseDelay(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.MULTI_THREADED: {
case SetTypes.DEFAULT_LOCK_TIMEOUT:
session.getUser().checkAdmin();
database.setMultiThreaded(getIntValue() == 1);
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.DB_CLOSE_DELAY: {
case SetTypes.DEFAULT_TABLE_TYPE:
session.getUser().checkAdmin();
database.setCloseDelay(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.EXCLUSIVE: {
session.getUser().checkAdmin();
int value = getIntValue();
database.setExclusiveSession(value == 1 ? session : null);
break;
}
case SetTypes.IGNORECASE:
session.getUser().checkAdmin();
database.setIgnoreCase(getIntValue() == 1);
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.LOCK_MODE:
session.getUser().checkAdmin();
database.setLockMode(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.LOCK_TIMEOUT:
session.setLockTimeout(getIntValue());
break;
case SetTypes.LOG: {
int value = getIntValue();
if (value < 0 || value > 2) {
......@@ -199,52 +188,59 @@ public class Set extends Prepared {
}
database.setLog(value);
break;
}
case SetTypes.THROTTLE: {
}
case SetTypes.MAX_LENGTH_INPLACE_LOB: {
if (getIntValue() < 0) {
throw Message.getInvalidValueException("" + getIntValue(), "THROTTLE");
throw Message.getInvalidValueException("" + getIntValue(), "MAX_LENGTH_INPLACE_LOB");
}
session.setThrottle(getIntValue());
session.getUser().checkAdmin();
database.setMaxLengthInplaceLob(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.MAX_MEMORY_UNDO: {
if (getIntValue() < 0) {
throw Message.getInvalidValueException("" + getIntValue(), "MAX_MEMORY_UNDO");
}
case SetTypes.MAX_LOG_SIZE:
session.getUser().checkAdmin();
database.setMaxMemoryUndo(getIntValue());
database.setMaxLogSize((long) getIntValue() * 1024 * 1024);
addOrUpdateSetting(name, null, getIntValue());
break;
case SetTypes.MAX_MEMORY_ROWS: {
session.getUser().checkAdmin();
database.setMaxMemoryRows(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.MAX_LENGTH_INPLACE_LOB: {
case SetTypes.MAX_MEMORY_UNDO: {
if (getIntValue() < 0) {
throw Message.getInvalidValueException("" + getIntValue(), "MAX_LENGTH_INPLACE_LOB");
throw Message.getInvalidValueException("" + getIntValue(), "MAX_MEMORY_UNDO");
}
session.getUser().checkAdmin();
database.setMaxLengthInplaceLob(getIntValue());
database.setMaxMemoryUndo(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.COMPRESS_LOB: {
case SetTypes.MAX_OPERATION_MEMORY: {
session.getUser().checkAdmin();
int algo = CompressTool.getInstance().getCompressAlgorithm(stringValue);
database.setLobCompressionAlgorithm(algo == Compressor.NO ? null : stringValue);
addOrUpdateSetting(name, stringValue, 0);
int value = getIntValue();
database.setMaxOperationMemory(value);
break;
}
case SetTypes.ALLOW_LITERALS: {
case SetTypes.MODE:
session.getUser().checkAdmin();
int value = getIntValue();
if (value < 0 || value > 2) {
throw Message.getInvalidValueException("" + getIntValue(), "ALLOW_LITERALS");
Mode mode = Mode.getInstance(stringValue);
if (mode == null) {
throw Message.getSQLException(ErrorCode.UNKNOWN_MODE_1, stringValue);
}
database.setAllowLiterals(value);
addOrUpdateSetting(name, null, value);
database.setMode(mode);
break;
case SetTypes.MULTI_THREADED: {
session.getUser().checkAdmin();
database.setMultiThreaded(getIntValue() == 1);
break;
}
case SetTypes.SCHEMA: {
Schema schema = database.getSchema(stringValue);
session.setCurrentSchema(schema);
case SetTypes.MVCC: {
if (database.isMultiVersion() != (getIntValue() == 1)) {
throw Message.getSQLException(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, "MVCC");
}
break;
}
case SetTypes.OPTIMIZE_REUSE_RESULTS: {
......@@ -252,16 +248,9 @@ public class Set extends Prepared {
database.setOptimizeReuseResults(getIntValue() != 0);
break;
}
case SetTypes.SCHEMA_SEARCH_PATH: {
session.setSchemaSearchPath(stringValueList);
break;
}
case SetTypes.UNDO_LOG: {
case SetTypes.QUERY_TIMEOUT: {
int value = getIntValue();
if (value < 0 || value > 1) {
throw Message.getInvalidValueException("" + getIntValue(), "UNDO_LOG");
}
session.setUndoLogEnabled(value == 1);
session.setQueryTimeout(value);
break;
}
case SetTypes.REFERENTIAL_INTEGRITY: {
......@@ -273,32 +262,53 @@ public class Set extends Prepared {
database.setReferentialIntegrity(value == 1);
break;
}
case SetTypes.MVCC: {
if (database.isMultiVersion() != (getIntValue() == 1)) {
throw Message.getSQLException(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, "MVCC");
}
case SetTypes.SCHEMA: {
Schema schema = database.getSchema(stringValue);
session.setCurrentSchema(schema);
break;
}
case SetTypes.MAX_OPERATION_MEMORY: {
session.getUser().checkAdmin();
int value = getIntValue();
database.setMaxOperationMemory(value);
case SetTypes.SCHEMA_SEARCH_PATH: {
session.setSchemaSearchPath(stringValueList);
break;
}
case SetTypes.EXCLUSIVE: {
case SetTypes.TRACE_LEVEL_FILE:
session.getUser().checkAdmin();
int value = getIntValue();
database.setExclusiveSession(value == 1 ? session : null);
if (getCurrentObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
database.getTraceSystem().setLevelFile(getIntValue());
}
break;
}
case SetTypes.CREATE_BUILD: {
case SetTypes.TRACE_LEVEL_SYSTEM_OUT:
session.getUser().checkAdmin();
if (database.isStarting()) {
// just ignore the command if not starting
// this avoids problems when running recovery scripts
int value = getIntValue();
addOrUpdateSetting(name, null, value);
if (getCurrentObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
database.getTraceSystem().setLevelSystemOut(getIntValue());
}
break;
case SetTypes.TRACE_MAX_FILE_SIZE: {
session.getUser().checkAdmin();
int size = getIntValue() * 1024 * 1024;
database.getTraceSystem().setMaxFileSize(size);
addOrUpdateSetting(name, null, getIntValue());
break;
}
case SetTypes.THROTTLE: {
if (getIntValue() < 0) {
throw Message.getInvalidValueException("" + getIntValue(), "THROTTLE");
}
session.setThrottle(getIntValue());
break;
}
case SetTypes.UNDO_LOG: {
int value = getIntValue();
if (value < 0 || value > 1) {
throw Message.getInvalidValueException("" + getIntValue(), "UNDO_LOG");
}
session.setUndoLogEnabled(value == 1);
break;
}
case SetTypes.VARIABLE: {
......@@ -306,9 +316,10 @@ public class Set extends Prepared {
session.setVariable(stringValue, expr.getValue(session));
break;
}
case SetTypes.QUERY_TIMEOUT: {
int value = getIntValue();
session.setQueryTimeout(value);
case SetTypes.WRITE_DELAY: {
session.getUser().checkAdmin();
database.setWriteDelay(getIntValue());
addOrUpdateSetting(name, null, getIntValue());
break;
}
default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论