Bug #8483 True varchar: InnoDB strips trailing spaces

Submitted: 12 Feb 2005 22:47 Modified: 30 Mar 2005 9:19
Reporter: Trudy Pelzer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.0.3-alpha-debug OS:Linux (SuSE 9.1)
Assigned to: Heikki Tuuri CPU Architecture:Any

[12 Feb 2005 22:47] Trudy Pelzer
Description:
A source value that has trailing spaces which
would fit into a VARCHAR target should not
have the trailing spaces stripped, as is currently
the case when the table uses the InnoDB
storage engine. MyISAM tables do this correctly.

How to repeat:
mysql> create table t1 (col2 varchar(5)) engine=innodb;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t1 (col2) values('hello');
Query OK, 1 row affected (0.00 sec)
-- size should be 5, source is exactly 5 characters long

mysql> insert into t1 (col2) values('hi');
Query OK, 1 row affected (0.00 sec)
-- size should be 2, source is exactly 2 characters long

mysql> insert into t1 (col2) values('hi  o');
Query OK, 1 row affected (0.00 sec)
-- size should be 5, source is exactly 5 characters long

mysql> insert into t1 (col2) values('hi  o ');
Query OK, 1 row affected (0.01 sec)
-- size should be 5, source is 6 characters long but the trailing
space that would make the value too long for the column
may be stripped

mysql> insert into t1 (col2) values('h5   ');
Query OK, 1 row affected (0.00 sec)
-- size should be 5, source is exactly 5 characters long,
including the trailing spaces which must not be stripped

mysql> insert into t1 (col2) values('h6    ');
Query OK, 1 row affected (0.00 sec)
-- size should be 5, source is 6 characters long, but
the 6th character is a trailing space that may be stripped 
because it makes the value too big for the column. The rest
of the trailing spaces may not be stripped.

mysql> select col2,char_length(col2) from t1;
+-------+-------------------+
| col2  | char_length(col2) |
+-------+-------------------+
| hello |                 5 |
| hi    |                 2 |
| hi  o |                 5 |
| hi  o |                 5 |
| h5    |                 2 |
| h6    |                 2 |
+-------+-------------------+
6 rows in set (0.00 sec)
-- should return char_length of 5,2,5,5,5,5
Note that the final two examples are not treated correctly.
[13 Feb 2005 2:21] MySQL Verification Team
Thank you for the bug report.
[16 Mar 2005 14:59] Heikki Tuuri
Implemented and pushed to 5.0 but needs more testing.

Regards,

Heikki

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.060 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.