Bug #4414 tabular result sets with multibyte utf8 characters don't align correctly
Submitted: 6 Jul 2004 3:31 Modified: 7 Jul 2004 13:57
Reporter: Linus Upson Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.3 OS:
Assigned to: Assigned Account CPU Architecture:Any

[6 Jul 2004 3:31] Linus Upson
Description:
This will be difficult to see if you aren't in a fixed pitch font, but the mysql command line client doesn't align multibyte utf8 characters correctly in tabular result sets. The code which pads out the columns appears to count bytes, not characters. The result is that the vertical bars '|' are not drawn in the correct places.

How to repeat:
This should be done from a utf8 terminal.

set names 'utf8';
drop table if exists `t`;
CREATE TABLE `t` (
  `c` varchar(20) default NULL
) TYPE=MyISAM DEFAULT CHARSET=utf8;
insert into `t` values ('fübar');
insert into `t` values ('fubar');

mysql-4.1.3> select LENGTH(c), CHAR_LENGTH(c), c from t;
+-----------+----------------+--------+
| LENGTH(c) | CHAR_LENGTH(c) | c      |
+-----------+----------------+--------+
|         6 |              5 | fübar |
|         5 |              5 | fubar  |
+-----------+----------------+--------+

Suggested fix:
When computing the number of spaces to draw after the column data, characters, not bytes, should be counted.
[7 Jul 2004 13:57] Alexander Barkov
This is a duplicate bug with this one:
http://bugs.mysql.com/bug.php?id=3453