Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
35564d9f
Commit
35564d9f
authored
Nov 03, 2003
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1
into gw.mysql.r18.ru:/usr/home/ram/work/4.1.wl1279
parents
ef672974
08e62691
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
58 deletions
+136
-58
client/mysqldump.c
client/mysqldump.c
+104
-56
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+27
-2
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+5
-0
No files found.
client/mysqldump.c
View file @
35564d9f
...
@@ -68,13 +68,6 @@
...
@@ -68,13 +68,6 @@
/* Size of buffer for dump's select query */
/* Size of buffer for dump's select query */
#define QUERY_LENGTH 1536
#define QUERY_LENGTH 1536
#define print_xml_tag(out_file, sbeg, sval, send) \
{ \
fputs(sbeg, out_file); \
print_quoted_xml(out_file, sval, 0); \
fputs(send, out_file); \
}
static
char
*
add_load_option
(
char
*
ptr
,
const
char
*
object
,
static
char
*
add_load_option
(
char
*
ptr
,
const
char
*
object
,
const
char
*
statement
);
const
char
*
statement
);
static
ulong
find_set
(
TYPELIB
*
lib
,
const
char
*
x
,
uint
length
,
static
ulong
find_set
(
TYPELIB
*
lib
,
const
char
*
x
,
uint
length
,
...
@@ -305,7 +298,6 @@ static int init_dumping(char *);
...
@@ -305,7 +298,6 @@ 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
(
const
char
*
name
,
char
*
buff
,
my_bool
force
);
static
char
*
quote_name
(
const
char
*
name
,
char
*
buff
,
my_bool
force
);
static
void
print_quoted_xml
(
FILE
*
output
,
char
*
str
,
ulong
len
);
static
void
print_version
(
void
)
static
void
print_version
(
void
)
{
{
...
@@ -658,8 +650,98 @@ static char *quote_name(const char *name, char *buff, my_bool force)
...
@@ -658,8 +650,98 @@ static char *quote_name(const char *name, char *buff, my_bool force)
}
/* quote_name */
}
/* quote_name */
void
print_xml_row
(
FILE
*
xml_file
,
const
char
*
row_name
,
MYSQL_RES
*
tableRes
,
/*
MYSQL_ROW
*
row
)
Quote and print a string.
SYNOPSIS
print_quoted_xml()
output - output file
str - string to print
len - its length
DESCRIPTION
Quote '<' '>' '&' '\"' singns and print a string to the xml_file.
*/
static
void
print_quoted_xml
(
FILE
*
xml_file
,
const
char
*
str
,
ulong
len
)
{
const
char
*
end
;
for
(
end
=
str
+
len
;
str
!=
end
;
str
++
)
{
switch
(
*
str
)
{
case
'<'
:
fputs
(
"<"
,
xml_file
);
break
;
case
'>'
:
fputs
(
">"
,
xml_file
);
break
;
case
'&'
:
fputs
(
"&"
,
xml_file
);
break
;
case
'\"'
:
fputs
(
"""
,
xml_file
);
break
;
default:
fputc
(
*
str
,
xml_file
);
break
;
}
}
}
/*
Print xml tag with one attribute.
SYNOPSIS
print_xml_tag1()
xml_file - output file
sbeg - line beginning
stag_atr - tag and attribute
sval - value of attribute
send - line ending
DESCRIPTION
Print tag with one attribute to the xml_file. Format is:
sbeg<stag_atr="sval">send
NOTE
sval MUST be a NULL terminated string.
sval string will be qouted before output.
*/
static
void
print_xml_tag1
(
FILE
*
xml_file
,
const
char
*
sbeg
,
const
char
*
stag_atr
,
const
char
*
sval
,
const
char
*
send
)
{
fputs
(
sbeg
,
xml_file
);
fputs
(
"<"
,
xml_file
);
fputs
(
stag_atr
,
xml_file
);
fputs
(
"
\"
"
,
xml_file
);
print_quoted_xml
(
xml_file
,
sval
,
strlen
(
sval
));
fputs
(
"
\"
>"
,
xml_file
);
fputs
(
send
,
xml_file
);
}
/*
Print xml tag with many attributes.
SYNOPSIS
print_xml_row()
xml_file - output file
row_name - xml tag name
tableRes - query result
row - result row
DESCRIPTION
Print tag with many attribute to the xml_file. Format is:
\t\t<row_name Atr1="Val1" Atr2="Val2"... />
NOTE
All atributes and values will be quoted before output.
*/
static
void
print_xml_row
(
FILE
*
xml_file
,
const
char
*
row_name
,
MYSQL_RES
*
tableRes
,
MYSQL_ROW
*
row
)
{
{
uint
i
;
uint
i
;
MYSQL_FIELD
*
field
;
MYSQL_FIELD
*
field
;
...
@@ -669,10 +751,10 @@ void print_xml_row(FILE *xml_file, const char *row_name, MYSQL_RES *tableRes,
...
@@ -669,10 +751,10 @@ void print_xml_row(FILE *xml_file, const char *row_name, MYSQL_RES *tableRes,
mysql_field_seek
(
tableRes
,
0
);
mysql_field_seek
(
tableRes
,
0
);
for
(
i
=
0
;
(
field
=
mysql_fetch_field
(
tableRes
));
i
++
)
for
(
i
=
0
;
(
field
=
mysql_fetch_field
(
tableRes
));
i
++
)
{
{
if
((
*
row
)[
i
]
&&
(
*
row
)[
i
][
0
]
)
if
((
*
row
)[
i
])
{
{
fputs
(
" "
,
xml_file
);
fputs
(
" "
,
xml_file
);
print_quoted_xml
(
xml_file
,
field
->
name
,
0
);
print_quoted_xml
(
xml_file
,
field
->
name
,
field
->
name_length
);
fputs
(
"=
\"
"
,
xml_file
);
fputs
(
"=
\"
"
,
xml_file
);
print_quoted_xml
(
xml_file
,
(
*
row
)[
i
],
lengths
[
i
]);
print_quoted_xml
(
xml_file
,
(
*
row
)[
i
],
lengths
[
i
]);
fputs
(
"
\"
"
,
xml_file
);
fputs
(
"
\"
"
,
xml_file
);
...
@@ -849,7 +931,7 @@ static uint getTableStructure(char *table, char* db)
...
@@ -849,7 +931,7 @@ static uint getTableStructure(char *table, char* db)
if
(
!
opt_xml
)
if
(
!
opt_xml
)
fprintf
(
sql_file
,
"CREATE TABLE %s (
\n
"
,
result_table
);
fprintf
(
sql_file
,
"CREATE TABLE %s (
\n
"
,
result_table
);
else
else
print_xml_tag
(
sql_file
,
"
\t
<table_structure name=
\"
"
,
table
,
"
\"
>
\n
"
);
print_xml_tag
1
(
sql_file
,
"
\t
"
,
"table_structure name="
,
table
,
"
\n
"
);
}
}
if
(
cFlag
)
if
(
cFlag
)
sprintf
(
insert_pat
,
"INSERT %sINTO %s ("
,
delayed
,
result_table
);
sprintf
(
insert_pat
,
"INSERT %sINTO %s ("
,
delayed
,
result_table
);
...
@@ -1192,9 +1274,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1192,9 +1274,7 @@ static void dumpTable(uint numFields, char *table)
rownr
=
0
;
rownr
=
0
;
init_length
=
(
uint
)
strlen
(
insert_pat
)
+
4
;
init_length
=
(
uint
)
strlen
(
insert_pat
)
+
4
;
if
(
opt_xml
)
if
(
opt_xml
)
{
print_xml_tag1
(
md_result_file
,
"
\t
"
,
"table_data name="
,
table
,
"
\n
"
);
print_xml_tag
(
md_result_file
,
"
\t
<table_data name=
\"
"
,
table
,
"
\"
>
\n
"
);
}
if
(
opt_autocommit
)
if
(
opt_autocommit
)
fprintf
(
md_result_file
,
"set autocommit=0;
\n
"
);
fprintf
(
md_result_file
,
"set autocommit=0;
\n
"
);
...
@@ -1275,8 +1355,8 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1275,8 +1355,8 @@ static void dumpTable(uint numFields, char *table)
{
{
if
(
opt_xml
)
if
(
opt_xml
)
{
{
print_xml_tag
(
md_result_file
,
"
\t\t
<field name=
\"
"
,
field
->
name
,
print_xml_tag
1
(
md_result_file
,
"
\t\t
"
,
"field name="
,
"
\"
>
"
);
field
->
name
,
"
"
);
print_quoted_xml
(
md_result_file
,
row
[
i
],
lengths
[
i
]);
print_quoted_xml
(
md_result_file
,
row
[
i
],
lengths
[
i
]);
fputs
(
"</field>
\n
"
,
md_result_file
);
fputs
(
"</field>
\n
"
,
md_result_file
);
}
}
...
@@ -1289,8 +1369,8 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1289,8 +1369,8 @@ static void dumpTable(uint numFields, char *table)
char
*
ptr
=
row
[
i
];
char
*
ptr
=
row
[
i
];
if
(
opt_xml
)
if
(
opt_xml
)
{
{
print_xml_tag
(
md_result_file
,
"
\t\t
<field name=
\"
"
,
field
->
name
,
print_xml_tag
1
(
md_result_file
,
"
\t\t
"
,
"field name="
,
"
\"
>
"
);
field
->
name
,
"
"
);
fputs
(
!
my_isalpha
(
charset_info
,
*
ptr
)
?
ptr
:
"NULL"
,
fputs
(
!
my_isalpha
(
charset_info
,
*
ptr
)
?
ptr
:
"NULL"
,
md_result_file
);
md_result_file
);
fputs
(
"</field>
\n
"
,
md_result_file
);
fputs
(
"</field>
\n
"
,
md_result_file
);
...
@@ -1303,10 +1383,8 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1303,10 +1383,8 @@ static void dumpTable(uint numFields, char *table)
else
else
{
{
if
(
opt_xml
)
if
(
opt_xml
)
{
print_xml_tag1
(
md_result_file
,
"
\t\t
"
,
"field name="
,
print_xml_tag
(
md_result_file
,
"
\t\t
<field name=
\"
"
,
field
->
name
,
field
->
name
,
"NULL</field>
\n
"
);
"
\"
>NULL</field>
\n
"
);
}
else
else
fputs
(
"NULL"
,
md_result_file
);
fputs
(
"NULL"
,
md_result_file
);
}
}
...
@@ -1372,32 +1450,6 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1372,32 +1450,6 @@ static void dumpTable(uint numFields, char *table)
}
/* dumpTable */
}
/* dumpTable */
static
void
print_quoted_xml
(
FILE
*
output
,
char
*
str
,
ulong
len
)
{
const
char
*
end
=
str
+
(
len
?
len
:
strlen
(
str
));
for
(;
str
!=
end
;
str
++
)
{
switch
(
*
str
)
{
case
'<'
:
fputs
(
"<"
,
output
);
break
;
case
'>'
:
fputs
(
">"
,
output
);
break
;
case
'&'
:
fputs
(
"&"
,
output
);
break
;
case
'\"'
:
fputs
(
"""
,
output
);
break
;
default:
fputc
(
*
str
,
output
);
break
;
}
}
}
static
char
*
getTableName
(
int
reset
)
static
char
*
getTableName
(
int
reset
)
{
{
static
MYSQL_RES
*
res
=
NULL
;
static
MYSQL_RES
*
res
=
NULL
;
...
@@ -1516,9 +1568,7 @@ static int dump_all_tables_in_db(char *database)
...
@@ -1516,9 +1568,7 @@ static int dump_all_tables_in_db(char *database)
if
(
init_dumping
(
database
))
if
(
init_dumping
(
database
))
return
1
;
return
1
;
if
(
opt_xml
)
if
(
opt_xml
)
{
print_xml_tag1
(
md_result_file
,
""
,
"database name="
,
database
,
"
\n
"
);
print_xml_tag
(
md_result_file
,
"<database name=
\"
"
,
database
,
"
\"
>
\n
"
);
}
if
(
lock_tables
)
if
(
lock_tables
)
{
{
DYNAMIC_STRING
query
;
DYNAMIC_STRING
query
;
...
@@ -1584,9 +1634,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
...
@@ -1584,9 +1634,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
/* We shall countinue here, if --force was given */
/* We shall countinue here, if --force was given */
}
}
if
(
opt_xml
)
if
(
opt_xml
)
{
print_xml_tag1
(
md_result_file
,
""
,
"database name="
,
db
,
"
\n
"
);
print_xml_tag
(
md_result_file
,
"<database name=
\"
"
,
db
,
"
\"
>
\n
"
);
}
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
{
{
numrows
=
getTableStructure
(
*
table_names
,
db
);
numrows
=
getTableStructure
(
*
table_names
,
db
);
...
...
mysql-test/r/mysqldump.result
View file @
35564d9f
...
@@ -5,7 +5,7 @@ INSERT INTO t1 VALUES (1), (2);
...
@@ -5,7 +5,7 @@ INSERT INTO t1 VALUES (1), (2);
<mysqldump>
<mysqldump>
<database name="test">
<database name="test">
<table_structure name="t1">
<table_structure name="t1">
<field Field="a" Type="int(11)" Null="YES" />
<field Field="a" Type="int(11)" Null="YES"
Key="" Extra=""
/>
</table_structure>
</table_structure>
<table_data name="t1">
<table_data name="t1">
<row>
<row>
...
@@ -18,13 +18,38 @@ INSERT INTO t1 VALUES (1), (2);
...
@@ -18,13 +18,38 @@ INSERT INTO t1 VALUES (1), (2);
</database>
</database>
</mysqldump>
</mysqldump>
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1(a int, b text, c varchar(3));
INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
<?xml version="1.0"?>
<mysqldump>
<database name="test">
<table_structure name="t1">
<field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
<field Field="b" Type="text" Null="YES" Key="" Extra="" />
<field Field="c" Type="char(3)" Null="YES" Key="" Extra="" />
</table_structure>
<table_data name="t1">
<row>
<field name="a">1</field>
<field name="b">test</field>
<field name="c">tes</field>
</row>
<row>
<field name="a">2</field>
<field name="b">TEST</field>
<field name="c">TES</field>
</row>
</table_data>
</database>
</mysqldump>
DROP TABLE t1;
CREATE TABLE `"t"1` (`a"b"` char(2));
CREATE TABLE `"t"1` (`a"b"` char(2));
INSERT INTO `"t"1` VALUES ("1\""), ("\"2");
INSERT INTO `"t"1` VALUES ("1\""), ("\"2");
<?xml version="1.0"?>
<?xml version="1.0"?>
<mysqldump>
<mysqldump>
<database name="test">
<database name="test">
<table_structure name=""t"1">
<table_structure name=""t"1">
<field Field="a"b"" Type="char(2)" Null="YES" />
<field Field="a"b"" Type="char(2)" Null="YES"
Key="" Extra=""
/>
</table_structure>
</table_structure>
<table_data name=""t"1">
<table_data name=""t"1">
<row>
<row>
...
...
mysql-test/t/mysqldump.test
View file @
35564d9f
...
@@ -9,6 +9,11 @@ INSERT INTO t1 VALUES (1), (2);
...
@@ -9,6 +9,11 @@ INSERT INTO t1 VALUES (1), (2);
--
exec
$MYSQL_DUMP
--
skip
-
all
-
X
test
t1
--
exec
$MYSQL_DUMP
--
skip
-
all
-
X
test
t1
DROP
TABLE
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
int
,
b
text
,
c
varchar
(
3
));
INSERT
INTO
t1
VALUES
(
1
,
"test"
,
"tes"
),
(
2
,
"TEST"
,
"TES"
);
--
exec
$MYSQL_DUMP
--
skip
-
all
-
X
test
t1
DROP
TABLE
t1
;
#
#
# Bug #1707
# Bug #1707
#
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment