summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <dlenev@brandersnatch.localdomain>2004-05-22 23:41:58 +0400
committerunknown <dlenev@brandersnatch.localdomain>2004-05-22 23:41:58 +0400
commit0e86cf8aba3c7d067dd28efd78f138d467ec7e7b (patch)
tree396b746d77b997977420c7bc8c1903ab26a53a21 /sql
parent11ee33b181f20b3d746da871918c96890480a1ae (diff)
downloadmariadb-git-0e86cf8aba3c7d067dd28efd78f138d467ec7e7b.tar.gz
Fix for bug which caused grant.test fail on darwin7.3. We were converting db and table
names to lower case using latin1 instead of utf-8 in sql_acl.cc if lower_case_table_names was on. Also replaced in other such places system_charset_info with files_charset_info for consistency. sql/handler.cc: Replaced system_charset_info with files_charset_info in places where we are converting names to lower case because of lower_case_table_names for consistency. sql/sql_acl.cc: We should use files_charset_info when converting db/table names to lower case because they could be in utf-8 and not in latin1! sql/sql_cache.cc: Added clarifying comments in tricky place after discussion with Sanja. Replaced system_charset_info with files_charset_info in places where we are converting names to lower case because of lower_case_table_names for consistency. sql/sql_db.cc: Replaced system_charset_info with files_charset_info in places where we are converting names to lower case because of lower_case_table_names for consistency. sql/sql_show.cc: Replaced system_charset_info with files_charset_info in places where we are converting names to lower case because of lower_case_table_names for consistency. sql/sql_table.cc: Replaced system_charset_info with files_charset_info in places where we are converting names to lower case because of lower_case_table_names for consistency.
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/sql_acl.cc12
-rw-r--r--sql/sql_cache.cc19
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_table.cc10
6 files changed, 32 insertions, 17 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 9acd55db0b1..bc86241bd00 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -743,7 +743,7 @@ int ha_delete_table(enum db_type table_type, const char *path)
{
/* Ensure that table handler get path in lower case */
strmov(tmp_path, path);
- my_casedn_str(system_charset_info, tmp_path);
+ my_casedn_str(files_charset_info, tmp_path);
path= tmp_path;
}
int error=file->delete_table(path);
@@ -1247,7 +1247,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
{
/* Ensure that handler gets name in lower case */
strmov(name_buff, name);
- my_casedn_str(system_charset_info, name_buff);
+ my_casedn_str(files_charset_info, name_buff);
name= name_buff;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index fbd47d4954d..25ff4c5676b 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -953,7 +953,7 @@ ulong acl_get(const char *host, const char *ip,
end=strmov((tmp_db=strmov(strmov(key, ip ? ip : "")+1,user)+1),db);
if (lower_case_table_names)
{
- my_casedn_str(&my_charset_latin1, tmp_db);
+ my_casedn_str(files_charset_info, tmp_db);
db=tmp_db;
}
key_length=(uint) (end-key);
@@ -1733,8 +1733,8 @@ GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u,
tname= strdup_root(&memex,t);
if (lower_case_table_names)
{
- my_casedn_str(&my_charset_latin1, db);
- my_casedn_str(&my_charset_latin1, tname);
+ my_casedn_str(files_charset_info, db);
+ my_casedn_str(files_charset_info, tname);
}
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length);
@@ -1768,8 +1768,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs)
}
if (lower_case_table_names)
{
- my_casedn_str(&my_charset_latin1, db);
- my_casedn_str(&my_charset_latin1, tname);
+ my_casedn_str(files_charset_info, db);
+ my_casedn_str(files_charset_info, tname);
}
key_length = ((uint) strlen(db) + (uint) strlen(user) +
(uint) strlen(tname) + 3);
@@ -2416,7 +2416,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
if (lower_case_table_names && db)
{
strmov(tmp_db,db);
- my_casedn_str(&my_charset_latin1, tmp_db);
+ my_casedn_str(files_charset_info, tmp_db);
db=tmp_db;
}
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index d7d4219c7fd..b9fe61ac48a 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1512,13 +1512,28 @@ ulong Query_cache::init_cache()
VOID(hash_init(&queries, &my_charset_bin, def_query_hash_size, 0, 0,
query_cache_query_get_key, 0, 0));
#ifndef FN_NO_CASE_SENCE
+ /*
+ If lower_case_table_names!=0 then db and table names are already
+ converted to lower case and we can use binary collation for their
+ comparison (no matter if file system case sensitive or not).
+ If we have case-sensitive file system (like on most Unixes) and
+ lower_case_table_names == 0 then we should distinguish my_table
+ and MY_TABLE cases and so again can use binary collation.
+ */
VOID(hash_init(&tables, &my_charset_bin, def_table_hash_size, 0, 0,
query_cache_table_get_key, 0, 0));
#else
- // windows, OS/2 or other case insensitive file names work around
+ /*
+ On windows, OS/2, MacOS X with HFS+ or any other case insensitive
+ file system if lower_case_table_names!=0 we have same situation as
+ in previous case, but if lower_case_table_names==0 then we should
+ not distinguish cases (to be compatible in behavior with underlaying
+ file system) and so should use case insensitive collation for
+ comparison.
+ */
VOID(hash_init(&tables,
lower_case_table_names ? &my_charset_bin :
- system_charset_info,
+ files_charset_info,
def_table_hash_size, 0, 0,query_cache_table_get_key, 0, 0));
#endif
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index bddaebdc0f2..39c8c00898d 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -366,7 +366,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
/* Convert database to lower case */
strmov(tmp_db, db);
- my_casedn_str(system_charset_info, tmp_db);
+ my_casedn_str(files_charset_info, tmp_db);
db= tmp_db;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 80634c68ac7..4fb85d9bab7 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -422,7 +422,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
{
if (lower_case_table_names)
{
- if (wild_case_compare(system_charset_info,file->name,wild))
+ if (wild_case_compare(files_charset_info, file->name, wild))
continue;
}
else if (wild_compare(file->name,wild,0))
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index e017bc7e6b5..383165824d7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1395,11 +1395,11 @@ mysql_rename_table(enum db_type base,
{
/* Table handler expects to get all file names as lower case */
strmov(tmp_from, old_name);
- my_casedn_str(system_charset_info, tmp_from);
+ my_casedn_str(files_charset_info, tmp_from);
old_name= tmp_from;
strmov(tmp_to, new_name);
- my_casedn_str(system_charset_info, tmp_to);
+ my_casedn_str(files_charset_info, tmp_to);
new_name= tmp_to;
}
my_snprintf(from, sizeof(from), "%s/%s/%s",
@@ -2514,10 +2514,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (lower_case_table_names != 2)
{
- my_casedn_str(system_charset_info, new_name_buff);
+ my_casedn_str(files_charset_info, new_name_buff);
new_alias= new_name; // Create lower case table name
}
- my_casedn_str(system_charset_info, new_name);
+ my_casedn_str(files_charset_info, new_name);
}
if (new_db == db &&
!my_strcasecmp(table_alias_charset, new_name_buff, table_name))
@@ -2880,7 +2880,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
current_pid, thd->thread_id);
/* Safety fix for innodb */
if (lower_case_table_names)
- my_casedn_str(system_charset_info, tmp_name);
+ my_casedn_str(files_charset_info, tmp_name);
create_info->db_type=new_db_type;
if (!create_info->comment)
create_info->comment=table->comment;