提交 34e8b659 authored 作者: Thomas Mueller's avatar Thomas Mueller

Formatting, javadocs, cleanup

上级 0d27db6c
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -226,7 +226,7 @@ public class Set extends Prepared { ...@@ -226,7 +226,7 @@ public class Set extends Prepared {
if (table != null) { if (table != null) {
throw DbException.get(ErrorCode.JAVA_OBJECT_SERIALIZER_CHANGE_WITH_DATA_TABLE, table.getSQL()); throw DbException.get(ErrorCode.JAVA_OBJECT_SERIALIZER_CHANGE_WITH_DATA_TABLE, table.getSQL());
} }
database.setJavaObjectSerializerFQN (stringValue); database.setJavaObjectSerializerName(stringValue);
addOrUpdateSetting(name, stringValue, 0); addOrUpdateSetting(name, stringValue, 0);
break; break;
} }
......
...@@ -179,7 +179,7 @@ public class Database implements DataHandler { ...@@ -179,7 +179,7 @@ public class Database implements DataHandler {
private DbException backgroundException; private DbException backgroundException;
private JavaObjectSerializer javaObjectSerializer; private JavaObjectSerializer javaObjectSerializer;
private String javaObjectSerializerFQN; private String javaObjectSerializerName;
private volatile boolean javaObjectSerializerInitialized; private volatile boolean javaObjectSerializerInitialized;
public Database(ConnectionInfo ci, String cipher) { public Database(ConnectionInfo ci, String cipher) {
...@@ -216,7 +216,7 @@ public class Database implements DataHandler { ...@@ -216,7 +216,7 @@ public class Database implements DataHandler {
} }
this.multiVersion = ci.getProperty("MVCC", false); this.multiVersion = ci.getProperty("MVCC", false);
this.logMode = ci.getProperty("LOG", PageStore.LOG_MODE_SYNC); this.logMode = ci.getProperty("LOG", PageStore.LOG_MODE_SYNC);
this.javaObjectSerializerFQN = ci.getProperty("JAVA_OBJECT_SERIALIZER", null); this.javaObjectSerializerName = ci.getProperty("JAVA_OBJECT_SERIALIZER", null);
boolean closeAtVmShutdown = dbSettings.dbCloseOnExit; boolean closeAtVmShutdown = dbSettings.dbCloseOnExit;
int traceLevelFile = ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE, TraceSystem.DEFAULT_TRACE_LEVEL_FILE); int traceLevelFile = ci.getIntProperty(SetTypes.TRACE_LEVEL_FILE, TraceSystem.DEFAULT_TRACE_LEVEL_FILE);
...@@ -2518,12 +2518,12 @@ public class Database implements DataHandler { ...@@ -2518,12 +2518,12 @@ public class Database implements DataHandler {
if (javaObjectSerializerInitialized) { if (javaObjectSerializerInitialized) {
return; return;
} }
String serializerFQN = javaObjectSerializerFQN; String serializerName = javaObjectSerializerName;
if (serializerFQN != null) { if (serializerName != null) {
serializerFQN = serializerFQN.trim(); serializerName = serializerName.trim();
if (!serializerFQN.isEmpty() && !serializerFQN.equals("null")) { if (!serializerName.isEmpty() && !serializerName.equals("null")) {
try { try {
javaObjectSerializer = (JavaObjectSerializer) Utils.loadUserClass(serializerFQN).newInstance(); javaObjectSerializer = (JavaObjectSerializer) Utils.loadUserClass(serializerName).newInstance();
} catch (Exception e) { } catch (Exception e) {
throw DbException.convert(e); throw DbException.convert(e);
} }
...@@ -2533,10 +2533,10 @@ public class Database implements DataHandler { ...@@ -2533,10 +2533,10 @@ public class Database implements DataHandler {
} }
} }
public void setJavaObjectSerializerFQN(String javaObjectSerializerFQN) { public void setJavaObjectSerializerName(String serializerName) {
this.javaObjectSerializerFQN = javaObjectSerializerFQN;
synchronized (this) { synchronized (this) {
javaObjectSerializerInitialized = false; javaObjectSerializerInitialized = false;
javaObjectSerializerName = serializerName;
} }
} }
} }
...@@ -785,18 +785,20 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -785,18 +785,20 @@ public class SessionRemote extends SessionWithState implements DataHandler {
} }
/** /**
* Read needed persistent db settings * Read the serializer name from the persistent database settings.
*
* @return the serializer
*/ */
private String readSerializationSettings () { private String readSerializationSettings() {
String javaObjectSerializerFQN = null; String javaObjectSerializerFQN = null;
CommandInterface ci = prepareCommand( CommandInterface ci = prepareCommand(
"SELECT * FROM INFORMATION_SCHEMA.SETTINGS "+ "SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS "+
" WHERE NAME='JAVA_OBJECT_SERIALIZER'", Integer.MAX_VALUE); " WHERE NAME='JAVA_OBJECT_SERIALIZER'", Integer.MAX_VALUE);
try { try {
ResultInterface result = ci.executeQuery(0, false); ResultInterface result = ci.executeQuery(0, false);
if (result.next()) { if (result.next()) {
Value[] row = result.currentRow(); Value[] row = result.currentRow();
javaObjectSerializerFQN = row[1].getString(); javaObjectSerializerFQN = row[0].getString();
} }
} finally { } finally {
ci.close(); ci.close();
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=Neplatný název databáze: {0} 90138=Neplatný název databáze: {0}
90139=Nenalezena veřejná statická Java metoda: {0} 90139=Nenalezena veřejná statická Java metoda: {0}
90140=Vrácený výsledek je pouze pro čtení. Možná budete muset použít conn.createStatement(..., ResultSet.CONCUR_UPDATABLE). 90140=Vrácený výsledek je pouze pro čtení. Možná budete muset použít conn.createStatement(..., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Obecná chyba: {0} HY000=Obecná chyba: {0}
HY004=Neznámý datový typ: {0} HY004=Neznámý datový typ: {0}
HYC00=Vlastnost není podporována: {0} HYC00=Vlastnost není podporována: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=Ungültiger Datenbank Name: {0} 90138=Ungültiger Datenbank Name: {0}
90139=Die (public static) Java Funktion wurde nicht gefunden: {0} 90139=Die (public static) Java Funktion wurde nicht gefunden: {0}
90140=Die Resultat-Zeilen können nicht verändert werden. Mögliche Lösung: conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=Die Resultat-Zeilen können nicht verändert werden. Mögliche Lösung: conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=Serialisierer kann nicht geändert werden wenn eine Daten-Tabelle existiert: {0}
HY000=Allgemeiner Fehler: {0} HY000=Allgemeiner Fehler: {0}
HY004=Unbekannter Datentyp: {0} HY004=Unbekannter Datentyp: {0}
HYC00=Dieses Feature wird nicht unterstützt: {0} HYC00=Dieses Feature wird nicht unterstützt: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=Nombre de base de datos Invalido: {0} 90138=Nombre de base de datos Invalido: {0}
90139=El metodo Java (publico y estatico) : {0} no fue encontrado 90139=El metodo Java (publico y estatico) : {0} no fue encontrado
90140=El conjunto de resultados es de solo lectura. Puede ser necesario usar conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=El conjunto de resultados es de solo lectura. Puede ser necesario usar conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Error General : {0} HY000=Error General : {0}
HY004=Tipo de dato desconocido : {0} HY004=Tipo de dato desconocido : {0}
HYC00=Caracteristica no soportada: {0} HYC00=Caracteristica no soportada: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=不正なデータベース名: {0} 90138=不正なデータベース名: {0}
90139=public staticであるJavaメソッドが見つかりません: {0} 90139=public staticであるJavaメソッドが見つかりません: {0}
90140=リザルトセットは読み込み専用です。conn.createStatement(.., ResultSet.CONCUR_UPDATABLE) を使う必要があるかもしれません 90140=リザルトセットは読み込み専用です。conn.createStatement(.., ResultSet.CONCUR_UPDATABLE) を使う必要があるかもしれません
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=一般エラー: {0} HY000=一般エラー: {0}
HY004=不明なデータ型: {0} HY004=不明なデータ型: {0}
HYC00=機能はサポートされていません: {0} HYC00=機能はサポートされていません: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=#Invalid database name: {0} 90138=#Invalid database name: {0}
90139=#The public static Java method was not found: {0} 90139=#The public static Java method was not found: {0}
90140=#The result set is readonly. You may need to use conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=#The result set is readonly. You may need to use conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Blad ogolny: {0} HY000=Blad ogolny: {0}
HY004=Nieznany typ danyche: {0} HY004=Nieznany typ danyche: {0}
HYC00=Cecha nie jest wspierana: {0} HYC00=Cecha nie jest wspierana: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=#Invalid database name: {0} 90138=#Invalid database name: {0}
90139=#The public static Java method was not found: {0} 90139=#The public static Java method was not found: {0}
90140=#The result set is readonly. You may need to use conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=#The result set is readonly. You may need to use conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Erro geral: {0} HY000=Erro geral: {0}
HY004=Tipo de dados desconhecido: {0} HY004=Tipo de dados desconhecido: {0}
HYC00=Recurso não suportado: {0} HYC00=Recurso não suportado: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=Недопустимое имя базы данных: {0} 90138=Недопустимое имя базы данных: {0}
90139=public static Java метод не найден: {0} 90139=public static Java метод не найден: {0}
90140=Набор записей не является обновляемым. Возможно необходимо использовать conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=Набор записей не является обновляемым. Возможно необходимо использовать conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Внутренняя ошибка: {0} HY000=Внутренняя ошибка: {0}
HY004=Неизвестный тип данных: {0} HY004=Неизвестный тип данных: {0}
HYC00=Данная функция не поддерживается: {0} HYC00=Данная функция не поддерживается: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=Nesprávne meno databázy: {0} 90138=Nesprávne meno databázy: {0}
90139=Verejná statická Java metóda nebola nájdená: {0} 90139=Verejná statická Java metóda nebola nájdená: {0}
90140=Výsledok (result set) je iba na čítanie. Je potrebné použiť conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=Výsledok (result set) je iba na čítanie. Je potrebné použiť conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=Všeobecná chyba: {0} HY000=Všeobecná chyba: {0}
HY004=Neznámy dátový typ: {0} HY004=Neznámy dátový typ: {0}
HYC00=Vlastnosť nie je podporovaná: {0} HYC00=Vlastnosť nie je podporovaná: {0}
......
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
90138=无效数据库名称: {0} 90138=无效数据库名称: {0}
90139=找不到公用Java静态方法: {0} 90139=找不到公用Java静态方法: {0}
90140=结果集是只读的. 你可以使用 conn.createStatement(.., ResultSet.CONCUR_UPDATABLE). 90140=结果集是只读的. 你可以使用 conn.createStatement(.., ResultSet.CONCUR_UPDATABLE).
90141=#Serializer cannot be changed because there is a data table: {0}
HY000=常规错误: {0} HY000=常规错误: {0}
HY004=位置数据类型: {0} HY004=位置数据类型: {0}
HYC00=不支持的特性: {0} HYC00=不支持的特性: {0}
......
...@@ -172,7 +172,7 @@ ON tableName ( indexColumn [,...] ) ...@@ -172,7 +172,7 @@ ON tableName ( indexColumn [,...] )
"," ","
Creates a new index." Creates a new index."
"Commands (DDL)","CREATE LINKED TABLE"," "Commands (DDL)","CREATE LINKED TABLE","
CREATE [ [ GLOBAL | LOCAL ] TEMPORARY ] LINKED TABLE [ IF NOT EXISTS ] CREATE [ FORCE ] [ [ GLOBAL | LOCAL ] TEMPORARY ] LINKED TABLE [ IF NOT EXISTS ]
name ( driverString, urlString, userString, passwordString, name ( driverString, urlString, userString, passwordString,
[ originalSchemaString, ] originalTableString ) [ EMIT UPDATES | READONLY ] [ originalSchemaString, ] originalTableString ) [ EMIT UPDATES | READONLY ]
"," ","
......
...@@ -628,7 +628,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -628,7 +628,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
if (o == null || o instanceof byte[]) { if (o == null || o instanceof byte[]) {
return (byte[]) o; return (byte[]) o;
} }
return Utils.serialize(o); return Utils.serialize(o, null);
} }
/** /**
......
...@@ -328,21 +328,8 @@ public class Utils { ...@@ -328,21 +328,8 @@ public class Utils {
} }
/** /**
* Serialize the object to a byte array. * Serialize the object to a byte array, using the serializer specified by
* * the connection info if set, or the default serializer.
* @param obj the object to serialize
* @return the byte array
*
* @deprecated use {@link #serialize(Object, DataHandler)} instead
*/
@Deprecated
public static byte[] serialize(Object obj) {
return serialize(obj, null);
}
/**
* Serialize the object to a byte array, eventually using the serializer
* specified by the connection info.
* *
* @param obj the object to serialize * @param obj the object to serialize
* @param dataHandler provides the object serializer (may be null) * @param dataHandler provides the object serializer (may be null)
...@@ -350,12 +337,12 @@ public class Utils { ...@@ -350,12 +337,12 @@ public class Utils {
*/ */
public static byte[] serialize(Object obj, DataHandler dataHandler) { public static byte[] serialize(Object obj, DataHandler dataHandler) {
try { try {
JavaObjectSerializer dbJavaObjectSerializer = null; JavaObjectSerializer handlerSerializer = null;
if (dataHandler != null) { if (dataHandler != null) {
dbJavaObjectSerializer = dataHandler.getJavaObjectSerializer(); handlerSerializer = dataHandler.getJavaObjectSerializer();
} }
if (dbJavaObjectSerializer != null) { if (handlerSerializer != null) {
return dbJavaObjectSerializer.serialize(obj); return handlerSerializer.serialize(obj);
} }
if (serializer != null) { if (serializer != null) {
return serializer.serialize(obj); return serializer.serialize(obj);
......
...@@ -350,8 +350,6 @@ java org.h2.test.TestAll timer ...@@ -350,8 +350,6 @@ java org.h2.test.TestAll timer
private Server server; private Server server;
public String javaObjectSerializer;
/** /**
* Run all tests. * Run all tests.
* *
......
...@@ -320,9 +320,6 @@ public abstract class TestBase { ...@@ -320,9 +320,6 @@ public abstract class TestBase {
if (config.nestedJoins) { if (config.nestedJoins) {
url = addOption(url, "NESTED_JOINS", "TRUE"); url = addOption(url, "NESTED_JOINS", "TRUE");
} }
if (config.javaObjectSerializer!=null) {
url = addOption(url, "JAVA_OBJECT_SERIALIZER", config.javaObjectSerializer);
}
return "jdbc:h2:" + url; return "jdbc:h2:" + url;
} }
......
...@@ -507,7 +507,8 @@ public class TestIndex extends TestBase { ...@@ -507,7 +507,8 @@ public class TestIndex extends TestBase {
private void testHashIndexOnMemoryTable() throws SQLException { private void testHashIndexOnMemoryTable() throws SQLException {
reconnect(); reconnect();
stat.execute("drop table if exists hash_index_test"); stat.execute("drop table if exists hash_index_test");
stat.execute("create memory table hash_index_test as select x as id, x % 10 as data from (select * from system_range(1, 100))"); stat.execute("create memory table hash_index_test as " +
"select x as id, x % 10 as data from (select * from system_range(1, 100))");
stat.execute("create hash index idx2 on hash_index_test(data)"); stat.execute("create hash index idx2 on hash_index_test(data)");
assertEquals(10, getValue("select count(*) from hash_index_test where data = 1")); assertEquals(10, getValue("select count(*) from hash_index_test where data = 1"));
......
...@@ -46,7 +46,7 @@ public class TestJavaObjectSerializer extends TestBase { ...@@ -46,7 +46,7 @@ public class TestJavaObjectSerializer extends TestBase {
deleteDb("javaSerializer"); deleteDb("javaSerializer");
} }
public void testStaticGlobalSerializer() throws Exception { private void testStaticGlobalSerializer() throws Exception {
Utils.serializer = new JavaObjectSerializer() { Utils.serializer = new JavaObjectSerializer() {
@Override @Override
public byte[] serialize(Object obj) throws Exception { public byte[] serialize(Object obj) throws Exception {
...@@ -91,11 +91,12 @@ public class TestJavaObjectSerializer extends TestBase { ...@@ -91,11 +91,12 @@ public class TestJavaObjectSerializer extends TestBase {
} }
/** /**
* Tests per-db {@link JavaObjectSerializer} when set through the related * Tests per-database serializer when set through the related SET command.
* SET command.
*/ */
public void testDbLevelJavaObjectSerializer() throws Exception { public void testDbLevelJavaObjectSerializer() throws Exception {
DbLevelJavaObjectSerializer.testBaseRef = this; DbLevelJavaObjectSerializer.testBaseRef = this;
try { try {
deleteDb("javaSerializer"); deleteDb("javaSerializer");
Connection conn = getConnection("javaSerializer"); Connection conn = getConnection("javaSerializer");
...@@ -125,9 +126,15 @@ public class TestJavaObjectSerializer extends TestBase { ...@@ -125,9 +126,15 @@ public class TestJavaObjectSerializer extends TestBase {
} }
} }
/**
* The serializer to use for this test.
*/
public static class DbLevelJavaObjectSerializer implements JavaObjectSerializer { public static class DbLevelJavaObjectSerializer implements JavaObjectSerializer {
private static TestBase testBaseRef; /**
* The test.
*/
static TestBase testBaseRef;
@Override @Override
public byte[] serialize(Object obj) throws Exception { public byte[] serialize(Object obj) throws Exception {
......
...@@ -31,7 +31,6 @@ public class TestUrlJavaObjectSerializer extends TestBase { ...@@ -31,7 +31,6 @@ public class TestUrlJavaObjectSerializer extends TestBase {
test.config.traceTest = true; test.config.traceTest = true;
test.config.memory = true; test.config.memory = true;
test.config.networked = true; test.config.networked = true;
test.config.javaObjectSerializer = FakeJavaObjectSerializer.class.getName();
test.config.beforeTest(); test.config.beforeTest();
test.test(); test.test();
test.config.afterTest(); test.config.afterTest();
...@@ -68,9 +67,15 @@ public class TestUrlJavaObjectSerializer extends TestBase { ...@@ -68,9 +67,15 @@ public class TestUrlJavaObjectSerializer extends TestBase {
} }
} }
/**
* The serializer to use for this test.
*/
public static class FakeJavaObjectSerializer implements JavaObjectSerializer { public static class FakeJavaObjectSerializer implements JavaObjectSerializer {
private static TestBase testBaseRef; /**
* The test.
*/
static TestBase testBaseRef;
@Override @Override
public byte[] serialize(Object obj) throws Exception { public byte[] serialize(Object obj) throws Exception {
......
...@@ -735,4 +735,4 @@ mgcodeact cumer reach notably computation varies smuggled stderr sees messes ...@@ -735,4 +735,4 @@ mgcodeact cumer reach notably computation varies smuggled stderr sees messes
nico devel nicolas linestring atelier fortin cnrs tweet geospatialnews bundles nico devel nicolas linestring atelier fortin cnrs tweet geospatialnews bundles
srid roads srid roads
overlaps anyhow poly overlaps anyhow poly manifested cardinal invalidated
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论