summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0dict.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@oracle.com>2010-05-14 16:31:44 +0300
committerMarko Mäkelä <marko.makela@oracle.com>2010-05-14 16:31:44 +0300
commitb6fa4b11941549be8596f6720ec4f3c346a65bc9 (patch)
tree6c2b1a0ffff00ad0c3b9d684f898ab9a982b2771 /storage/innobase/dict/dict0dict.c
parent0ad0827fde63063bd006d7e84492fb1ffa76df90 (diff)
downloadmariadb-git-b6fa4b11941549be8596f6720ec4f3c346a65bc9.tar.gz
Merge from mysql-5.1-innodb:
Post-merge fixes: Remove the MYSQL_VERSION_ID checks, because they only apply to the InnoDB Plugin. Fix potential race condition accessing trx->op_info and trx->detailed_error. ------------------------------------------------------------ revno: 3466 revision-id: marko.makela@oracle.com-20100514130815-ym7j7cfu88ro6km4 parent: marko.makela@oracle.com-20100514130228-n3n42nw7ht78k0wn committer: Marko Mäkelä <marko.makela@oracle.com> branch nick: mysql-5.1-innodb2 timestamp: Fri 2010-05-14 16:08:15 +0300 message: Make the InnoDB FOREIGN KEY parser understand multi-statements. (Bug #48024) Also make InnoDB thinks that /*/ only starts a comment. (Bug #53644). This fixes the bugs in the InnoDB Plugin. ha_innodb.h: Use trx_query_string() instead of trx_query() when available (MySQL 5.1.42 or later). innobase_get_stmt(): New function, to retrieve the currently running SQL statement. struct trx_struct: Remove mysql_query_str. Use innobase_get_stmt() instead. dict_strip_comments(): Add and observe the parameter sql_length. Treat /*/ as the start of a comment. dict_create_foreign_constraints(), row_table_add_foreign_constraints(): Add the parameter sql_length.
Diffstat (limited to 'storage/innobase/dict/dict0dict.c')
-rw-r--r--storage/innobase/dict/dict0dict.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index ae3e7520b85..a298d785449 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -3023,25 +3023,28 @@ static
char*
dict_strip_comments(
/*================*/
- const char* sql_string) /*!< in: SQL string */
+ const char* sql_string, /*!< in: SQL string */
+ size_t sql_length) /*!< in: length of sql_string */
{
char* str;
const char* sptr;
+ const char* eptr = sql_string + sql_length;
char* ptr;
/* unclosed quote character (0 if none) */
char quote = 0;
- str = mem_alloc(strlen(sql_string) + 1);
+ str = mem_alloc(sql_length + 1);
sptr = sql_string;
ptr = str;
for (;;) {
scan_more:
- if (*sptr == '\0') {
+ if (sptr >= eptr || *sptr == '\0') {
+end_of_string:
*ptr = '\0';
- ut_a(ptr <= str + strlen(sql_string));
+ ut_a(ptr <= str + sql_length);
return(str);
}
@@ -3060,30 +3063,35 @@ scan_more:
|| (sptr[0] == '-' && sptr[1] == '-'
&& sptr[2] == ' ')) {
for (;;) {
+ if (++sptr >= eptr) {
+ goto end_of_string;
+ }
+
/* In Unix a newline is 0x0A while in Windows
it is 0x0D followed by 0x0A */
- if (*sptr == (char)0x0A
- || *sptr == (char)0x0D
- || *sptr == '\0') {
-
+ switch (*sptr) {
+ case (char) 0X0A:
+ case (char) 0x0D:
+ case '\0':
goto scan_more;
}
-
- sptr++;
}
} else if (!quote && *sptr == '/' && *(sptr + 1) == '*') {
+ sptr += 2;
for (;;) {
- if (*sptr == '*' && *(sptr + 1) == '/') {
-
- sptr += 2;
-
- goto scan_more;
+ if (sptr >= eptr) {
+ goto end_of_string;
}
- if (*sptr == '\0') {
-
+ switch (*sptr) {
+ case '\0':
goto scan_more;
+ case '*':
+ if (sptr[1] == '/') {
+ sptr += 2;
+ goto scan_more;
+ }
}
sptr++;
@@ -3764,6 +3772,7 @@ dict_create_foreign_constraints(
name before it: test.table2; the
default database id the database of
parameter name */
+ size_t sql_length, /*!< in: length of sql_string */
const char* name, /*!< in: table full name in the
normalized form
database_name/table_name */
@@ -3778,7 +3787,7 @@ dict_create_foreign_constraints(
ut_a(trx);
ut_a(trx->mysql_thd);
- str = dict_strip_comments(sql_string);
+ str = dict_strip_comments(sql_string, sql_length);
heap = mem_heap_create(10000);
err = dict_create_foreign_constraints_low(
@@ -3811,6 +3820,7 @@ dict_foreign_parse_drop_constraints(
dict_foreign_t* foreign;
ibool success;
char* str;
+ size_t len;
const char* ptr;
const char* id;
FILE* ef = dict_foreign_err_file;
@@ -3825,7 +3835,10 @@ dict_foreign_parse_drop_constraints(
*constraints_to_drop = mem_heap_alloc(heap, 1000 * sizeof(char*));
- str = dict_strip_comments(*(trx->mysql_query_str));
+ ptr = innobase_get_stmt(trx->mysql_thd, &len);
+
+ str = dict_strip_comments(ptr, len);
+
ptr = str;
ut_ad(mutex_own(&(dict_sys->mutex)));