diff options
-rw-r--r-- | mysql-test/r/lowercase_table.result | 11 | ||||
-rw-r--r-- | mysql-test/t/lowercase_table.test | 15 | ||||
-rw-r--r-- | sql/item.cc | 5 | ||||
-rw-r--r-- | sql/set_var.h | 2 | ||||
-rw-r--r-- | sql/sql_cache.cc | 7 | ||||
-rw-r--r-- | sql/sql_db.cc | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 5 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
8 files changed, 34 insertions, 16 deletions
diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index f4e7723a608..8bf3db8cad0 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -1,4 +1,4 @@ -drop table if exists t1,t2,t3,t4,T1; +drop table if exists t1,t2,t3,t4; create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table t4 (id int primary key, Word varchar(40) not null); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); @@ -49,3 +49,12 @@ delete P1.*,p2.* from t1 as P1, t2 as P2 where P1.a=p2.a; update t1 as p1, t2 as p2 SET p1.a=1,P2.a=1 where p1.a=P2.a; update t1 as P1, t2 as P2 SET P1.a=1,p2.a=1 where P1.a=p2.a; drop table t1,t2; +create table t1 (a int); +create table t2 (a int); +select * from t1 c, t2 C; +ERROR 42000: Not unique table/alias: 'C' +select C.a, c.a from t1 c, t2 C; +ERROR 42000: Not unique table/alias: 'C' +drop table t1, t2; +show tables; +Tables_in_test diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index 42e9cdc9f3d..db46f3d432d 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1,t2,t3,t4,T1; +drop table if exists t1,t2,t3,t4; --enable_warnings create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); @@ -41,3 +41,16 @@ delete P1.*,p2.* from t1 as P1, t2 as P2 where P1.a=p2.a; update t1 as p1, t2 as p2 SET p1.a=1,P2.a=1 where p1.a=P2.a; update t1 as P1, t2 as P2 SET P1.a=1,p2.a=1 where P1.a=p2.a; drop table t1,t2; + +# +# aliases case insensitive +# +create table t1 (a int); +create table t2 (a int); +-- error 1066 +select * from t1 c, t2 C; +-- error 1066 +select C.a, c.a from t1 c, t2 C; +drop table t1, t2; + +show tables; diff --git a/sql/item.cc b/sql/item.cc index 3df40dba5b7..7549bac71b8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -456,9 +456,8 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const (!my_strcasecmp(table_alias_charset, item_field->table_name, table_name) && (!item_field->db_name || - (item_field->db_name && !my_strcasecmp(table_alias_charset, - item_field->db_name, - db_name)))))); + (item_field->db_name && !strcmp(item_field->db_name, + db_name)))))); } diff --git a/sql/set_var.h b/sql/set_var.h index 8f21c5a729f..dc5b1bf927f 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -141,7 +141,7 @@ public: sys_update_func update_func_arg, sys_set_default_func set_default_func_arg, char *value_arg) - :sys_var(name_arg), check_func(check_func_arg), value(value_arg), + :sys_var(name_arg), value(value_arg), check_func(check_func_arg), update_func(update_func_arg),set_default_func(set_default_func_arg) {} bool check(THD *thd, set_var *var); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index afeee044799..40d9b1b42d8 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1259,12 +1259,7 @@ void Query_cache::invalidate(char *db) do { next= curr->next; - /* - table_alias_charset used here because it depends of - lower_case_table_names variable - */ - if (my_strcasecmp(table_alias_charset, db, - (char*)(curr->table()->db())) == 0) + if (strcmp(db, (char*)(curr->table()->db())) == 0) invalidate_table(curr); /* invalidate_table can freed block on which point 'next' (if diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6aaca975e53..08582391754 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -504,7 +504,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, found_other_files++; continue; } - if (db && !my_strcasecmp(&my_charset_latin1, + // just for safety we use files_charset_info + if (db && !my_strcasecmp(files_charset_info, extension, reg_ext)) { /* Drop the table nicely */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d21f20d1697..73811dddf75 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2712,7 +2712,7 @@ mysql_execute_command(THD *thd) for (walk= (TABLE_LIST*) tables; walk; walk= walk->next) { if (!my_strcasecmp(table_alias_charset, auxi->alias, walk->alias) && - !my_strcasecmp(table_alias_charset, walk->db, auxi->db)) + !strcmp(walk->db, auxi->db)) break; } if (!walk) @@ -4495,7 +4495,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, tables ; tables=tables->next) { - if (!strcmp(alias_str,tables->alias) && !strcmp(ptr->db, tables->db)) + if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) && + !strcmp(ptr->db, tables->db)) { net_printf(thd,ER_NONUNIQ_TABLE,alias_str); /* purecov: tested */ DBUG_RETURN(0); /* purecov: tested */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 020356782ba..94bedd9bfa2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9376,7 +9376,7 @@ void st_select_lex::print(THD *thd, String *str) str->append(table->db); str->append('.'); str->append(table->real_name); - if (strcmp(table->real_name, table->alias)) + if (my_strcasecmp(table_alias_charset, table->real_name, table->alias)) { str->append(' '); str->append(table->alias); |