summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/lowercase_table.result11
-rw-r--r--mysql-test/t/lowercase_table.test5
-rw-r--r--sql/sql_class.cc23
-rw-r--r--sql/sql_class.h11
-rw-r--r--sql/sql_parse.cc5
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_yacc.yy4
7 files changed, 24 insertions, 37 deletions
diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result
index c884e5de0f0..8edf43a51ad 100644
--- a/mysql-test/r/lowercase_table.result
+++ b/mysql-test/r/lowercase_table.result
@@ -6,6 +6,14 @@ id Word
1 a
2 b
3 c
+SELECT T1.id from T1 LIMIT 1;
+id
+1
+SELECT T2.id from t1 as T2 LIMIT 1;
+id
+1
+SELECT T2.id from t1 as t2 LIMIT 1;
+Unknown table 'T2' in field list
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
@@ -21,8 +29,7 @@ select count(*) from t1;
count(*)
0
select count(T1.a) from t1;
-count(T1.a)
-0
+Unknown table 'T1' in field list
select count(bags.a) from t1 as Bags;
Unknown table 'bags' in field list
drop table t1;
diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test
index 397cc26e127..86ea2918fd2 100644
--- a/mysql-test/t/lowercase_table.test
+++ b/mysql-test/t/lowercase_table.test
@@ -6,6 +6,10 @@ drop table if exists t1,t2,t3;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
+SELECT T1.id from T1 LIMIT 1;
+SELECT T2.id from t1 as T2 LIMIT 1;
+--error 1109
+SELECT T2.id from t1 as t2 LIMIT 1;
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
@@ -18,6 +22,7 @@ drop table t3;
create table t1 (a int);
select count(*) from T1;
select count(*) from t1;
+--error 1109
select count(T1.a) from t1;
--error 1109
select count(bags.a) from t1 as Bags;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 71aec69e49b..132e0d7745f 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -431,29 +431,6 @@ void THD::close_active_vio()
#endif
/*****************************************************************************
- Table Ident
-****************************************************************************/
-
-
-Table_ident::Table_ident(LEX_STRING db_arg,LEX_STRING table_arg,bool force)
- :table(table_arg)
-{
- if (!force && (current_thd->client_capabilities & CLIENT_NO_SCHEMA))
- db.str=0;
- else
- db= db_arg;
- if (db.str)
- table_case_convert(db.str,db.length);
- table_case_convert(table.str,table.length);
-}
-
-Table_ident::Table_ident(LEX_STRING table_arg) :table(table_arg)
-{
- db.str=0;
- table_case_convert(table.str,table.length);
-}
-
-/*****************************************************************************
** Functions to provide a interface to select results
*****************************************************************************/
diff --git a/sql/sql_class.h b/sql/sql_class.h
index abf69628d2c..8aa3d48bc35 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -762,8 +762,15 @@ class Table_ident :public Sql_alloc {
public:
LEX_STRING db;
LEX_STRING table;
- Table_ident(LEX_STRING db_arg,LEX_STRING table_arg,bool force);
- Table_ident(LEX_STRING table_arg);
+ inline Table_ident(LEX_STRING db_arg,LEX_STRING table_arg,bool force)
+ :table(table_arg)
+ {
+ if (!force && (current_thd->client_capabilities & CLIENT_NO_SCHEMA))
+ db.str=0;
+ else
+ db= db_arg;
+ }
+ inline Table_ident(LEX_STRING table_arg) :table(table_arg) {db.str=0;}
inline void change_db(char *db_name)
{ db.str= db_name; db.length=(uint) strlen(db_name); }
};
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6686f927e05..d7d7469ceed 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3396,10 +3396,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
}
ptr->alias= alias_str;
-#ifdef TO_BE_DELETED
- if (lower_case_table_names)
- casedn_str(table->table.str);
-#endif
+ table_case_convert(table->table.str, table->table.length);
ptr->real_name=table->table.str;
ptr->real_name_length=table->table.length;
ptr->lock_type= lock_type;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3250db75a6a..79105a94dec 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1463,10 +1463,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
strmov(new_name_buff,new_name);
fn_same(new_name_buff,table_name,3);
-#ifdef TO_BE_DELETED
if (lower_case_table_names)
casedn_str(new_name);
-#endif
if ((lower_case_table_names &&
!my_strcasecmp(new_name_buff,table_name)) ||
(!lower_case_table_names &&
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 32c5bd11be9..03837300904 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3221,20 +3221,16 @@ simple_ident:
| ident '.' ident
{
SELECT_LEX *sel=Select;
- table_case_convert($1.str, $1.length);
$$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$1.str,$3.str) : (Item*) new Item_ref(NullS,$1.str,$3.str);
}
| '.' ident '.' ident
{
SELECT_LEX *sel=Select;
- table_case_convert($2.str,$2.length);
$$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$2.str,$4.str) : (Item*) new Item_ref(NullS,$2.str,$4.str);
}
| ident '.' ident '.' ident
{
SELECT_LEX *sel=Select;
- table_case_convert($1.str,$1.length);
- table_case_convert($3.str,$3.length);
$$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str) : (Item*) new Item_ref((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str);
};