diff options
author | unknown <marko@hundin.mysql.fi> | 2004-11-03 14:56:48 +0200 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-11-03 14:56:48 +0200 |
commit | 0aa8d14149e6cd22f91dd60db99d56fb93b11b9c (patch) | |
tree | 0a5cbba09f77c33b46d4faa0e191b12000ecc8ac /innobase | |
parent | 1d6350900536aa8f9eacf2ed3c70c42b3c49a726 (diff) | |
download | mariadb-git-0aa8d14149e6cd22f91dd60db99d56fb93b11b9c.tar.gz |
InnoDB: fix bugs in the FOREIGN KEY parser (Bug #6340)
innobase/dict/dict0dict.c:
dict_scan_to(): skip quoted strings while scanning for the keyword
dict_create_foreign_constraints_low(): allow quote immediately after CONSTRAINT
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/dict/dict0dict.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 5ca31ecd422..aa5bab210ef 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -604,7 +604,7 @@ dict_table_get_on_id( } /************************************************************************ -Looks for column n postion in the clustered index. */ +Looks for column n position in the clustered index. */ ulint dict_table_get_nth_col_pos( @@ -2140,8 +2140,8 @@ dict_foreign_add_to_cache( /************************************************************************* Scans from pointer onwards. Stops if is at the start of a copy of -'string' where characters are compared without case sensitivity. Stops -also at '\0'. */ +'string' where characters are compared without case sensitivity, and +only outside `` or "" quotes. Stops also at '\0'. */ static const char* dict_scan_to( @@ -2150,31 +2150,34 @@ dict_scan_to( const char* ptr, /* in: scan from */ const char* string) /* in: look for this */ { - ibool success; - ulint i; -loop: - if (*ptr == '\0') { - return(ptr); - } - - success = TRUE; - - for (i = 0; i < ut_strlen(string); i++) { - if (toupper((ulint)(ptr[i])) != toupper((ulint)(string[i]))) { - success = FALSE; + char quote = '\0'; + for (; *ptr; ptr++) { + if (*ptr == quote) { + /* Closing quote character: do not look for + starting quote or the keyword. */ + quote = '\0'; + } else if (quote) { + /* Within quotes: do nothing. */ + } else if (*ptr == '`' || *ptr == '"') { + /* Starting quote: remember the quote character. */ + quote = *ptr; + } else { + /* Outside quotes: look for the keyword. */ + ulint i; + for (i = 0; string[i]; i++) { + if (toupper((ulint)(ptr[i])) + != toupper((ulint)(string[i]))) { + goto nomatch; + } + } break; + nomatch: + ; } } - if (success) { - - return(ptr); - } - - ptr++; - - goto loop; + return(ptr); } /************************************************************************* @@ -2762,13 +2765,13 @@ loop: ut_a(success); - if (!isspace(*ptr)) { + if (!isspace(*ptr) && *ptr != '"' && *ptr != '`') { goto loop; } - do { + while (isspace(*ptr)) { ptr++; - } while (isspace(*ptr)); + } /* read constraint name unless got "CONSTRAINT FOREIGN" */ if (ptr != ptr2) { |