314
314
ulint mode) /*!< in: latch mode BTR_MODIFY_LEAF or
315
315
BTR_MODIFY_TREE */
324
enum row_search_result search_result;
326
326
log_free_check();
329
found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
331
329
btr_cur = btr_pcur_get_btr_cur(&pcur);
331
ut_ad(mode == BTR_MODIFY_TREE || mode == BTR_MODIFY_LEAF);
333
search_result = row_search_index_entry(index, entry, mode,
336
switch (UNIV_EXPECT(search_result, ROW_FOUND)) {
334
338
/* In crash recovery, the secondary index record may
335
339
be missing if the UPDATE did not have time to insert
336
340
the secondary index records before the crash. When we
341
345
before it has inserted all updated secondary index
342
346
records, then the undo will not find those records. */
344
btr_pcur_close(&pcur);
353
case ROW_NOT_DELETED_REF:
354
/* These are invalid outcomes, because the mode passed
355
to row_search_index_entry() did not include any of the
356
flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */
350
360
/* We should remove the index record if no prior version of the row,
448
460
dict_index_t* index, /*!< in: index */
449
461
const dtuple_t* entry) /*!< in: index entry */
454
ulint err = DB_SUCCESS;
455
big_rec_t* dummy_big_rec;
457
trx_t* trx = thr_get_trx(thr);
467
ulint err = DB_SUCCESS;
468
big_rec_t* dummy_big_rec;
470
trx_t* trx = thr_get_trx(thr);
471
enum row_search_result search_result;
459
473
/* Ignore indexes that are being created. */
460
474
if (UNIV_UNLIKELY(*index->name == TEMP_INDEX_PREFIX)) {
465
479
log_free_check();
468
if (UNIV_UNLIKELY(!row_search_index_entry(index, entry,
469
mode, &pcur, &mtr))) {
482
ut_ad(mode == BTR_MODIFY_TREE || mode == BTR_MODIFY_LEAF);
484
search_result = row_search_index_entry(index, entry, mode,
487
switch (search_result) {
489
case ROW_NOT_DELETED_REF:
490
/* These are invalid outcomes, because the mode passed
491
to row_search_index_entry() did not include any of the
492
flags BTR_INSERT, BTR_DELETE, or BTR_DELETE_MARK. */
470
495
fputs("InnoDB: error in sec index entry del undo in\n"
471
496
"InnoDB: ", stderr);
472
497
dict_index_name_print(stderr, trx, index);
482
507
"InnoDB: Submit a detailed bug report"
483
508
" to http://bugs.mysql.com\n", stderr);
485
btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
511
btr_cur = btr_pcur_get_btr_cur(&pcur);
487
512
err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG,
488
513
btr_cur, FALSE, thr, &mtr);
489
514
ut_a(err == DB_SUCCESS);
657
682
/* Build the newest version of the index entry */
658
683
entry = row_build_index_entry(node->row, node->ext,
661
/* NOTE that if we updated the fields of a
662
delete-marked secondary index record so that
663
alphabetically they stayed the same, e.g.,
664
'abc' -> 'aBc', we cannot return to the original
665
values because we do not know them. But this should
666
not cause problems because in row0sel.c, in queries
667
we always retrieve the clustered index record or an
668
earlier version of it, if the secondary index record
669
through which we do the search is delete-marked. */
671
err = row_undo_mod_del_mark_or_remove_sec(node, thr,
674
if (err != DB_SUCCESS) {
685
if (UNIV_UNLIKELY(!entry)) {
686
/* The server must have crashed in
687
row_upd_clust_rec_by_insert(), in
688
row_ins_index_entry_low() before
689
btr_store_big_rec_extern_fields()
690
has written the externally stored columns
691
(BLOBs) of the new clustered index entry. */
693
/* The table must be in DYNAMIC or COMPRESSED
694
format. REDUNDANT and COMPACT formats
695
store a local 768-byte prefix of each
696
externally stored column. */
697
ut_a(dict_table_get_format(index->table)
698
>= DICT_TF_FORMAT_ZIP);
700
/* This is only legitimate when
701
rolling back an incomplete transaction
702
after crash recovery. */
703
ut_a(thr_get_trx(thr)->is_recovered);
705
/* The server must have crashed before
706
completing the insert of the new
707
clustered index entry and before
708
inserting to the secondary indexes.
709
Because node->row was not yet written
710
to this index, we can ignore it. But
711
we must restore node->undo_row. */
713
/* NOTE that if we updated the fields of a
714
delete-marked secondary index record so that
715
alphabetically they stayed the same, e.g.,
716
'abc' -> 'aBc', we cannot return to the
717
original values because we do not know them.
718
But this should not cause problems because
719
in row0sel.c, in queries we always retrieve
720
the clustered index record or an earlier
721
version of it, if the secondary index record
722
through which we do the search is
725
err = row_undo_mod_del_mark_or_remove_sec(
726
node, thr, index, entry);
727
if (err != DB_SUCCESS) {
733
mem_heap_empty(heap);
680
736
/* We may have to update the delete mark in the