Commit d88eb71f authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Fixed handling of lower_case_table_names in SHOW TABLE STATUS,...

Fixed handling of lower_case_table_names in SHOW TABLE STATUS, mysql_list_fields() and mysql_table_dump().
This fixes some Errcode 13 errors on Windows when deleting tables.
parent 710ffb2d
......@@ -654,7 +654,7 @@ int create_frm(char *name,uint reclength,uchar *fileinfo,
HA_CREATE_INFO *create_info, uint keys);
void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
int rename_file_ext(const char * from,const char * to,const char * ext);
bool check_db_name(const char *db);
bool check_db_name(char *db);
bool check_column_name(const char *name);
bool check_table_name(const char *name, uint length);
char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr);
......
......@@ -2031,7 +2031,7 @@ The server will not act as a slave.");
init_master_info(&glob_mi);
}
printf(ER(ER_READY),my_progname,server_version,"");
printf(ER(ER_READY),my_progname,server_version, mysql_unix_port, mysql_port);
fflush(stdout);
#ifdef __NT__
......
......@@ -337,8 +337,6 @@ bool mysql_change_db(THD *thd,const char *name)
x_free(dbname);
DBUG_RETURN(1);
}
if (lower_case_table_names)
casedn_str(dbname);
DBUG_PRINT("general",("Use database: %s", dbname));
if (test_all_bits(thd->master_access,DB_ACLS))
db_access=DB_ACLS;
......
......@@ -674,16 +674,19 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
table_list->real_name = table_list->alias = tbl_name;
table_list->lock_type = TL_READ_NO_INSERT;
table_list->next = 0;
remove_escape(table_list->real_name);
if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
DBUG_RETURN(1);
if (!db || check_db_name(db))
{
net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
goto err;
}
if (lower_case_table_names)
casedn_str(tbl_name);
remove_escape(tbl_name);
if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
DBUG_RETURN(1);
if (check_access(thd, SELECT_ACL, db, &table_list->grant.privilege))
goto err;
if (grant_option && check_grant(thd, SELECT_ACL, table_list))
......@@ -859,6 +862,8 @@ bool do_command(THD *thd)
table_list.alias= table_list.real_name= thd->strdup(packet+1);
thd->query=fields=thd->strdup(strend(packet+1)+1);
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
if (lower_case_table_names)
casedn_str(table_list.real_name);
remove_escape(table_list.real_name); // This can't have wildcards
if (check_access(thd,SELECT_ACL,table_list.db,&thd->col_access))
......@@ -888,8 +893,6 @@ bool do_command(THD *thd)
net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
break;
}
if (lower_case_table_names)
casedn_str(db);
if (check_access(thd,CREATE_ACL,db,0,1))
break;
mysql_log.write(thd,command,packet+1);
......@@ -906,8 +909,6 @@ bool do_command(THD *thd)
net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL");
break;
}
if (lower_case_table_names)
casedn_str(db);
if (check_access(thd,DROP_ACL,db,0,1) || end_active_trans(thd))
break;
mysql_log.write(thd,command,db);
......@@ -1944,8 +1945,6 @@ mysql_execute_command(void)
net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name);
break;
}
if (lower_case_table_names)
casedn_str(lex->name);
if (check_access(thd,CREATE_ACL,lex->name,0,1))
break;
mysql_create_db(thd,lex->name,lex->create_info.options);
......@@ -1958,8 +1957,6 @@ mysql_execute_command(void)
net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name);
break;
}
if (lower_case_table_names)
casedn_str(lex->name);
if (check_access(thd,DROP_ACL,lex->name,0,1) ||
end_active_trans(thd))
break;
......@@ -2773,11 +2770,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
if (!(alias_str=sql_strmake(alias_str,table->table.length)))
DBUG_RETURN(0);
if (lower_case_table_names)
{
casedn_str(table->table.str);
if (table->db.str)
casedn_str(table->db.str);
}
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
DBUG_RETURN(0); /* purecov: inspected */
ptr->db= table->db.str;
......
......@@ -307,6 +307,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
net_store_data(packet,file_name);
table_list.db=(char*) db;
table_list.real_name= table_list.alias= file_name;
if (lower_case_table_names)
casedn_str(file_name);
if (!(table = open_ltable(thd, &table_list, TL_READ)))
{
for (uint i=0 ; i < field_list.elements ; i++)
......
......@@ -1045,9 +1045,29 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr)
return to;
}
bool check_db_name(const char *name)
/*
Check if database name is valid
SYNPOSIS
check_db_name()
name Name of database
NOTES
If lower_case_table_names is set then database is converted to lower case
RETURN
0 ok
1 error
*/
bool check_db_name(char *name)
{
const char *start=name;
char *start=name;
if (lower_case_table_names)
casedn_str(name);
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
......
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