summaryrefslogtreecommitdiff
path: root/client/mysqltest.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-06-27 14:00:10 +0200
committerSergei Golubchik <serg@mariadb.org>2017-06-27 14:00:37 +0200
commitd5cd33450413816f8696125cd66c8393921e6267 (patch)
tree80c1a9b013e218aaee4ade6c55984a791dfe61ca /client/mysqltest.cc
parent39385ff7b253302723a94c896d199a83adb8622f (diff)
downloadmariadb-git-d5cd33450413816f8696125cd66c8393921e6267.tar.gz
MDEV-13187 incorrect backslash parsing in clients
cover ANSI_QUOTES and NO_BACKSLASH_ESCAPES in mysqltest
Diffstat (limited to 'client/mysqltest.cc')
-rw-r--r--client/mysqltest.cc14
1 files changed, 12 insertions, 2 deletions
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;