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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
01908009
Commit
01908009
authored
Apr 24, 2001
by
jani@hynda.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New option to mysqldump.
parent
32774ad5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
60 deletions
+81
-60
Docs/manual.texi
Docs/manual.texi
+4
-0
client/mysqldump.c
client/mysqldump.c
+77
-60
No files found.
Docs/manual.texi
View file @
01908009
...
@@ -32515,6 +32515,10 @@ used.)
...
@@ -32515,6 +32515,10 @@ used.)
@item -q, --quick
@item -q, --quick
Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
to do this.
to do this.
@item -r, --result-file=...
Direct output to a given file. This option should be used in MSDOS,
because it prevents new line '\n' from being converted to '\n\r' (new
line + carriage return).
@item -S /path/to/socket, --socket=/path/to/socket
@item -S /path/to/socket, --socket=/path/to/socket
The socket file to use when connecting to @code{localhost} (which is the
The socket file to use when connecting to @code{localhost} (which is the
default host).
default host).
client/mysqldump.c
View file @
01908009
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
**/
**/
#define DUMP_VERSION "8.1
3
"
#define DUMP_VERSION "8.1
4
"
#include <global.h>
#include <global.h>
#include <my_sys.h>
#include <my_sys.h>
...
@@ -73,7 +73,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
...
@@ -73,7 +73,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
lock_tables
=
0
,
ignore_errors
=
0
,
flush_logs
=
0
,
replace
=
0
,
lock_tables
=
0
,
ignore_errors
=
0
,
flush_logs
=
0
,
replace
=
0
,
ignore
=
0
,
opt_drop
=
0
,
opt_keywords
=
0
,
opt_lock
=
0
,
opt_compress
=
0
,
ignore
=
0
,
opt_drop
=
0
,
opt_keywords
=
0
,
opt_lock
=
0
,
opt_compress
=
0
,
opt_delayed
=
0
,
create_options
=
0
,
opt_quoted
=
0
,
opt_databases
=
0
,
opt_delayed
=
0
,
create_options
=
0
,
opt_quoted
=
0
,
opt_databases
=
0
,
opt_alldbs
=
0
,
opt_create_db
=
0
,
opt_first_slave
=
0
;
opt_alldbs
=
0
,
opt_create_db
=
0
,
opt_first_slave
=
0
,
opt_resultfile
=
0
;
static
MYSQL
mysql_connection
,
*
sock
=
0
;
static
MYSQL
mysql_connection
,
*
sock
=
0
;
static
char
insert_pat
[
12
*
1024
],
*
opt_password
=
0
,
*
current_user
=
0
,
static
char
insert_pat
[
12
*
1024
],
*
opt_password
=
0
,
*
current_user
=
0
,
*
current_host
=
0
,
*
path
=
0
,
*
fields_terminated
=
0
,
*
current_host
=
0
,
*
path
=
0
,
*
fields_terminated
=
0
,
...
@@ -127,6 +128,7 @@ static struct option long_options[] =
...
@@ -127,6 +128,7 @@ static struct option long_options[] =
{
"port"
,
required_argument
,
0
,
'P'
},
{
"port"
,
required_argument
,
0
,
'P'
},
{
"quick"
,
no_argument
,
0
,
'q'
},
{
"quick"
,
no_argument
,
0
,
'q'
},
{
"quote-names"
,
no_argument
,
0
,
'Q'
},
{
"quote-names"
,
no_argument
,
0
,
'Q'
},
{
"result-file"
,
required_argument
,
0
,
'r'
},
{
"set-variable"
,
required_argument
,
0
,
'O'
},
{
"set-variable"
,
required_argument
,
0
,
'O'
},
{
"socket"
,
required_argument
,
0
,
'S'
},
{
"socket"
,
required_argument
,
0
,
'S'
},
#include "sslopt-longopts.h"
#include "sslopt-longopts.h"
...
@@ -227,6 +229,10 @@ puts("\
...
@@ -227,6 +229,10 @@ puts("\
-P, --port=... Port number to use for connection.
\n
\
-P, --port=... Port number to use for connection.
\n
\
-q, --quick Don't buffer query, dump directly to stdout.
\n
\
-q, --quick Don't buffer query, dump directly to stdout.
\n
\
-Q, --quote-names Quote table and column names with `
\n
\
-Q, --quote-names Quote table and column names with `
\n
\
-r, --result-file=... Direct output to a given file. This option should be
\n
\
used in MSDOS, because it prevents new line '
\\
n'
\n
\
from being converted to '
\\
n
\\
r' (newline + carriage
\n
\
return).
\n
\
-S, --socket=... Socket file to use for connection.
\n
\
-S, --socket=... Socket file to use for connection.
\n
\
--tables Overrides option --databases (-B).
\n
"
);
--tables Overrides option --databases (-B).
\n
"
);
#include "sslopt-usage.h"
#include "sslopt-usage.h"
...
@@ -283,10 +289,12 @@ static int get_options(int *argc,char ***argv)
...
@@ -283,10 +289,12 @@ static int get_options(int *argc,char ***argv)
{
{
int
c
,
option_index
;
int
c
,
option_index
;
my_bool
tty_password
=
0
;
my_bool
tty_password
=
0
;
FILE
*
resultfile
;
load_defaults
(
"my"
,
load_default_groups
,
argc
,
argv
);
load_defaults
(
"my"
,
load_default_groups
,
argc
,
argv
);
set_all_changeable_vars
(
changeable_vars
);
set_all_changeable_vars
(
changeable_vars
);
while
((
c
=
getopt_long
(
*
argc
,
*
argv
,
"#::p::h:u:O:P:S:T:EBaAcCdefFlnqtvVw:?Ix"
,
while
((
c
=
getopt_long
(
*
argc
,
*
argv
,
"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix"
,
long_options
,
&
option_index
))
!=
EOF
)
long_options
,
&
option_index
))
!=
EOF
)
{
{
switch
(
c
)
{
switch
(
c
)
{
...
@@ -346,6 +354,15 @@ static int get_options(int *argc,char ***argv)
...
@@ -346,6 +354,15 @@ static int get_options(int *argc,char ***argv)
case
'P'
:
case
'P'
:
opt_mysql_port
=
(
unsigned
int
)
atoi
(
optarg
);
opt_mysql_port
=
(
unsigned
int
)
atoi
(
optarg
);
break
;
break
;
case
'r'
:
if
(
!
(
resultfile
=
my_fopen
(
optarg
,
O_WRONLY
,
MYF
(
MY_WME
))))
{
printf
(
"Couldn't open result-file %s, aborting!
\n
"
,
optarg
);
exit
(
1
);
}
opt_resultfile
=
1
;
stdout
=
resultfile
;
break
;
case
'S'
:
case
'S'
:
opt_mysql_unix_port
=
optarg
;
opt_mysql_unix_port
=
optarg
;
break
;
break
;
...
@@ -737,8 +754,8 @@ static uint getTableStructure(char *table, char* db)
...
@@ -737,8 +754,8 @@ static uint getTableStructure(char *table, char* db)
fprintf
(
sql_file
,
" %s.%s %s"
,
table_name
,
fprintf
(
sql_file
,
" %s.%s %s"
,
table_name
,
quote_name
(
row
[
SHOW_FIELDNAME
],
name_buff
),
row
[
SHOW_TYPE
]);
quote_name
(
row
[
SHOW_FIELDNAME
],
name_buff
),
row
[
SHOW_TYPE
]);
else
else
fprintf
(
sql_file
,
" %s %s"
,
quote_name
(
row
[
SHOW_FIELDNAME
],
name_buff
)
,
fprintf
(
sql_file
,
" %s %s"
,
quote_name
(
row
[
SHOW_FIELDNAME
]
,
row
[
SHOW_TYPE
]);
name_buff
),
row
[
SHOW_TYPE
]);
if
(
row
[
SHOW_DEFAULT
])
if
(
row
[
SHOW_DEFAULT
])
{
{
fputs
(
" DEFAULT "
,
sql_file
);
fputs
(
" DEFAULT "
,
sql_file
);
...
@@ -777,10 +794,10 @@ static uint getTableStructure(char *table, char* db)
...
@@ -777,10 +794,10 @@ static uint getTableStructure(char *table, char* db)
if
(
atoi
(
row
[
3
])
==
1
)
if
(
atoi
(
row
[
3
])
==
1
)
{
{
keynr
++
;
keynr
++
;
#ifdef FORCE_PRIMARY_KEY
#ifdef FORCE_PRIMARY_KEY
if
(
atoi
(
row
[
1
])
==
0
&&
primary_key
==
INT_MAX
)
if
(
atoi
(
row
[
1
])
==
0
&&
primary_key
==
INT_MAX
)
primary_key
=
keynr
;
primary_key
=
keynr
;
#endif
#endif
if
(
!
strcmp
(
row
[
2
],
"PRIMARY"
))
if
(
!
strcmp
(
row
[
2
],
"PRIMARY"
))
{
{
primary_key
=
keynr
;
primary_key
=
keynr
;
...
@@ -967,7 +984,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -967,7 +984,7 @@ static void dumpTable(uint numFields, char *table)
printf
(
"# WHERE: %s
\n
"
,
where
);
printf
(
"# WHERE: %s
\n
"
,
where
);
strxmov
(
strend
(
query
),
" WHERE "
,
where
,
NullS
);
strxmov
(
strend
(
query
),
" WHERE "
,
where
,
NullS
);
}
}
puts
(
"#
\n
"
);
fputs
(
"#
\n\n
"
,
stdout
);
if
(
mysql_query
(
sock
,
query
))
if
(
mysql_query
(
sock
,
query
))
{
{
...
@@ -1090,7 +1107,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1090,7 +1107,7 @@ static void dumpTable(uint numFields, char *table)
else
else
{
{
if
(
row_break
)
if
(
row_break
)
puts
(
";"
);
fputs
(
";
\n
"
,
stdout
);
row_break
=
1
;
/* This is first row */
row_break
=
1
;
/* This is first row */
fputs
(
insert_pat
,
stdout
);
fputs
(
insert_pat
,
stdout
);
fputs
(
extended_row
.
str
,
stdout
);
fputs
(
extended_row
.
str
,
stdout
);
...
@@ -1098,12 +1115,10 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1098,12 +1115,10 @@ static void dumpTable(uint numFields, char *table)
}
}
}
}
else
else
{
fputs
(
");
\n
"
,
stdout
);
puts
(
");"
);
}
}
}
if
(
extended_insert
&&
row_break
)
if
(
extended_insert
&&
row_break
)
puts
(
";"
);
/* If not empty table */
fputs
(
";
\n
"
,
stdout
);
/* If not empty table */
fflush
(
stdout
);
fflush
(
stdout
);
if
(
mysql_errno
(
sock
))
if
(
mysql_errno
(
sock
))
{
{
...
@@ -1118,7 +1133,7 @@ static void dumpTable(uint numFields, char *table)
...
@@ -1118,7 +1133,7 @@ static void dumpTable(uint numFields, char *table)
return
;
return
;
}
}
if
(
opt_lock
)
if
(
opt_lock
)
puts
(
"UNLOCK TABLES;"
);
fputs
(
"UNLOCK TABLES;
\n
"
,
stdout
);
mysql_free_result
(
res
);
mysql_free_result
(
res
);
}
}
}
/* dumpTable */
}
/* dumpTable */
...
@@ -1365,7 +1380,9 @@ int main(int argc, char **argv)
...
@@ -1365,7 +1380,9 @@ int main(int argc, char **argv)
}
}
}
}
dbDisconnect
(
current_host
);
dbDisconnect
(
current_host
);
puts
(
""
);
fputs
(
"
\n
"
,
stdout
);
if
(
opt_resultfile
)
my_fclose
(
stdout
,
MYF
(
0
));
my_free
(
opt_password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
my_free
(
opt_password
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(
extended_insert
)
if
(
extended_insert
)
dynstr_free
(
&
extended_row
);
dynstr_free
(
&
extended_row
);
...
...
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