Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL connection query process source code

Shulou Source: shulou.com Published: 2022-06-01 05:50:42 11月15日 Update

Source: Internet

Version: unknown, for reference only

Initialize:

Click (here) to collapse or open

Main

| |-mysqld |

| |-my_init / / initial thread variables, mutexes |

| |-load_defaults / / get the configuration |

| |-init_common_variables / / initialize variables |

| |-init_server_components / / initialize plug-in |

| |-plugin_init |

| | |-plugin_initialize |

| |-initialize_storage_engine |

| |-network_init / / listen to the network |

| |-grant_init |

| |-servers_init |

| |-udf_init |

Plug-in launch:

Click (here) to collapse or open

Main

| |-mysqld_main |

| |-init_server_components |

| |-plugin_init |

| |-plugin_initialize |

| |-ha_initialize_handlerton |

| |-innobase_init |

Login process:

Click (here) to collapse or open

Main

| |-mysqld_main |

| |-network_init / / establish socket snooping, one for network and one for Unix domain |

| |-handle_connections_sockets |

| |-poll |

| |-mysql_socket_accept / / establish a connection with the client |

| |-create_new_thread / / create a new thread for each socket connection |

| |-create_thread_to_handle_connection |

| |-waiting_thd_list- > push_back (thd); mysql_cond_signal (& COND_thread_cache); / / Wake up by signal when there is a connection processing thread, and the processing thread function is pfs_spawn_thread |

| |-mysql_thread_create (started thread executes function, inline_mysql_thread_create) |

| |-spawn_thread_v1 |

| |-pthread_create (pfs_spawn_thread) |

Working with connections:

Click (here) to collapse or open

Pfs_spawn_thread

| |-handle_one_connection |

| |-do_handle_one_connection |

|-MYSQL_CALLBACK_ELSE (thread_scheduler, init_new_connection_thread, (), 0)

| |-init_new_connection_handler_thread |

| |-thd_prepare_connection |

|-login_connection / / determines whether login is allowed. If not, an error is returned when disconnecting. |

| | |-check_connection |

| |-acl_authenticate |

| |-do_auth_once |

| |-native_password_authenticate |

| |-server_mpvio_write_packet |

| |-send_server_handshake_packet / / send a handshake packet to the client |

| |-my_net_write |

| |-net_write_buff / / write data to memory |

| |-net_flush / / send in-memory data to the network |

| |-server_mpvio_read_packet / / receives Login Request information from the client |

| |-my_net_read |

| | |-Protocol::end_statement |

| | |-Protocol::send_ok |

| | |-net_send_ok / / send response ok |

| | |-my_net_write |

| |-prepare_new_connection_state |

| |-do_command |

| |-dispatch_command |

| |-mysql_parse |

Select command:

Click (here) to collapse or open

Pfs_swpawn_thread

| |-handle_one_connection |

| |-do_handle_one_connection |

| |-do_command |

| |-dispatch_command |

| |-mysql_parse |

| |-parse_sql |

| |-MYSQLparse |

| |-mysql_execute_command |

| |-select_precheck |

| |-check_table_access |

| |-execute_sqlcom_select |

| |-open_normal_and_derived_tables |

| |-open_tables |

| | |-open_and_process_table |

| | |-open_table (THD * thd, TABLE_LIST * table_list, Open_table_context * ot_ctx) |

| | |-Table_cache::get_table |

| | |-get_table_share_with_discover |

| |-get_table_share |

| |-open_table_def |

| | |-my_malloc / / data structure of the application form |

| | |-open_table_from_share |

| | |-handler::ha_open |

| | |-ha_innobase::open |

| | |-dict_table_open_on_name |

| | |-dict_load_table |

| | |-btr_pcur_is_on_user_rec |

| | |-dict_load_table_low |

| |-dict_mem_table_create |

| | |-fil_space_for_table_exists_in_mem |

| | |-fil_open_single_table_tablespace / / Open tablespace file |

| |-mysql_handle_derived |

| |-handle_select |

| |-mysql_select |

| |-mysql_prepare_select |

| |-JOIN::prepare |

| |-mysql_execute_select |

| |-JOIN::exec |

| |-select_send::send_result_set_metadata |

| |-Protocol::send_result_set_metadata |

| |-do_select |

| |-sub_select |

| |-evaluate_join_record |

| |-end_send |

| |-select_send::send_data |

| |-Protocol::write |

Tags: Thread client client data network processing memory function variable plug-in monitor Internet signal information command data structure file source version application form Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Xiaomi Huawei MySQL