| Bug #21255 | alter table varchar(255) to char don't set EndOfString character | ||
|---|---|---|---|
| Submitted: | 24 Jul 2006 16:12 | Modified: | 9 Aug 2006 13:51 |
| Reporter: | patrick Blesson | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Cluster: Cluster (NDB) storage engine | Severity: | S3 (Non-critical) |
| Version: | MYSQL V51 (5.1.12-BETA) | OS: | Linux vm10 2.4.20-28.9 #1 Thu D |
| Assigned to: | Geert Vanderkelen | CPU Architecture: | Any |
| Tags: | alter, char, table, varchar | ||
[24 Jul 2006 16:26]
Valeriy Kravchuk
Thank you for a problem report. Isn't it a duplicate of bug #21254?
[24 Jul 2006 16:56]
patrick Blesson
answer to [24 Jul 18:26] Valeriy Kravchuk
> Thank you for a problem report. Isn't it a duplicate of bug #21254?
No: there is a bit difference, we try both altering table :
CHAR to varchar, and
varchar to CHAR
in both tests there is some problem, but not exactly the same!
-by altering char to varchar we expected that mysql sets correctly size attribut of new varchar string
-by altering varchar to char, we expected that mysql adds an EndOfString char ('\0') at old size position in new fixed length string
Best regards
Patrick
[9 Aug 2006 13:51]
Geert Vanderkelen
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: Trailing spaces are kept for CHAR fields and no \0 will be put in to denote the end of the string. This is expected behaviour. Removing of trailing spaces should be done in the NDB API application or using VARCHAR.

Description: This 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 vvchar column of type VARCHAR(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 varchar to CHAR(255) altering seems OK altering command is : /usr/mysql/bin/mysql -D hlr -e "alter table IMSI modify vvchar CHAR(255);" see test test linked shell file : run -reading again vvchar population with CHAR type is KO source of read is basic-read-read.cpp linked file read result is readres2.txt altering is OK but reading of vvchar value is false because !!! string is padded with blank(h'20) by mysql alter function without EndOfString character !!! (maybe alter table command needs to specify "endOfString character" to be able to set it after significant character of string using previous length of string) (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 varchar(255) column set a value to this column (ex : size=28 string='French CHEESE with Jam&Salad') read value OK alter table this column to char(255) read value result is : "French CHEESE with Jam&Salady?/%_-3u-vènè_432ç)çij.." awaiting string 'French CHEESE with Jam&Salad''\0' Suggested fix: write a EndOfString char ('\0') at the end of string : String[size]='\0'