Issue Details (XML | Word | Printable)

Key: CORE-2875
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Vlad Khorsun
Votes: 0
Watchers: 0
Operations

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

String right truncation error when char column longer than 4096 bytes compared with string constant

Created: 18/Feb/10 06:39 PM   Updated: 15/Jun/11 09:49 AM
Component/s: Engine
Affects Version/s: 2.5 RC1, 2.5 RC2
Fix Version/s: 2.5 RC3, 3.0 Alpha 1

Time Tracking:
Not Specified

Environment: I didn't checked if it exists in v2.1 or v2.0
Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
create database 'test.fdb' default character set none;

recreate table tab1 (id int, txt varchar(5000));
commit;

insert into tab1 values (1, rpad('', 5000, '1'));
commit;

set names win1251;
connect 'test.fdb';

update tab1 set id = 2 where txt = 'x';

Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vlad Khorsun added a comment - 18/Feb/10 06:48 PM - edited
The error is raised when INTL_convert_bytes is called from INTL_compare.
The internal buffer used for conversion (NONE -> WIN1251) is (MAX_KEY or 4096) smaller then size of field contents (5000) therefore conversion failed.

We can use HalfStaticArray instead but i don't know why MAX_KEY is used here ?

Also it seems more logical to convert MIN(length1, length2) bytes for comparison.

I think Adriano able to choose the best solution for this case :)

Adriano dos Santos Fernandes added a comment - 19/Feb/10 11:28 AM
Vlad, comparing less bytes would be a trick thing.

The strings may be multibyte, there may be trailing spaces...