Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String right truncation error when char column longer than 4096 bytes compared with string constant [CORE2875] #3259

Closed
firebird-automations opened this issue Feb 18, 2010 · 7 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @hvlad

Is related to QA429

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

Commits: 1db35d4 84185f2

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

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 :)

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Vlad, comparing less bytes would be a trick thing.

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC3 [ 10381 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA429 [ QA429 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment