mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Added quoting to XML in mysqldump.
client/mysqldump.c: Added quoting to XML option. <, >, & and " covered.
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
** and adapted to mysqldump 05/11/01 by Jani Tolonen
|
** and adapted to mysqldump 05/11/01 by Jani Tolonen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DUMP_VERSION "8.18"
|
#define DUMP_VERSION "8.19"
|
||||||
|
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
#include <my_sys.h>
|
#include <my_sys.h>
|
||||||
@@ -163,6 +163,7 @@ static int init_dumping(char *);
|
|||||||
static int dump_databases(char **);
|
static int dump_databases(char **);
|
||||||
static int dump_all_databases();
|
static int dump_all_databases();
|
||||||
static char *quote_name(char *name, char *buff);
|
static char *quote_name(char *name, char *buff);
|
||||||
|
static void print_quoted_xml(FILE *output, char *fname, char *str, uint len);
|
||||||
|
|
||||||
static void print_version(void)
|
static void print_version(void)
|
||||||
{
|
{
|
||||||
@@ -1113,21 +1114,21 @@ static void dumpTable(uint numFields, char *table)
|
|||||||
{
|
{
|
||||||
if (!IS_NUM_FIELD(field))
|
if (!IS_NUM_FIELD(field))
|
||||||
{
|
{
|
||||||
if (opt_xml)
|
if (opt_xml)
|
||||||
fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
|
print_quoted_xml(md_result_file, field->name, row[i],
|
||||||
field->name, row[i], field->name);
|
lengths[i]);
|
||||||
else
|
else
|
||||||
unescape(md_result_file, row[i], lengths[i]);
|
unescape(md_result_file, row[i], lengths[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* change any strings ("inf","nan",..) into NULL */
|
/* change any strings ("inf","nan",..) into NULL */
|
||||||
char *ptr = row[i];
|
char *ptr = row[i];
|
||||||
if (opt_xml)
|
if (opt_xml)
|
||||||
fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
|
fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
|
||||||
field->name,!isalpha(*ptr) ?ptr: "NULL",field->name);
|
field->name,!isalpha(*ptr) ?ptr: "NULL",field->name);
|
||||||
else
|
else
|
||||||
fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file);
|
fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1197,6 +1198,27 @@ static void dumpTable(uint numFields, char *table)
|
|||||||
} /* dumpTable */
|
} /* dumpTable */
|
||||||
|
|
||||||
|
|
||||||
|
static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
|
||||||
|
{
|
||||||
|
const char *end;
|
||||||
|
|
||||||
|
fprintf(output, "\t\t<%s>", fname);
|
||||||
|
for (end = str + len; str != end; str++)
|
||||||
|
{
|
||||||
|
if (*str == '<')
|
||||||
|
fputs("<", output);
|
||||||
|
else if (*str == '>')
|
||||||
|
fputs(">", output);
|
||||||
|
else if (*str == '&')
|
||||||
|
fputs("&", output);
|
||||||
|
else if (*str == '\"')
|
||||||
|
fputs(""", output);
|
||||||
|
else
|
||||||
|
fputc(*str, output);
|
||||||
|
}
|
||||||
|
fprintf(output, "<%s>\n", fname);
|
||||||
|
}
|
||||||
|
|
||||||
static char *getTableName(int reset)
|
static char *getTableName(int reset)
|
||||||
{
|
{
|
||||||
static MYSQL_RES *res = NULL;
|
static MYSQL_RES *res = NULL;
|
||||||
|
Reference in New Issue
Block a user