Commit 38404d90 authored by unknown's avatar unknown

ixed table and db name of fields incase of lower_case_table_names (BUG#5154)


sql/item.cc:
  fixed table and db name of fields incase of lower_case_table_names
parent 3db98095
drop database if exists MySQLTest;
create database MySQLTest;
use MySQLTest;
create table TaB (Field int);
create view ViE as select * from TAb;
show create table VIe;
Table Create Table
vie CREATE VIEW `mysqltest`.`vie` AS select `mysqltest`.`tab`.`Field` AS `Field` from `mysqltest`.`tab`
drop database MySQLTest;
--disable_warnings
drop database if exists MySQLTest;
--enable_warnings
create database MySQLTest;
use MySQLTest;
create table TaB (Field int);
create view ViE as select * from TAb;
show create table VIe;
drop database MySQLTest;
......@@ -421,6 +421,24 @@ const char *Item_ident::full_name() const
void Item_ident::print(String *str)
{
THD *thd= current_thd;
char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME];
const char *d_name= db_name, *t_name= table_name;
if (lower_case_table_names)
{
if (table_name && table_name[0])
{
strmov(t_name_buff, table_name);
my_casedn_str(files_charset_info, t_name_buff);
t_name= t_name_buff;
}
if (db_name && db_name[0])
{
strmov(d_name_buff, db_name);
my_casedn_str(files_charset_info, d_name_buff);
d_name= d_name_buff;
}
}
if (!table_name || !field_name)
{
const char *nm= field_name ? field_name : name ? name : "tmp_field";
......@@ -429,9 +447,9 @@ void Item_ident::print(String *str)
}
if (db_name && db_name[0])
{
append_identifier(thd, str, db_name, strlen(db_name));
append_identifier(thd, str, d_name, strlen(d_name));
str->append('.');
append_identifier(thd, str, table_name, strlen(table_name));
append_identifier(thd, str, t_name, strlen(t_name));
str->append('.');
append_identifier(thd, str, field_name, strlen(field_name));
}
......@@ -439,7 +457,7 @@ void Item_ident::print(String *str)
{
if (table_name[0])
{
append_identifier(thd, str, table_name, strlen(table_name));
append_identifier(thd, str, t_name, strlen(t_name));
str->append('.');
append_identifier(thd, str, field_name, strlen(field_name));
}
......
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