• unknown's avatar
    Bug#17939: Wrong table format when using UTF8 strings · ca9c4793
    unknown authored
    Lines with column names consisting of national letters
    were wrongly formatted in "mysql --table" results:
    
    mysql> SELECT 'xxx xxx xxx' as 'xxx xxx xxx';
    +-------------------+
    | xxx xxx xxx |
    +-------------------+
    | xxx xxx xxx       |
    +-------------------+
    1 row in set (0.00 sec)
    
    It happened because in UTF-8 (and other multibyte charsets)
    the number of display cells is not always equal to the number
    of bytes of the string.
    
    Data lines (unlike column name lines) were formatted correctly,
    because data lines were displayed taking in account number of
    display cells. This patch takes in account number of cells when
    displaying column names, the same way like displaying data lines does.
    
    Note: The patch is going to be applied to 4.1.
    Test case will be added after merge to 5.0,
    into "mysql.test", which appeared in 5.0.
    
    mysql.cc:
      Adding column name allignment using numcells(),
      the same to data alignment, which was implemented earlier.
    
    
    
    client/mysql.cc:
      Adding column name allignment, the same to
      data alignment, which was implemented earlier.
    ca9c4793
mysql.cc 94.5 KB