- 当用户发出 DROP TABLE 命令后:
- ############# MYSQL SERVER 处理删除一个表 ##################
- /* Sql_table.cc delete (drop) tables. */
- bool mysql_rm_table( )
- /* Execute the drop of a normal or temporary table */
- int mysql_rm_table_part2 ()
- /* Remove matching tables from the HANDLER’s hash table. */
- void mysql_ha_rm_tables ()
- /* Mark all entries with the table as deleted to force an reopen of the table */
- remove_table_from_cache ()
- /* remove engine files */ LINE 2024
- int handler::ha_delete_table(const char *name)
- file->ha_delete_table(path) line 1991
- int handler::delete_table(const char *name) //删除物理表文件;
- /* 这里INNODB继承了父类handler ,
- 实际调用的是这个 int ha_innobase::delete_table
- 转到下面: #### INNODB 处理删除一个表 ####
- 若是是其余引擎,则直接删除数据文件,往下走*/
- int mysys::my_delete_with_symlink(const char *name, myf MyFlags)
- int mysys::my_delete(const char *name, myf MyFlags)
- /* Delete the table definition file */ LINE 2042
- int mysys::my_delete()
- /* clear query cache*/
- query_cache_invalidate3
- /* writes to BINLOG */
- ############# INNODB 处理删除一个表 ##################
- /* Drops a table from an InnoDB database. */
- int ha_innobase::delete_table( const char* name) ; // 从INNODB删除表
- int row_drop_table_for_mysql()
- /* 外键关联检查 */
- /* 锁住数据字典(独占锁)*/
- /* Serialize data dictionary operations with dictionary mutex:
- row_mysql_lock_data_dictionary(trx);
- /* 更新数字字典(MEMDB,information_schema), line 3178 */
- que_eval_sql(info, “PROCEDURE DROP_TABLE_PROC () IS\n”
- /*这里是经过一个PROCEDURE来处理的*/
- /* 更新数字字典(CACHE) */
- void dict_table_remove_from_cache(dict_table_t* table))
- /* 删除数据文件
- /* Deletes a single-table tablespace */
- ibool fil_delete_tablespace()
- /* Frees a space object from the tablespace memory cache*/
- ibool fil_space_free ()
- /* Deletes a file. The file has to be closed before calling this. */
- ibool os_file_delete ()
- unlink((const char*)name);
- /* 释放锁 */
- row_mysql_unlock_data_dictionary(trx);