Below is the list of changes that have just been committed into a local
5.0 repository of cmiller. When cmiller 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.2102 06/03/03 14:16:26 cmiller@zippy.(none) +3 -0
Bug#16859 involves truncating column data at NUL characters. Instead, the
client will now substitute spaces for NULs, so that the grid isn't messed
up due to silently consumed NULs, and so that the full field is shown.
mysql-test/t/mysql.test
1.8 06/03/03 14:16:21 cmiller@zippy.(none) +1 -1
Add a test.
mysql-test/r/mysql.result
1.7 06/03/03 14:16:21 cmiller@zippy.(none) +1 -27
Add a test.
client/mysql.cc
1.198 06/03/03 14:16:21 cmiller@zippy.(none) +42 -30
For non-numbers, print each character at a time, instead of using the
fprintf() facility, which interprets an array of chars as a C string,
which is necessarily NUL terminated. We mustn't terminate on NULs, and
since we know the length of the data, we needn't.
# 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: cmiller
# Host: zippy.(none)
# Root: /home/cmiller/work/mysql/mysql-5.0.19-tbr
--- 1.197/client/mysql.cc 2006-03-03 12:08:09 -05:00
+++ 1.198/client/mysql.cc 2006-03-03 14:16:21 -05:00
@@ -185,6 +185,7 @@
void tee_fputs(const char *s, FILE *file);
void tee_puts(const char *s, FILE *file);
void tee_putc(int c, FILE *file);
+static void tee_print_sized_data(const char *data, unsigned int length, unsigned int
width);
/* The names of functions that actually do the manipulation. */
static int get_options(int argc,char **argv);
static int com_quit(String *str,char*),
@@ -2308,47 +2309,29 @@
for (uint off= 0; off < mysql_num_fields(result); off++)
{
const char *str= cur[off] ? cur[off] : "NULL";
+ uint currlength;
+ uint maxlength;
+ uint numcells;
+
field= mysql_fetch_field(result);
- uint maxlength= field->max_length;
+ maxlength= field->max_length;
+ currlength= (uint) lengths[off];
+ numcells= charset_info->cset->numcells(charset_info,
+ str, str + currlength);
if (maxlength > MAX_COLUMN_LENGTH)
{
- tee_fputs(str, PAGER);
+ tee_print_sized_data(str, currlength, maxlength);
tee_fputs(" |", PAGER);
}
else
{
- uint currlength= (uint) lengths[off];
- uint numcells= charset_info->cset->numcells(charset_info,
- str, str + currlength);
if (num_flag[off] != 0)
tee_fprintf(PAGER, " %-*s|", maxlength + currlength - numcells, str);
else
- {
- /* It is not a number, so print each character justified to the left.
- * For '\0's print ASCII spaces instead, as '\0' is eaten by (at
- * least my) console driver, and that messes up the pretty table
- * grid. (The \0 is also the reason we can't use fprintf() .) */
- unsigned int i;
- const char *p;
-
- tee_putc(' ', PAGER);
-
- for (i = 0, p = str; i < currlength; i += 1, p += 1)
- {
- if (*p == '\0')
- tee_putc((int)' ', PAGER);
- else
- tee_putc((int)*p, PAGER);
- }
-
- i += 1; /* I don't know why. */
- for ( /**/; i < maxlength; i += 1)
- tee_putc((int)' ', PAGER);
-
- tee_putc(' ', PAGER);
- tee_putc('|', PAGER);
+ {
+ tee_print_sized_data(str, currlength, maxlength);
+ tee_fputs(" |", PAGER);
}
-
}
}
(void) tee_fputs("\n", PAGER);
@@ -2356,6 +2339,35 @@
tee_puts((char*) separator.ptr(), PAGER);
my_afree((gptr) num_flag);
}
+
+
+static void
+tee_print_sized_data(const char *data, unsigned int length, unsigned int width)
+{
+ /*
+ It is not a number, so print each character justified to the left.
+ For '\0's print ASCII spaces instead, as '\0' is eaten by (at
+ least my) console driver, and that messes up the pretty table
+ grid. (The \0 is also the reason we can't use fprintf() .)
+ */
+ unsigned int i;
+ const char *p;
+
+ tee_putc(' ', PAGER);
+
+ for (i= 0, p= data; i < length; i+= 1, p+= 1)
+ {
+ if (*p == '\0')
+ tee_putc((int)' ', PAGER);
+ else
+ tee_putc((int)*p, PAGER);
+ }
+
+ i+= 1;
+ for ( ; i < width; i+= 1)
+ tee_putc((int)' ', PAGER);
+}
+
static void
--- 1.6/mysql-test/r/mysql.result 2006-03-03 12:08:09 -05:00
+++ 1.7/mysql-test/r/mysql.result 2006-03-03 14:16:21 -05:00
@@ -69,36 +69,10 @@
ソ
ソ
ソ
---------------
-create table t1 (col1 binary(4), col2 varchar(10), col3 int)
---------------
-
-Query OK, 0 rows affected (0.01 sec)
-
---------------
-insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd', '0123456789',
4)
---------------
-
-Query OK, 3 rows affected (0.00 sec)
-Records: 3 Duplicates: 0 Warnings: 0
-
---------------
-select concat('>',col1,'<'), col2, col3 from t1
---------------
-
+----------------------+------------+--------+
| concat('>',col1,'<') | col2 | col3 |
+----------------------+------------+--------+
| >a < | b | 123421 |
| >a < | 0123456789 | 4 |
-| >abcd< | 0123456789 | 4 |
+| >abcd< | | 4 |
+----------------------+------------+--------+
-3 rows in set (0.00 sec)
-
---------------
-drop table t1
---------------
-
-Query OK, 0 rows affected (0.00 sec)
-
-Bye
--- 1.7/mysql-test/t/mysql.test 2006-03-03 12:08:09 -05:00
+++ 1.8/mysql-test/t/mysql.test 2006-03-03 14:16:21 -05:00
@@ -62,4 +62,4 @@
#
# This uses three verbose flags so that the output is rendered using the
# functions that had the problem.
---exec $MYSQL -v -v -v test -e "create table t1 (col1 binary(4), col2 varchar(10), col3
int); insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd',
'0123456789', 4); select concat('>',col1,'<'), col2, col3 from t1; drop table t1;"
2>&1
+--exec $MYSQL -t test -e "create table t1 (col1 binary(4), col2 varchar(10), col3 int);
insert into t1 values ('a', 'b', 123421),('a ', '0123456789', 4), ('abcd', '', 4); select
concat('>',col1,'<'), col2, col3 from t1; drop table t1;" 2>&1
| Thread |
|---|
| • bk commit into 5.0 tree (cmiller:1.2102) BUG#16859 | Chad MILLER | 3 Mar |