Bug #48855 XML stylesheet option for mysql/mysqldump CLIs
| Submitted: | 18 Nov 2009 4:46 | ||
|---|---|---|---|
| Reporter: | Mikiya Okuno | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: mysqldump Command-line Client | Severity: | S4 (Feature request) |
| Version: | 5.1 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[18 Nov 2009 4:46]
Mikiya Okuno
[18 Nov 2009 5:17]
MySQL Verification Team
=== modified file 'client/client_priv.h'
--- client/client_priv.h 2008-01-31 16:46:50 +0000
+++ client/client_priv.h 2009-11-18 04:47:25 +0000
@@ -79,6 +79,6 @@
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
- OPT_WRITE_BINLOG, OPT_DUMP_DATE,
+ OPT_WRITE_BINLOG, OPT_DUMP_DATE, OPT_XML_STYLESHEET,
OPT_MAX_CLIENT_OPTION
};
=== modified file 'client/mysql.cc'
--- client/mysql.cc 2009-10-20 18:00:07 +0000
+++ client/mysql.cc 2009-11-18 05:14:02 +0000
@@ -155,7 +155,8 @@
static int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0,
*current_prompt=0, *delimiter_str= 0,
- *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
+ *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME,
+ *xml_stylesheet=NULL;
static char *histfile;
static char *histfile_tmp;
static String glob_buffer,old_buffer;
@@ -1409,6 +1410,9 @@
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Produce XML output", (uchar**) &opt_xml, (uchar**) &opt_xml, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"xsl", OPT_XML_STYLESHEET, "Stylesheet added when XML output is specified.",
+ (uchar**) &xml_stylesheet, (uchar**) &xml_stylesheet, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
{"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",
(uchar**) &line_numbers, (uchar**) &line_numbers, 0, GET_BOOL,
NO_ARG, 1, 0, 0, 0, 0, 0},
@@ -3464,7 +3468,13 @@
mysql_field_seek(result,0);
- tee_fputs("<?xml version=\"1.0\"?>\n\n<resultset statement=\"", PAGER);
+ tee_fputs("<?xml version=\"1.0\"?>\n", PAGER);
+ if (xml_stylesheet) {
+ tee_fputs("<?xml-stylesheet type=\"text/xsl\" href=\"", PAGER);
+ xmlencode_print(xml_stylesheet, (int)strlen(xml_stylesheet));
+ tee_fputs("\"?>\n", PAGER);
+ }
+ tee_fputs("\n<resultset statement=\"", PAGER);
xmlencode_print(glob_buffer.ptr(), (int)strlen(glob_buffer.ptr()));
tee_fputs("\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">",
PAGER);
=== modified file 'client/mysqldump.c'
--- client/mysqldump.c 2009-08-28 15:06:59 +0000
+++ client/mysqldump.c 2009-11-18 04:50:43 +0000
@@ -110,7 +110,8 @@
*where=0, *order_by=0,
*opt_compatible_mode_str= 0,
*err_ptr= 0,
- *log_error_file= NULL;
+ *log_error_file= NULL,
+ *xml_stylesheet=NULL;
static char **defaults_argv= 0;
static char compatible_mode_normal_str[255];
/* Server supports character_set_results session variable? */
@@ -464,6 +465,9 @@
(uchar**) &where, (uchar**) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"xsl", OPT_XML_STYLESHEET, "Stylesheet added when XML output is specified.",
+ (uchar**) &xml_stylesheet, (uchar**) &xml_stylesheet, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -572,12 +576,18 @@
#include <help_end.h>
+static void print_quoted_xml(FILE *xml_file, const char *str, ulong len);
static void write_header(FILE *sql_file, char *db_name)
{
if (opt_xml)
{
fputs("<?xml version=\"1.0\"?>\n", sql_file);
+ if (xml_stylesheet) {
+ fputs("<?xml-stylesheet type=\"text/xsl\" href=\"", sql_file);
+ print_quoted_xml(sql_file, xml_stylesheet, strlen(xml_stylesheet));
+ fputs("\"?>\n", sql_file);
+ }
/*
Schema reference. Allows use of xsi:nil for NULL values and
xsi:type to define an element's data type.
[18 Nov 2009 5:21]
MySQL Verification Team
The above is a patch just works. Please review it.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.