summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/dict/dict0dict.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index aec2264ad1c..699897b41f8 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -2872,14 +2872,27 @@ dict_scan_to(
const char* string) /*!< in: look for this */
{
char quote = '\0';
+ ibool escape = FALSE;
for (; *ptr; ptr++) {
if (*ptr == quote) {
/* Closing quote character: do not look for
starting quote or the keyword. */
- quote = '\0';
+
+ /* If the quote character is escaped by a
+ backslash, ignore it. */
+ if (escape) {
+ escape = FALSE;
+ } else {
+ quote = '\0';
+ }
} else if (quote) {
/* Within quotes: do nothing. */
+ if (escape) {
+ escape = FALSE;
+ } else if (*ptr == '\\') {
+ escape = TRUE;
+ }
} else if (*ptr == '`' || *ptr == '"' || *ptr == '\'') {
/* Starting quote: remember the quote character. */
quote = *ptr;
@@ -3265,6 +3278,11 @@ dict_strip_comments(
char* ptr;
/* unclosed quote character (0 if none) */
char quote = 0;
+ ibool escape = FALSE;
+
+ DBUG_ENTER("dict_strip_comments");
+
+ DBUG_PRINT("dict_strip_comments", ("%s", sql_string));
str = mem_alloc(sql_length + 1);
@@ -3279,16 +3297,29 @@ end_of_string:
ut_a(ptr <= str + sql_length);
- return(str);
+ DBUG_PRINT("dict_strip_comments", ("%s", str));
+ DBUG_RETURN(str);
}
if (*sptr == quote) {
/* Closing quote character: do not look for
starting quote or comments. */
- quote = 0;
+
+ /* If the quote character is escaped by a
+ backslash, ignore it. */
+ if (escape) {
+ escape = FALSE;
+ } else {
+ quote = 0;
+ }
} else if (quote) {
/* Within quotes: do not look for
starting quotes or comments. */
+ if (escape) {
+ escape = FALSE;
+ } else if (*sptr == '\\') {
+ escape = TRUE;
+ }
} else if (*sptr == '"' || *sptr == '`' || *sptr == '\'') {
/* Starting quote: remember the quote character. */
quote = *sptr;