#include "row0uins.h"#include "dict0dict.h"#include "dict0boot.h"#include "dict0crea.h"#include "trx0undo.h"#include "trx0roll.h"#include "btr0btr.h"#include "mach0data.h"#include "row0undo.h"#include "row0vers.h"#include "trx0trx.h"#include "trx0rec.h"#include "row0row.h"#include "row0upd.h"#include "que0que.h"#include "ibuf0ibuf.h"#include "log0log.h"Include dependency graph for row0uins.c:

Go to the source code of this file.
Functions | |
| static ulint | row_undo_ins_remove_clust_rec (undo_node_t *node) |
| static ulint | row_undo_ins_remove_sec_low (ulint mode, dict_index_t *index, dtuple_t *entry) |
| static ulint | row_undo_ins_remove_sec (dict_index_t *index, dtuple_t *entry) |
| static void | row_undo_ins_parse_undo_rec (undo_node_t *node) |
| ulint | row_undo_ins (undo_node_t *node) |
| ulint row_undo_ins | ( | undo_node_t * | node | ) |
Definition at line 263 of file row0uins.c.
References DB_SUCCESS, dict_table_get_first_index(), dict_table_get_next_index(), err, FALSE, undo_node_struct::heap, undo_node_struct::index, NULL, undo_node_struct::row, row_build_index_entry(), row_undo_ins_parse_undo_rec(), row_undo_ins_remove_clust_rec(), row_undo_ins_remove_sec(), row_undo_search_clust_to_pcur(), undo_node_struct::state, undo_node_struct::table, undo_node_struct::trx, trx_undo_rec_release(), undo_node_struct::undo_no, UNDO_NODE_INSERT, and ut_ad.
Referenced by row_undo().
00265 : DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ 00266 undo_node_t* node) /* in: row undo node */ 00267 { 00268 dtuple_t* entry; 00269 ibool found; 00270 ulint err; 00271 00272 ut_ad(node); 00273 ut_ad(node->state == UNDO_NODE_INSERT); 00274 00275 row_undo_ins_parse_undo_rec(node); 00276 00277 if (node->table == NULL) { 00278 found = FALSE; 00279 } else { 00280 found = row_undo_search_clust_to_pcur(node); 00281 } 00282 00283 if (!found) { 00284 trx_undo_rec_release(node->trx, node->undo_no); 00285 00286 return(DB_SUCCESS); 00287 } 00288 00289 node->index = dict_table_get_next_index( 00290 dict_table_get_first_index(node->table)); 00291 00292 while (node->index != NULL) { 00293 entry = row_build_index_entry(node->row, node->index, 00294 node->heap); 00295 err = row_undo_ins_remove_sec(node->index, entry); 00296 00297 if (err != DB_SUCCESS) { 00298 00299 return(err); 00300 } 00301 00302 node->index = dict_table_get_next_index(node->index); 00303 } 00304 00305 err = row_undo_ins_remove_clust_rec(node); 00306 00307 return(err); 00308 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void row_undo_ins_parse_undo_rec | ( | undo_node_t * | node | ) | [static] |
Definition at line 218 of file row0uins.c.
References dict_table_get_first_index(), dict_table_get_on_id(), undo_node_struct::heap, dict_table_struct::ibd_file_missing, NULL, undo_node_struct::rec_type, undo_node_struct::ref, undo_node_struct::table, undo_node_struct::trx, TRX_UNDO_INSERT_REC, trx_undo_rec_get_pars(), trx_undo_rec_get_row_ref(), undo_node_struct::undo_rec, and ut_ad.
Referenced by row_undo_ins().
00220 : row undo node */ 00221 { 00222 dict_index_t* clust_index; 00223 byte* ptr; 00224 dulint undo_no; 00225 dulint table_id; 00226 ulint type; 00227 ulint dummy; 00228 ibool dummy_extern; 00229 00230 ut_ad(node); 00231 00232 ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &dummy, 00233 &dummy_extern, &undo_no, &table_id); 00234 ut_ad(type == TRX_UNDO_INSERT_REC); 00235 node->rec_type = type; 00236 00237 node->table = dict_table_get_on_id(table_id, node->trx); 00238 00239 if (node->table == NULL) { 00240 00241 return; 00242 } 00243 00244 if (node->table->ibd_file_missing) { 00245 /* We skip undo operations to missing .ibd files */ 00246 node->table = NULL; 00247 00248 return; 00249 } 00250 00251 clust_index = dict_table_get_first_index(node->table); 00252 00253 ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref), 00254 node->heap); 00255 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint row_undo_ins_remove_clust_rec | ( | undo_node_t * | node | ) | [static] |
Definition at line 37 of file row0uins.c.
References btr_cur_optimistic_delete(), btr_cur_pessimistic_delete(), BTR_CUR_RETRY_DELETE_N_TIMES, BTR_CUR_RETRY_SLEEP_TIME, BTR_MODIFY_LEAF, BTR_MODIFY_TREE, btr_pcur_commit_specify_mtr(), btr_pcur_get_btr_cur(), btr_pcur_get_rec(), btr_pcur_restore_position(), DB_OUT_OF_FILE_SPACE, DB_SUCCESS, dict_drop_index_tree(), DICT_INDEXES_ID, err, FALSE, dict_table_struct::id, mtr_commit(), mtr_start(), os_thread_sleep(), undo_node_struct::pcur, undo_node_struct::table, TRUE, undo_node_struct::trx, trx_undo_rec_release(), undo_node_struct::undo_no, ut_a, and ut_dulint_cmp().
Referenced by row_undo_ins().
00039 : DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ 00040 undo_node_t* node) /* in: undo node */ 00041 { 00042 btr_cur_t* btr_cur; 00043 ibool success; 00044 ulint err; 00045 ulint n_tries = 0; 00046 mtr_t mtr; 00047 00048 mtr_start(&mtr); 00049 00050 success = btr_pcur_restore_position(BTR_MODIFY_LEAF, &(node->pcur), 00051 &mtr); 00052 ut_a(success); 00053 00054 if (ut_dulint_cmp(node->table->id, DICT_INDEXES_ID) == 0) { 00055 00056 /* Drop the index tree associated with the row in 00057 SYS_INDEXES table: */ 00058 00059 dict_drop_index_tree(btr_pcur_get_rec(&(node->pcur)), &mtr); 00060 00061 mtr_commit(&mtr); 00062 00063 mtr_start(&mtr); 00064 00065 success = btr_pcur_restore_position(BTR_MODIFY_LEAF, 00066 &(node->pcur), &mtr); 00067 ut_a(success); 00068 } 00069 00070 btr_cur = btr_pcur_get_btr_cur(&(node->pcur)); 00071 00072 success = btr_cur_optimistic_delete(btr_cur, &mtr); 00073 00074 btr_pcur_commit_specify_mtr(&(node->pcur), &mtr); 00075 00076 if (success) { 00077 trx_undo_rec_release(node->trx, node->undo_no); 00078 00079 return(DB_SUCCESS); 00080 } 00081 retry: 00082 /* If did not succeed, try pessimistic descent to tree */ 00083 mtr_start(&mtr); 00084 00085 success = btr_pcur_restore_position(BTR_MODIFY_TREE, 00086 &(node->pcur), &mtr); 00087 ut_a(success); 00088 00089 btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr); 00090 00091 /* The delete operation may fail if we have little 00092 file space left: TODO: easiest to crash the database 00093 and restart with more file space */ 00094 00095 if (err == DB_OUT_OF_FILE_SPACE 00096 && n_tries < BTR_CUR_RETRY_DELETE_N_TIMES) { 00097 00098 btr_pcur_commit_specify_mtr(&(node->pcur), &mtr); 00099 00100 n_tries++; 00101 00102 os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); 00103 00104 goto retry; 00105 } 00106 00107 btr_pcur_commit_specify_mtr(&(node->pcur), &mtr); 00108 00109 trx_undo_rec_release(node->trx, node->undo_no); 00110 00111 return(err); 00112 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint row_undo_ins_remove_sec | ( | dict_index_t * | index, | |
| dtuple_t * | entry | |||
| ) | [static] |
Definition at line 176 of file row0uins.c.
References BTR_CUR_RETRY_DELETE_N_TIMES, BTR_CUR_RETRY_SLEEP_TIME, BTR_MODIFY_LEAF, BTR_MODIFY_TREE, DB_SUCCESS, err, index(), os_thread_sleep(), and row_undo_ins_remove_sec_low().
Referenced by row_undo_ins().
00178 : DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ 00179 dict_index_t* index, /* in: index */ 00180 dtuple_t* entry) /* in: index entry to insert */ 00181 { 00182 ulint err; 00183 ulint n_tries = 0; 00184 00185 /* Try first optimistic descent to the B-tree */ 00186 00187 err = row_undo_ins_remove_sec_low(BTR_MODIFY_LEAF, index, entry); 00188 00189 if (err == DB_SUCCESS) { 00190 00191 return(err); 00192 } 00193 00194 /* Try then pessimistic descent to the B-tree */ 00195 retry: 00196 err = row_undo_ins_remove_sec_low(BTR_MODIFY_TREE, index, entry); 00197 00198 /* The delete operation may fail if we have little 00199 file space left: TODO: easiest to crash the database 00200 and restart with more file space */ 00201 00202 if (err != DB_SUCCESS && n_tries < BTR_CUR_RETRY_DELETE_N_TIMES) { 00203 00204 n_tries++; 00205 00206 os_thread_sleep(BTR_CUR_RETRY_SLEEP_TIME); 00207 00208 goto retry; 00209 } 00210 00211 return(err); 00212 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint row_undo_ins_remove_sec_low | ( | ulint | mode, | |
| dict_index_t * | index, | |||
| dtuple_t * | entry | |||
| ) | [static] |
Definition at line 118 of file row0uins.c.
References btr_cur_optimistic_delete(), btr_cur_pessimistic_delete(), BTR_MODIFY_LEAF, BTR_MODIFY_TREE, btr_pcur_close(), btr_pcur_get_btr_cur(), DB_FAIL, DB_SUCCESS, err, FALSE, index(), log_free_check(), mtr_commit(), mtr_start(), row_search_index_entry(), TRUE, and ut_ad.
Referenced by row_undo_ins_remove_sec().
00120 : DB_SUCCESS, DB_FAIL, or 00121 DB_OUT_OF_FILE_SPACE */ 00122 ulint mode, /* in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, 00123 depending on whether we wish optimistic or 00124 pessimistic descent down the index tree */ 00125 dict_index_t* index, /* in: index */ 00126 dtuple_t* entry) /* in: index entry to remove */ 00127 { 00128 btr_pcur_t pcur; 00129 btr_cur_t* btr_cur; 00130 ibool found; 00131 ibool success; 00132 ulint err; 00133 mtr_t mtr; 00134 00135 log_free_check(); 00136 mtr_start(&mtr); 00137 00138 found = row_search_index_entry(index, entry, mode, &pcur, &mtr); 00139 00140 btr_cur = btr_pcur_get_btr_cur(&pcur); 00141 00142 if (!found) { 00143 /* Not found */ 00144 00145 btr_pcur_close(&pcur); 00146 mtr_commit(&mtr); 00147 00148 return(DB_SUCCESS); 00149 } 00150 00151 if (mode == BTR_MODIFY_LEAF) { 00152 success = btr_cur_optimistic_delete(btr_cur, &mtr); 00153 00154 if (success) { 00155 err = DB_SUCCESS; 00156 } else { 00157 err = DB_FAIL; 00158 } 00159 } else { 00160 ut_ad(mode == BTR_MODIFY_TREE); 00161 00162 btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr); 00163 } 00164 00165 btr_pcur_close(&pcur); 00166 mtr_commit(&mtr); 00167 00168 return(err); 00169 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

