Debian Codegraph @

storage/innobase/row/row0purge.cc

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2017, 2023, MariaDB Corporation.
5
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17
18 *****************************************************************************/
19
20 /**************************************************//**
21 @file row/row0purge.cc
22 Purge obsolete records
23
24 Created 3/14/1997 Heikki Tuuri
25 *******************************************************/
26
27 #include "row0purge.h"cxx . . $ `<file>/storage/innobase/include/row0purge.h`/
28 #include "btr0cur.h"cxx . . $ `<file>/storage/innobase/include/btr0cur.h`/
29 #include "fsp0fsp.h"cxx . . $ `<file>/storage/innobase/include/fsp0fsp.h`/
30 #include "mach0data.h"cxx . . $ `<file>/storage/innobase/include/mach0data.h`/
31 #include "dict0crea.h"cxx . . $ `<file>/storage/innobase/include/dict0crea.h`/
32 #include "dict0stats.h"cxx . . $ `<file>/storage/innobase/include/dict0stats.h`/
33 #include "trx0rseg.h"cxx . . $ `<file>/storage/innobase/include/trx0rseg.h`/
34 #include "trx0trx.h"cxx . . $ `<file>/storage/innobase/include/trx0trx.h`/
35 #include "trx0roll.h"cxx . . $ `<file>/storage/innobase/include/trx0roll.h`/
36 #include "trx0undo.h"cxx . . $ `<file>/storage/innobase/include/trx0undo.h`/
37 #include "trx0purge.h"cxx . . $ `<file>/storage/innobase/include/trx0purge.h`/
38 #include "trx0rec.h"cxx . . $ `<file>/storage/innobase/include/trx0rec.h`/
39 #include "que0que.h"cxx . . $ `<file>/storage/innobase/include/que0que.h`/
40 #include "row0row.h"cxx . . $ `<file>/storage/innobase/include/row0row.h`/
41 #include "row0upd.h"cxx . . $ `<file>/storage/innobase/include/row0upd.h`/
42 #include "row0vers.h"cxx . . $ `<file>/storage/innobase/include/row0vers.h`/
43 #include "row0mysql.h"cxx . . $ `<file>/storage/innobase/include/row0mysql.h`/
44 #include "log0log.h"cxx . . $ `<file>/storage/innobase/include/log0log.h`/
45 #include "srv0mon.h"cxx . . $ `<file>/storage/innobase/include/srv0mon.h`/
46 #include "srv0start.h"cxx . . $ `<file>/storage/innobase/include/srv0start.h`/
47 #include "handler.h"cxx . . $ `<file>/sql/handler.h`/
48 #include "ha_innodb.h"cxx . . $ `<file>/storage/innobase/handler/ha_innodb.h`/
49 #include "fil0fil.h"cxx . . $ `<file>/storage/innobase/include/fil0fil.h`/
50 #include "debug_sync.h"cxx . . $ `<file>/sql/debug_sync.h`/
51 #include <mysql/service_thd_mdl.h>cxx . . $ `<file>/include/mysql/service_thd_mdl.h`/
52
53 void reset_thdcxx . . $ reset_thd(4b9aaf75000f3009).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd);
54 /*************************************************************************
55 IMPORTANT NOTE: Any operation that generates redo MUST check that there
56 is enough space in the redo log before for that operation. This is
57 done by calling log_free_check(). The reason for checking the
58 availability of the redo log space before the start of the operation is
59 that we MUST not hold any synchonization objects when performing the
60 check.
61 If you make a change in this module make sure that no codepath is
62 introduced where a call to log_free_check() is bypassed. */
63
64 /***********************************************************//**
65 Repositions the pcur in the purge node on the clustered index record,
66 if found. If the record is not found, close pcur.
67 @return TRUE if the record was found */
68 static
69 iboolcxx . . $ `storage/innobase/include/univ.i:355:9`!
70 row_purge_reposition_pcurcxx . . $ row_purge_reposition_pcur(b51d4f745d9b9456).(
71 /*======================*/
72 btr_latch_modecxx . . $ btr_latch_mode# mode, /*!< in: latching mode */
73 purge_node_tcxx . . $ purge_node_t#* node, /*!< in: row purge node */
74 mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */
75 {
76 if (node->found_clustcxx . . $ purge_node_t#found_clust.) {
77 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(node->validate_pcur());
78
79 node->found_clustcxx . . $ purge_node_t#found_clust. =
80 node->pcurcxx . . $ purge_node_t#pcur..restore_positioncxx . . $ btr_pcur_t#restore_position(8c85f028503b2912).(mode, mtr) ==
81 btr_pcur_tcxx . . $ btr_pcur_t#::SAME_ALLcxx . . $ btr_pcur_t#SAME_ALL.;
82
83 } else {
84 node->found_clustcxx . . $ purge_node_t#found_clust. = row_search_on_row_refcxx . . $ row_search_on_row_ref(375584ed178677b9).(
85 &node->pcurcxx . . $ purge_node_t#pcur., mode, node->ptcxx . . $ purge_node_t#pt..tablecxx . . $ purge_table#table., node->refcxx . . $ purge_node_t#ref., mtr);
86
87 if (node->found_clustcxx . . $ purge_node_t#found_clust.) {
88 btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(&node->pcurcxx . . $ purge_node_t#pcur., mtr);
89 }
90 }
91
92 /* Close the current cursor if we fail to position it correctly. */
93 if (!node->found_clustcxx . . $ purge_node_t#found_clust.) {
94 btr_pcur_closecxx . . $ btr_pcur_close(57c44ef9c177cfb0).(&node->pcurcxx . . $ purge_node_t#pcur.);
95 }
96
97 return(node->found_clustcxx . . $ purge_node_t#found_clust.);
98 }
99
100 /***********************************************************//**
101 Removes a delete marked clustered index record if possible.
102 @retval true if the row was not found, or it was successfully removed
103 @retval false if the row was modified after the delete marking */
104 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
105 bool
106 row_purge_remove_clust_if_poss_lowcxx . . $ row_purge_remove_clust_if_poss_low(b60fc2a5054767c).(
107 /*===============================*/
108 purge_node_tcxx . . $ purge_node_t#* node, /*!< in/out: row purge node */
109 btr_latch_modecxx . . $ btr_latch_mode# mode) /*!< in: BTR_MODIFY_LEAF or BTR_PURGE_TREE */
110 {
111 dict_index_tcxx . . $ dict_index_t#* index = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(node->pt.table);
112 table_id_tcxx . . $ table_id_t# table_id = 0;
113 index_id_tcxx . . $ index_id_t# index_id = 0;
114 dict_table_tcxx . . $ dict_table_t# *table = nullptr;
115 pfs_os_file_tcxx . . $ pfs_os_file_t# f = OS_FILE_CLOSEDcxx . . $ pfs_os_file_t#pfs_os_file_t(d4f767463ce0a6b3).;
116
117 if (table_id) {
118 retry:
119 dict_syscxx . . $ dict_sys..lockcxx . . $ dict_sys_t#lock(9bb8261ff8654062).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
120 table = dict_syscxx . . $ dict_sys..find_tablecxx . . $ dict_sys_t#find_table(b1a5e428135389cd).(table_id);
121 if (!table) {
122 dict_syscxx . . $ dict_sys..unlockcxx . . $ dict_sys_t#unlock(ced63f7c635d850d).();
123 } else if (table->n_rec_lockscxx . . $ dict_table_t#n_rec_locks.) {
124 for (dict_index_tcxx . . $ dict_index_t#* ind = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(
125 table->indexes); ind;
126 ind = UT_LIST_GET_NEXTcxx . . $ `storage/innobase/include/ut0lst.h:401:9`!(indexes, ind)) {
127 if (ind->idcxx . . $ dict_index_t#id. == index_id) {
128 lock_discard_for_indexcxx . . $ lock_discard_for_index(2d597176275c4795).(*ind);
129 }
130 }
131 }
132 }
133 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{node->trxcxx . . $ purge_node_t#trx.};
134 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
135 index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr);
136 log_free_checkcxx . . $ log_free_check(ced63f7c635d850d).();
137 bool success = true;
138
139 if (!row_purge_reposition_pcurcxx . . $ row_purge_reposition_pcur(b51d4f745d9b9456).(mode, node, &mtr)) {
140 /* The record was already removed. */
141 removed:
142 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
143 close_and_exit:
144 if (table) {
145 dict_syscxx . . $ dict_sys..unlockcxx . . $ dict_sys_t#unlock(ced63f7c635d850d).();
146 }
147 return success;
148 }
149
150 if (node->ptcxx . . $ purge_node_t#pt..tablecxx . . $ purge_table#table.->idcxx . . $ dict_table_t#id. == DICT_INDEXES_IDcxx . . $ `storage/innobase/include/dict0boot.h:77:9`!) {
151 /* If this is a record of the SYS_INDEXES table, then
152 we have to free the file segments of the index tree
153 associated with the index */
154 if (!table_id) {
155 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&node->pcurcxx . . $ purge_node_t#pcur.);
156
157 table_id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(rec);
158 index_id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(rec + 8);
159 if (table_id) {
160 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
161 goto retry;
162 }
163 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corrupted SYS_INDEXES record" == 0);
164 }
165
166 const uint32_tcxx . . $ uint32_t# space_id = dict_drop_index_treecxx . . $ dict_drop_index_tree(853be89b3dedbb79).(
167 &node->pcurcxx . . $ purge_node_t#pcur., nullptr, &mtr);
168 if (space_id) {
169 if (table) {
170 if (table->get_ref_countcxx . . $ dict_table_t#get_ref_count(ddd8539a2fcdd4ce).() == 0) {
171 dict_syscxx . . $ dict_sys..removecxx . . $ dict_sys_t#remove(bc56845296a133e5).(table);
172 } else if (table->space_idcxx . . $ dict_table_t#space_id. == space_id) {
173 table->spacecxx . . $ dict_table_t#space. = nullptr;
174 table->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true;
175 }
176 dict_syscxx . . $ dict_sys..unlockcxx . . $ dict_sys_t#unlock(ced63f7c635d850d).();
177 table = nullptr;
178 }
179 f =cxx . . $ pfs_os_file_t#`operator=`(a945d8173081eda2). fil_delete_tablespacecxx . . $ fil_delete_tablespace(2cb9640f29b6b4ff).(space_id);
180 }
181
182 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
183
184 if (table) {
185 dict_syscxx . . $ dict_sys..unlockcxx . . $ dict_sys_t#unlock(ced63f7c635d850d).();
186 table = nullptr;
187 }
188
189 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
190 index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr);
191
192 if (!row_purge_reposition_pcurcxx . . $ row_purge_reposition_pcur(b51d4f745d9b9456).(mode, node, &mtr)) {
193 goto removed;
194 }
195 }
196
197 rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&node->pcurcxx . . $ purge_node_t#pcur.);
198 rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.];
199 rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_);
200 mem_heap_tcxx . . $ mem_heap_t#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
201 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, index, offsets_,
202 index->n_core_fields,
203 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
204
205 if (node->roll_ptrcxx . . $ purge_node_t#roll_ptr. != row_get_rec_roll_ptrcxx . . $ row_get_rec_roll_ptr(e491d669e75572c9).(rec, index, offsets)) {
206 /* Someone else has modified the record later: do not remove */
207 goto func_exit;
208 }
209
210 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
211 /* In delete-marked records, DB_TRX_ID must
212 always refer to an existing undo log record. */
213 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(row_get_rec_trx_id(rec, index, offsets));
214
215 #ifdef ENABLED_DEBUG_SYNC
216 DBUG_EXECUTE_IF("enable_row_purge_remove_clust_if_poss_low_sync_point",
217 debug_sync_set_action
218 (current_thd,
219 STRING_WITH_LEN(
220 "now SIGNAL "
221 "row_purge_remove_clust_if_poss_low_before_delete "
222 "WAIT_FOR "
223 "row_purge_remove_clust_if_poss_low_cont"));
224 );
225 #endif
226 if (mode == BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.) {
227 success = DB_FAILcxx . . $ DB_FAIL. != btr_cur_optimistic_deletecxx . . $ btr_cur_optimistic_delete(5923638ae82be759).(
228 btr_pcur_get_btr_curcxx . . $ `storage/innobase/include/btr0pcur.h:214:9`!(&node->pcur), 0, &mtr);
229 } else {
230 dberr_tcxx . . $ dberr_t# err;
231 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mode == BTR_PURGE_TREE);
232 btr_cur_pessimistic_deletecxx . . $ btr_cur_pessimistic_delete(8e234601f90ce98f).(
233 &err, FALSEcxx . . $ `include/my_global.h:477:9`!, btr_pcur_get_btr_curcxx . . $ `storage/innobase/include/btr0pcur.h:214:9`!(&node->pcur), 0,
234 false, &mtr);
235 success = err == DB_SUCCESScxx . . $ DB_SUCCESS.;
236 }
237
238 func_exit:
239 if (heap) {
240 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
241 }
242
243 /* Persistent cursor is closed if reposition fails. */
244 if (node->found_clustcxx . . $ purge_node_t#found_clust.) {
245 btr_pcur_commit_specify_mtrcxx . . $ btr_pcur_commit_specify_mtr(f723d369374bc0bf).(&node->pcurcxx . . $ purge_node_t#pcur., &mtr);
246 } else {
247 mtr_commitcxx . . $ `storage/innobase/include/mtr0mtr.h:38:9`!(&mtr);
248 }
249
250 goto close_and_exit;
251 }
252
253 /***********************************************************//**
254 Removes a clustered index record if it has not been modified after the delete
255 marking.
256 @retval true if the row was not found, or it was successfully removed
257 @retval false the purge needs to be suspended because of running out
258 of file space. */
259 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
260 bool
261 row_purge_remove_clust_if_posscxx . . $ row_purge_remove_clust_if_poss(46ae5329a1dcb504).(
262 /*===========================*/
263 purge_node_tcxx . . $ purge_node_t#* node) /*!< in/out: row purge node */
264 {
265 if (row_purge_remove_clust_if_poss_lowcxx . . $ row_purge_remove_clust_if_poss_low(b60fc2a5054767c).(node, BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.)) {
266 return(true);
267 }
268
269 for (ulintcxx . . $ ulint# n_tries = 0;
270 n_tries < BTR_CUR_RETRY_DELETE_N_TIMEScxx . . $ `storage/innobase/include/btr0cur.h:780:9`!;
271 n_tries++) {
272 if (row_purge_remove_clust_if_poss_lowcxx . . $ row_purge_remove_clust_if_poss_low(b60fc2a5054767c).(node, BTR_PURGE_TREEcxx . . $ BTR_PURGE_TREE.)) {
273 return(true);
274 }
275
276 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(BTR_CUR_RETRY_SLEEP_TIMEcxx . . $ BTR_CUR_RETRY_SLEEP_TIME.);
277 }
278
279 return(false);
280 }
281
282 /** Check a virtual column value index secondary virtual index matches
283 that of current cluster index record, which is recreated from information
284 stored in undo log
285 @param[in] rec record in the clustered index
286 @param[in] icentry the index entry built from a cluster row
287 @param[in] clust_index cluster index
288 @param[in] clust_offsets offsets on the cluster record
289 @param[in] index the secondary index
290 @param[in] ientry the secondary index entry
291 @param[in] node purge node
292 @param[in,out] mtr mini-transaction
293 @param[in,out] v_row dtuple holding the virtual rows (if needed)
294 @return true if matches, false otherwise */
295 static
296 bool
297 row_purge_vc_matches_clustercxx . . $ row_purge_vc_matches_cluster(5d8cf1f6a5c1a9bc).(
298 const rec_tcxx . . $ rec_t#* rec,
299 const dtuple_tcxx . . $ dtuple_t#* icentry,
300 dict_index_tcxx . . $ dict_index_t#* clust_index,
301 rec_offscxx . . $ rec_offs#* clust_offsets,
302 dict_index_tcxx . . $ dict_index_t#* index,
303 const dtuple_tcxx . . $ dtuple_t#* ientry,
304 const purge_node_tcxx . . $ purge_node_t#&node,
305 mtr_tcxx . . $ mtr_t#* mtr,
306 dtuple_tcxx . . $ dtuple_t#** vrow)
307 {
308 const rec_tcxx . . $ rec_t#* version;
309 rec_tcxx . . $ rec_t#* prev_version;
310 mem_heap_tcxx . . $ mem_heap_t#* heap2;
311 mem_heap_tcxx . . $ mem_heap_t#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
312 mem_heap_tcxx . . $ mem_heap_t#* tuple_heap;
313 ulintcxx . . $ ulint# num_v = dict_table_get_n_v_colscxx . . $ dict_table_get_n_v_cols(30e33a5fb3242ebb).(index->tablecxx . . $ dict_index_t#table.);
314 bool compare[REC_MAX_N_FIELDScxx . . $ `storage/innobase/include/rem0types.h:37:9`!];
315 ulintcxx . . $ ulint# n_fields = dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(ientry);
316 ulintcxx . . $ ulint# n_non_v_col = 0;
317 ulintcxx . . $ ulint# n_cmp_v_col = 0;
318 const dfield_tcxx . . $ dfield_t#* field1;
319 dfield_tcxx . . $ dfield_t#* field2;
320 ulintcxx . . $ ulint# i;
321
322 /* First compare non-virtual columns (primary keys) */
323 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->n_fields == n_fields);
324 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields == dtuple_get_n_fields(icentry));
325 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_page_flagged(rec,
326 MTR_MEMO_PAGE_S_FIX
327 | MTR_MEMO_PAGE_X_FIX));
328
329 {
330 const dfield_tcxx . . $ dfield_t#* a = ientry->fieldscxx . . $ dtuple_t#fields.;
331 const dfield_tcxx . . $ dfield_t#* b = icentry->fieldscxx . . $ dtuple_t#fields.;
332
333 for (const dict_field_tcxx . . $ dict_field_t# *ifield = index->fieldscxx . . $ dict_index_t#fields.,
334 *const end = &index->fieldscxx . . $ dict_index_t#fields.[index->n_fieldscxx . . $ dict_index_t#n_fields.];
335 ifield != end; ifield++, a++, b++) {
336 if (!ifield->colcxx . . $ dict_field_t#col.->is_virtualcxx . . $ dict_col_t#is_virtual(50ce9a9e25b4a850).()) {
337 if (cmp_dfield_dfieldcxx . . $ cmp_dfield_dfield(9d216ee2a4deec1f).(a, b)) {
338 return false;
339 }
340 n_non_v_col++;
341 }
342 }
343 }
344
345 tuple_heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
346
347 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields > n_non_v_col);
348
349 *vrow = dtuple_create_with_vcolcxx . . $ dtuple_create_with_vcol(450a09b424f51781).(tuple_heap, 0, num_v);
350 dtuple_init_v_fldcxx . . $ dtuple_init_v_fld(984aa751a02e0831).(*vrow);
351
352 for (i = 0; i < num_v; i++) {
353 dfield_get_typecxx . . $ dfield_get_type(c1d58f3834c4404a).(dtuple_get_nth_v_fieldcxx . . $ dtuple_get_nth_v_field(71af1a8d94eba0f9).(*vrow, i))->mtypecxx . . $ dtype_t#mtype.
354 = DATA_MISSINGcxx . . $ `storage/innobase/include/data0type.h:49:9`!;
355 compare[i] = false;
356 }
357
358 version = rec;
359
360 while (n_cmp_v_col < n_fields - n_non_v_col) {
361 heap2 = heap;
362 heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
363 roll_ptr_tcxx . . $ roll_ptr_t# cur_roll_ptr = row_get_rec_roll_ptrcxx . . $ row_get_rec_roll_ptr(e491d669e75572c9).(
364 version, clust_index, clust_offsets);
365
366 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cur_roll_ptr != 0);
367 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(node.roll_ptr != 0);
368
369 trx_undo_prev_version_buildcxx . . $ trx_undo_prev_version_build(a23d9403dd7b3c31).(
370 version, clust_index, clust_offsets,
371 heap, &prev_version, mtr,
372 TRX_UNDO_PREV_IN_PURGEcxx . . $ TRX_UNDO_PREV_IN_PURGE. | TRX_UNDO_GET_OLD_V_VALUEcxx . . $ TRX_UNDO_GET_OLD_V_VALUE.,
373 nullptr, vrow);
374
375 if (heap2) {
376 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap2);
377 }
378
379 if (!prev_version) {
380 /* Versions end here */
381 goto func_exit;
382 }
383
384 clust_offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(prev_version, clust_index,
385 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
386 clust_index->n_core_fields,
387 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
388
389 ulintcxx . . $ ulint# entry_len = dict_index_get_n_fieldscxx . . $ dict_index_get_n_fields(40995254b96f8651).(index);
390
391 for (i = 0; i < entry_len; i++) {
392 const dict_field_tcxx . . $ dict_field_t#* ind_field
393 = dict_index_get_nth_fieldcxx . . $ `storage/innobase/include/dict0dict.h:978:10`!(index, i);
394 const dict_col_tcxx . . $ dict_col_t#* col = ind_field->colcxx . . $ dict_field_t#col.;
395 field1 = dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(128e8215f1708476).(ientry, i);
396
397 if (!col->is_virtualcxx . . $ dict_col_t#is_virtual(50ce9a9e25b4a850).()) {
398 continue;
399 }
400
401 const dict_v_col_tcxx . . $ dict_v_col_t#* v_col
402 = reinterpret_cast<const dict_v_col_tcxx . . $ dict_v_col_t#*>(col);
403 field2
404 = dtuple_get_nth_v_fieldcxx . . $ dtuple_get_nth_v_field(71af1a8d94eba0f9).(*vrow, v_col->v_poscxx . . $ dict_v_col_t#v_pos.);
405
406 if ((dfield_get_typecxx . . $ dfield_get_type(c1d58f3834c4404a).(field2)->mtypecxx . . $ dtype_t#mtype. != DATA_MISSINGcxx . . $ `storage/innobase/include/data0type.h:49:9`!)
407 && (!compare[v_col->v_poscxx . . $ dict_v_col_t#v_pos.])) {
408
409 if (ind_field->prefix_lencxx . . $ dict_field_t#prefix_len. != 0
410 && !dfield_is_nullcxx . . $ dfield_is_null(421b5b1f6d6093e7).(field2)) {
411 field2->lencxx . . $ dfield_t#len. = unsigned(
412 dtype_get_at_most_n_mbcharscxx . . $ dtype_get_at_most_n_mbchars(5f195766ff7d60bc).(
413 field2->typecxx . . $ dfield_t#type..prtypecxx . . $ dtype_t#prtype.,
414 field2->typecxx . . $ dfield_t#type..mbminlencxx . . $ dtype_t#mbminlen.,
415 field2->typecxx . . $ dfield_t#type..mbmaxlencxx . . $ dtype_t#mbmaxlen.,
416 ind_field->prefix_lencxx . . $ dict_field_t#prefix_len.,
417 field2->lencxx . . $ dfield_t#len.,
418 static_cast<char*>
419 (field2->datacxx . . $ dfield_t#data.)));
420 }
421
422 /* The index field mismatch */
423 if (cmp_dfield_dfieldcxx . . $ cmp_dfield_dfield(9d216ee2a4deec1f).(field2, field1)) {
424 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(tuple_heap);
425 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
426 return(false);
427 }
428
429 compare[v_col->v_poscxx . . $ dict_v_col_t#v_pos.] = true;
430 n_cmp_v_col++;
431 }
432 }
433
434 if (node.roll_ptrcxx . . $ purge_node_t#roll_ptr. == cur_roll_ptr
435 || row_get_rec_trx_idcxx . . $ row_get_rec_trx_id(e491d669e75572c9).(
436 prev_version, clust_index, clust_offsets)
437 < node.trx_idcxx . . $ purge_node_t#trx_id.) {
438 break;
439 }
440
441 version = prev_version;
442 }
443
444 func_exit:
445 if (n_cmp_v_col == 0) {
446 *vrow = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
447 }
448
449 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(tuple_heap);
450 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
451
452 /* FIXME: In the case of n_cmp_v_col is not the same as
453 n_fields - n_non_v_col, callback is needed to compare the rest
454 columns. At the timebeing, we will need to return true */
455 return (true);
456 }
457
458 /** @return whether two data tuples are equal */
459 bool dtuple_coll_eqcxx . . $ dtuple_coll_eq(a028fb04125eafec).(const dtuple_tcxx . . $ dtuple_t# &tuple1, const dtuple_tcxx . . $ dtuple_t# &tuple2)
460 {
461 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(tuple1.magic_n == DATA_TUPLE_MAGIC_N);
462 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(tuple2.magic_n == DATA_TUPLE_MAGIC_N);
463 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(&tuple1));
464 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(&tuple2));
465 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(tuple1.n_fields == tuple2.n_fields);
466
467 for (ulintcxx . . $ ulint# i= 0; i < tuple1.n_fieldscxx . . $ dtuple_t#n_fields.; i++)
468 if (cmp_dfield_dfieldcxx . . $ cmp_dfield_dfield(9d216ee2a4deec1f).(&tuple1.fieldscxx . . $ dtuple_t#fields.[i], &tuple2.fieldscxx . . $ dtuple_t#fields.[i]))
469 return false;
470 return true;
471 }
472
473 /** Finds out if a version of the record, where the version >= the current
474 purge_sys.view, should have ientry as its secondary index entry. We check
475 if there is any not delete marked version of the record where the trx
476 id >= purge view, and the secondary index entry == ientry; exactly in
477 this case we return TRUE.
478 @param node purge node
479 @param index secondary index
480 @param ientry secondary index entry
481 @param mtr mini-transaction
482 @return whether ientry cannot be purged */
483 static bool row_purge_is_unsafecxx . . $ row_purge_is_unsafe(1d397948c8baeae1).(const purge_node_tcxx . . $ purge_node_t# &node,
484 dict_index_tcxx . . $ dict_index_t# *index,
485 const dtuple_tcxx . . $ dtuple_t# *ientry, mtr_tcxx . . $ mtr_t# *mtr)
486 {
487 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&node.pcurcxx . . $ purge_node_t#pcur.);
488 roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr = node.roll_ptrcxx . . $ purge_node_t#roll_ptr.;
489 trx_id_tcxx . . $ trx_id_t# trx_id = node.trx_idcxx . . $ purge_node_t#trx_id.;
490 const rec_tcxx . . $ rec_t#* version;
491 rec_tcxx . . $ rec_t#* prev_version;
492 dict_index_tcxx . . $ dict_index_t#* clust_index = node.pcurcxx . . $ purge_node_t#pcur..indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).();
493 rec_offscxx . . $ rec_offs#* clust_offsets;
494 mem_heap_tcxx . . $ mem_heap_t#* heap;
495 dtuple_tcxx . . $ dtuple_t#* row;
496 const dtuple_tcxx . . $ dtuple_t#* entry;
497 dtuple_tcxx . . $ dtuple_t#* vrow = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
498 mem_heap_tcxx . . $ mem_heap_t#* v_heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
499 dtuple_tcxx . . $ dtuple_t#* cur_vrow = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
500
501 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table == clust_index->table);
502 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(node.pt.table == index->table);
503 heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
504 clust_offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, clust_index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
505 clust_index->n_core_fields,
506 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
507
508 if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(clust_offsets))) {
509 row_ext_tcxx . . $ row_ext_t#* ext;
510
511 /* The top of the stack of versions is locked by the
512 mtr holding a latch on the page containing the
513 clustered index record. The bottom of the stack is
514 locked by the fact that the purge_sys.view must
515 'overtake' any read view of an active transaction.
516 Thus, it is safe to fetch the prefixes for
517 externally stored columns. */
518 row = row_buildcxx . . $ row_build(b7bc9c2b35ba2522).(ROW_COPY_POINTERScxx . . $ `storage/innobase/include/row0row.h:350:9`!, clust_index,
519 rec, clust_offsets,
520 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &ext, heap);
521
522 if (dict_index_has_virtualcxx . . $ `storage/innobase/include/dict0dict.h:621:9`!(index)) {
523
524
525 #ifdef DBUG_OFFcxx . . $ `<built-in>:492:9`!
526 # define dbug_v_purgecxx . . $ `storage/innobase/row/row0purge.cc:526:10`! false
527 #else /* DBUG_OFF */
528 bool dbug_v_purge = false;
529 #endif /* DBUG_OFF */
530
531 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!(
532 "ib_purge_virtual_index_callback",
533 dbug_v_purge = true;);
534
535 roll_ptr_tcxx . . $ roll_ptr_t# t_roll_ptr = row_get_rec_roll_ptrcxx . . $ row_get_rec_roll_ptr(e491d669e75572c9).(
536 rec, clust_index, clust_offsets);
537
538 /* if the row is newly inserted, then the virtual
539 columns need to be computed */
540 if (trx_undo_roll_ptr_is_insertcxx . . $ trx_undo_roll_ptr_is_insert(31596a199e1d8a50).(t_roll_ptr)
541 || dbug_v_purgecxx . . $ `storage/innobase/row/row0purge.cc:526:10`!) {
542
543 if (!row_vers_build_clust_v_colcxx . . $ row_vers_build_clust_v_col(4350a4a7ebae41b4).(
544 row, clust_index, index, heap,
545 node.ptcxx . . $ purge_node_t#pt..get_maria_tablecxx . . $ purge_table#get_maria_table(198d021c806d525d).())) {
546 goto unsafe_to_purge;
547 }
548
549 entry = row_build_index_entrycxx . . $ row_build_index_entry(c4abbf812e179ab1).(
550 row, ext, index, heap);
551 if (entry && dtuple_coll_eqcxx . . $ dtuple_coll_eq(a028fb04125eafec).(*ientry, *entry)) {
552 goto unsafe_to_purge;
553 }
554 } else {
555 /* Build index entry out of row */
556 entry = row_build_index_entrycxx . . $ row_build_index_entry(c4abbf812e179ab1).(row, ext, index, heap);
557 /* entry could only be NULL if
558 the clustered index record is an uncommitted
559 inserted record whose BLOBs have not been
560 written yet. The secondary index record
561 can be safely removed, because it cannot
562 possibly refer to this incomplete
563 clustered index record. (Insert would
564 always first be completed for the
565 clustered index record, then proceed to
566 secondary indexes.) */
567
568 if (entry && row_purge_vc_matches_clustercxx . . $ row_purge_vc_matches_cluster(5d8cf1f6a5c1a9bc).(
569 rec, entry,
570 clust_index, clust_offsets,
571 index, ientry, node, mtr, &vrow)) {
572 goto unsafe_to_purge;
573 }
574 }
575 clust_offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, clust_index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
576 clust_index
577 ->n_core_fields,
578 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
579 } else {
580
581 entry = row_build_index_entrycxx . . $ row_build_index_entry(c4abbf812e179ab1).(
582 row, ext, index, heap);
583
584 /* If entry == NULL, the record contains unset BLOB
585 pointers. This must be a freshly inserted record. If
586 this is called from
587 row_purge_remove_sec_if_poss_low(), the thread will
588 hold latches on the clustered index and the secondary
589 index. Because the insert works in three steps:
590
591 (1) insert the record to clustered index
592 (2) store the BLOBs and update BLOB pointers
593 (3) insert records to secondary indexes
594
595 the purge thread can safely ignore freshly inserted
596 records and delete the secondary index record. The
597 thread that inserted the new record will be inserting
598 the secondary index records. */
599
600 /* NOTE that we cannot do the comparison as binary
601 fields because the row is maybe being modified so that
602 the clustered index record has already been updated to
603 a different binary value in a char field, but the
604 collation identifies the old and new value anyway! */
605 if (entry && dtuple_coll_eqcxx . . $ dtuple_coll_eq(a028fb04125eafec).(*ientry, *entry)) {
606 unsafe_to_purge:
607 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
608
609 if (v_heap) {
610 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(v_heap);
611 }
612 return true;
613 }
614 }
615 } else if (dict_index_has_virtualcxx . . $ `storage/innobase/include/dict0dict.h:621:9`!(index)) {
616 /* The current cluster index record could be
617 deleted, but the previous version of it might not. We will
618 need to get the virtual column data from undo record
619 associated with current cluster index */
620 v_heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(100);
621
622 cur_vrow = row_vers_build_cur_vrowcxx . . $ row_vers_build_cur_vrow(4077a9abd4752b3f).(
623 rec, clust_index, &clust_offsets,
624 index, trx_id, roll_ptr, heap, v_heap, mtr,
625 node.ptcxx . . $ purge_node_t#pt..get_maria_tablecxx . . $ purge_table#get_maria_table(198d021c806d525d).());
626 }
627
628 version = rec;
629
630 for (;;) {
631 mem_heap_tcxx . . $ mem_heap_t#* heap2 = heap;
632 heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
633 vrow = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
634
635 trx_undo_prev_version_buildcxx . . $ trx_undo_prev_version_build(a23d9403dd7b3c31).(version,
636 clust_index, clust_offsets,
637 heap, &prev_version, mtr,
638 TRX_UNDO_CHECK_PURGE_PAGEScxx . . $ TRX_UNDO_CHECK_PURGE_PAGES.,
639 nullptr,
640 dict_index_has_virtualcxx . . $ `storage/innobase/include/dict0dict.h:621:9`!(index)
641 ? &vrow : nullptr);
642 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap2); /* free version and clust_offsets */
643
644 if (!prev_version) {
645 /* Versions end here */
646 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
647
648 if (v_heap) {
649 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(v_heap);
650 }
651
652 return false;
653 }
654
655 clust_offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(prev_version, clust_index,
656 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
657 clust_index->n_core_fields,
658 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
659
660 if (dict_index_has_virtualcxx . . $ `storage/innobase/include/dict0dict.h:621:9`!(index)) {
661 if (vrow) {
662 if (dtuple_vcol_data_missingcxx . . $ dtuple_vcol_data_missing(40ced016f328598b).(*vrow, *index)) {
663 goto nochange_index;
664 }
665 /* Keep the virtual row info for the next
666 version, unless it is changed */
667 if (v_heap) {
668 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(v_heap);
669 } else {
670 v_heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(100);
671 }
672 cur_vrow = dtuple_copycxx . . $ dtuple_copy(c8b6759a637e04b5).(vrow, v_heap);
673 dtuple_dup_v_fldcxx . . $ dtuple_dup_v_fld(cedfa3a525073ff4).(cur_vrow, v_heap);
674 }
675
676 if (!cur_vrow) {
677 /* Nothing for this index has changed,
678 continue */
679 nochange_index:
680 version = prev_version;
681 continue;
682 }
683 }
684
685 if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(prev_version,
686 rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(clust_offsets))) {
687 row_ext_tcxx . . $ row_ext_t#* ext;
688
689 /* The stack of versions is locked by mtr.
690 Thus, it is safe to fetch the prefixes for
691 externally stored columns. */
692 row = row_buildcxx . . $ row_build(b7bc9c2b35ba2522).(ROW_COPY_POINTERScxx . . $ `storage/innobase/include/row0row.h:350:9`!, clust_index,
693 prev_version, clust_offsets,
694 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &ext, heap);
695
696 if (dict_index_has_virtualcxx . . $ `storage/innobase/include/dict0dict.h:621:9`!(index)) {
697 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cur_vrow);
698 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(row->n_v_fields == cur_vrow->n_v_fields);
699 dtuple_copy_v_fieldscxx . . $ dtuple_copy_v_fields(1800bb243c7e063e).(row, cur_vrow);
700 }
701
702 entry = row_build_index_entrycxx . . $ row_build_index_entry(c4abbf812e179ab1).(row, ext, index, heap);
703
704 /* If entry == NULL, the record contains unset
705 BLOB pointers. This must be a freshly
706 inserted record that we can safely ignore.
707 For the justification, see the comments after
708 the previous row_build_index_entry() call. */
709
710 /* NOTE that we cannot do the comparison as binary
711 fields because maybe the secondary index record has
712 already been updated to a different binary value in
713 a char field, but the collation identifies the old
714 and new value anyway! */
715
716 if (entry && dtuple_coll_eqcxx . . $ dtuple_coll_eq(a028fb04125eafec).(*ientry, *entry)) {
717 goto unsafe_to_purge;
718 }
719 }
720
721 version = prev_version;
722 }
723 }
724
725 /** Determines if it is possible to remove a secondary index entry.
726 Removal is possible if the secondary index entry does not refer to any
727 not delete marked version of a clustered index record where DB_TRX_ID
728 is newer than the purge view.
729
730 NOTE: This function should only be called by the purge thread, only
731 while holding a latch on the leaf page of the secondary index entry.
732 It is possible that this function first returns true and then false,
733 if a user transaction inserts a record that the secondary index entry
734 would refer to.
735 However, in that case, the user transaction would also re-insert the
736 secondary index entry after purge has removed it and released the leaf
737 page latch.
738 @param node row purge node
739 @param index secondary index
740 @param entry secondary index entry
741 @param mtr mini-transaction for looking up clustered index
742 @return whether the secondary index record can be purged */
743 static bool row_purge_poss_seccxx . . $ row_purge_poss_sec(31fcfa0b6db1bf65).(purge_node_tcxx . . $ purge_node_t# *node, dict_index_tcxx . . $ dict_index_t# *index,
744 const dtuple_tcxx . . $ dtuple_t# *entry, mtr_tcxx . . $ mtr_t# *mtr)
745 {
746 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->trx == node->trx);
747 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_clust());
748 const auto savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
749 bool can_delete= !row_purge_reposition_pcurcxx . . $ row_purge_reposition_pcur(b51d4f745d9b9456).(BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., node, mtr);
750
751 if (!can_delete)
752 {
753 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(node->pcur.pos_state == BTR_PCUR_IS_POSITIONED);
754 can_delete= !row_purge_is_unsafecxx . . $ row_purge_is_unsafe(1d397948c8baeae1).(*node, index, entry, mtr);
755 node->pcurcxx . . $ purge_node_t#pcur..pos_statecxx . . $ btr_pcur_t#pos_state. = BTR_PCUR_WAS_POSITIONEDcxx . . $ BTR_PCUR_WAS_POSITIONED.;
756 node->pcurcxx . . $ purge_node_t#pcur..latch_modecxx . . $ btr_pcur_t#latch_mode.= BTR_NO_LATCHEScxx . . $ BTR_NO_LATCHES.;
757 }
758
759 mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
760 return can_delete;
761 }
762
763 /** Report an error about not delete-marked secondary index record
764 that was about to be purged.
765 @param cur cursor on the secondary index record
766 @param entry search key */
767 ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`! ATTRIBUTE_NOINLINEcxx . . $ `include/my_compiler.h:157:10`!
768 static void row_purge_del_mark_errorcxx . . $ row_purge_del_mark_error(9ebf4210e148c956).(const btr_cur_tcxx . . $ btr_cur_t# &cursor,
769 const dtuple_tcxx . . $ dtuple_t# &entry)
770 {
771 const dict_index_tcxx . . $ dict_index_t# *index= cursor.indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).();
772 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "tried to purge non-delete-marked record in index "
773 <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name. <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name.
774 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). ": tuple: " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). entry
775 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). ", record: " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). rec_index_printcxx . . $ rec_index_print#rec_index_print(cc6e49105d2081a2).(cursor.page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., index);
776 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(0);
777 }
778
779 __attribute__((nonnull, warn_unused_result))
780 /** Remove a secondary index entry if possible, by modifying the index tree.
781 @param node purge node
782 @param index secondary index
783 @param entry index entry
784 @param page_max_trx_id the PAGE_MAX_TRX_ID
785 when row_purge_remove_sec_if_poss_leaf() was invoked
786 @return whether the operation succeeded */
787 static bool row_purge_remove_sec_if_poss_treecxx . . $ row_purge_remove_sec_if_poss_tree(928e0c6504e5b71e).(purge_node_tcxx . . $ purge_node_t# *node,
788 dict_index_tcxx . . $ dict_index_t# *index,
789 const dtuple_tcxx . . $ dtuple_t# *entry,
790 trx_id_tcxx . . $ trx_id_t# page_max_trx_id)
791 {
792 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
793 bool success = true;
794 dberr_tcxx . . $ dberr_t# err;
795 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{node->trxcxx . . $ purge_node_t#trx.};
796
797 log_free_checkcxx . . $ log_free_check(ced63f7c635d850d).();
798 #ifdef ENABLED_DEBUG_SYNC
799 DBUG_EXECUTE_IF("enable_row_purge_sec_tree_sync",
800 debug_sync_set_action(node->trx->mysql_thd, STRING_WITH_LEN(
801 "now SIGNAL "
802 "purge_sec_tree_begin"));
803 debug_sync_set_action(node->trx->mysql_thd, STRING_WITH_LEN(
804 "now WAIT_FOR "
805 "purge_sec_tree_execute"));
806 );
807 #endif
808 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
809 index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr);
810 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = index;
811
812 if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) {
813 if (rtr_searchcxx . . $ rtr_search(413c0a91d94575a9).(entry, BTR_PURGE_TREEcxx . . $ BTR_PURGE_TREE., &pcur, nullptr, &mtr)) {
814 goto func_exit;
815 }
816 } else if (!row_search_index_entrycxx . . $ row_search_index_entry(e4c62adc5b14c039).(entry, BTR_PURGE_TREEcxx . . $ BTR_PURGE_TREE.,
817 &pcur, &mtr)) {
818 /* Not found. This is a legitimate condition. In a
819 rollback, InnoDB will remove secondary recs that would
820 be purged anyway. Then the actual purge will not find
821 the secondary index record. Also, the purge itself is
822 eager: if it comes to consider a secondary index
823 record, and notices it does not need to exist in the
824 index, it will remove it. Then if/when the purge
825 comes to consider the secondary index record a second
826 time, it will not exist any more in the index. */
827 goto func_exit;
828 }
829
830 /* We should remove the index record if no later version of the row,
831 which cannot be purged yet, requires its existence. If some requires,
832 we should do nothing. */
833
834 if (page_max_trx_id
835 == page_get_max_trx_idcxx . . $ page_get_max_trx_id(b191ace3c5bffbd9).(btr_cur_get_pagecxx . . $ `storage/innobase/include/btr0cur.h:76:9`!(&pcur.btr_cur))
836 || row_purge_poss_seccxx . . $ row_purge_poss_sec(31fcfa0b6db1bf65).(node, index, entry, &mtr)) {
837
838 /* Remove the index record, which should have been
839 marked for deletion. */
840 if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur),
841 index->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).())) {
842 row_purge_del_mark_errorcxx . . $ row_purge_del_mark_error(9ebf4210e148c956).(pcur.btr_curcxx . . $ btr_pcur_t#btr_cur., *entry);
843 goto func_exit;
844 }
845
846 btr_cur_pessimistic_deletecxx . . $ btr_cur_pessimistic_delete(8e234601f90ce98f).(&err, FALSEcxx . . $ `include/my_global.h:477:9`!, &pcur.btr_curcxx . . $ btr_pcur_t#btr_cur.,
847 0, false, &mtr);
848 switch (UNIV_EXPECTcxx . . $ `storage/innobase/include/univ.i:391:10`!(err, DB_SUCCESS)) {
849 case DB_SUCCESScxx . . $ DB_SUCCESS.:
850 break;
851 case DB_OUT_OF_FILE_SPACEcxx . . $ DB_OUT_OF_FILE_SPACE.:
852 success = FALSEcxx . . $ `include/my_global.h:477:9`!;
853 break;
854 default:
855 ut_errorcxx . . $ `storage/innobase/include/ut0dbg.h:58:9`!;
856 }
857 }
858
859 func_exit:
860 btr_pcur_closecxx . . $ btr_pcur_close(57c44ef9c177cfb0).(&pcur); // FIXME: need this?
861 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
862 return success;
863 }
864
865 /** Compute a nonzero return value of row_purge_remove_sec_if_poss_leaf().
866 @param page latched secondary index page
867 @return PAGE_MAX_TRX_ID for row_purge_remove_sec_if_poss_tree()
868 @retval 1 if a further row_purge_poss_sec() check is necessary */
869 ATTRIBUTE_NOINLINEcxx . . $ `include/my_compiler.h:157:10`! ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`!
870 static trx_id_tcxx . . $ trx_id_t# row_purge_checkcxx . . $ row_purge_check(176b319dba56b078).(const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *page) noexcept
871 {
872 trx_id_tcxx . . $ trx_id_t# id= page_get_max_trx_idcxx . . $ page_get_max_trx_id(b191ace3c5bffbd9).(page);
873 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(id);
874 if (trx_syscxx . . $ trx_sys..find_same_or_older_in_purgecxx . . $ trx_sys_t#find_same_or_older_in_purge(1a5626169aafe626).(purge_syscxx . . $ purge_sys..querycxx . . $ purge_sys_t#query.->trxcxx . . $ que_fork_t#trx., id))
875 /* Because an active transaction may modify the secondary index
876 but not PAGE_MAX_TRX_ID, row_purge_poss_sec() must be invoked
877 again after re-latching the page. Let us return a bogus ID. Yes,
878 an actual transaction with ID 1 would create the InnoDB dictionary
879 tables in dict_sys_t::create_or_check_sys_tables(), but it would
880 exclusively write TRX_UNDO_INSERT_REC records. Purging those
881 records never involves row_purge_remove_sec_if_poss_tree(). */
882 id= 1;
883 return id;
884 }
885
886 __attribute__((nonnull, warn_unused_result))
887 /** Remove a secondary index entry if possible, without modifying the tree.
888 @param node purge node
889 @param index secondary index
890 @param entry index entry
891 @return PAGE_MAX_TRX_ID for row_purge_remove_sec_if_poss_tree()
892 @retval 1 if a further row_purge_poss_sec() check is necessary
893 @retval 0 if success or if not found */
894 static trx_id_tcxx . . $ trx_id_t# row_purge_remove_sec_if_poss_leafcxx . . $ row_purge_remove_sec_if_poss_leaf(b11a020a2d42aa5f).(purge_node_tcxx . . $ purge_node_t# *node,
895 dict_index_tcxx . . $ dict_index_t# *index,
896 const dtuple_tcxx . . $ dtuple_t# *entry)
897 {
898 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{node->trxcxx . . $ purge_node_t#trx.};
899 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
900 trx_id_tcxx . . $ trx_id_t# page_max_trx_id = 0;
901
902 log_free_checkcxx . . $ log_free_check(ced63f7c635d850d).();
903 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table == node->pt.table);
904 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary());
905 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
906 index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr);
907
908 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = index;
909
910 if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) {
911 if (!rtr_searchcxx . . $ rtr_search(413c0a91d94575a9).(entry, BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF., &pcur, nullptr,
912 &mtr)) {
913 goto found;
914 }
915 } else if (btr_pcur_opencxx . . $ btr_pcur_open(fc6cd1a58061ff83).(entry, PAGE_CUR_LEcxx . . $ PAGE_CUR_LE., BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF., &pcur,
916 &mtr)
917 == DB_SUCCESScxx . . $ DB_SUCCESS.
918 && !btr_pcur_is_before_first_on_pagecxx . . $ btr_pcur_is_before_first_on_page(c5e2b82e26308d5e).(&pcur)
919 && btr_pcur_get_low_matchcxx . . $ btr_pcur_get_low_match(c5e2b82e26308d5e).(&pcur)
920 == dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(entry)) {
921 found:
922 /* Before attempting to purge a record, check
923 if it is safe to do so. */
924 if (row_purge_poss_seccxx . . $ row_purge_poss_sec(31fcfa0b6db1bf65).(node, index, entry, &mtr)) {
925 /* Only delete-marked records should be purged. */
926 if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur),
927 index->tablecxx . . $ dict_index_t#table.
928 ->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).())) {
929 row_purge_del_mark_errorcxx . . $ row_purge_del_mark_error(9ebf4210e148c956).(pcur.btr_curcxx . . $ btr_pcur_t#btr_cur., *entry);
930 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
931 dict_set_corruptedcxx . . $ dict_set_corrupted(41f975e379a1c310).(node->trxcxx . . $ purge_node_t#trx., index, "purge");
932 goto cleanup;
933 }
934
935 if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) {
936 const buf_block_tcxx . . $ buf_block_t#* block = btr_pcur_get_blockcxx . . $ btr_pcur_get_block(73fb1691f91dfae3).(
937 &pcur);
938 const page_id_tcxx . . $ page_id_t# id{block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()};
939
940 if (id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() != index->pagecxx . . $ dict_index_t#page.
941 && page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) < 2
942 && !lock_test_prdt_page_lockcxx . . $ lock_test_prdt_page_lock(d21ec259cc96fe00).(nullptr, id)){
943 /* this is the last record on page,
944 and it has a "page" lock on it,
945 which mean search is still depending
946 on it, so do not delete */
947 DBUG_LOGcxx . . $ `include/my_dbug.h:235:11`!("purge",
948 "skip purging last"
949 " record on page " << id);
950 goto func_exit;
951 }
952 }
953
954 if (btr_cur_optimistic_deletecxx . . $ btr_cur_optimistic_delete(5923638ae82be759).(&pcur.btr_curcxx . . $ btr_pcur_t#btr_cur., 0, &mtr)
955 == DB_FAILcxx . . $ DB_FAIL.) {
956 page_max_trx_id = row_purge_checkcxx . . $ row_purge_check(176b319dba56b078).(
957 btr_pcur_get_pagecxx . . $ `storage/innobase/include/btr0pcur.h:216:9`!(&pcur));
958 }
959 }
960 }
961
962 func_exit:
963 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
964 cleanup:
965 btr_pcur_closecxx . . $ btr_pcur_close(57c44ef9c177cfb0).(&pcur);
966 return page_max_trx_id;
967 }
968
969 /***********************************************************//**
970 Removes a secondary index entry if possible. */
971 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull(1,2)))
972 void
973 row_purge_remove_sec_if_posscxx . . $ row_purge_remove_sec_if_poss(e28f247dd11724c0).(
974 /*=========================*/
975 purge_node_tcxx . . $ purge_node_t#* node, /*!< in: row purge node */
976 dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index */
977 const dtuple_tcxx . . $ dtuple_t#* entry) /*!< in: index entry */
978 {
979 if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!entry))
980 /* The node->row must have lacked some fields of this index. This
981 is possible when the undo log record was written before this index
982 was created. */
983 return;
984
985 if (trx_id_tcxx . . $ trx_id_t# page_max_trx_id=
986 row_purge_remove_sec_if_poss_leafcxx . . $ row_purge_remove_sec_if_poss_leaf(b11a020a2d42aa5f).(node, index, entry))
987 for (auto n_tries= BTR_CUR_RETRY_DELETE_N_TIMEScxx . . $ `storage/innobase/include/btr0cur.h:780:9`!;
988 !row_purge_remove_sec_if_poss_treecxx . . $ row_purge_remove_sec_if_poss_tree(928e0c6504e5b71e).(node, index, entry,
989 page_max_trx_id);
990 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(BTR_CUR_RETRY_SLEEP_TIMEcxx . . $ BTR_CUR_RETRY_SLEEP_TIME.))
991 /* The delete operation may fail if we have little
992 file space left (if innodb_file_per_table=0?) */
993 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(--n_tries);
994 }
995
996 /**
997 Purges a delete marking of a record.
998 @param node row purge node
999 @retval true if the row was not found, or it was successfully removed
1000 @retval false the purge needs to be suspended because of
1001 running out of file space */
1002 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
1003 bool row_purge_del_markcxx . . $ row_purge_del_mark(f21dbde4c7c4a176).(purge_node_tcxx . . $ purge_node_t# *node) noexcept
1004 {
1005 if (node->indexcxx . . $ purge_node_t#index.)
1006 {
1007 mem_heap_tcxx . . $ mem_heap_t# *heap= mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
1008
1009 do
1010 {
1011 if (node->indexcxx . . $ purge_node_t#index.->typecxx . . $ dict_index_t#type. & (DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`! | DICT_CORRUPTcxx . . $ `storage/innobase/include/dict0mem.h:69:9`!))
1012 continue;
1013 if (!node->indexcxx . . $ purge_node_t#index.->is_committedcxx . . $ dict_index_t#is_committed(50ce9a9e25b4a850).())
1014 continue;
1015 dtuple_tcxx . . $ dtuple_t#* entry= row_build_index_entry_lowcxx . . $ row_build_index_entry_low(34377639624d7a55).(node->rowcxx . . $ purge_node_t#row., nullptr,
1016 node->indexcxx . . $ purge_node_t#index., heap,
1017 ROW_BUILD_FOR_PURGEcxx . . $ `storage/innobase/include/row0row.h:73:9`!);
1018 row_purge_remove_sec_if_posscxx . . $ row_purge_remove_sec_if_poss(e28f247dd11724c0).(node, node->indexcxx . . $ purge_node_t#index., entry);
1019 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(heap);
1020 }
1021 while ((node->indexcxx . . $ purge_node_t#index.= dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(node->index)));
1022
1023 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
1024 }
1025
1026 bool result= row_purge_remove_clust_if_posscxx . . $ row_purge_remove_clust_if_poss(46ae5329a1dcb504).(node);
1027
1028 #ifdef ENABLED_DEBUG_SYNC
1029 DBUG_EXECUTE_IF("enable_row_purge_del_mark_exit_sync_point",
1030 debug_sync_set_action
1031 (node->trx->mysql_thd,
1032 STRING_WITH_LEN("now SIGNAL row_purge_del_mark_finished"));
1033 );
1034 #endif
1035
1036 return result;
1037 }
1038
1039 /***********************************************************//**
1040 Purges an update of an existing record. Also purges an update of a delete
1041 marked record if that record contained an externally stored field. */
1042 static
1043 void
1044 row_purge_upd_exist_or_externcxx . . $ row_purge_upd_exist_or_extern(72ec3d860c675492).(
1045 const que_thr_tcxx . . $ que_thr_t#*thr, /*!< in: query thread */
1046 purge_node_tcxx . . $ purge_node_t#* node, /*!< in: row purge node */
1047 const trx_undo_rec_tcxx . . $ trx_undo_rec_t#* undo_rec) /*!< in: record to purge */
1048 {
1049 mem_heap_tcxx . . $ mem_heap_t#* heap;
1050
1051 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!node->pt.table->skip_alter_undo);
1052
1053 if (node->rec_typecxx . . $ purge_node_t#rec_type. == TRX_UNDO_UPD_DEL_RECcxx . . $ `storage/innobase/include/trx0rec.h:263:9`!
1054 || (node->cmpl_infocxx . . $ purge_node_t#cmpl_info. & UPD_NODE_NO_ORD_CHANGEcxx . . $ `storage/innobase/include/row0upd.h:550:9`!)
1055 || !node->indexcxx . . $ purge_node_t#index.) {
1056
1057 goto skip_secondaries;
1058 }
1059
1060 heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
1061
1062 do {
1063 if (node->indexcxx . . $ purge_node_t#index.->typecxx . . $ dict_index_t#type. & (DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`! | DICT_CORRUPTcxx . . $ `storage/innobase/include/dict0mem.h:69:9`!)) {
1064 continue;
1065 }
1066
1067 if (!node->indexcxx . . $ purge_node_t#index.->is_committedcxx . . $ dict_index_t#is_committed(50ce9a9e25b4a850).()) {
1068 continue;
1069 }
1070
1071 if (row_upd_changes_ord_field_binarycxx . . $ `storage/innobase/include/row0upd.h:257:10`!(node->index, node->update,
1072 thr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) {
1073 /* Build the older version of the index entry */
1074 dtuple_tcxx . . $ dtuple_t#* entry = row_build_index_entry_lowcxx . . $ row_build_index_entry_low(34377639624d7a55).(
1075 node->rowcxx . . $ purge_node_t#row., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, node->indexcxx . . $ purge_node_t#index.,
1076 heap, ROW_BUILD_FOR_PURGEcxx . . $ `storage/innobase/include/row0row.h:73:9`!);
1077 row_purge_remove_sec_if_posscxx . . $ row_purge_remove_sec_if_poss(e28f247dd11724c0).(
1078 node, node->indexcxx . . $ purge_node_t#index., entry);
1079
1080 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(node->pt.table);
1081
1082 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(heap);
1083 }
1084 } while ((node->indexcxx . . $ purge_node_t#index. = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(node->index)));
1085
1086 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
1087
1088 skip_secondaries:
1089 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{node->trxcxx . . $ purge_node_t#trx.};
1090 dict_index_tcxx . . $ dict_index_t#* index = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(node->pt.table);
1091 /* Free possible externally stored fields */
1092 for (ulintcxx . . $ ulint# i = 0; i < upd_get_n_fieldscxx . . $ upd_get_n_fields(c9dccea53ab13a00).(node->updatecxx . . $ purge_node_t#update.); i++) {
1093
1094 const upd_field_tcxx . . $ upd_field_t#* ufield
1095 = upd_get_nth_fieldcxx . . $ `storage/innobase/include/row0upd.h:68:10`!(node->update, i);
1096
1097 if (dfield_is_extcxx . . $ dfield_is_ext(421b5b1f6d6093e7).(&ufield->new_valcxx . . $ upd_field_t#new_val.)) {
1098 bool is_insert;
1099 ulintcxx . . $ ulint# rseg_id;
1100 uint32_tcxx . . $ uint32_t# page_no;
1101 uint16_tcxx . . $ uint16_t# offset;
1102
1103 /* We use the fact that new_val points to
1104 undo_rec and get thus the offset of
1105 dfield data inside the undo record. Then we
1106 can calculate from node->roll_ptr the file
1107 address of the new_val data */
1108
1109 const uint16_tcxx . . $ uint16_t# internal_offset = uint16_tcxx . . $ uint16_t#(
1110 static_cast<const bytecxx . . $ byte#*>
1111 (dfield_get_datacxx . . $ dfield_get_data(8fcad372944bd35).(&ufield->new_valcxx . . $ upd_field_t#new_val.))
1112 - undo_rec);
1113
1114 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(internal_offset < srv_page_size);
1115
1116 trx_undo_decode_roll_ptrcxx . . $ trx_undo_decode_roll_ptr(97fc687a4179e1b6).(node->roll_ptrcxx . . $ purge_node_t#roll_ptr.,
1117 &is_insert, &rseg_id,
1118 &page_no, &offset);
1119
1120 const trx_rseg_tcxx . . $ trx_rseg_t# &rseg = trx_syscxx . . $ trx_sys..rseg_arraycxx . . $ trx_sys_t#rseg_array.[rseg_id];
1121 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rseg.is_persistent());
1122
1123 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
1124
1125 /* We have to acquire an SX-latch to the clustered
1126 index tree (exclude other tree changes) */
1127
1128 mtr_sx_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:47:10`!(index, &mtr);
1129
1130 index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr);
1131
1132 /* NOTE: we must also acquire a U latch to the
1133 root page of the tree. We will need it when we
1134 free pages from the tree. If the tree is of height 1,
1135 the tree X-latch does NOT protect the root page,
1136 because it is also a leaf page. Since we will have a
1137 latch on an undo log page, we would break the
1138 latching order if we would only later latch the
1139 root page of such a tree! */
1140
1141 dberr_tcxx . . $ dberr_t# err;
1142 if (!btr_root_block_getcxx . . $ btr_root_block_get(4bcbd40788d58e0a).(index, RW_SX_LATCHcxx . . $ RW_SX_LATCH., &mtr,
1143 &err)) {
1144 } else if (buf_block_tcxx . . $ buf_block_t#* block =
1145 buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!(page_id_t(rseg.space->id,
1146 page_no),
1147 0, RW_X_LATCH, &mtr)) {
1148 buf_page_make_young_if_neededcxx . . $ buf_page_make_young_if_needed(12ea16e51c748147).(&block->pagecxx . . $ buf_block_t#page.);
1149
1150 bytecxx . . $ byte#* data_field = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.
1151 + offset + internal_offset;
1152
1153 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(dfield_get_len(&ufield->new_val)
1154 >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!);
1155 btr_free_externally_stored_fieldcxx . . $ btr_free_externally_stored_field(599858604e27e4ad).(
1156 index,
1157 data_field
1158 + dfield_get_lencxx . . $ dfield_get_len(61c431dfc6825316).(&ufield->new_valcxx . . $ upd_field_t#new_val.)
1159 - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!,
1160 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, block, 0, false, &mtr);
1161 }
1162
1163 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
1164 }
1165 }
1166 }
1167
1168 /** Build a partial row from an update undo log record for purge.
1169 Any columns which occur as ordering in any index of the table are present.
1170 Any missing columns are indicated by col->mtype == DATA_MISSING.
1171
1172 @param ptr remaining part of the undo log record
1173 @param index clustered index
1174 @param node purge node
1175 @return pointer to remaining part of undo record */
1176 static bytecxx . . $ byte# *row_purge_get_partialcxx . . $ row_purge_get_partial(ac8845d2ecaa005a).(const bytecxx . . $ byte# *ptr, const dict_index_tcxx . . $ dict_index_t# &index,
1177 purge_node_tcxx . . $ purge_node_t# *node)
1178 {
1179 bool first_v_col= true;
1180 bool is_undo_log= true;
1181
1182 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index.is_primary());
1183 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index.n_uniq == node->ref->n_fields);
1184
1185 node->rowcxx . . $ purge_node_t#row.= dtuple_create_with_vcolcxx . . $ dtuple_create_with_vcol(450a09b424f51781).(node->heapcxx . . $ purge_node_t#heap., index.tablecxx . . $ dict_index_t#table.->n_colscxx . . $ dict_table_t#n_cols.,
1186 index.tablecxx . . $ dict_index_t#table.->n_v_colscxx . . $ dict_table_t#n_v_cols.);
1187
1188 /* Mark all columns in the row uninitialized, so that
1189 we can distinguish missing fields from fields that are SQL NULL. */
1190 for (ulintcxx . . $ ulint# i= 0; i < index.tablecxx . . $ dict_index_t#table.->n_colscxx . . $ dict_table_t#n_cols.; i++)
1191 node->rowcxx . . $ purge_node_t#row.->fieldscxx . . $ dtuple_t#fields.[i].typecxx . . $ dfield_t#type..mtypecxx . . $ dtype_t#mtype.= DATA_MISSINGcxx . . $ `storage/innobase/include/data0type.h:49:9`!;
1192
1193 dtuple_init_v_fldcxx . . $ dtuple_init_v_fld(984aa751a02e0831).(node->rowcxx . . $ purge_node_t#row.);
1194
1195 for (const upd_field_tcxx . . $ upd_field_t# *uf= node->updatecxx . . $ purge_node_t#update.->fieldscxx . . $ upd_t#fields., *const ue=
1196 node->updatecxx . . $ purge_node_t#update.->fieldscxx . . $ upd_t#fields. + node->updatecxx . . $ purge_node_t#update.->n_fieldscxx . . $ upd_t#n_fields.; uf != ue; uf++)
1197 {
1198 if (!uf->old_v_valcxx . . $ upd_field_t#old_v_val.)
1199 {
1200 const dict_col_tcxx . . $ dict_col_t# &c= *dict_index_get_nth_colcxx . . $ dict_index_get_nth_col(c951a315c3826e7f).(&index, uf->field_nocxx . . $ upd_field_t#field_no.);
1201 if (!c.is_droppedcxx . . $ dict_col_t#is_dropped(50ce9a9e25b4a850).())
1202 node->rowcxx . . $ purge_node_t#row.->fieldscxx . . $ dtuple_t#fields.[c.indcxx . . $ dict_col_t#ind.]=cxx . . $ dfield_t#`operator=`(bc88386fbb4fa2e0). uf->new_valcxx . . $ upd_field_t#new_val.;
1203 }
1204 }
1205
1206 const bytecxx . . $ byte# *end_ptr= ptr + mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(ptr);
1207 ptr+= 2;
1208
1209 while (ptr != end_ptr)
1210 {
1211 dfield_tcxx . . $ dfield_t# *dfield;
1212 const bytecxx . . $ byte# *field;
1213 const dict_col_tcxx . . $ dict_col_t# *col;
1214 uint32_tcxx . . $ uint32_t# len, orig_len, field_no= mach_read_next_compressedcxx . . $ mach_read_next_compressed(ca92e78148f412b7).(&ptr);
1215
1216 if (field_no >= REC_MAX_N_FIELDScxx . . $ `storage/innobase/include/rem0types.h:37:9`!)
1217 {
1218 ptr= trx_undo_read_v_idxcxx . . $ trx_undo_read_v_idx(a0f069508ebc3366).(index.tablecxx . . $ dict_index_t#table., ptr, first_v_col, &is_undo_log,
1219 &field_no);
1220 first_v_col= false;
1221
1222 ptr= trx_undo_rec_get_col_valcxx . . $ trx_undo_rec_get_col_val(a3f77713af2855be).(ptr, &field, &len, &orig_len);
1223
1224 if (field_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!)
1225 continue; /* there no longer is an index on the virtual column */
1226
1227 dict_v_col_tcxx . . $ dict_v_col_t# *vcol= dict_table_get_nth_v_colcxx . . $ `storage/innobase/include/dict0dict.h:741:9`!(index.table, field_no);
1228 col =&vcol->m_colcxx . . $ dict_v_col_t#m_col.;
1229 dfield= dtuple_get_nth_v_fieldcxx . . $ dtuple_get_nth_v_field(71af1a8d94eba0f9).(node->rowcxx . . $ purge_node_t#row., vcol->v_poscxx . . $ dict_v_col_t#v_pos.);
1230 dict_col_copy_typecxx . . $ dict_col_copy_type(393e471bd65769db).(&vcol->m_colcxx . . $ dict_v_col_t#m_col., &dfield->typecxx . . $ dfield_t#type.);
1231 }
1232 else
1233 {
1234 ptr= trx_undo_rec_get_col_valcxx . . $ trx_undo_rec_get_col_val(a3f77713af2855be).(ptr, &field, &len, &orig_len);
1235 col= dict_index_get_nth_colcxx . . $ dict_index_get_nth_col(c951a315c3826e7f).(&index, field_no);
1236 if (col->is_droppedcxx . . $ dict_col_t#is_dropped(50ce9a9e25b4a850).())
1237 continue;
1238 dfield= dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).(node->rowcxx . . $ purge_node_t#row., col->indcxx . . $ dict_col_t#ind.);
1239 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dfield->type.mtype == DATA_MISSING ||
1240 dict_col_type_assert_equal(col, &dfield->type));
1241 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dfield->type.mtype == DATA_MISSING ||
1242 dfield->len == len ||
1243 (len != UNIV_SQL_NULL && len >= UNIV_EXTERN_STORAGE_FIELD));
1244 dict_col_copy_typecxx . . $ dict_col_copy_type(393e471bd65769db).(dict_table_get_nth_colcxx . . $ `storage/innobase/include/dict0dict.h:737:9`!(index.table, col->ind),
1245 &dfield->typecxx . . $ dfield_t#type.);
1246 }
1247
1248 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(dfield, field, len);
1249
1250 if (len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`! || len < UNIV_EXTERN_STORAGE_FIELDcxx . . $ `storage/innobase/include/univ.i:379:9`!)
1251 continue;
1252
1253 spatial_status_tcxx . . $ spatial_status_t# spatial_status= static_cast<spatial_status_tcxx . . $ spatial_status_t#>
1254 ((len & SPATIAL_STATUS_MASKcxx . . $ `storage/innobase/include/dict0types.h:155:9`!) >> SPATIAL_STATUS_SHIFTcxx . . $ `storage/innobase/include/dict0types.h:152:9`!);
1255 len&= ~SPATIAL_STATUS_MASKcxx . . $ `storage/innobase/include/dict0types.h:155:9`!;
1256
1257 /* Keep compatible with 5.7.9 format. */
1258 if (spatial_status == SPATIAL_UNKNOWNcxx . . $ SPATIAL_UNKNOWN.)
1259 spatial_status= dict_col_get_spatial_statuscxx . . $ dict_col_get_spatial_status(8f8e8b956021eb2f).(col);
1260
1261 switch (UNIV_EXPECTcxx . . $ `storage/innobase/include/univ.i:391:10`!(spatial_status, SPATIAL_NONE)) {
1262 case SPATIAL_ONLYcxx . . $ SPATIAL_ONLY.:
1263 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len - UNIV_EXTERN_STORAGE_FIELD == DATA_MBR_LEN);
1264 dfield_set_lencxx . . $ dfield_set_len(6aa1c2dd5c610b1).(dfield, len - UNIV_EXTERN_STORAGE_FIELDcxx . . $ `storage/innobase/include/univ.i:379:9`!);
1265 break;
1266
1267 case SPATIAL_MIXEDcxx . . $ SPATIAL_MIXED.:
1268 dfield_set_lencxx . . $ dfield_set_len(6aa1c2dd5c610b1).(dfield, len - UNIV_EXTERN_STORAGE_FIELDcxx . . $ `storage/innobase/include/univ.i:379:9`! - DATA_MBR_LENcxx . . $ DATA_MBR_LEN.);
1269 break;
1270
1271 default:
1272 dfield_set_lencxx . . $ dfield_set_len(6aa1c2dd5c610b1).(dfield, len - UNIV_EXTERN_STORAGE_FIELDcxx . . $ `storage/innobase/include/univ.i:379:9`!);
1273 break;
1274 }
1275
1276 dfield_set_extcxx . . $ dfield_set_ext(9f766d81c2981ba3).(dfield);
1277 dfield_set_spatial_statuscxx . . $ dfield_set_spatial_status(1289ee18acc3937).(dfield, spatial_status);
1278
1279 if (!col->ord_partcxx . . $ dict_col_t#ord_part. || spatial_status == SPATIAL_ONLYcxx . . $ SPATIAL_ONLY. ||
1280 node->rec_typecxx . . $ purge_node_t#rec_type. == TRX_UNDO_UPD_DEL_RECcxx . . $ `storage/innobase/include/trx0rec.h:263:9`!)
1281 continue;
1282 /* If the prefix of this BLOB column is indexed, ensure that enough
1283 prefix is stored in the undo log record. */
1284 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(dfield_get_len(dfield) >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!);
1285 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(dict_table_has_atomic_blobs(index.table) ||
1286 dfield_get_len(dfield) >=
1287 REC_ANTELOPE_MAX_INDEX_COL_LENcxx . . $ `storage/innobase/include/rem0types.h:60:9`! + BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!);
1288 }
1289
1290 for (ulintcxx . . $ ulint# i= 0; i < index.n_uniqcxx . . $ dict_index_t#n_uniq.; i++)
1291 {
1292 dfield_tcxx . . $ dfield_t# &field= node->rowcxx . . $ purge_node_t#row.->fieldscxx . . $ dtuple_t#fields.[index.fieldscxx . . $ dict_index_t#fields.[i].colcxx . . $ dict_field_t#col.->indcxx . . $ dict_col_t#ind.];
1293 if (field.typecxx . . $ dfield_t#type..mtypecxx . . $ dtype_t#mtype. == DATA_MISSINGcxx . . $ `storage/innobase/include/data0type.h:49:9`!)
1294 field=cxx . . $ dfield_t#`operator=`(bc88386fbb4fa2e0). node->refcxx . . $ purge_node_t#ref.->fieldscxx . . $ dtuple_t#fields.[i];
1295 }
1296
1297 return const_cast<bytecxx . . $ byte#*>(ptr);
1298 }
1299
1300 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull,warn_unused_result))
1301 /** Parses the row reference and other info in a modify undo log record.
1302 @param[in] node row undo node
1303 @param[in] undo_rec record to purge
1304 @param[in] thr query thread
1305 @param[in] thd worker thread
1306 @param[out] updated_extern true if an externally stored field was
1307 updated
1308 @return true if purge operation required */
1309 static
1310 bool
1311 row_purge_parse_undo_reccxx . . $ row_purge_parse_undo_rec(8dd9c3092cb63e7a).(
1312 purge_node_tcxx . . $ purge_node_t#* node,
1313 const trx_undo_rec_tcxx . . $ trx_undo_rec_t#* undo_rec,
1314 que_thr_tcxx . . $ que_thr_t#* thr,
1315 const THDcxx . . $ THD#* thd,
1316 bool* updated_extern)
1317 {
1318 dict_index_tcxx . . $ dict_index_t#* clust_index;
1319 undo_no_tcxx . . $ undo_no_t# undo_no;
1320 table_id_tcxx . . $ table_id_t# table_id;
1321 roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr;
1322 bytecxx . . $ byte# info_bits;
1323 bytecxx . . $ byte# type;
1324
1325 const bytecxx . . $ byte#* ptr = trx_undo_rec_get_parscxx . . $ trx_undo_rec_get_pars(b561dee8b4b160a7).(
1326 undo_rec, &type, &node->cmpl_infocxx . . $ purge_node_t#cmpl_info.,
1327 updated_extern, &undo_no, &table_id);
1328
1329 node->rec_typecxx . . $ purge_node_t#rec_type. = type;
1330
1331 switch (type) {
1332 case TRX_UNDO_RENAME_TABLEcxx . . $ TRX_UNDO_RENAME_TABLE.:
1333 return false;
1334 case TRX_UNDO_EMPTYcxx . . $ `storage/innobase/include/trx0rec.h:273:9`!:
1335 case TRX_UNDO_INSERT_METADATAcxx . . $ TRX_UNDO_INSERT_METADATA.:
1336 case TRX_UNDO_INSERT_RECcxx . . $ `storage/innobase/include/trx0rec.h:260:9`!:
1337 /* These records do not store any transaction identifier. */
1338 node->trx_idcxx . . $ purge_node_t#trx_id. = TRX_ID_MAXcxx . . $ `storage/innobase/include/dict0types.h:55:9`!;
1339 break;
1340 default:
1341 #ifdef UNIV_DEBUG
1342 ut_ad("unknown undo log record type" == 0);
1343 return false;
1344 case TRX_UNDO_UPD_DEL_REC:
1345 case TRX_UNDO_UPD_EXIST_REC:
1346 case TRX_UNDO_DEL_MARK_REC:
1347 #endif /* UNIV_DEBUG */
1348 ptr = trx_undo_update_rec_get_sys_colscxx . . $ trx_undo_update_rec_get_sys_cols(2cecf27af2ad08af).(ptr, &node->trx_idcxx . . $ purge_node_t#trx_id.,
1349 &roll_ptr, &info_bits);
1350 break;
1351 }
1352
1353 node->ptcxx . . $ purge_node_t#pt. =cxx . . $ purge_table#`operator=`(a25edc242f4397ee). node->tablescxx . . $ purge_node_t#tables.[cxx . . $ std/unordered_map#`operator[]`(4f10b6009f0ee734).table_id];
1354 if (!node->ptcxx . . $ purge_node_t#pt..tablecxx . . $ purge_table#table.) {
1355 return false;
1356 }
1357
1358 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!node->pt.table->is_temporary());
1359
1360 if (TABLEcxx . . $ TABLE# *maria_table = node->ptcxx . . $ purge_node_t#pt..get_maria_tablecxx . . $ purge_table#get_maria_table(198d021c806d525d).()) {
1361 maria_table->in_usecxx . . $ TABLE#in_use. = (THDcxx . . $ THD#*)thd;
1362 }
1363
1364 clust_index = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(node->pt.table);
1365
1366 if (clust_index->is_corruptedcxx . . $ dict_index_t#is_corrupted(50ce9a9e25b4a850).()) {
1367 /* The table was corrupt in the data dictionary.
1368 dict_set_corrupted() works on an index, and
1369 we do not have an index to call it with. */
1370 DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(table_id == node->pt.table->id);
1371 return false;
1372 }
1373
1374 switch (type) {
1375 case TRX_UNDO_INSERT_METADATAcxx . . $ TRX_UNDO_INSERT_METADATA.:
1376 node->refcxx . . $ purge_node_t#ref. = &trx_undo_metadatacxx . . $ trx_undo_metadata.;
1377 return true;
1378 case TRX_UNDO_EMPTYcxx . . $ `storage/innobase/include/trx0rec.h:273:9`!:
1379 node->refcxx . . $ purge_node_t#ref. = nullptr;
1380 return true;
1381 }
1382
1383 ptr = trx_undo_rec_get_row_refcxx . . $ trx_undo_rec_get_row_ref(b795372261dac20e).(ptr, clust_index, &(node->refcxx . . $ purge_node_t#ref.),
1384 node->heapcxx . . $ purge_node_t#heap.);
1385
1386 if (type == TRX_UNDO_INSERT_RECcxx . . $ `storage/innobase/include/trx0rec.h:260:9`!) {
1387 return(true);
1388 }
1389
1390 ptr = trx_undo_update_rec_get_updatecxx . . $ trx_undo_update_rec_get_update(b86b5c4f542f6411).(ptr, clust_index, type,
1391 node->trx_idcxx . . $ purge_node_t#trx_id.,
1392 roll_ptr, info_bits,
1393 node->heapcxx . . $ purge_node_t#heap., &(node->updatecxx . . $ purge_node_t#update.));
1394
1395 /* Read to the partial row the fields that occur in indexes */
1396
1397 if (!(node->cmpl_infocxx . . $ purge_node_t#cmpl_info. & UPD_NODE_NO_ORD_CHANGEcxx . . $ `storage/innobase/include/row0upd.h:550:9`!)) {
1398 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(node->update->info_bits & REC_INFO_MIN_REC_FLAG));
1399 ptr = row_purge_get_partialcxx . . $ row_purge_get_partial(ac8845d2ecaa005a).(ptr, *clust_index, node);
1400 } else if (node->updatecxx . . $ purge_node_t#update.->info_bitscxx . . $ upd_t#info_bits. & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!) {
1401 node->refcxx . . $ purge_node_t#ref. = &trx_undo_metadatacxx . . $ trx_undo_metadata.;
1402 }
1403
1404 return(true);
1405 }
1406
1407 /** Purges the parsed record.
1408 @param[in] node row purge node
1409 @param[in] undo_rec record to purge
1410 @param[in] thr query thread
1411 @param[in] updated_extern whether external columns were updated
1412 @return true if purged, false if skipped */
1413 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
1414 bool
1415 row_purge_recordcxx . . $ row_purge_record(1dee1932094d8ac4).(
1416 purge_node_tcxx . . $ purge_node_t#* node,
1417 const trx_undo_rec_tcxx . . $ trx_undo_rec_t#* undo_rec,
1418 const que_thr_tcxx . . $ que_thr_t#*thr,
1419 bool updated_extern)
1420 {
1421 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!node->found_clust);
1422 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!node->pt.table->skip_alter_undo);
1423 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!trx_undo_roll_ptr_is_insert(node->roll_ptr));
1424
1425 node->indexcxx . . $ purge_node_t#index. = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(
1426 dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(node->pt.table));
1427
1428 bool purged = true;
1429
1430 switch (node->rec_typecxx . . $ purge_node_t#rec_type.) {
1431 case TRX_UNDO_EMPTYcxx . . $ `storage/innobase/include/trx0rec.h:273:9`!:
1432 break;
1433 case TRX_UNDO_DEL_MARK_RECcxx . . $ `storage/innobase/include/trx0rec.h:266:9`!:
1434 purged = row_purge_del_markcxx . . $ row_purge_del_mark(f21dbde4c7c4a176).(node);
1435 if (purged) {
1436 if (node->ptcxx . . $ purge_node_t#pt..tablecxx . . $ purge_table#table.->stat_initializedcxx . . $ dict_table_t#stat_initialized(3482b152b9333168).()
1437 && srv_stats_include_delete_markedcxx . . $ srv_stats_include_delete_marked.) {
1438 dict_stats_update_if_neededcxx . . $ dict_stats_update_if_needed(abb00c7c94814f8d).(
1439 node->ptcxx . . $ purge_node_t#pt..tablecxx . . $ purge_table#table., *thr->graphcxx . . $ que_thr_t#graph.->trxcxx . . $ que_fork_t#trx.);
1440 }
1441 MONITOR_INCcxx . . $ `storage/innobase/include/srv0mon.h:512:9`!(MONITOR_N_DEL_ROW_PURGE);
1442 }
1443 break;
1444 case TRX_UNDO_INSERT_METADATAcxx . . $ TRX_UNDO_INSERT_METADATA.:
1445 case TRX_UNDO_INSERT_RECcxx . . $ `storage/innobase/include/trx0rec.h:260:9`!:
1446 node->roll_ptrcxx . . $ purge_node_t#roll_ptr. |= 1ULL << ROLL_PTR_INSERT_FLAG_POScxx . . $ `storage/innobase/include/trx0undo.h:33:9`!;
1447 /* fall through */
1448 default:
1449 if (!updated_extern) {
1450 break;
1451 }
1452 /* fall through */
1453 case TRX_UNDO_UPD_EXIST_RECcxx . . $ `storage/innobase/include/trx0rec.h:261:9`!:
1454 row_purge_upd_exist_or_externcxx . . $ row_purge_upd_exist_or_extern(72ec3d860c675492).(thr, node, undo_rec);
1455 MONITOR_INCcxx . . $ `storage/innobase/include/srv0mon.h:512:9`!(MONITOR_N_UPD_EXIST_EXTERN);
1456 break;
1457 }
1458
1459 if (node->found_clustcxx . . $ purge_node_t#found_clust.) {
1460 node->found_clustcxx . . $ purge_node_t#found_clust. = false;
1461 btr_pcur_closecxx . . $ btr_pcur_close(57c44ef9c177cfb0).(&node->pcurcxx . . $ purge_node_t#pcur.);
1462 }
1463
1464 return(purged);
1465 }
1466
1467 /***********************************************************//**
1468 Fetches an undo log record and does the purge for the recorded operation.
1469 If none left, or the current purge completed, returns the control to the
1470 parent node, which is always a query thread node. */
1471 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull))
1472 void
1473 row_purgecxx . . $ row_purge(8714fe818dbccf74).(
1474 /*======*/
1475 purge_node_tcxx . . $ purge_node_t#* node, /*!< in: row purge node */
1476 const trx_undo_rec_tcxx . . $ trx_undo_rec_t#* undo_rec, /*!< in: record to purge */
1477 que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread */
1478 const THDcxx . . $ THD#* thd) /*!< in: Worker thread */
1479 {
1480 if (undo_rec != reinterpret_cast<trx_undo_rec_tcxx . . $ trx_undo_rec_t#*>(-1)) {
1481 bool updated_extern;
1482
1483 while (row_purge_parse_undo_reccxx . . $ row_purge_parse_undo_rec(8dd9c3092cb63e7a).(node, undo_rec, thr,
1484 thd, &updated_extern)) {
1485
1486 bool purged = row_purge_recordcxx . . $ row_purge_record(1dee1932094d8ac4).(
1487 node, undo_rec, thr, updated_extern);
1488
1489 if (purged
1490 || srv_shutdown_statecxx . . $ srv_shutdown_state. > SRV_SHUTDOWN_INITIATEDcxx . . $ SRV_SHUTDOWN_INITIATED.) {
1491 return;
1492 }
1493
1494 /* Retry the purge in a second. */
1495 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(1));
1496 }
1497 }
1498 }
1499
1500 inline void purge_node_tcxx . . $ purge_node_t#::startcxx . . $ purge_node_t#start(49f6e7a06ebc5aa8).()
1501 {
1502 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(in_progress);
1503 DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(common.type == QUE_NODE_PURGE);
1504
1505 rowcxx . . $ purge_node_t#row.= nullptr;
1506 refcxx . . $ purge_node_t#ref.= nullptr;
1507 indexcxx . . $ purge_node_t#index.= nullptr;
1508 updatecxx . . $ purge_node_t#update.= nullptr;
1509 found_clustcxx . . $ purge_node_t#found_clust.= false;
1510 rec_typecxx . . $ purge_node_t#rec_type.= 0;
1511 cmpl_infocxx . . $ purge_node_t#cmpl_info.= 0;
1512 }
1513
1514 inline void purge_sys_tcxx . . $ purge_sys_t#::reset_worker_thdcxx . . $ purge_sys_t#reset_worker_thd(db60e84b6837d0f0).(THDcxx . . $ THD# *thd) const noexcept
1515 {
1516 /* Only reset THD for worker threads, not the coordinator.
1517 The coordinator thread opens TABLE* objects in
1518 trx_purge_attach_undo_recs() and stores them in
1519 purge_node_t->tables. These TABLE* objects must remain open until
1520 the entire purge batch completes. Coordinator thread could
1521 close the tables prematurely if it calls reset_thd()
1522 The coordinator handles cleanup centrally in trx_purge() after all
1523 purge_node_t entries are processed. Worker threads have their own
1524 THD lifecycle and must call reset_thd() to clean up their
1525 thread-local resources. */
1526 if (thd != coordinator_thdcxx . . $ purge_sys_t#coordinator_thd.)
1527 reset_thdcxx . . $ reset_thd(4b9aaf75000f3009).(thd);
1528 }
1529
1530 /** Reset the state at end
1531 @return the query graph parent */
1532 inline que_node_tcxx . . $ que_node_t# *purge_node_tcxx . . $ purge_node_t#::endcxx . . $ purge_node_t#end(b0ad8147fc699c91).(THDcxx . . $ THD# *thd)
1533 {
1534 DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(common.type == QUE_NODE_PURGE);
1535 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(undo_recs.empty());
1536 ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(in_progress= false);
1537 purge_syscxx . . $ purge_sys..reset_worker_thdcxx . . $ purge_sys_t#reset_worker_thd(db60e84b6837d0f0).(thd);
1538 #ifndef DBUG_OFFcxx . . $ `<built-in>:492:9`!
1539 static_cast<MDL_context*>(thd_mdl_context(thd))->lock_warrant= nullptr;
1540 #endif
1541 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(heapcxx . . $ purge_node_t#heap.);
1542 return commoncxx . . $ purge_node_t#common..parentcxx . . $ que_common_t#parent.;
1543 }
1544
1545
1546 /***********************************************************//**
1547 Does the purge operation.
1548 @return query thread to run next */
1549 que_thr_tcxx . . $ que_thr_t#*
1550 row_purge_stepcxx . . $ row_purge_step(e73e5dc3217c6744).(
1551 /*===========*/
1552 que_thr_tcxx . . $ que_thr_t#* thr) /*!< in: query thread */
1553 {
1554 const THDcxx . . $ THD# *thd = current_thdcxx . . $ `sql/mysqld.h:916:9`!;
1555 purge_node_tcxx . . $ purge_node_t#* node;
1556
1557 node = static_cast<purge_node_tcxx . . $ purge_node_t#*>(thr->run_nodecxx . . $ que_thr_t#run_node.);
1558
1559 node->startcxx . . $ purge_node_t#start(49f6e7a06ebc5aa8).();
1560
1561 while (!node->undo_recscxx . . $ purge_node_t#undo_recs..emptycxx . . $ std/queue#empty(50ce9a9e25b4a850).()) {
1562 trx_purge_rec_tcxx . . $ trx_purge_rec_t# purge_rec = node->undo_recscxx . . $ purge_node_t#undo_recs..frontcxx . . $ std/queue#front(d8c1a3bbdff15733).();
1563 node->undo_recscxx . . $ purge_node_t#undo_recs..popcxx . . $ std/queue#pop(49f6e7a06ebc5aa8).();
1564 node->roll_ptrcxx . . $ purge_node_t#roll_ptr. = purge_rec.roll_ptrcxx . . $ trx_purge_rec_t#roll_ptr.;
1565 row_purgecxx . . $ row_purge(8714fe818dbccf74).(node, purge_rec.undo_reccxx . . $ trx_purge_rec_t#undo_rec., thr, thd);
1566 }
1567
1568 thr->run_nodecxx . . $ que_thr_t#run_node. = node->endcxx . . $ purge_node_t#end(b0ad8147fc699c91).(current_thdcxx . . $ `sql/mysqld.h:916:9`!);
1569 return(thr);
1570 }
1571
1572 #ifdef UNIV_DEBUG
1573 /***********************************************************//**
1574 Validate the persisent cursor. The purge node has two references
1575 to the clustered index record - one via the ref member, and the
1576 other via the persistent cursor. These two references must match
1577 each other if the found_clust flag is set.
1578 @return true if the stored copy of persistent cursor is consistent
1579 with the ref member.*/
1580 bool
1581 purge_node_t::validate_pcur()
1582 {
1583 if (!found_clust) {
1584 return(true);
1585 }
1586
1587 if (index == NULL) {
1588 return(true);
1589 }
1590
1591 if (index->type == DICT_FTS) {
1592 return(true);
1593 }
1594
1595 if (!pcur.old_rec) {
1596 return(true);
1597 }
1598
1599 dict_index_t* clust_index = pcur.index();
1600
1601 rec_offs* offsets = rec_get_offsets(
1602 pcur.old_rec, clust_index, NULL, pcur.old_n_core_fields,
1603 pcur.old_n_fields, &heap);
1604
1605 /* Here we are comparing the purge ref record and the stored initial
1606 part in persistent cursor. Both cases we store n_uniq fields of the
1607 cluster index and so it is fine to do the comparison. We note this
1608 dependency here as pcur and ref belong to different modules. */
1609 int st = cmp_dtuple_rec(ref, pcur.old_rec, clust_index, offsets);
1610
1611 if (st != 0) {
1612 ib::error() << "Purge node pcur validation failed";
1613 ib::error() << rec_printer(ref).str();
1614 ib::error() << rec_printer(pcur.old_rec, offsets).str();
1615 return(false);
1616 }
1617
1618 return(true);
1619 }
1620
1621 #endif /* UNIV_DEBUG */