summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-13 12:03:32 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-13 12:03:32 +0300
commita736a3174a4e7c0d92a38901ae61f563d4afede7 (patch)
tree348d15f7c9cc883e86d852fbddc780f506669ee4 /client
parentb44e12fef176bfc0884fb2c5f4ba7f42bf054f44 (diff)
parent4a7dfda373ff9e28e4f4f35bad76cbfc20934a9a (diff)
downloadmariadb-git-a736a3174a4e7c0d92a38901ae61f563d4afede7.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 7b3f34b755f..5db52a3ef36 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1672,11 +1672,14 @@ static struct my_option my_long_options[] =
&opt_default_auth, &opt_default_auth, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"binary-mode", 0,
- "By default, ASCII '\\0' is disallowed and '\\r\\n' is translated to '\\n'. "
- "This switch turns off both features, and also turns off parsing of all client"
- "commands except \\C and DELIMITER, in non-interactive mode (for input "
- "piped to mysql or loaded using the 'source' command). This is necessary "
- "when processing output from mysqlbinlog that may contain blobs.",
+ "Binary mode allows certain character sequences to be processed as data "
+ "that would otherwise be treated with a special meaning by the parser. "
+ "Specifically, this switch turns off parsing of all client commands except "
+ "\\C and DELIMITER in non-interactive mode (i.e., when binary mode is "
+ "combined with either 1) piped input, 2) the --batch mysql option, or 3) "
+ "the 'source' command). Also, in binary mode, occurrences of '\\r\\n' and "
+ "ASCII '\\0' are preserved within strings, whereas by default, '\\r\\n' is "
+ "translated to '\\n' and '\\0' is disallowed in user input.",
&opt_binary_mode, &opt_binary_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect-expired-password", 0,
"Notify the server that this client is prepared to handle expired "
@@ -2316,8 +2319,15 @@ static bool add_line(String &buffer, char *line, size_t line_length,
{
// Found possbile one character command like \c
- if (!(inchar = (uchar) *++pos))
- break; // readline adds one '\'
+ /*
+ The null-terminating character (ASCII '\0') marks the end of user
+ input. Then, by default, upon encountering a '\0' while parsing, it
+ should stop. However, some data naturally contains binary zeros
+ (e.g., zipped files). Real_binary_mode signals the parser to expect
+ '\0' within the data and not to end parsing if found.
+ */
+ if (!(inchar = (uchar) *++pos) && (!real_binary_mode || !*in_string))
+ break; // readline adds one '\'
if (*in_string || inchar == 'N') // \N is short for NULL
{ // Don't allow commands in string
*out++='\\';