当前位置:网站首页>Analysis on the specific execution process of an insert statement in MySQL 8.0 (3)
Analysis on the specific execution process of an insert statement in MySQL 8.0 (3)
2022-06-29 10:27:00 【A ray of sunshine a】
Code version :mysql 8.0.22
programing language :c++ && c++11 && c++14 && c++17
Last article :mysql 8.0 One insert Analysis of the specific execution process of the statement ( Two )_ A ray of sunshine blog -CSDN Blog
It mainly introduces the storage engine , This chapter mainly introduces insert Which interfaces need to be called when a statement has a secondary index , The order of calling interfaces is as follows :
The following interfaces can be understood basically from the source code , Don't repeat .
Let's take clustered indexes and secondary indexes as examples , Clustered index The calling interface is as follows :
| > row_ins_clust_index_entry
| | > row_ins_clust_index_entry_low
| | | > btr_cur_optimistic_insert
| | | | > btr_cur_ins_lock_and_undo
| | | | | > trx_undo_report_row_operation
| | | | | | > trx_undo_page_report_insert
| | | | | | | > trx_undo_page_set_next_prev_and_add
| | | | | | | | > trx_undof_page_add_undo_rec_log
| | | | > page_cur_tuple_insert
| | | | | > rec_convert_dtuple_to_rec
> rec_convert_dtuple_to_rec_new
> rec_convert_dtuple_to_rec_old
> rec_convert_dtuple_to_rec_comp
| | | | | > page_cur_insert_rec_low
> page_cur_insert_rec_write_log(12)、row_ins_clust_index_entry : Insert entry To a clustered index , Would call 13 The interface
(13)、row_ins_clust_index_entry_low : Try to entry Insert into clustered index , Ignore foreign key constraints .
(14)、btr_cur_optimistic_insert : Insert a page To an index tree
(15)、btr_cur_ins_lock_and_undo : Check lock And write undo log
(16)、page_cur_tuple_insert : Take one record Append to current page, Need and 17 The function in completes
(17)、page_cur_insert_rec_low : Take one record Append to current page, Write uncompressed
Secondary indexes The calling interface is as follows :
| > row_ins_sec_index_entry
| | > row_ins_sec_index_entry_low
| | | > btr_cur_search_to_nth_level
> ibuf_should_try
| | | > row_ins_scan_sec_index_for_duplicate(18)、row_ins_sec_index_entry : Insert... In the secondary index entry
(19)、row_ins_sec_index_entry_low : Try to entry Insert secondary index . If you find a record with exactly the same field , The other record must be marked as deleted , Then insert it into the secondary index
(20)、btr_cur_search_to_nth_level : In the index tree Given in level Find the current location on
(21)、row_ins_scan_sec_index_for_duplicate : Scans for unique nonclustered indexes at a given index entry , To determine whether the key value of the item has a uniqueness conflict . Set the shared lock for possible duplicate records
Last , After all breakpoints have been executed , Use bt The command prints the stack information , Because there are too many breakpoints , Some of the main functions are printed , as follows :
(gdb) bt
#0 btr_cur_optimistic_insert (flags=0, cursor=0x7fffe83d4ae0, offsets=0x7fffe83d4a78,
heap=0x7fffe83d4a70, entry=0x7fff300cb370, rec=0x7fffe83d4a80, big_rec=0x7fffe83d4a68,
thr=0x7fff3029c6f8, mtr=0x7fffe83d50a0)
at /storage/innobase/btr/btr0cur.cc:2833
#1 0x000055555a4c7571 in row_ins_clust_index_entry_low (flags=0, mode=2, index=0x7fff3028a640,
n_uniq=1, entry=0x7fff300cb370, thr=0x7fff3029c6f8, dup_chk_only=false)
at storage/innobase/row/row0ins.cc:2518
#2 0x000055555a4c945c in row_ins_clust_index_entry (index=0x7fff3028a640, entry=0x7fff300cb370,
thr=0x7fff3029c6f8, dup_chk_only=false)
at /storage/innobase/row/row0ins.cc:3097
#3 0x000055555a4c9c14 in row_ins_index_entry (index=0x7fff3028a640, entry=0x7fff300cb370,
[email protected]: 0, thr=0x7fff3029c6f8)
at /storage/innobase/row/row0ins.cc:3289
#4 0x000055555a4ca26f in row_ins_index_entry_step (node=0x7fff3029c338, thr=0x7fff3029c6f8)
at /storage/innobase/row/row0ins.cc:3425
#5 0x000055555a4ca616 in row_ins (node=0x7fff3029c338, thr=0x7fff3029c6f8)
at /storage/innobase/row/row0ins.cc:3544
#6 0x000055555a4caa92 in row_ins_step (thr=0x7fff3029c6f8)
at /storage/innobase/row/row0ins.cc:3668
#7 0x000055555a4ea804 in row_insert_for_mysql_using_ins_graph (mysql_rec=0x7fff302892c8 "\376\005",
prebuilt=0x7fff3029b830) at /storage/innobase/row/row0mysql.cc:1581
#8 0x000055555a4eae9a in row_insert_for_mysql (mysql_rec=0x7fff302892c8 "\376\005",
prebuilt=0x7fff3029b830) at /storage/innobase/row/row0mysql.cc:1711
#9 0x000055555a2a9ad9 in ha_innobase::write_row (this=0x7fff30287bf8, record=0x7fff302892c8 "\376\005")
at /storage/innobase/handler/ha_innodb.cc:8629
#10 0x0000555558d4ace2 in handler::ha_write_row (this=0x7fff30287bf8, buf=0x7fff302892c8 "\376\005")
at /sql/handler.cc:7831
#11 0x00005555590a14a7 in write_record (thd=0x7fff30001040, table=0x7fff30287270, info=0x7fffe83d64f0,
update=0x7fffe83d6570) at /sql/sql_insert.cc:2148
#12 0x000055555909cb7e in Sql_cmd_insert_values::execute_inner (this=0x7fff302becc8, thd=0x7fff30001040)
at /sql/sql_insert.cc:633
#13 0x00005555589ff8fc in Sql_cmd_dml::execute (this=0x7fff302becc8, thd=0x7fff30001040)
at /sql/sql_select.cc:612
#14 0x000055555897bd6e in mysql_execute_command (thd=0x7fff30001040, first_level=true)
at /sql/sql_parse.cc:3420
#15 0x00005555589810b9 in dispatch_sql_command (thd=0x7fff30001040, parser_state=0x7fffe83d7b90)
at /sql/sql_parse.cc:4988
#16 0x0000555558977226 in dispatch_command (thd=0x7fff30001040, com_data=0x7fffe83d8b80,
command=COM_QUERY) at /sql/sql_parse.cc:1836
#17 0x00005555589756df in do_command (thd=0x7fff30001040)
at /sql/sql_parse.cc:1320
#18 0x0000555558b6ee3d in handle_connection (arg=0x55556006bbe0)
at /sql/conn_handler/connection_handler_per_thread.cc:301
#19 0x000055555aa337b6 in pfs_spawn_thread (arg=0x55555fee7ae0)
at /storage/perfschema/pfs.cc:2900
--Type <RET> for more, q to quit, c to continue without paging--
#20 0x00007ffff7f95609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007ffff76e0293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95Only this and nothing more , stay MySQL in insert One record The basic process of has been sorted out , The process is quite clear , Those who have primary database experience can sort it out .
The next few articles are mainly about MySQL in redo.log Medium mtr.
边栏推荐
- 同花顺炒股软件可靠吗,安全吗?
- September 21, 2020 referer string segmentation boost gateway code organization level
- qgis制图
- Basic operations during dev use
- To 3 -- the last programming challenge
- std::make_shared<T>/std::make_unique<T>与std::shared_ptr<T>/std::unique_ptr<T>的区别与联系
- 2019.10.30 learning summary
- 2019.10.27 training summary
- 蛇形填数
- Codeforces - 1151b thinking
猜你喜欢

