summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorAnnamalai Gurusami <annamalai.gurusami@oracle.com>2013-05-18 10:20:56 +0530
committerAnnamalai Gurusami <annamalai.gurusami@oracle.com>2013-05-18 10:20:56 +0530
commit5ca36b3b46de00e9eb8030c0551e7e97bc8e24eb (patch)
treebccadc181ca132cacfbe7048262274ffd76df18c /storage
parent7397aa913d077ea961a81fd9042d83d854fb6255 (diff)
downloadmariadb-git-5ca36b3b46de00e9eb8030c0551e7e97bc8e24eb.tar.gz
Bug #12762377 FOREIGN KEYS NOT CONSTRUCTED WHEN APOSTROPHES ARE
ESCAPED WITH BACKSLASH Problem: When the CREATE TABLE statement used COMMENTS with escape sequences like 'foo\'s', InnoDB did not parse is correctly when trying to extract the foreign key information. Because of this, the foreign keys specified in the CREATE TABLE statement were not created. Solution: Make the InnoDB internal parser aware of escape sequences. rb#2457 approved by Kevin.
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;