Commit 34b340c4 authored by unknown's avatar unknown

Review of new code:

Change argument order to be database, tablename for some functions


sql/lock.cc:
  Remove not needed block
sql/mysql_priv.h:
  Change argument order to be database, tablename (like in most other functions)
sql/sql_table.cc:
  Change argument order to be database, tablename (like in most other functions)
  Make 'flags' inline
sql/table.cc:
  Change argument order to be database, tablename (like in most other functions)
sql/unireg.cc:
  Change argument order to be database, tablename (like in most other functions)
parent 062258ca
...@@ -584,12 +584,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) ...@@ -584,12 +584,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (remove_table_from_cache(thd, db, table_list->real_name, RTFC_NO_FLAG))
{ {
if (remove_table_from_cache(thd, db, DBUG_RETURN(1); // Table is in use
table_list->real_name, RTFC_NO_FLAG))
{
DBUG_RETURN(1); // Table is in use
}
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -1029,12 +1029,12 @@ void unlock_table_names(THD *thd, TABLE_LIST *table_list, ...@@ -1029,12 +1029,12 @@ void unlock_table_names(THD *thd, TABLE_LIST *table_list,
void unireg_init(ulong options); void unireg_init(ulong options);
void unireg_end(void); void unireg_end(void);
bool mysql_create_frm(THD *thd, my_string file_name, bool mysql_create_frm(THD *thd, my_string file_name,
const char *table, const char* db, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_field, List<create_field> &create_field,
uint key_count,KEY *key_info,handler *db_type); uint key_count,KEY *key_info,handler *db_type);
int rea_create_table(THD *thd, my_string file_name, int rea_create_table(THD *thd, my_string file_name,
const char *table, const char* db, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_field, List<create_field> &create_field,
uint key_count,KEY *key_info); uint key_count,KEY *key_info);
...@@ -1107,7 +1107,7 @@ ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames, ...@@ -1107,7 +1107,7 @@ ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
const char *newname); const char *newname);
ulong next_io_size(ulong pos); ulong next_io_size(ulong pos);
void append_unescaped(String *res, const char *pos, uint length); void append_unescaped(String *res, const char *pos, uint length);
int create_frm(char *name, const char *table, const char *db, int create_frm(char *name, const char *db, const char *table,
uint reclength,uchar *fileinfo, uint reclength,uchar *fileinfo,
HA_CREATE_INFO *create_info, uint keys); HA_CREATE_INFO *create_info, uint keys);
void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
......
...@@ -220,7 +220,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -220,7 +220,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table=tables ; table ; table=table->next) for (table=tables ; table ; table=table->next)
{ {
char *db=table->db; char *db=table->db;
uint flags;
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL); mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL);
if (!close_temporary_table(thd, db, table->real_name)) if (!close_temporary_table(thd, db, table->real_name))
{ {
...@@ -232,8 +231,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -232,8 +231,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (!drop_temporary) if (!drop_temporary)
{ {
abort_locked_tables(thd,db,table->real_name); abort_locked_tables(thd,db,table->real_name);
flags= RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG; remove_table_from_cache(thd,db,table->real_name,
remove_table_from_cache(thd,db,table->real_name,flags); RTFC_WAIT_OTHER_THREAD_FLAG |
RTFC_CHECK_KILLED_FLAG);
drop_locked_tables(thd,db,table->real_name); drop_locked_tables(thd,db,table->real_name);
if (thd->killed) if (thd->killed)
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -1418,7 +1418,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1418,7 +1418,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
create_info->data_file_name= create_info->index_file_name= 0; create_info->data_file_name= create_info->index_file_name= 0;
create_info->table_options=db_options; create_info->table_options=db_options;
if (rea_create_table(thd, path, table_name, db, if (rea_create_table(thd, path, db, table_name,
create_info, fields, key_count, create_info, fields, key_count,
key_info_buffer)) key_info_buffer))
goto end; goto end;
...@@ -1979,14 +1979,14 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -1979,14 +1979,14 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* Close all instances of the table to allow repair to rename files */ /* Close all instances of the table to allow repair to rename files */
if (lock_type == TL_WRITE && table->table->version) if (lock_type == TL_WRITE && table->table->version)
{ {
uint flags;
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open, const char *old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting to get writelock"); "Waiting to get writelock");
mysql_lock_abort(thd,table->table); mysql_lock_abort(thd,table->table);
flags= RTFC_WAIT_OTHER_THREAD_FLAG | RTFC_CHECK_KILLED_FLAG;
remove_table_from_cache(thd, table->table->table_cache_key, remove_table_from_cache(thd, table->table->table_cache_key,
table->table->real_name, flags); table->table->real_name,
RTFC_WAIT_OTHER_THREAD_FLAG |
RTFC_CHECK_KILLED_FLAG);
thd->exit_cond(old_message); thd->exit_cond(old_message);
if (thd->killed) if (thd->killed)
goto err; goto err;
...@@ -3410,9 +3410,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3410,9 +3410,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (table) if (table)
{ {
VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Use new file VOID(table->file->extra(HA_EXTRA_FORCE_REOPEN)); // Use new file
/* Mark in-use copies old */
remove_table_from_cache(thd,db,table_name,RTFC_NO_FLAG); remove_table_from_cache(thd,db,table_name,RTFC_NO_FLAG);
// Mark in-use copies old /* end threads waiting on lock */
mysql_lock_abort(thd,table); // end threads waiting on lock mysql_lock_abort(thd,table);
} }
VOID(quick_rm_table(old_db_type,db,old_name)); VOID(quick_rm_table(old_db_type,db,old_name));
if (close_data_tables(thd,db,table_name) || if (close_data_tables(thd,db,table_name) ||
......
...@@ -1238,7 +1238,7 @@ void append_unescaped(String *res, const char *pos, uint length) ...@@ -1238,7 +1238,7 @@ void append_unescaped(String *res, const char *pos, uint length)
/* Create a .frm file */ /* Create a .frm file */
File create_frm(register my_string name, const char *table, const char *db, File create_frm(register my_string name, const char *db, const char *table,
uint reclength, uchar *fileinfo, uint reclength, uchar *fileinfo,
HA_CREATE_INFO *create_info, uint keys) HA_CREATE_INFO *create_info, uint keys)
{ {
......
...@@ -56,8 +56,8 @@ static bool make_empty_rec(int file, enum db_type table_type, ...@@ -56,8 +56,8 @@ static bool make_empty_rec(int file, enum db_type table_type,
mysql_create_frm() mysql_create_frm()
thd Thread handler thd Thread handler
file_name Name of file (including database and .frm) file_name Name of file (including database and .frm)
table Name of table
db Name of database db Name of database
table Name of table
create_info create info parameters create_info create info parameters
create_fields Fields to create create_fields Fields to create
keys number of keys to create keys number of keys to create
...@@ -70,7 +70,7 @@ static bool make_empty_rec(int file, enum db_type table_type, ...@@ -70,7 +70,7 @@ static bool make_empty_rec(int file, enum db_type table_type,
*/ */
bool mysql_create_frm(THD *thd, my_string file_name, bool mysql_create_frm(THD *thd, my_string file_name,
const char *table, const char *db, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_fields, List<create_field> &create_fields,
uint keys, KEY *key_info, uint keys, KEY *key_info,
...@@ -117,7 +117,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -117,7 +117,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
reclength=uint2korr(forminfo+266); reclength=uint2korr(forminfo+266);
null_fields=uint2korr(forminfo+282); null_fields=uint2korr(forminfo+282);
if ((file=create_frm(file_name, table, db, reclength, fileinfo, if ((file=create_frm(file_name, db, table, reclength, fileinfo,
create_info, keys)) < 0) create_info, keys)) < 0)
{ {
my_free((gptr) screen_buff,MYF(0)); my_free((gptr) screen_buff,MYF(0));
...@@ -219,8 +219,8 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -219,8 +219,8 @@ bool mysql_create_frm(THD *thd, my_string file_name,
rea_create_table() rea_create_table()
thd Thread handler thd Thread handler
file_name Name of file (including database and .frm) file_name Name of file (including database and .frm)
table Name of table
db Name of database db Name of database
table Name of table
create_info create info parameters create_info create info parameters
create_fields Fields to create create_fields Fields to create
keys number of keys to create keys number of keys to create
...@@ -233,14 +233,14 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -233,14 +233,14 @@ bool mysql_create_frm(THD *thd, my_string file_name,
*/ */
int rea_create_table(THD *thd, my_string file_name, int rea_create_table(THD *thd, my_string file_name,
const char *table, const char *db, const char *db, const char *table,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
List<create_field> &create_fields, List<create_field> &create_fields,
uint keys, KEY *key_info) uint keys, KEY *key_info)
{ {
DBUG_ENTER("rea_create_table"); DBUG_ENTER("rea_create_table");
if (mysql_create_frm(thd, file_name, table, db, create_info, if (mysql_create_frm(thd, file_name, db, table, create_info,
create_fields, keys, key_info, NULL)) create_fields, keys, key_info, NULL))
DBUG_RETURN(1); DBUG_RETURN(1);
if (ha_create_table(file_name,create_info,0)) if (ha_create_table(file_name,create_info,0))
......
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