main |-mysqld |-my_init // 初始話線程變量,互斥量 |-load_defaults // 獲取配置 |-init_common_variables // 初始化變量 |-init_server_components // 初始化插件 | |-plugin_init | | |-plugin_initialize | |-initialize_storage_engine |-network_init // 監聽網絡 |-grant_init |-servers_init |-udf_init
插件啟動:
main |-mysqld_main |-init_server_components |-plugin_init |-plugin_initialize |-ha_initialize_handlerton |-innobase_init
登錄過程:
main |-mysqld_main |-network_init // 建立socket監聽,一個針對網絡,一個針對unix域 |-handle_connections_sockets |-poll |-mysql_socket_accept // 和客戶端建立連接 |-create_new_thread // 針對每個socket連接建立一個新的線程 |-create_thread_to_handle_connection |-waiting_thd_list->push_back(thd);mysql_cond_signal(&COND_thread_cache); // 已有連接處理線程時,通過信號喚醒,處理線程函數為pfs_spawn_thread |-mysql_thread_create(啟動的線程執行函數,inline_mysql_thread_create) |-spawn_thread_v1 |-pthread_create(pfs_spawn_thread)
處理連接:
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 // 判斷是否可以login,不可以則斷開連接返回錯誤 | | |-check_connection | | | |-acl_authenticate | | | |-do_auth_once | | | |-native_password_authenticate | | | |-server_mpvio_write_packet | | | | |-send_server_handshake_packet // 發送handshake包到客戶端 | | | | |-my_net_write | | | | | |-net_write_buff // 將數據寫入到內存 | | | | |-net_flush // 將內存中數據發送到網絡 | | | |-server_mpvio_read_packet // 從客戶端接收Login Request信息 | | | |-my_net_read | | |-Protocol::end_statement | | |-Protocol::send_ok | | |-net_send_ok // 發送response ok | | |-my_net_write | |-prepare_new_connection_state |-do_command |-dispatch_command |-mysql_parse
select命令:
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 // 申請表數據結構 | | |-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 // 打開表空間文件 | |-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 |
免責聲明:本站部分文章和圖片均來自用戶投稿和網絡收集,旨在傳播知識,文章和圖片版權歸原作者及原出處所有,僅供學習與參考,請勿用于商業用途,如果損害了您的權利,請聯系我們及時修正或刪除。謝謝!
始終以前瞻性的眼光聚焦站長、創業、互聯網等領域,為您提供最新最全的互聯網資訊,幫助站長轉型升級,為互聯網創業者提供更加優質的創業信息和品牌營銷服務,與站長一起進步!讓互聯網創業者不再孤獨!
掃一掃,關注站長網微信