diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-06-27 14:00:10 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-06-27 14:00:37 +0200 |
commit | d5cd33450413816f8696125cd66c8393921e6267 (patch) | |
tree | 80c1a9b013e218aaee4ade6c55984a791dfe61ca /client | |
parent | 39385ff7b253302723a94c896d199a83adb8622f (diff) | |
download | mariadb-git-d5cd33450413816f8696125cd66c8393921e6267.tar.gz |
MDEV-13187 incorrect backslash parsing in clients
cover ANSI_QUOTES and NO_BACKSLASH_ESCAPES in mysqltest
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 2 | ||||
-rw-r--r-- | client/mysqltest.cc | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 6a800e407a3..a965ced89c6 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2288,6 +2288,8 @@ static bool add_line(String &buffer, char *line, ulong line_length, } #endif if (!*ml_comment && inchar == '\\' && *in_string != '`' && + !(*in_string == '"' && + (mysql.server_status & SERVER_STATUS_ANSI_QUOTES)) && !(*in_string && (mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES))) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index ee636c9401d..f5ee94f1839 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -6486,6 +6486,16 @@ my_bool end_of_query(int c) } +static inline bool is_escape_char(char c, char in_string) +{ + if (c != '\\' || in_string == '`') return false; + if (!cur_con) return true; + uint server_status= cur_con->mysql->server_status; + if (server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) return false; + return !(server_status & SERVER_STATUS_ANSI_QUOTES && in_string == '"'); +} + + /* Read one "line" from the file @@ -6594,7 +6604,7 @@ int read_line(char *buf, int size) state= R_Q; } } - have_slash= (c == '\\' && last_quote != '`'); + have_slash= is_escape_char(c, last_quote); break; case R_COMMENT: @@ -6664,7 +6674,7 @@ int read_line(char *buf, int size) case R_Q: if (c == last_quote) state= R_NORMAL; - else if (c == '\\' && last_quote != '`') + else if (is_escape_char(c, last_quote)) state= R_SLASH_IN_Q; break; |