Commit a2565fac authored by marko's avatar marko

branches/zip: dict_table_rename_in_cache(): Improve the diagnostic printout

for the error cases.  Avoid copying the old table->name; the string will
remain valid in table->heap.
parent 9ab3abd6
...@@ -913,13 +913,13 @@ dict_table_rename_in_cache( ...@@ -913,13 +913,13 @@ dict_table_rename_in_cache(
dict_index_t* index; dict_index_t* index;
ulint fold; ulint fold;
ulint old_size; ulint old_size;
char* old_name; const char* old_name;
ibool success;
ut_ad(table); ut_ad(table);
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
old_size = mem_heap_get_size(table->heap); old_size = mem_heap_get_size(table->heap);
old_name = table->name;
fold = ut_fold_string(new_name); fold = ut_fold_string(new_name);
...@@ -929,11 +929,15 @@ dict_table_rename_in_cache( ...@@ -929,11 +929,15 @@ dict_table_rename_in_cache(
HASH_SEARCH(name_hash, dict_sys->table_hash, fold, HASH_SEARCH(name_hash, dict_sys->table_hash, fold,
dict_table_t*, table2, dict_table_t*, table2,
(ut_strcmp(table2->name, new_name) == 0)); (ut_strcmp(table2->name, new_name) == 0));
if (table2) { if (UNIV_LIKELY_NULL(table2)) {
fprintf(stderr, ut_print_timestamp(stderr);
"InnoDB: Error: dictionary cache" fputs(" InnoDB: Error: dictionary cache"
" already contains a table of name %s\n", " already contains a table ", stderr);
new_name); ut_print_name(stderr, NULL, TRUE, new_name);
fputs("\n"
"InnoDB: cannot rename table ", stderr);
ut_print_name(stderr, NULL, TRUE, old_name);
putc('\n', stderr);
return(FALSE); return(FALSE);
} }
} }
...@@ -943,27 +947,24 @@ dict_table_rename_in_cache( ...@@ -943,27 +947,24 @@ dict_table_rename_in_cache(
if (table->space != 0) { if (table->space != 0) {
if (table->dir_path_of_temp_table != NULL) { if (table->dir_path_of_temp_table != NULL) {
fprintf(stderr, ut_print_timestamp(stderr);
"InnoDB: Error: trying to rename a table" fputs(" InnoDB: Error: trying to rename a"
" %s (%s) created with CREATE\n" " TEMPORARY TABLE ", stderr);
"InnoDB: TEMPORARY TABLE\n", ut_print_name(stderr, NULL, TRUE, old_name);
table->name, table->dir_path_of_temp_table); fputs(" (", stderr);
success = FALSE; ut_print_filename(stderr,
} else { table->dir_path_of_temp_table);
success = fil_rename_tablespace( fputs(" )\n", stderr);
table->name, table->space, new_name); return(FALSE);
} } else if (!fil_rename_tablespace(old_name, table->space,
new_name)) {
if (!success) {
return(FALSE); return(FALSE);
} }
} }
/* Remove table from the hash tables of tables */ /* Remove table from the hash tables of tables */
HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash,
ut_fold_string(table->name), table); ut_fold_string(old_name), table);
old_name = mem_heap_strdup(table->heap, table->name);
table->name = mem_heap_strdup(table->heap, new_name); table->name = mem_heap_strdup(table->heap, new_name);
/* Add table to hash table of tables */ /* Add table to hash table of tables */
......
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