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

Trying to convert a value could throw the wrong exception.

上级 aab03e23
...@@ -497,6 +497,7 @@ public abstract class Value { ...@@ -497,6 +497,7 @@ public abstract class Value {
if (getType() == targetType) { if (getType() == targetType) {
return this; return this;
} }
try {
// decimal conversion // decimal conversion
switch (targetType) { switch (targetType) {
case BOOLEAN: { case BOOLEAN: {
...@@ -772,7 +773,6 @@ public abstract class Value { ...@@ -772,7 +773,6 @@ public abstract class Value {
} }
// conversion by parsing the string value // conversion by parsing the string value
String s = getString(); String s = getString();
try {
switch (targetType) { switch (targetType) {
case NULL: case NULL:
return ValueNull.INSTANCE; return ValueNull.INSTANCE;
...@@ -834,7 +834,7 @@ public abstract class Value { ...@@ -834,7 +834,7 @@ public abstract class Value {
throw DbException.throwInternalError("type=" + targetType); throw DbException.throwInternalError("type=" + targetType);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, e, s); throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, e, getString());
} }
} }
......
...@@ -44,6 +44,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -44,6 +44,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb("preparedStatement"); deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement"); Connection conn = getConnection("preparedStatement");
testExecuteUpdateCall(conn);
testPrepareExecute(conn); testPrepareExecute(conn);
testUUID(conn); testUUID(conn);
testScopedGeneratedKey(conn); testScopedGeneratedKey(conn);
...@@ -77,6 +78,15 @@ public class TestPreparedStatement extends TestBase { ...@@ -77,6 +78,15 @@ public class TestPreparedStatement extends TestBase {
deleteDb("preparedStatement"); deleteDb("preparedStatement");
} }
private void testExecuteUpdateCall(Connection conn) throws SQLException {
Statement stat = conn.createStatement();
try {
stat.executeUpdate("CALL HASH('SHA256', STRINGTOUTF8('Password'), 1000)");
} catch (SQLException e) {
assertEquals(ErrorCode.DATA_CONVERSION_ERROR_1, e.getErrorCode());
}
}
private void testPrepareExecute(Connection conn) throws SQLException { private void testPrepareExecute(Connection conn) throws SQLException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("prepare test(int, int) as select ?1*?2"); stat.execute("prepare test(int, int) as select ?1*?2");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论