Bug #7630 Missing trailing Blanks in VARCHAR and CHAR Datatypes
Submitted: 3 Jan 2005 14:00 Modified: 3 Jan 2005 20:44
Reporter: Bug Report Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S2 (Serious)
Version:4.1.3-beta OS:Linux (Linux, Suse 7.2)
Assigned to: CPU Architecture:Any

[3 Jan 2005 14:00] Bug Report
Description:
Varchar and Char-Types ignore trailing Blanks on insert.
This is not consistent to SQL92 and SQL99.

How to repeat:
Create a table:
create table mytable (id integer, name1 varchar(20), name2 char(20), primary key (id));

insert data:
insert into mytable values (1, "myname1   ", "myname2   ");

query data:
select name1 from mytable;
select name2 from mytable;
both return "myname1"/"myname2" instead of "myname1   "/"myname2   "

query data length:
select length(name1) from mytable;
select length(name2) from mytable;

both return 7 instead of 10.

Suggested fix:
There should be a parameter to have the old behaviour as a work around.
The correct behaviour should be standard.
[3 Jan 2005 20:44] MySQL Verification Team
Thank you for taking the time to report a problem.  Unfortunately
you are not using a version of the product that uses a correct, standard behaviour with CHAR and VARCHAR columns.

Simply, a  standard behaviour is achieved in the latest tree of MySQL 5.0. 

This change will not be ported back to 4.1.