Fuller implementation of lower case table names.

Bug record #828
parent 40756106
...@@ -21,7 +21,8 @@ select count(*) from t1; ...@@ -21,7 +21,8 @@ select count(*) from t1;
count(*) count(*)
0 0
select count(T1.a) from t1; select count(T1.a) from t1;
Unknown table 'T1' in field list count(T1.a)
0
select count(bags.a) from t1 as Bags; select count(bags.a) from t1 as Bags;
Unknown table 'bags' in field list Unknown table 'bags' in field list
drop table t1; drop table t1;
...@@ -18,7 +18,6 @@ drop table t3; ...@@ -18,7 +18,6 @@ drop table t3;
create table t1 (a int); create table t1 (a int);
select count(*) from T1; select count(*) from T1;
select count(*) from t1; select count(*) from t1;
--error 1109
select count(T1.a) from t1; select count(T1.a) from t1;
--error 1109 --error 1109
select count(bags.a) from t1 as Bags; select count(bags.a) from t1 as Bags;
......
...@@ -862,3 +862,9 @@ inline void mark_as_null_row(TABLE *table) ...@@ -862,3 +862,9 @@ inline void mark_as_null_row(TABLE *table)
table->status|=STATUS_NULL_ROW; table->status|=STATUS_NULL_ROW;
bfill(table->null_flags,table->null_bytes,255); bfill(table->null_flags,table->null_bytes,255);
} }
inline void table_case_convert(char * name, uint length)
{
if (lower_case_table_names)
casedn(name, length);
}
...@@ -33,7 +33,7 @@ enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_IGNORE }; ...@@ -33,7 +33,7 @@ enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_IGNORE };
enum enum_log_type { LOG_CLOSED, LOG_TO_BE_OPENED, LOG_NORMAL, LOG_NEW, LOG_BIN}; enum enum_log_type { LOG_CLOSED, LOG_TO_BE_OPENED, LOG_NORMAL, LOG_NEW, LOG_BIN};
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON, enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
DELAY_KEY_WRITE_ALL }; DELAY_KEY_WRITE_ALL };
extern inline void table_case_convert(char * name, uint length);
/* log info errors */ /* log info errors */
#define LOG_INFO_EOF -1 #define LOG_INFO_EOF -1
#define LOG_INFO_IO -2 #define LOG_INFO_IO -2
...@@ -758,7 +758,6 @@ typedef struct st_sort_buffer { ...@@ -758,7 +758,6 @@ typedef struct st_sort_buffer {
SORT_FIELD *sortorder; SORT_FIELD *sortorder;
} SORT_BUFFER; } SORT_BUFFER;
/* Structure for db & table in sql_yacc */ /* Structure for db & table in sql_yacc */
class Table_ident :public Sql_alloc { class Table_ident :public Sql_alloc {
...@@ -772,8 +771,15 @@ class Table_ident :public Sql_alloc { ...@@ -772,8 +771,15 @@ class Table_ident :public Sql_alloc {
db.str=0; db.str=0;
else else
db= db_arg; db= db_arg;
if (db.str)
table_case_convert(db.str,db.length);
table_case_convert(table.str,table.length);
}
inline Table_ident(LEX_STRING table_arg) :table(table_arg)
{
db.str=0;
table_case_convert(table.str,table.length);
} }
inline Table_ident(LEX_STRING table_arg) :table(table_arg) {db.str=0;}
inline void change_db(char *db_name) inline void change_db(char *db_name)
{ db.str= db_name; db.length=(uint) strlen(db_name); } { db.str= db_name; db.length=(uint) strlen(db_name); }
}; };
......
...@@ -3385,8 +3385,10 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, ...@@ -3385,8 +3385,10 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
} }
ptr->alias= alias_str; ptr->alias= alias_str;
#ifdef TO_BE_DELETED
if (lower_case_table_names) if (lower_case_table_names)
casedn_str(table->table.str); casedn_str(table->table.str);
#endif
ptr->real_name=table->table.str; ptr->real_name=table->table.str;
ptr->real_name_length=table->table.length; ptr->real_name_length=table->table.length;
ptr->lock_type= lock_type; ptr->lock_type= lock_type;
......
...@@ -1459,8 +1459,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -1459,8 +1459,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{ {
strmov(new_name_buff,new_name); strmov(new_name_buff,new_name);
fn_same(new_name_buff,table_name,3); fn_same(new_name_buff,table_name,3);
#ifdef TO_BE_DELETED
if (lower_case_table_names) if (lower_case_table_names)
casedn_str(new_name); casedn_str(new_name);
#endif
if ((lower_case_table_names && if ((lower_case_table_names &&
!my_strcasecmp(new_name_buff,table_name)) || !my_strcasecmp(new_name_buff,table_name)) ||
(!lower_case_table_names && (!lower_case_table_names &&
......
...@@ -3221,16 +3221,20 @@ simple_ident: ...@@ -3221,16 +3221,20 @@ simple_ident:
| ident '.' ident | ident '.' ident
{ {
SELECT_LEX *sel=Select; 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); $$ = !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 | '.' ident '.' ident
{ {
SELECT_LEX *sel=Select; 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); $$ = !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 | ident '.' ident '.' ident
{ {
SELECT_LEX *sel=Select; 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); $$ = !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);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment