When trying to show "conversion error", "arithmetic exception/string truncation" may appear instead, misleading the user [CORE2001] #2438
Labels
affect-version: 1.0.3
affect-version: 1.5.4
affect-version: 1.5.5
affect-version: 2.0.0
affect-version: 2.0.1
affect-version: 2.0.2
affect-version: 2.0.3
affect-version: 2.0.4
affect-version: 2.1 Alpha 1
affect-version: 2.1 Beta 1
affect-version: 2.1 Beta 2
affect-version: 2.1 RC1
affect-version: 2.1 RC2
affect-version: 2.1.0
affect-version: 2.5 Initial
component: engine
fix-version: 2.5 Beta 1
priority: minor
qa: done successfully
type: bug
Submitted by: Claudio Valderrama C. (robocop)
Assigned to: Claudio Valderrama C. (robocop)
Is related to QA354
This is a case of one error causing another.
When FB is asked to convert one data type to another, it may not always succeed. This is the case with explicit user requests (a string that doesn't hold a date is casted to date) or internal conversion from UDF results (the UDF's dynamically returned type doesn't match the declared type), etc.
However, due to the way the conversion error message is produced, it may cause a string truncation when trying to assemble the error message. Therefore, the client application receives "string truncation" instead of "conversion error". Example:
1.- This is correct:
SQL> select cast('1995' as date) from rdb$database;
===========
Statement failed, SQLSTATE = 22018
conversion error from string "1995"
2.- This is misleading:
SQL> select cast('1995-12-2444444444444444444444444444444' as date) from rdb$database;
===========
Statement failed, SQLCODE = -802
arithmetic exception, numeric overflow, or string truncation
3.- This is the fix when the source string is too long to report it or try to convert it:
SQL> select cast('1995-12-2444444444444444444444444444444' as date) from rdb$database;
===========
Statement failed, SQLSTATE = 22018
conversion error from string "<Too long string or can't be translated>"
Another solution would be to take a substring of the original string.
Commits: bb672a9
The text was updated successfully, but these errors were encountered: