Bug #7048 | whitespace gets chopped off for char and varchar fields for "load data" | ||
---|---|---|---|
Submitted: | 6 Dec 2004 19:26 | Modified: | 6 Dec 2004 20:54 |
Reporter: | Mark nielsen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S3 (Non-critical) |
Version: | 4.1.7 | OS: | Linux (Linux) |
Assigned to: | CPU Architecture: | Any |
[6 Dec 2004 19:26]
Mark nielsen
[6 Dec 2004 20:54]
Hartmut Holzgraefe
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: See http://dev.mysql.com/doc/mysql/en/CHAR.html Values in VARCHAR columns are variable-length strings. You can declare a VARCHAR column to be any length from 0 to 255, just as for CHAR columns. (Before MySQL 4.0.2, the length of VARCHAR may be from 1 to 255.) However, in contrast to CHAR, VARCHAR values are stored using only as many characters as are needed, plus one byte to record the length. Values are not padded; instead, trailing spaces are removed when values are stored. This space removal differs from the standard SQL specification. As you can see this is documented behaviour but as we are aware that it is not standard compliant we are planing to change it in MySQL 5: http://dev.mysql.com/doc/mysql/en/TODO_MySQL_5.0.html * Add true VARCHAR support (column lengths longer than 255, and no stripping of trailing whitespace). There is already support for this in the MyISAM storage engine, but it is not yet available at the user level.
[6 Dec 2004 22:40]
Mark nielsen
My bad, obviously. I thought I had managed to insert trailing spaces into a varchar field, but I think I mistyped my command and made field a text field. I tried it again with a new table and couldn't reproduce the results. Probably, on the mysqlimport webpage and the 'load form infile' webpages, it might be useful to make a note of it. I was looking there and didn't even think of the varchar type webpage. I thought it was a mysqlimport for load from infile problem.