diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-07-05 19:08:55 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-07-05 19:08:55 +0200 |
commit | f6633bf058802ad7da8196d01fd19d75c53f7274 (patch) | |
tree | b7ba9832aae2a3d0c72d2bf3d89cf2a5f13a44f6 /client | |
parent | fc5932a1b733b331be20c3f1b45c61c798227dba (diff) | |
parent | e555540ab6b9c3e0d4fdd00af093b115a9401d0a (diff) | |
download | mariadb-git-f6633bf058802ad7da8196d01fd19d75c53f7274.tar.gz |
Merge branch '10.1' into 10.2
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 6 | ||||
-rw-r--r-- | client/mysqltest.cc | 35 |
2 files changed, 32 insertions, 9 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index d85b118a2bb..d81d8abfcfd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2323,8 +2323,10 @@ static bool add_line(String &buffer, char *line, ulong line_length, continue; } #endif - if (!*ml_comment && inchar == '\\' && - !(*in_string && + 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))) { // Found possbile one character command like \c diff --git a/client/mysqltest.cc b/client/mysqltest.cc index a23e61f1fc3..95f358524cf 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1720,12 +1720,23 @@ void log_msg(const char *fmt, ...) int cat_file(DYNAMIC_STRING* ds, const char* filename) { int fd; - int len; - char buff[16384]; + size_t len; + char *buff; if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0) return 1; - while((len= (int)my_read(fd, (uchar*)&buff, sizeof(buff)-1, MYF(0))) > 0) + + len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0)); + my_seek(fd, 0, SEEK_SET, MYF(0)); + if (len == (size_t)MY_FILEPOS_ERROR || + !(buff= (char*)my_malloc(len + 1, MYF(0)))) + { + my_close(fd, MYF(0)); + return 1; + } + len= my_read(fd, (uchar*)buff, len, MYF(0)); + my_close(fd, MYF(0)); + { char *p= buff, *start= buff,*end=buff+len; while (p < end) @@ -1748,7 +1759,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename) *p= 0; replace_dynstr_append_mem(ds, start, p-start); } - my_close(fd, MYF(0)); + my_free(buff); return 0; } @@ -6490,6 +6501,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 @@ -6516,7 +6537,7 @@ my_bool end_of_query(int c) int read_line(char *buf, int size) { - char c, UNINIT_VAR(last_quote), last_char= 0; + char c, last_quote=0, last_char= 0; char *p= buf, *buf_end= buf + size - 1; int skip_char= 0; my_bool have_slash= FALSE; @@ -6598,7 +6619,7 @@ int read_line(char *buf, int size) state= R_Q; } } - have_slash= (c == '\\'); + have_slash= is_escape_char(c, last_quote); break; case R_COMMENT: @@ -6668,7 +6689,7 @@ int read_line(char *buf, int size) case R_Q: if (c == last_quote) state= R_NORMAL; - else if (c == '\\') + else if (is_escape_char(c, last_quote)) state= R_SLASH_IN_Q; break; |