Commit a31b8f24 authored by unknown's avatar unknown

InnoDB: make ALTER TABLE to work on table names containing '#' (Bug #5856)


innobase/dict/dict0dict.c:
  dict_strip_comments(): do not look for comments within quotes (Bug #5856)
innobase/row/row0mysql.c:
  row_drop_table_for_mysql(): Remove a memory leak
parent fcf27382
...@@ -2500,6 +2500,8 @@ dict_strip_comments( ...@@ -2500,6 +2500,8 @@ dict_strip_comments(
char* str; char* str;
char* sptr; char* sptr;
char* ptr; char* ptr;
/* unclosed quote character (0 if none) */
char quote = 0;
str = mem_alloc(strlen(sql_string) + 1); str = mem_alloc(strlen(sql_string) + 1);
...@@ -2516,7 +2518,17 @@ dict_strip_comments( ...@@ -2516,7 +2518,17 @@ dict_strip_comments(
return(str); return(str);
} }
if (*sptr == '#' if (*sptr == quote) {
/* Closing quote character: do not look for
starting quote or comments. */
quote = 0;
} else if (quote) {
/* Within quotes: do not look for
starting quotes or comments. */
} else if (*sptr == '"' || *sptr == '`') {
/* Starting quote: remember the quote character. */
quote = *sptr;
} else if (*sptr == '#'
|| (0 == memcmp("-- ", sptr, 3))) { || (0 == memcmp("-- ", sptr, 3))) {
for (;;) { for (;;) {
/* In Unix a newline is 0x0A while in Windows /* In Unix a newline is 0x0A while in Windows
...@@ -2531,9 +2543,7 @@ dict_strip_comments( ...@@ -2531,9 +2543,7 @@ dict_strip_comments(
sptr++; sptr++;
} }
} } else if (!quote && *sptr == '/' && *(sptr + 1) == '*') {
if (*sptr == '/' && *(sptr + 1) == '*') {
for (;;) { for (;;) {
if (*sptr == '*' && *(sptr + 1) == '/') { if (*sptr == '*' && *(sptr + 1) == '/') {
......
...@@ -2051,6 +2051,7 @@ row_drop_table_for_mysql( ...@@ -2051,6 +2051,7 @@ row_drop_table_for_mysql(
memcpy(sql, str1, (sizeof str1) - 1); memcpy(sql, str1, (sizeof str1) - 1);
memcpy(sql + (sizeof str1) - 1, quoted_name, namelen); memcpy(sql + (sizeof str1) - 1, quoted_name, namelen);
memcpy(sql + (sizeof str1) - 1 + namelen, str2, sizeof str2); memcpy(sql + (sizeof str1) - 1 + namelen, str2, sizeof str2);
mem_free(quoted_name);
/* Serialize data dictionary operations with dictionary mutex: /* Serialize data dictionary operations with dictionary mutex:
no deadlocks can occur then in these operations */ no deadlocks can occur then in these operations */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment