溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MySQL對 DROP TABLE的處理過程

發(fā)布時間:2021-09-18 12:41:15 來源:億速云 閱讀:167 作者:chen 欄目:數(shù)據(jù)庫

本篇內(nèi)容介紹了“MySQL對 DROP TABLE的處理過程”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

前幾天,在DROP TABLE的時候,所有進程不管是DDL還是DML都被HANG起;直到DROP結(jié)束才繼續(xù)執(zhí)行;
    對這個現(xiàn)象甚其不解;
    今天研究了一個 MYSQL 源代碼,看其對DROP TABLE 的內(nèi)部處理過程 ;
    當用戶發(fā)出 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 ,
    實際調(diào)用的是這個 int ha_innobase::delete_table
    轉(zhuǎn)到下面:   #### INNODB 處理刪除一個表 ####
    如果是其他引擎,則直接刪除數(shù)據(jù)文件,往下走*/
    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()
    /* 外鍵關(guān)聯(lián)檢查 */
    /* 鎖住數(shù)據(jù)字典(獨占鎖)*/
    /* Serialize data dictionary operations with dictionary mutex:
    row_mysql_lock_data_dictionary(trx);
    /* 更新數(shù)字字典(MEMDB,information_schema), line 3178 */
    que_eval_sql(info, “PROCEDURE DROP_TABLE_PROC () IS\n”
    /*這里是通過一個PROCEDURE來處理的*/
    /* 更新數(shù)字字典(CACHE) */
    void dict_table_remove_from_cache(dict_table_t* table))
    /* 刪除數(shù)據(jù)文件
    /* 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);
    DROP TABLE大概就是這么一個過程 ;

“MySQL對 DROP TABLE的處理過程”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI