提交 e198f0dc authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Allow no-op changes in BINARY and UUID collations

上级 4a2696c3
...@@ -158,42 +158,46 @@ public class Set extends Prepared { ...@@ -158,42 +158,46 @@ public class Set extends Prepared {
} }
case SetTypes.BINARY_COLLATION: { case SetTypes.BINARY_COLLATION: {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
Table table = database.getFirstUserTable(); boolean unsigned;
if (table != null) {
throw DbException.get(ErrorCode.COLLATION_CHANGE_WITH_DATA_TABLE_1, table.getSQL());
}
CompareMode currentMode = database.getCompareMode();
CompareMode newMode;
if (stringValue.equals(CompareMode.SIGNED)) { if (stringValue.equals(CompareMode.SIGNED)) {
newMode = CompareMode.getInstance(currentMode.getName(), unsigned = false;
currentMode.getStrength(), false, currentMode.isUuidUnsigned());
} else if (stringValue.equals(CompareMode.UNSIGNED)) { } else if (stringValue.equals(CompareMode.UNSIGNED)) {
newMode = CompareMode.getInstance(currentMode.getName(), unsigned = true;
currentMode.getStrength(), true, currentMode.isUuidUnsigned());
} else { } else {
throw DbException.getInvalidValueException("BINARY_COLLATION", stringValue); throw DbException.getInvalidValueException("BINARY_COLLATION", stringValue);
} }
CompareMode currentMode = database.getCompareMode();
if (currentMode.isBinaryUnsigned() != unsigned) {
Table table = database.getFirstUserTable();
if (table != null) {
throw DbException.get(ErrorCode.COLLATION_CHANGE_WITH_DATA_TABLE_1, table.getSQL());
}
}
CompareMode newMode = CompareMode.getInstance(currentMode.getName(),
currentMode.getStrength(), unsigned, currentMode.isUuidUnsigned());
addOrUpdateSetting(name, stringValue, 0); addOrUpdateSetting(name, stringValue, 0);
database.setCompareMode(newMode); database.setCompareMode(newMode);
break; break;
} }
case SetTypes.UUID_COLLATION: { case SetTypes.UUID_COLLATION: {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
Table table = database.getFirstUserTable(); boolean unsigned;
if (table != null) {
throw DbException.get(ErrorCode.COLLATION_CHANGE_WITH_DATA_TABLE_1, table.getSQL());
}
CompareMode currentMode = database.getCompareMode();
CompareMode newMode;
if (stringValue.equals(CompareMode.SIGNED)) { if (stringValue.equals(CompareMode.SIGNED)) {
newMode = CompareMode.getInstance(currentMode.getName(), unsigned = false;
currentMode.getStrength(), currentMode.isBinaryUnsigned(), false);
} else if (stringValue.equals(CompareMode.UNSIGNED)) { } else if (stringValue.equals(CompareMode.UNSIGNED)) {
newMode = CompareMode.getInstance(currentMode.getName(), unsigned = true;
currentMode.getStrength(), currentMode.isBinaryUnsigned(), true);
} else { } else {
throw DbException.getInvalidValueException("UUID_COLLATION", stringValue); throw DbException.getInvalidValueException("UUID_COLLATION", stringValue);
} }
CompareMode currentMode = database.getCompareMode();
if (currentMode.isUuidUnsigned() != unsigned) {
Table table = database.getFirstUserTable();
if (table != null) {
throw DbException.get(ErrorCode.COLLATION_CHANGE_WITH_DATA_TABLE_1, table.getSQL());
}
}
CompareMode newMode = CompareMode.getInstance(currentMode.getName(),
currentMode.getStrength(), currentMode.isBinaryUnsigned(), unsigned);
addOrUpdateSetting(name, stringValue, 0); addOrUpdateSetting(name, stringValue, 0);
database.setCompareMode(newMode); database.setCompareMode(newMode);
break; break;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论