- 當用戶發出 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);