Issue Details (XML | Word | Printable)

Key: CORE-4730
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Pavel Zotov
Votes: 0
Watchers: 4
Operations

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

ACTUAL capacity of field declared in character set UTF8 can be reduced by changing to character set NONE, table data are unavaliable after this.

Created: 31/Mar/15 04:18 PM   Updated: 31/Mar/15 04:28 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
set autoddl off;
recreate table test(id int);
commit;

set term ^;
execute block as
begin
  execute statement 'drop domain dmxx';
when any do begin end
end
^
set term ;^
commit;

create domain dmxx varchar(15) character set none;
commit;

alter table test add s01 varchar(8) character set utf8;
commit;
insert into test(id, s01) values( 1, 'qwertyui');
insert into test(id, s01) values( 2, 'âêûėżöé');
insert into test(id, s01) values( 3, 'öüčřžéèê');
commit;
select id, s01, char_length(s01) s01_char_length, octet_length(s01) s01_octecs from test;

alter table test alter column s01 type dmxx;
commit;
show table test;

select * from test;


Result in WI-T3.0.0.31756:
~~~~~~~~~~~~~~~~~~~~~

          ID S01 S01_CHAR_LENGTH S01_OCTECS
============ ======== =============== ============
           1 qwertyui 8 8
           2 âêûėżöé 7 14
           3 öüčřžéèê 8 16

ID INTEGER Nullable
S01 (DMXX) VARCHAR(15) Nullable -- <<< table DDL has been changes SUCCESSFULLY despite data with more than 15 octets in it ?

          ID S01
============ ===============
           1 qwertyui
           2 âêûėżöé
Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 15, actual 32


Result in WI-V2.5.4.26853:
~~~~~~~~~~~~~~~~~~~~~

          ID S01 S01_CHAR_LENGTH S01_OCTECS
============ ================================ =============== ============
           1 qwertyui 8 8
           2 âêûėżöé 7 14
           3 öüčřžéèê 8 16

Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-New size specified for column S01 must be at least 32 characters.

ID INTEGER Nullable
S01 VARCHAR(8) CHARACTER SET UTF8 Nullable

          ID S01
============ ================================
           1 qwertyui
           2 âêûėżöé
           3 öüčřžéèê


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dimitry Sibiryakov added a comment - 31/Mar/15 04:27 PM - edited
IMHO, altering of field's datatype with changing of character set must be prohibited at all.
"right truncation" is just one of possible errors. "transliteration error" is possible as well if old data contain characters missing in new charset.