Bug#55222 - RB://517 - Approved by Sunny

InnoDB does not attempt to handle lower_case_table_names == 2 when looking
up foreign table names and referenced table name.  It turned that server
variable into a boolean and ignored the possibility of it being '2'.  

The setting lower_case_table_names == 2 means that it should be stored and
displayed in mixed case as given, but compared internally in lower case.
Normally the server deals with this since it stores table names.  But
InnoDB stores referential constraints for the server, so it needs to keep
track of both lower case and given names.

This solution creates two table name pointers for each foreign and referenced
table name.  One to display the name, and one to look it up.  Both pointers
point to the same allocated string unless this setting is 2.  So the overhead
added is not too much.

Two functions are created in dict0mem.c to populate the ..._lookup versions
of these pointers.  Both dict_mem_foreign_table_name_lookup_set() and
dict_mem_referenced_table_name_lookup_set() are called 5 times each.
This commit is contained in:
unknown 2010-11-30 12:25:52 -06:00
commit 2dde698e0e
14 changed files with 331 additions and 75 deletions

View file

@ -3639,6 +3639,7 @@ ha_innobase::open(
UT_NOT_USED(test_if_locked);
thd = ha_thd();
srv_lower_case_table_names = lower_case_table_names;
/* Under some cases MySQL seems to call this function while
holding btr_search_latch. This breaks the latching order as
@ -6750,11 +6751,7 @@ ha_innobase::create(
trx = innobase_trx_allocate(thd);
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
} else {
srv_lower_case_table_names = FALSE;
}
srv_lower_case_table_names = lower_case_table_names;
strcpy(name2, name);
@ -7179,11 +7176,7 @@ ha_innobase::delete_table(
trx = innobase_trx_allocate(thd);
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
} else {
srv_lower_case_table_names = FALSE;
}
srv_lower_case_table_names = lower_case_table_names;
name_len = strlen(name);
@ -7306,11 +7299,7 @@ innobase_rename_table(
char* norm_to;
char* norm_from;
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
} else {
srv_lower_case_table_names = FALSE;
}
srv_lower_case_table_names = lower_case_table_names;
// Magic number 64 arbitrary
norm_to = (char*) my_malloc(strlen(to) + 64, MYF(0));