Issue Details (XML | Word | Printable)

Key: CORE-2001
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Claudio Valderrama C.
Reporter: Claudio Valderrama C.
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

When trying to show "conversion error", "arithmetic exception/string truncation" may appear instead, misleading the user

Created: 18/Jul/08 01:51 AM   Updated: 25/Apr/11 02:47 PM
Component/s: Engine
Affects Version/s: 1.0.3, 2.0.0, 1.5.4, 2.0.1, 2.1 Alpha 1, 2.1 Beta 1, 2.0.2, 2.0.3, 2.1 Beta 2, 1.5.5, 2.1 RC1, 2.5 Initial, 2.1 RC2, 2.1.0, 2.0.4
Fix Version/s: 2.5 Beta 1

Time Tracking:
Not Specified

Environment: Platform independent
Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
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;

       CAST
===========
Statement failed, SQLSTATE = 22018
conversion error from string "1995"

2.- This is misleading:
SQL> select cast('1995-12-2444444444444444444444444444444' as date) from rdb$database;

       CAST
===========
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;

       CAST
===========
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.

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Pavel Cisar added a comment - 25/Apr/11 02:47 PM
QA test added.