提交 5f5a7566 authored 作者: Thomas Mueller's avatar Thomas Mueller

Updating many rows with the same CLOB or BLOB values could result in FileNotFoundException.

上级 ba641b68
......@@ -70,7 +70,12 @@ public class RowList {
if (lobs == null) {
lobs = ObjectArray.newInstance();
}
// need to create a copy, otherwise,
// if stored multiple times, it may be renamed
// and then not found
lob = lob.copyToTemp();
lobs.add(lob);
v = lob;
}
}
buff.checkCapacity(buff.getValueLen(v));
......
......@@ -838,4 +838,20 @@ public class ValueLob extends Value {
return 128;
}
/**
* Create an independent copy of this temporary value.
* The file will not be deleted automatically.
*
* @return the value
*/
public ValueLob copyToTemp() throws SQLException {
ValueLob lob;
if (type == CLOB) {
lob = ValueLob.createClob(getReader(), precision, handler);
} else {
lob = ValueLob.createBlob(getInputStream(), precision, handler);
}
return lob;
}
}
......@@ -23,7 +23,6 @@ import java.sql.Savepoint;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
import org.h2.constant.SysProperties;
import org.h2.store.FileLister;
import org.h2.test.TestBase;
......@@ -49,6 +48,7 @@ public class TestLob extends TestBase {
if (config.memory) {
return;
}
testLobUpdateMany();
testLobDeleteTemp();
testLobDelete();
testLobVariable();
......@@ -73,6 +73,17 @@ public class TestLob extends TestBase {
deleteDb("lob");
}
private void testLobUpdateMany() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
Statement stat = conn.createStatement();
stat.execute("create table post(id int primary key, text clob) as select x, space(96) from system_range(1, 329)");
PreparedStatement prep = conn.prepareStatement("update post set text = ?");
prep.setCharacterStream(1, new StringReader(new String(new char[1025])), -1);
prep.executeUpdate();
conn.close();
}
private void testLobDeleteTemp() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论