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

Message 'malformed string' appear instead of 'expected length 8191, actual NNNN' when trying to generate UTF8 multi-byte chars with char_length >= 10922 [CORE4894] #5187

Open
firebird-automations opened this issue Jul 30, 2015 · 1 comment

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Script for running on Windows (replace port and path + database file with your env.):

set names utf8;
set list on;
shell del C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb 2>nul;
create database 'localhost/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb' default character set utf8;
commit;

set list on;
out nul;
select rpad('', 10921,'∏Ω∑') as multi_byte_10921 from rdb$database;
select rpad('', 10922,'∏Ω∑') as multi_byte_10922 from rdb$database;
out;
quit;

Similar script for running on Linux:

set names utf8;
set list on;
shell rm -f /var/db/fb30/c4881.fdb 2>nul;
create database 'localhost/3333:/var/db/fb30/c4881.fdb' default character set utf8;
commit;

set list on;
out /dev/null;
select rpad('', 10921,'∑∏Ω') as multi_byte_10921 from rdb$database;
select rpad('', 10922,'∑∏Ω') as multi_byte_10922 from rdb$database;
out;
quit;

Result in any case will be:

Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 8191, actual 10921

Statement failed, SQLSTATE = 22000
Malformed string

IMHO, second expression (which tries to do RPAD up to 10922 should raise the same exception as first one, no matter of its argument.

PS.

All three characters in the padded string '∑', '∏' and 'Ω' -- requires three byte for encoding. Symbol '∏' should not be confused with cyrillic upper 'Pe', it is mathematical sign of number producing.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

description: Script for running on Windows (replace port and path + database file with your env.):

set names utf8;
set list on;
shell del C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb 2>nul;
create database 'localhost/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb' default character set utf8;
commit;

set list on;
out nul;
select rpad('', 10921,'∏Ω∑') as multi_byte_10922 from rdb$database;
select rpad('', 10922,'∏Ω∑') as multi_byte_10922 from rdb$database;
out;
quit;

Similar script for running on Linux:

set names utf8;
set list on;
shell rm -f /var/db/fb30/c4881.fdb 2>nul;
create database 'localhost/3333:/var/db/fb30/c4881.fdb' default character set utf8;
commit;

set list on;
out /dev/null;
select rpad('', 10921,'∑∏Ω') as multi_byte_10921 from rdb$database;
select rpad('', 10922,'∑∏Ω') as multi_byte_10922 from rdb$database;
out;
quit;

Result in any case will be:

Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 8191, actual 10921

Statement failed, SQLSTATE = 22000
Malformed string

IMHO, second expression (which tries to do RPAD up to 10922 should raise the same exception as first one, no matter of its argument.

PS.

All three characters in the padded string '∑', '∏' and 'Ω' -- requires three byte for encoding. Symbol '∏' should not be confused with cyrillic upper 'Pe', it is mathematical sign of number producing.

=>

Script for running on Windows (replace port and path + database file with your env.):

set names utf8;
set list on;
shell del C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb 2>nul;
create database 'localhost/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4881.fdb' default character set utf8;
commit;

set list on;
out nul;
select rpad('', 10921,'∏Ω∑') as multi_byte_10921 from rdb$database;
select rpad('', 10922,'∏Ω∑') as multi_byte_10922 from rdb$database;
out;
quit;

Similar script for running on Linux:

set names utf8;
set list on;
shell rm -f /var/db/fb30/c4881.fdb 2>nul;
create database 'localhost/3333:/var/db/fb30/c4881.fdb' default character set utf8;
commit;

set list on;
out /dev/null;
select rpad('', 10921,'∑∏Ω') as multi_byte_10921 from rdb$database;
select rpad('', 10922,'∑∏Ω') as multi_byte_10922 from rdb$database;
out;
quit;

Result in any case will be:

Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 8191, actual 10921

Statement failed, SQLSTATE = 22000
Malformed string

IMHO, second expression (which tries to do RPAD up to 10922 should raise the same exception as first one, no matter of its argument.

PS.

All three characters in the padded string '∑', '∏' and 'Ω' -- requires three byte for encoding. Symbol '∏' should not be confused with cyrillic upper 'Pe', it is mathematical sign of number producing.

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

No branches or pull requests

1 participant