Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of dealing with DROP TABLE by MySQL

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "MySQL's handling of DROP TABLE". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

A few days ago, during DROP TABLE, all processes, whether DDL or DML, were started by HANG; execution did not continue until the end of DROP.

I am very confused about this phenomenon.

Today, I studied a MYSQL source code to see its internal processing of DROP TABLE.

When the user issues the DROP TABLE command:

# MYSQL SERVER handles deleting a table #

/ * 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) / / Delete the physical table file

/ * here INNODB inherits the parent class handler

What is actually called is this int ha_innobase::delete_table

Go to the following: # INNODB handles deleting a table #

If it is another engine, delete the data file directly and go down * /

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 handles deleting a table #

/ * Drops a table from an InnoDB database. , /

Int ha_innobase::delete_table (const char* name); / / Delete the table from INNODB

Int row_drop_table_for_mysql ()

/ * Foreign key association check * /

/ * Lock the data dictionary (exclusive lock) * /

/ * Serialize data dictionary operations with dictionary mutex:

Row_mysql_lock_data_dictionary (trx)

/ * Update Digital Dictionary (MEMDB,information_schema), line 3178 * /

Que_eval_sql (info, "PROCEDURE DROP_TABLE_PROC () IS\ n"

/ * this is handled through a PROCEDURE * /

/ * Update Digital Dictionary (CACHE) * /

Void dict_table_remove_from_cache (dict_table_t* table))

/ * Delete the data file

/ * 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)

/ * release the lock * /

Row_mysql_unlock_data_dictionary (trx)

DROP TABLE is probably such a process.

This is the end of the content of "MySQL's handling of DROP TABLE". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report