diff options
author | unknown <heikki@hundin.mysql.fi> | 2004-12-10 02:36:45 +0200 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2004-12-10 02:36:45 +0200 |
commit | 7a60d1558a89df5f198884d360a14bf2b48f2c49 (patch) | |
tree | d8859cfb8a76950ce482022d74cdfa9d3bbd5a3c /innobase | |
parent | 07cebc14254fbf36d83f9eaad81d91e87ecf8cc7 (diff) | |
download | mariadb-git-7a60d1558a89df5f198884d360a14bf2b48f2c49.tar.gz |
dict0dict.c:
Fix the bug that the character 0xA0 that EMS MySQL Manager in ALTER TABLE adds after a table name confuses the InnoDB FOREIGN KEY parser, causing an error 121 when we try to add a new constraint; a full fix would require the lexer to be aware of thd->charset_info() and UTF-8
innobase/dict/dict0dict.c:
Fix the bug that the character 0xA0 that EMS MySQL Manager in ALTER TABLE adds after a table name confuses the InnoDB FOREIGN KEY parser, causing an error 121 when we try to add a new constraint; a full fix would require the lexer to be aware of thd->charset_info() and UTF-8
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/dict/dict0dict.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 183c547ab2b..ecc533ed26f 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2364,6 +2364,8 @@ dict_scan_id( ulint len = 0; const char* s; char* d; + ulint id_len; + byte* b; *id = NULL; @@ -2425,6 +2427,28 @@ dict_scan_id( *id = s; } + if (heap) { + /* EMS MySQL Manager sometimes adds characters 0xA0 (in + latin1, a 'non-breakable space') to the end of a table name. + But isspace(0xA0) is not true, which confuses our foreign key + parser. After the UTF-8 conversion in ha_innodb.cc, bytes 0xC2 + and 0xA0 are at the end of the string. + + TODO: we should lex the string using thd->charset_info, and + my_isspace(). Only after that, convert id names to UTF-8. */ + + b = (byte*)(*id); + id_len = strlen(b); + + if (id_len >= 3 && b[id_len - 1] == 0xA0 + && b[id_len - 2] == 0xC2) { + + /* Strip the 2 last bytes */ + + b[id_len - 2] = '\0'; + } + } + return(ptr); } @@ -2479,7 +2503,7 @@ dict_scan_col( } /************************************************************************* -Scans the referenced table name from an SQL string. */ +Scans a table name from an SQL string. */ static const char* dict_scan_table_name( @@ -2490,7 +2514,7 @@ dict_scan_table_name( const char* name, /* in: foreign key table name */ ibool* success,/* out: TRUE if ok name found */ mem_heap_t* heap, /* in: heap where to allocate the id */ - const char** ref_name)/* out,own: the referenced table name; + const char** ref_name)/* out,own: the table name; NULL if no name was scannable */ { const char* database_name = NULL; |