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