mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
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.
This commit is contained in:
parent
7397aa913d
commit
5ca36b3b46
1 changed files with 34 additions and 3 deletions
|
@ -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. */
|
||||
|
||||
/* 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. */
|
||||
|
||||
/* 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;
|
||||
|
|
Loading…
Reference in a new issue