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
247468f1
Commit
247468f1
authored
Nov 05, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client_priv.h:
Backport --hex-blob to 4.0 client/client_priv.h: Backport --hex-blob to 4.0
parent
76cd7e9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
8 deletions
+51
-8
client/client_priv.h
client/client_priv.h
+2
-1
client/mysqldump.c
client/mysqldump.c
+49
-7
No files found.
client/client_priv.h
View file @
247468f1
...
...
@@ -38,4 +38,5 @@ enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_SSL_KEY
,
OPT_SSL_CERT
,
OPT_SSL_CA
,
OPT_SSL_CAPATH
,
OPT_SSL_CIPHER
,
OPT_SHUTDOWN_TIMEOUT
,
OPT_LOCAL_INFILE
,
OPT_DELETE_MASTER_LOGS
,
OPT_PROMPT
,
OPT_IGN_LINES
,
OPT_TRANSACTION
,
OPT_FRM
};
OPT_PROMPT
,
OPT_IGN_LINES
,
OPT_TRANSACTION
,
OPT_FRM
,
OPT_HEXBLOB
};
client/mysqldump.c
View file @
247468f1
...
...
@@ -78,7 +78,8 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
opt_alldbs
=
0
,
opt_create_db
=
0
,
opt_first_slave
=
0
,
opt_autocommit
=
0
,
opt_master_data
,
opt_disable_keys
=
0
,
opt_xml
=
0
,
opt_delete_master_logs
=
0
,
tty_password
=
0
,
opt_single_transaction
=
0
,
opt_comments
=
0
;
opt_single_transaction
=
0
,
opt_comments
=
0
,
opt_hex_blob
;
static
ulong
opt_max_allowed_packet
,
opt_net_buffer_length
;
static
MYSQL
mysql_connection
,
*
sock
=
0
;
static
char
insert_pat
[
12
*
1024
],
*
opt_password
=
0
,
*
current_user
=
0
,
...
...
@@ -248,6 +249,8 @@ static struct my_option my_long_options[] =
{
"comments"
,
'i'
,
"Write additional information."
,
(
gptr
*
)
&
opt_comments
,
(
gptr
*
)
&
opt_comments
,
0
,
GET_BOOL
,
NO_ARG
,
1
,
0
,
0
,
0
,
0
,
0
},
{
"hex-blob"
,
OPT_HEXBLOB
,
"Dump BLOBs in HEX."
,
(
gptr
*
)
&
opt_hex_blob
,
(
gptr
*
)
&
opt_hex_blob
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
,
GET_NO_ARG
,
NO_ARG
,
0
,
0
,
0
,
0
,
0
,
0
}
};
...
...
@@ -1104,6 +1107,7 @@ static void dumpTable(uint numFields, char *table)
for
(
i
=
0
;
i
<
mysql_num_fields
(
res
);
i
++
)
{
int
is_blob
;
if
(
!
(
field
=
mysql_fetch_field
(
res
)))
{
sprintf
(
query
,
"%s: Not enough fields from table %s! Aborting.
\n
"
,
...
...
@@ -1112,6 +1116,13 @@ static void dumpTable(uint numFields, char *table)
error
=
EX_CONSCHECK
;
goto
err
;
}
is_blob
=
(
opt_hex_blob
&&
(
field
->
flags
&
BINARY_FLAG
)
&&
(
field
->
type
==
FIELD_TYPE_STRING
||
field
->
type
==
FIELD_TYPE_BLOB
||
field
->
type
==
FIELD_TYPE_LONG_BLOB
||
field
->
type
==
FIELD_TYPE_MEDIUM_BLOB
||
field
->
type
==
FIELD_TYPE_TINY_BLOB
))
?
1
:
0
;
if
(
extended_insert
)
{
ulong
length
=
lengths
[
i
];
...
...
@@ -1126,18 +1137,37 @@ static void dumpTable(uint numFields, char *table)
{
if
(
!
IS_NUM_FIELD
(
field
))
{
/*
"length * 2 + 2" is OK for both HEX and non-HEX modes:
- In HEX mode we need exactly 2 bytes per character
plus 2 bytes for '0x' prefix.
- In non-HEX mode we need up to 2 bytes per character,
plus 2 bytes for leading and trailing '\'' characters.
*/
if
(
dynstr_realloc
(
&
extended_row
,
length
*
2
+
2
))
{
fputs
(
"Aborting dump (out of memory)"
,
stderr
);
error
=
EX_EOM
;
goto
err
;
}
dynstr_append
(
&
extended_row
,
"
\'
"
);
extended_row
.
length
+=
if
(
opt_hex_blob
&&
is_blob
)
{
dynstr_append
(
&
extended_row
,
"0x"
);
extended_row
.
length
+=
mysql_hex_string
(
extended_row
.
str
+
extended_row
.
length
,
row
[
i
],
length
);
extended_row
.
str
[
extended_row
.
length
]
=
'\0'
;
}
else
{
dynstr_append
(
&
extended_row
,
"
\'
"
);
extended_row
.
length
+=
mysql_real_escape_string
(
&
mysql_connection
,
&
extended_row
.
str
[
extended_row
.
length
],
row
[
i
],
length
);
extended_row
.
str
[
extended_row
.
length
]
=
'\0'
;
dynstr_append
(
&
extended_row
,
"
\'
"
);
&
extended_row
.
str
[
extended_row
.
length
],
row
[
i
],
length
);
extended_row
.
str
[
extended_row
.
length
]
=
'\0'
;
dynstr_append
(
&
extended_row
,
"
\'
"
);
}
}
else
{
...
...
@@ -1180,7 +1210,19 @@ static void dumpTable(uint numFields, char *table)
if
(
opt_xml
)
print_quoted_xml
(
md_result_file
,
field
->
name
,
row
[
i
],
lengths
[
i
]);
else
else
if
(
opt_hex_blob
&&
is_blob
)
{
/* sakaik got this idea. */
ulong
counter
;
char
xx
[
4
];
unsigned
char
*
ptr
=
row
[
i
];
fputs
(
"0x"
,
md_result_file
);
for
(
counter
=
0
;
counter
<
lengths
[
i
];
counter
++
)
{
sprintf
(
xx
,
"%02X"
,
ptr
[
counter
]);
fputs
(
xx
,
md_result_file
);
}
}
else
unescape
(
md_result_file
,
row
[
i
],
lengths
[
i
]);
}
else
...
...
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