From: Date: September 7 2008 9:57pm Subject: bzr commit into mysql-5.1 branch (Martin.Skold:2660) Bug#37921 List-Archive: http://lists.mysql.com/commits/53458 X-Bug: 37921 Message-Id: <200809071957.m87JvkbP021310@quadfish.liljeholmen.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/marty/MySQL/mysql-5.1-telco-6.2/ 2660 Martin Skold 2008-09-07 Bug #37921 sql node not aware that table does not exist on data nodes: Adding check for stale frm files in mysql_create_table modified: sql/sql_table.cc === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2008-09-02 09:51:07 +0000 +++ b/sql/sql_table.cc 2008-09-07 19:57:38 +0000 @@ -3606,6 +3606,9 @@ bool mysql_create_table(THD *thd, const bool internal_tmp_table, uint select_field_count) { + const char *alias; + char path[FN_REFLEN]; + List files; TABLE *name_lock= 0; bool result; DBUG_ENTER("mysql_create_table"); @@ -3625,6 +3628,21 @@ bool mysql_create_table(THD *thd, const DBUG_RETURN(TRUE); } creating_table++; + +/* + Check if any frm file already exists and + double check with storage engines to remove + them if they are stale. + */ + alias= table_case_name(create_info, table_name); + build_table_filename(path, sizeof(path), db, alias, reg_ext, + internal_tmp_table ? FN_IS_TMP : 0); + if (!access(path,F_OK)) + { + build_table_filename(path, sizeof(path), db, "", "", 0); + VOID(find_files(thd, &files, db, path, NullS, 0)); + } + pthread_mutex_unlock(&LOCK_lock_db); if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))