summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0mem.c
diff options
context:
space:
mode:
authorunknown <kevin.lewis@oracle.com>2010-11-30 12:25:52 -0600
committerunknown <kevin.lewis@oracle.com>2010-11-30 12:25:52 -0600
commit2dde698e0e4aa5a4264be6f34742f1f0702c0919 (patch)
tree329291d76745ac35c234ed2047706464bd4a938a /storage/innobase/dict/dict0mem.c
parent54840ede9f3a0ef3dda8dc18b7bc18b4c3147952 (diff)
downloadmariadb-git-2dde698e0e4aa5a4264be6f34742f1f0702c0919.tar.gz
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.
Diffstat (limited to 'storage/innobase/dict/dict0mem.c')
-rw-r--r--storage/innobase/dict/dict0mem.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c
index bbb8f810f44..32b02e3180f 100644
--- a/storage/innobase/dict/dict0mem.c
+++ b/storage/innobase/dict/dict0mem.c
@@ -33,6 +33,7 @@ Created 1/8/1996 Heikki Tuuri
#include "data0type.h"
#include "mach0data.h"
#include "dict0dict.h"
+#include "srv0srv.h" /* srv_lower_case_table_names */
#ifndef UNIV_HOTBACKUP
# include "lock0lock.h"
#endif /* !UNIV_HOTBACKUP */
@@ -288,6 +289,60 @@ dict_mem_foreign_create(void)
}
/**********************************************************************//**
+Sets the foreign_table_name_lookup pointer based on the value of
+srv_lower_case_table_names. If that is 0 or 1, foreign_table_name_lookup
+will point to foreign_table_name. If 2, then another string is allocated
+of the heap and set to lower case. */
+UNIV_INLINE
+void
+dict_mem_foreign_table_name_lookup_set(
+/*===================================*/
+ dict_foreign_t* foreign, /*!< in/out: foreign struct */
+ ibool do_alloc) /*!< in: is an alloc needed */
+{
+ if (srv_lower_case_table_names == 2) {
+ if (do_alloc) {
+ foreign->foreign_table_name_lookup = mem_heap_alloc(
+ foreign->heap,
+ strlen(foreign->foreign_table_name) + 1);
+ }
+ strcpy(foreign->foreign_table_name_lookup,
+ foreign->foreign_table_name);
+ innobase_casedn_str(foreign->foreign_table_name_lookup);
+ } else {
+ foreign->foreign_table_name_lookup
+ = foreign->foreign_table_name;
+ }
+}
+
+/**********************************************************************//**
+Sets the referenced_table_name_lookup pointer based on the value of
+srv_lower_case_table_names. If that is 0 or 1,
+referenced_table_name_lookup will point to referenced_table_name. If 2,
+then another string is allocated of the heap and set to lower case. */
+UNIV_INLINE
+void
+dict_mem_referenced_table_name_lookup_set(
+/*======================================*/
+ dict_foreign_t* foreign, /*!< in/out: foreign struct */
+ ibool do_alloc) /*!< in: is an alloc needed */
+{
+ if (srv_lower_case_table_names == 2) {
+ if (do_alloc) {
+ foreign->referenced_table_name_lookup = mem_heap_alloc(
+ foreign->heap,
+ strlen(foreign->referenced_table_name) + 1);
+ }
+ strcpy(foreign->referenced_table_name_lookup,
+ foreign->referenced_table_name);
+ innobase_casedn_str(foreign->referenced_table_name_lookup);
+ } else {
+ foreign->referenced_table_name_lookup
+ = foreign->referenced_table_name;
+ }
+}
+
+/**********************************************************************//**
Adds a field definition to an index. NOTE: does not take a copy
of the column name if the field is a column. The memory occupied
by the column name may be released only after publishing the index. */