List:Commits« Previous MessageNext Message »
From:bar Date:April 17 2006 7:34am
Subject:bk commit into 4.1 tree (bar:1.2459) BUG#17939
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2459 06/04/17 12:33:45 bar@stripped +1 -0
  Bug#17939: Wrong table format when using UTF8 strings
  
  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
    1.219 06/04/17 12:14:15 bar@stripped +7 -2
    Adding column name allignment, the same to
    data alignment, which was implemented earlier.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-4.1.b17939

--- 1.218/client/mysql.cc	2006-02-10 17:12:20 +04:00
+++ 1.219/client/mysql.cc	2006-04-17 12:14:15 +05:00
@@ -2145,9 +2145,14 @@ print_table_data(MYSQL_RES *result)
     (void) tee_fputs("|", PAGER);
     for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
     {
-      tee_fprintf(PAGER, " %-*s|",(int) min(field->max_length,
+      uint name_length= (uint) strlen(field->name);
+      uint numcells= charset_info->cset->numcells(charset_info,
+                                                  field->name,
+                                                  field->name + name_length);
+      uint display_length= field->max_length + name_length - numcells;
+      tee_fprintf(PAGER, " %-*s|",(int) min(display_length,
                                             MAX_COLUMN_LENGTH),
-		  field->name);
+                  field->name);
       num_flag[off]= IS_NUM(field->type);
     }
     (void) tee_fputs("\n", PAGER);
Thread
bk commit into 4.1 tree (bar:1.2459) BUG#17939bar17 Apr