mysql drop table都做了什麼

 

  1. 當用戶發出 DROP TABLE 命令後: 
  2. ############# MYSQL SERVER 處理刪除一個表 ##################     
  3. /* Sql_table.cc  delete (drop) tables. */ 
  4. bool mysql_rm_table( ) 
  5.   /*   Execute the drop of a normal or temporary table */ 
  6.   int mysql_rm_table_part2 () 
  7.   
  8.    /* Remove matching tables from the HANDLER’s hash table.  */ 
  9.    void mysql_ha_rm_tables ()  
  10.     /* Mark all entries with the table as deleted to force an reopen of the table */ 
  11.     remove_table_from_cache () 
  12.     
  13.    /* remove engine files */  LINE 2024 
  14.        int handler::ha_delete_table(const char *name)  
  15.           file->ha_delete_table(path)   line 1991 
  16.              int handler::delete_table(const char *name) //刪除物理表文件; 
  17.                  /* 這裏INNODB繼承了父類handler , 
  18.                  實際調用的是這個 int ha_innobase::delete_table 
  19.                  轉到下面:   #### INNODB 處理刪除一個表 ####  
  20.                  如果是其他引擎,則直接刪除數據文件,往下走*/                 
  21.                 int mysys::my_delete_with_symlink(const char *name, myf MyFlags) 
  22.                   int mysys::my_delete(const char *name, myf MyFlags)      
  23.                   
  24.    /* Delete the table definition file */  LINE 2042  
  25.     int mysys::my_delete() 
  26.   /* clear query cache*/  
  27.       query_cache_invalidate3 
  28.     /* writes to BINLOG */ 
  29. ############# INNODB 處理刪除一個表 ##################     
  30. /* Drops a table from an InnoDB database.  */ 
  31. int ha_innobase::delete_table( const charname) ; // 從INNODB刪除表 
  32.    int row_drop_table_for_mysql() 
  33.      /* 外鍵關聯檢查 */ 
  34.      /* 鎖住數據字典(獨佔鎖)*/ 
  35.         /* Serialize data dictionary operations with dictionary mutex: 
  36.         row_mysql_lock_data_dictionary(trx); 
  37.              
  38.      /* 更新數字字典(MEMDB,information_schema), line 3178 */ 
  39.         que_eval_sql(info, “PROCEDURE DROP_TABLE_PROC () IS\n” 
  40.         /*這裏是通過一個PROCEDURE來處理的*/ 
  41.            
  42.      /* 更新數字字典(CACHE) */ 
  43.         void dict_table_remove_from_cache(dict_table_t* table)) 
  44.            
  45.      /* 刪除數據文件 
  46.           /* Deletes a single-table tablespace */ 
  47.           ibool fil_delete_tablespace() 
  48.        
  49.             /* Frees a space object from the tablespace memory cache*/ 
  50.             ibool fil_space_free () 
  51.        
  52.             /* Deletes a file. The file has to be closed before calling this. */ 
  53.             ibool os_file_delete () 
  54.               unlink((const char*)name);      
  55.          
  56.      /* 釋放鎖 */ 
  57.         row_mysql_unlock_data_dictionary(trx); 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章