diff options
author | heikki@hundin.mysql.fi <> | 2004-02-02 01:03:05 +0200 |
---|---|---|
committer | heikki@hundin.mysql.fi <> | 2004-02-02 01:03:05 +0200 |
commit | b382ee2cb15a930adc9a0218f3e8ac903d666018 (patch) | |
tree | e1c8d546bd1133f0dec2af5995320c693fd9dfbe /innobase/dict | |
parent | 7533b0cfff98d03b616b9312073ec4f354c7b2b6 (diff) | |
download | mariadb-git-b382ee2cb15a930adc9a0218f3e8ac903d666018.tar.gz |
dict0dict.c:
Change print format of FOREIGN KEY constraints spanning multiple databases to: .; but we when parsing them we must also accept , because that was the output format in < 4.0.18
Diffstat (limited to 'innobase/dict')
-rw-r--r-- | innobase/dict/dict0dict.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index d132d082e6a..5e4821d7690 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2272,6 +2272,24 @@ dict_scan_table_name( return(ptr); /* Syntax error */ } } else { + /* To be able to read table dumps made with InnoDB-4.0.17 or + earlier, we must allow the dot separator between the database + name and the table name also to appear within a quoted + identifier! InnoDB used to print a constraint as: + ... REFERENCES `databasename.tablename` ... + starting from 4.0.18 it is + ... REFERENCES `databasename`.`tablename` ... */ + + for (i = 0; i < scanned_id_len; i++) { + if (scanned_id[i] == '.') { + database_name = scanned_id; + database_name_len = i; + + scanned_id = scanned_id + i + 1; + scanned_id_len -= i + 1; + } + } + table_name = scanned_id; table_name_len = scanned_id_len; } @@ -3878,6 +3896,7 @@ dict_print_info_on_foreign_key_in_create_format( char* buf) /* in: buffer of at least 5000 bytes */ { char* buf2 = buf; + ulint cpy_len; ulint i; buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (", @@ -3897,24 +3916,31 @@ dict_print_info_on_foreign_key_in_create_format( if (dict_tables_have_same_db(foreign->foreign_table_name, foreign->referenced_table_name)) { - /* Do not print the database name of the referenced - table */ + /* Do not print the database name of the referenced table */ buf2 += sprintf(buf2, ") REFERENCES `%.500s` (", dict_remove_db_name( foreign->referenced_table_name)); } else { - buf2 += sprintf(buf2, ") REFERENCES `%.500s` (", - foreign->referenced_table_name); - /* Change the '/' in the table name to '.' */ - - for (i = ut_strlen(buf); i > 0; i--) { - if (buf[i] == '/') { + buf2 += sprintf(buf2, ") REFERENCES `"); + + /* Look for the '/' in the table name */ - buf[i] = '.'; + i = 0; + while (foreign->referenced_table_name[i] != '/') { + i++; + } + + cpy_len = i; - break; - } + if (cpy_len > 500) { + cpy_len = 500; } + + memcpy(buf2, foreign->referenced_table_name, cpy_len); + buf2 += cpy_len; + + buf2 += sprintf(buf2, "`.`%.500s` (", + foreign->referenced_table_name + i + 1); } for (i = 0; i < foreign->n_fields; i++) { |