Bug #21254 alter table char to varchar(255) don't set string size
Submitted: 24 Jul 2006 15:54 Modified: 4 Nov 2009 10:46
Reporter: patrick Blesson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Any
Assigned to: Hartmut Holzgraefe CPU Architecture:Any
Tags: alter, char, MYSQL V51 (5.1.12-BETA), table, varchar
Triage: Triaged: D3 (Medium) / R6 (Needs Assessment) / E6 (Needs Assessment)

[24 Jul 2006 15:54] patrick Blesson
Description:
his test is realized in V50(V5.1.2 drop14) and in V51(V5.1.12_beta)
in both delivery test is not-satisfactory

test log file of following actions is linked as res.txt file

-Create a database with a shema which contain a vchar column of type CHAR(255)
-populate database
shema table is createtable.sql linked file
source of population is basic-type-popul.cpp linked file
-reading vchar population is OK
source of read is basic-read-read.cpp linked file
read result is readres1.txt
-alter table of vchar to VARCHAR(255)
altering seems OK
altering command is :
/usr/mysql/bin/mysql -D hlr -e "alter table IMSI modify vchar varchar(255);"
see test test linked shell file : run
-reading again vchar population with VARCHAR type is KO
source of read is basic-read-read.cpp linked file
read result is readres2.txt
altering is OK but reading of vchar value is false because
!!! size is forced by mysql alter function to 255 !!!
(maybe alter table command needs to specify "endOfString character" to be able to set real size value)
(Alcatel uses '00' or '\0')
-update of altered column is OK
source of population is basic-type-update-newColumn.cpp linked file
-reading updated vchar population is OK
source of read is basic-read-read.cpp linked file
read result is readres3.txt

How to repeat:
create a cluster
create a shema with a char(255) column
set a value to this column with EndOfString char '\0'  (ex : 'FRENCH-CHEESE''\0')
read value
alter table this column to varchar(255)
read column size = 255 insteed 13

Suggested fix:
read content of string before altering table from CHAR to varchar : position of first '\0' char is size of column
[24 Jul 2006 16:06] Valeriy Kravchuk
Changed some details to a more appropriate ones.
[4 Nov 2009 10:46] Jonas Oreland
i'll close this bug