1146 topological order (25 points)

Dev使用过程中的基本操作

这个开源项目超哇塞,手写照片在线生成

HDU 6778 car (group enumeration -- > shape pressure DP)

Codeforces Round #645 (Div. 2)

Using rancher to build kubernetes cluster

C#窗体向另一个窗体实时传值

Simulation problem of two stacks

Text of the basic component of the shutter

Rikka with cake (segment tree + segment tree)
随机推荐
Signal works: time varying and time invariant
JNI. H description
Use of Azkaban in task scheduler
Function pointer, function pointer array, calculator + transfer table, etc
蛇形填数
JNI.h说明
Nacos environmental isolation
任务调度器之Azkaban的使用
2021年团体程序设计天梯赛-模拟赛
1099 Build A Binary Search Tree (30 分)
std::unique_ptr<T>与boost::scoped_ptr<T>的特殊性
2020-09-21 visual studio header file and Library Directory configuration
Virtual machine port scanning
Shanke's C language 2018 exercise (Telecom)
Codeforces Round #657 Div. 2
2020-9-14 introduction to advertising system
To 3 --- 最后的编程挑战
六度空间 bfs
Analyze in detail the PBOT mining virus family behavior and the principle of exploited vulnerabilities, and provide detailed protection suggestions for the blue army
IIS server related error