提交 5185d722 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Try to check sizes of CLOBs

上级 8c69a427
...@@ -60,7 +60,7 @@ public class ValueLob extends Value { ...@@ -60,7 +60,7 @@ public class ValueLob extends Value {
} }
static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize) { static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize) {
if (dataSize >= 0) if (dataSize > 0)
rangeCheck(oneBasedOffset - 1, length, dataSize); rangeCheck(oneBasedOffset - 1, length, dataSize);
else else
rangeCheckUnknown(oneBasedOffset - 1, length); rangeCheckUnknown(oneBasedOffset - 1, length);
...@@ -71,8 +71,11 @@ public class ValueLob extends Value { ...@@ -71,8 +71,11 @@ public class ValueLob extends Value {
} }
} }
static Reader rangeReader(Reader reader, long oneBasedOffset, long length) { static Reader rangeReader(Reader reader, long oneBasedOffset, long length, long dataSize) {
rangeCheckUnknown(oneBasedOffset, length); if (dataSize > 0)
rangeCheck(oneBasedOffset - 1, length, dataSize);
else
rangeCheckUnknown(oneBasedOffset - 1, length);
try { try {
return new RangeReader(reader, oneBasedOffset - 1, length); return new RangeReader(reader, oneBasedOffset - 1, length);
} catch (IOException e) { } catch (IOException e) {
...@@ -666,7 +669,7 @@ public class ValueLob extends Value { ...@@ -666,7 +669,7 @@ public class ValueLob extends Value {
@Override @Override
public Reader getReader(long oneBasedOffset, long length) { public Reader getReader(long oneBasedOffset, long length) {
return rangeReader(getReader(), oneBasedOffset, length); return rangeReader(getReader(), oneBasedOffset, length, type == Value.CLOB ? precision : -1);
} }
@Override @Override
......
...@@ -376,7 +376,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -376,7 +376,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
@Override @Override
public Reader getReader(long oneBasedOffset, long length) { public Reader getReader(long oneBasedOffset, long length) {
return ValueLob.rangeReader(getReader(), oneBasedOffset, length); return ValueLob.rangeReader(getReader(), oneBasedOffset, length, type == Value.CLOB ? precision : -1);
} }
@Override @Override
......
...@@ -1103,7 +1103,7 @@ public class TestLob extends TestBase { ...@@ -1103,7 +1103,7 @@ public class TestLob extends TestBase {
fail("expected -1 got: " + ch); fail("expected -1 got: " + ch);
} }
r.close(); r.close();
// TODO assertThrows(ErrorCode.INVALID_VALUE_2, clob0).getCharacterStream(10001, 1); assertThrows(ErrorCode.INVALID_VALUE_2, clob0).getCharacterStream(10001, 1);
assertThrows(ErrorCode.INVALID_VALUE_2, clob0).getCharacterStream(10002, 0); assertThrows(ErrorCode.INVALID_VALUE_2, clob0).getCharacterStream(10002, 0);
conn0.close(); conn0.close();
} }
......
...@@ -1698,7 +1698,7 @@ public class TestResultSet extends TestBase { ...@@ -1698,7 +1698,7 @@ public class TestResultSet extends TestBase {
Clob clob = rs.getClob(2); Clob clob = rs.getClob(2);
try { try {
assertEquals("all", readString(clob.getCharacterStream(2, 3))); assertEquals("all", readString(clob.getCharacterStream(2, 3)));
// TODO assertThrows(ErrorCode.INVALID_VALUE_2, clob).getCharacterStream(6, 1); assertThrows(ErrorCode.INVALID_VALUE_2, clob).getCharacterStream(6, 1);
assertThrows(ErrorCode.INVALID_VALUE_2, clob).getCharacterStream(7, 0); assertThrows(ErrorCode.INVALID_VALUE_2, clob).getCharacterStream(7, 0);
} finally { } finally {
clob.free(); clob.free();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论