Interaction between main modules (introduces the main responsibilities of various modules of mysql)
When Connection Manager receives a Connection from the client, it initializes the network Connection process and establishes the Connection handler process. Then the connection handler process performs permission authentication.
The passed SQL script will be received by Command Dispatcher. If it is a complicated Command, it will be passed to other modules.
In Mysql terminology, the client has two types of requests: query and command. query includes not only select, but also delete and insert, these statements need to be processed by parser, while the command does not need to be processed by parser.
If query logging is enabled, the command dispatcher will ask the logging module to log.
Command dispatcher first calls query cache before using parser. query cache first checks whether the query can be cached and whether data that meets the query has been cached. If yes, if miss is returned, parser is executed.
After parser is executed, select is processed by optimizer; update, inserts, deletes, and table creation statements; schema Creation statements are processed by the table modification module; Other statements include the table maintenance module, replication module.
Then, by maintaining the access control module of the table list, go to Table manager, open the table and obtain the corresponding lock, and then call the corresponding engine to implement the query statement.
The specified acted storage engine module automatically converts the query method to the corresponding engine for processing.
When a query statement is executed, the corresponding module returns some result sets to the client.
Mysql does not use exceptions, so the error detection statement must be used at any layer.
After a task is completed, it will return to the connection module to wait for the new task.
Slave may also read binary update files, which will be the responsibility of the master node.
If a machine is defined as slave, two threads, one is SQL thread and the other is I/o thread, will be started.
The network connection is implemented through the Client/server protocol module. The Core functions of mysql are implemented by Core APIs.