提交 ce09cef8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Some CLOB and BLOB values could no longer be read when the original row was…

Some CLOB and BLOB values could no longer be read when the original row was removed (even when using the MVCC mode).
上级 cb092af1
......@@ -11,8 +11,8 @@ import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
/**
* A data handler contains a number of callback methods.
* The most important implementing class is a database.
* A data handler contains a number of callback methods, mostly related to CLOB
* and BLOB handling. The most important implementing class is a database.
*/
public interface DataHandler {
......
......@@ -206,6 +206,7 @@ public class LobStorageBackend implements LobStorageInterface {
}
if (tableId == LobStorageFrontend.TABLE_ID_SESSION_VARIABLE) {
removeAllForTable(LobStorageFrontend.TABLE_TEMP);
removeAllForTable(LobStorageFrontend.TABLE_RESULT);
}
}
......@@ -440,6 +441,11 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
@Override
public boolean isReadOnly() {
return database.isReadOnly();
}
@Override
public ValueLobDb copyLob(ValueLobDb old, int tableId, long length) {
int type = old.getType();
......
......@@ -28,6 +28,11 @@ public class LobStorageFrontend implements LobStorageInterface {
*/
public static final int TABLE_TEMP = -2;
/**
* The table id for result sets.
*/
public static final int TABLE_RESULT = -3;
private final DataHandler handler;
public LobStorageFrontend(DataHandler handler) {
......@@ -57,6 +62,11 @@ public class LobStorageFrontend implements LobStorageInterface {
handler, lob, hmac, byteCount));
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public ValueLobDb copyLob(ValueLobDb old, int tableId, long length) {
throw new UnsupportedOperationException();
......
......@@ -82,4 +82,11 @@ public interface LobStorageInterface {
*/
void init();
/**
* Whether the storage is read-only
*
* @return true if yes
*/
boolean isReadOnly();
}
......@@ -197,6 +197,11 @@ public class LobStorageMap implements LobStorageInterface {
}
}
@Override
public boolean isReadOnly() {
return database.isReadOnly();
}
@Override
public ValueLobDb copyLob(ValueLobDb old, int tableId, long length) {
init();
......
......@@ -1126,6 +1126,16 @@ public abstract class Value {
return this;
}
/**
* Create an independent copy of this value if needed, that will be bound to
* a result. If the original row is removed, this copy is still readable.
*
* @return the value (this for small objects)
*/
public Value copyToResult() {
return this;
}
public ResultSet getResultSet() {
SimpleResultSet rs = new SimpleResultSet();
rs.setAutoClose(false);
......
......@@ -476,6 +476,25 @@ public class ValueLobDb extends Value implements Value.ValueClob,
return this;
}
/**
* Create an independent copy of this value,
* that will be bound to a result.
*
* @return the value (this for small objects)
*/
@Override
public ValueLobDb copyToResult() {
if (handler == null) {
return this;
}
LobStorageInterface s = handler.getLobStorage();
if (s.isReadOnly()) {
return this;
}
return s.copyLob(this, LobStorageFrontend.TABLE_RESULT,
getPrecision());
}
public long getLobId() {
return lobId;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论