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
54c03ff7
Commit
54c03ff7
authored
Nov 18, 2002
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge vvagin@work.mysql.com:/home/bk/mysql-4.0
into genie.(none):/home/vva/work/mysqldump_xml/4.0
parents
a9c044ac
db7357a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
client/mysqldump.c
client/mysqldump.c
+27
-15
No files found.
client/mysqldump.c
View file @
54c03ff7
...
...
@@ -294,7 +294,10 @@ static void short_usage(void)
static
void
write_header
(
FILE
*
sql_file
,
char
*
db_name
)
{
if
(
opt_xml
)
{
fprintf
(
sql_file
,
"<?xml version=
\"
1.0
\"
?>
\n
"
);
fprintf
(
sql_file
,
"<mysqldump>
\n
"
);
}
else
{
fprintf
(
sql_file
,
"-- MySQL dump %s
\n
--
\n
"
,
DUMP_VERSION
);
...
...
@@ -308,6 +311,12 @@ static void write_header(FILE *sql_file, char *db_name)
return
;
}
/* write_header */
static
void
write_footer
(
FILE
*
sql_file
)
{
if
(
opt_xml
)
fprintf
(
sql_file
,
"</mysqldump>"
);
fputs
(
"
\n
"
,
sql_file
);
}
/* write_footer */
static
my_bool
get_one_option
(
int
optid
,
const
struct
my_option
*
opt
__attribute__
((
unused
)),
...
...
@@ -978,7 +987,7 @@ static void dumpTable(uint numFields, char *table)
rownr
=
0
;
init_length
=
(
uint
)
strlen
(
insert_pat
)
+
4
;
if
(
opt_xml
)
fprintf
(
md_result_file
,
"
\t
<
%s
>
\n
"
,
table
);
fprintf
(
md_result_file
,
"
\t
<
table name=
\"
%s
\"
>
\n
"
,
table
);
if
(
opt_autocommit
)
fprintf
(
md_result_file
,
"set autocommit=0;
\n
"
);
...
...
@@ -1067,8 +1076,8 @@ static void dumpTable(uint numFields, char *table)
/* change any strings ("inf","nan",..) into NULL */
char
*
ptr
=
row
[
i
];
if
(
opt_xml
)
fprintf
(
md_result_file
,
"
\t\t
<
%s>%s</%s
>
\n
"
,
field
->
name
,
!
isalpha
(
*
ptr
)
?
ptr
:
"NULL"
,
field
->
name
);
fprintf
(
md_result_file
,
"
\t\t
<
field name=
\"
%s
\"
>%s</field
>
\n
"
,
field
->
name
,
!
isalpha
(
*
ptr
)
?
ptr
:
"NULL"
);
else
fputs
((
!
isalpha
(
*
ptr
))
?
ptr
:
"NULL"
,
md_result_file
);
}
...
...
@@ -1076,8 +1085,8 @@ static void dumpTable(uint numFields, char *table)
else
{
if
(
opt_xml
)
fprintf
(
md_result_file
,
"
\t\t
<
%s>%s</%s
>
\n
"
,
field
->
name
,
"NULL"
,
field
->
name
);
fprintf
(
md_result_file
,
"
\t\t
<
field name=
\"
%s
\"
>%s</field
>
\n
"
,
field
->
name
,
"NULL"
);
else
fputs
(
"NULL"
,
md_result_file
);
}
...
...
@@ -1118,7 +1127,7 @@ static void dumpTable(uint numFields, char *table)
/* XML - close table tag and supress regular output */
if
(
opt_xml
)
fprintf
(
md_result_file
,
"
\t
</
%s>
\n
"
,
table
);
fprintf
(
md_result_file
,
"
\t
</
table>
\n
"
);
else
if
(
extended_insert
&&
row_break
)
fputs
(
";
\n
"
,
md_result_file
);
/* If not empty table */
fflush
(
md_result_file
);
...
...
@@ -1150,7 +1159,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
{
const
char
*
end
;
fprintf
(
output
,
"
\t\t
<
%s
>"
,
fname
);
fprintf
(
output
,
"
\t\t
<
field name=
\"
%s
\"
>"
,
fname
);
for
(
end
=
str
+
len
;
str
!=
end
;
str
++
)
{
if
(
*
str
==
'<'
)
...
...
@@ -1164,7 +1173,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
else
fputc
(
*
str
,
output
);
}
fprintf
(
output
,
"</
%s>
\n
"
,
fname
);
fprintf
(
output
,
"</
field>
\n
"
);
}
static
char
*
getTableName
(
int
reset
)
...
...
@@ -1219,13 +1228,8 @@ static int dump_databases(char **db_names)
int
result
=
0
;
for
(
;
*
db_names
;
db_names
++
)
{
/* XML edit - add database element */
if
(
opt_xml
)
fprintf
(
md_result_file
,
"<%s>
\n
"
,
*
db_names
);
if
(
dump_all_tables_in_db
(
*
db_names
))
result
=
1
;
if
(
opt_xml
)
fprintf
(
md_result_file
,
"</%s>
\n
"
,
*
db_names
);
}
return
result
;
}
/* dump_databases */
...
...
@@ -1238,7 +1242,7 @@ static int init_dumping(char *database)
DBerror
(
sock
,
"when selecting the database"
);
return
1
;
/* If --force */
}
if
(
!
path
)
if
(
!
path
&&
!
opt_xml
)
{
if
(
opt_databases
||
opt_alldbs
)
{
...
...
@@ -1264,6 +1268,8 @@ static int dump_all_tables_in_db(char *database)
if
(
init_dumping
(
database
))
return
1
;
if
(
opt_xml
)
fprintf
(
md_result_file
,
"<database name=
\"
%s
\"
>
\n
"
,
database
);
if
(
lock_tables
)
{
DYNAMIC_STRING
query
;
...
...
@@ -1290,6 +1296,8 @@ static int dump_all_tables_in_db(char *database)
if
(
!
dFlag
&&
numrows
>
0
)
dumpTable
(
numrows
,
table
);
}
if
(
opt_xml
)
fprintf
(
md_result_file
,
"</database>
\n
"
);
if
(
lock_tables
)
mysql_query
(
sock
,
"UNLOCK_TABLES"
);
return
0
;
...
...
@@ -1326,12 +1334,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DBerror
(
sock
,
"when doing refresh"
);
/* We shall countinue here, if --force was given */
}
if
(
opt_xml
)
fprintf
(
md_result_file
,
"<database name=
\"
%s
\"
>
\n
"
,
db
);
for
(;
tables
>
0
;
tables
--
,
table_names
++
)
{
numrows
=
getTableStructure
(
*
table_names
,
db
);
if
(
!
dFlag
&&
numrows
>
0
)
dumpTable
(
numrows
,
*
table_names
);
}
if
(
opt_xml
)
fprintf
(
md_result_file
,
"</database>
\n
"
);
if
(
lock_tables
)
mysql_query
(
sock
,
"UNLOCK_TABLES"
);
return
0
;
...
...
@@ -1462,7 +1474,7 @@ int main(int argc, char **argv)
}
}
dbDisconnect
(
current_host
);
fputs
(
"
\n
"
,
md_result_file
);
write_footer
(
md_result_file
);
if
(
md_result_file
!=
stdout
)
my_fclose
(
md_result_file
,
MYF
(
0
));
my_free
(
opt_password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
...
...
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