Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.4.17
-
None
-
openSUSE 15.2
libmariadb3-3.1.12-lp152.7.1.x86_64
mariadb-errormessages-10.4.17-lp152.2.8.1.noarch
mariadb-10.4.17-lp152.2.8.1.x86_64
mariadb-tools-10.4.17-lp152.2.8.1.x86_64
mariadb-client-10.4.17-lp152.2.8.1.x86_64
Description
When invoking mysql --xml from the command line, the first part of the output is:
<?xml version="1.0"?> |
|
<resultset ...
|
Note there is no encoding specified in the XML declaration.
As long as mysql is outputting UTF-8, this is technically correct because UTF-8 is the default (discussion here).
However, to avoid any possible confusion, perhaps the XML declaration should include an explicit declaration of the character encoding, e.g.:
<?xml version="1.0" encoding="UTF-8"?> |
|
<resultset ...
|
Just a thought...
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Priority | Trivial [ 5 ] | Minor [ 4 ] |
Labels | beginner-friendly |
Summary | XML output should include character encoding in <?xml?> declaration | XML output does not include character encoding in <?xml?> declaration |
Workflow | MariaDB v3 [ 120861 ] | MariaDB v4 [ 142763 ] |
This seems to be an easy fix. I'd like to work on it.
I have created a fork (https://github.com/haidong/server) and started digging around. It looks line 3829 under client/mysql.cc is where the problem. See snippet below.
// Line 3829
static void
print_table_data_xml(MYSQL_RES *result)
{
MYSQL_ROW cur;
MYSQL_FIELD *fields;
mysql_field_seek(result,0);
tee_fputs("<?xml version=\"1.0\"?>\n\n<resultset statement=\"", PAGER); // I think this is our main problem!
xmlencode_print(glob_buffer.ptr(), (int)strlen(glob_buffer.ptr()));
tee_fputs("\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">",
PAGER);
Additionally, there are a few places, particularly files in tests, that could also benefit from this small change. For example, mysql-test/main/client_xml.result file has many places where this encoding info might be helpful.
I have read the contribution guide. I'll start hacking against my own forked repo. I'd appreciate any steps you want me to follow and suggestions/tips you can give.
Thanks!