提交 2524b93d authored 作者: Noel Grandin's avatar Noel Grandin

Revert "filename in ValueLob is now never null"

This reverts commit c6cf352d.

hmmm, not quite right
上级 c6cf352d
...@@ -852,8 +852,8 @@ public class Data { ...@@ -852,8 +852,8 @@ public class Data {
return ValueLob.openUnlinked(type, handler, tableId, return ValueLob.openUnlinked(type, handler, tableId,
objectId, precision, compression, filename); objectId, precision, compression, filename);
} }
return ValueLobDb.create(type, handler, tableId, return ValueLob.openLinked(type, handler, tableId,
objectId, null, precision); objectId, precision, compression);
} }
} }
case Value.ARRAY: { case Value.ARRAY: {
......
...@@ -30,9 +30,18 @@ import org.h2.util.StringUtils; ...@@ -30,9 +30,18 @@ import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
/** /**
* This is the legacy implementation of LOBs for PageStore databases where the * Implementation of the BLOB and CLOB data types. Small objects are kept in
* LOB was stored in an external file. * memory and stored in the record.
* *
* Large objects are stored in their own files. When large objects are set in a
* prepared statement, they are first stored as 'temporary' files. Later, when
* they are used in a record, and when the record is stored, the lob files are
* linked: the file is renamed using the file format (tableId).(objectId). There
* is one exception: large variables are stored in the file (-1).(objectId).
*
* When lobs are deleted, they are first renamed to a temp file, and if the
* delete operation is committed the file is deleted.
*
* Data compression is supported. * Data compression is supported.
*/ */
public class ValueLob extends Value { public class ValueLob extends Value {
...@@ -132,6 +141,24 @@ public class ValueLob extends Value { ...@@ -132,6 +141,24 @@ public class ValueLob extends Value {
table + Constants.SUFFIX_LOB_FILE; table + Constants.SUFFIX_LOB_FILE;
} }
/**
* Create a LOB value with the given parameters.
*
* @param type the data type, either Value.BLOB or Value.CLOB
* @param handler the file handler
* @param tableId the table object id
* @param objectId the object id
* @param precision the precision (length in elements)
* @param compression if compression is used
* @return the value object
*/
public static ValueLob openLinked(int type, DataHandler handler,
int tableId, int objectId, long precision, boolean compression) {
String fileName = getFileName(handler, tableId, objectId);
return new ValueLob(type, handler, fileName, tableId, objectId,
true/* linked */, precision, compression);
}
/** /**
* Create a LOB value with the given parameters. * Create a LOB value with the given parameters.
* *
...@@ -301,11 +328,17 @@ public class ValueLob extends Value { ...@@ -301,11 +328,17 @@ public class ValueLob extends Value {
@Override @Override
public void remove() { public void remove() {
deleteFile(handler, fileName); if (fileName != null) {
deleteFile(handler, fileName);
}
} }
@Override @Override
public Value copy(DataHandler h, int tabId) { public Value copy(DataHandler h, int tabId) {
if (fileName == null) {
this.tableId = tabId;
return this;
}
if (linked) { if (linked) {
ValueLob copy = new ValueLob(this.valueType, this.handler, this.fileName, ValueLob copy = new ValueLob(this.valueType, this.handler, this.fileName,
this.tableId, getNewObjectId(h), this.linked, this.precision, this.compressed); this.tableId, getNewObjectId(h), this.linked, this.precision, this.compressed);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论