summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJim Winstead <jimw@mysql.com>2009-07-14 17:03:51 -0700
committerJim Winstead <jimw@mysql.com>2009-07-14 17:03:51 -0700
commitc754b00a1f79d1ea78b1a2d2c51a1b2281500fff (patch)
tree38245993a10bee6436ac1dd95810492d67293a44 /client
parentf0f4efd77e3eb7d62176396b5ccf53d7a7029c85 (diff)
downloadmariadb-git-c754b00a1f79d1ea78b1a2d2c51a1b2281500fff.tar.gz
The handling of NUL bytes in column data in the various output formats
supported by the mysql client was inconsistent. (Bug #28203)
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc31
1 files changed, 28 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 5dbcc5eabba..b92056b7617 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -169,6 +169,8 @@ static const char *xmlmeta[] = {
"<", "&lt;",
">", "&gt;",
"\"", "&quot;",
+ /* Turn \0 into a space. Why not &#0;? That's not valid XML or HTML. */
+ "\0", " ",
0, 0
};
static const char *day_names[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
@@ -3496,11 +3498,29 @@ print_table_data_vertically(MYSQL_RES *result)
mysql_field_seek(result,0);
tee_fprintf(PAGER,
"*************************** %d. row ***************************\n", row_count);
+
+ ulong *lengths= mysql_fetch_lengths(result);
+
for (uint off=0; off < mysql_num_fields(result); off++)
{
field= mysql_fetch_field(result);
tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name);
- tee_fprintf(PAGER, "%s\n",cur[off] ? (char*) cur[off] : "NULL");
+ if (cur[off])
+ {
+ unsigned int i;
+ const char *p;
+
+ for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
+ {
+ if (*p == '\0')
+ tee_putc((int)' ', PAGER);
+ else
+ tee_putc((int)*p, PAGER);
+ }
+ tee_putc('\n', PAGER);
+ }
+ else
+ tee_fprintf(PAGER, "NULL\n");
}
}
}
@@ -3567,7 +3587,7 @@ xmlencode_print(const char *src, uint length)
tee_fputs("NULL", PAGER);
else
{
- for (const char *p = src; *p && length; *p++, length--)
+ for (const char *p = src; length; *p++, length--)
{
const char *t;
if ((t = array_value(xmlmeta, *p)))
@@ -3587,7 +3607,12 @@ safe_put_field(const char *pos,ulong length)
else
{
if (opt_raw_data)
- tee_fputs(pos, PAGER);
+ {
+ unsigned long i;
+ /* Can't use tee_fputs(), it stops with NUL characters. */
+ for (i= 0; i < length; i++, pos++)
+ tee_putc(*pos, PAGER);
+ }
else for (const char *end=pos+length ; pos != end ; pos++)
{
#ifdef USE_MB