提交 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 {
if (getType() == targetType) {
return this;
}
try {
// decimal conversion
switch (targetType) {
case BOOLEAN: {
......@@ -772,7 +773,6 @@ public abstract class Value {
}
// conversion by parsing the string value
String s = getString();
try {
switch (targetType) {
case NULL:
return ValueNull.INSTANCE;
......@@ -834,7 +834,7 @@ public abstract class Value {
throw DbException.throwInternalError("type=" + targetType);
}
} 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 {
deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement");
testExecuteUpdateCall(conn);
testPrepareExecute(conn);
testUUID(conn);
testScopedGeneratedKey(conn);
......@@ -77,6 +78,15 @@ public class TestPreparedStatement extends TestBase {
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 {
Statement stat = conn.createStatement();
stat.execute("prepare test(int, int) as select ?1*?2");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论