~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/row/row0umod.c

  • Committer: Monty Taylor
  • Date: 2010-11-26 22:50:54 UTC
  • mfrom: (1953.1.6 build)
  • Revision ID: mordred@inaugust.com-20101126225054-sg90svw8579t5p3i
Stewart - InnoDB 1.1.1
Monty - Fixed some autoconf tests which were returning false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
314
314
        ulint           mode)   /*!< in: latch mode BTR_MODIFY_LEAF or
315
315
                                BTR_MODIFY_TREE */
316
316
{
317
 
        ibool           found;
318
 
        btr_pcur_t      pcur;
319
 
        btr_cur_t*      btr_cur;
320
 
        ibool           success;
321
 
        ibool           old_has;
322
 
        ulint           err;
323
 
        mtr_t           mtr;
324
 
        mtr_t           mtr_vers;
 
317
        btr_pcur_t              pcur;
 
318
        btr_cur_t*              btr_cur;
 
319
        ibool                   success;
 
320
        ibool                   old_has;
 
321
        ulint                   err;
 
322
        mtr_t                   mtr;
 
323
        mtr_t                   mtr_vers;
 
324
        enum row_search_result  search_result;
325
325
 
326
326
        log_free_check();
327
327
        mtr_start(&mtr);
328
328
 
329
 
        found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
330
 
 
331
329
        btr_cur = btr_pcur_get_btr_cur(&pcur);
332
330
 
333
 
        if (!found) {
 
331
        ut_ad(mode == BTR_MODIFY_TREE || mode == BTR_MODIFY_LEAF);
 
332
 
 
333
        search_result = row_search_index_entry(index, entry, mode,
 
334
                                               &pcur, &mtr);
 
335
 
 
336
        switch (UNIV_EXPECT(search_result, ROW_FOUND)) {
 
337
        case ROW_NOT_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. */
343
347
 
344
 
                btr_pcur_close(&pcur);
345
 
                mtr_commit(&mtr);
346
 
 
347
 
                return(DB_SUCCESS);
 
348
                err = DB_SUCCESS;
 
349
                goto func_exit;
 
350
        case ROW_FOUND:
 
351
                break;
 
352
        case ROW_BUFFERED:
 
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. */
 
357
                ut_error;
348
358
        }
349
359
 
350
360
        /* We should remove the index record if no prior version of the row,
394
404
        }
395
405
 
396
406
        btr_pcur_commit_specify_mtr(&(node->pcur), &mtr_vers);
 
407
 
 
408
func_exit:
397
409
        btr_pcur_close(&pcur);
398
410
        mtr_commit(&mtr);
399
411
 
448
460
        dict_index_t*   index,  /*!< in: index */
449
461
        const dtuple_t* entry)  /*!< in: index entry */
450
462
{
451
 
        mem_heap_t*     heap;
452
 
        btr_pcur_t      pcur;
453
 
        upd_t*          update;
454
 
        ulint           err             = DB_SUCCESS;
455
 
        big_rec_t*      dummy_big_rec;
456
 
        mtr_t           mtr;
457
 
        trx_t*          trx             = thr_get_trx(thr);
 
463
        mem_heap_t*             heap;
 
464
        btr_pcur_t              pcur;
 
465
        btr_cur_t*              btr_cur;
 
466
        upd_t*                  update;
 
467
        ulint                   err             = DB_SUCCESS;
 
468
        big_rec_t*              dummy_big_rec;
 
469
        mtr_t                   mtr;
 
470
        trx_t*                  trx             = thr_get_trx(thr);
 
471
        enum row_search_result  search_result;
458
472
 
459
473
        /* Ignore indexes that are being created. */
460
474
        if (UNIV_UNLIKELY(*index->name == TEMP_INDEX_PREFIX)) {
465
479
        log_free_check();
466
480
        mtr_start(&mtr);
467
481
 
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);
 
483
 
 
484
        search_result = row_search_index_entry(index, entry, mode,
 
485
                                               &pcur, &mtr);
 
486
 
 
487
        switch (search_result) {
 
488
        case ROW_BUFFERED:
 
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. */
 
493
                ut_error;
 
494
        case ROW_NOT_FOUND:
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);
481
506
                fputs("\n"
482
507
                      "InnoDB: Submit a detailed bug report"
483
508
                      " to http://bugs.mysql.com\n", stderr);
484
 
        } else {
485
 
                btr_cur_t*      btr_cur = btr_pcur_get_btr_cur(&pcur);
486
 
 
 
509
                break;
 
510
        case ROW_FOUND:
 
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,
659
684
                                                      index, heap);
660
 
                        ut_a(entry);
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. */
670
 
 
671
 
                        err = row_undo_mod_del_mark_or_remove_sec(node, thr,
672
 
                                                                  index,
673
 
                                                                  entry);
674
 
                        if (err != DB_SUCCESS) {
675
 
                                mem_heap_free(heap);
676
 
 
677
 
                                return(err);
 
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. */
 
692
 
 
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);
 
699
 
 
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);
 
704
 
 
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. */
 
712
                        } else {
 
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
 
723
                                delete-marked. */
 
724
 
 
725
                                err = row_undo_mod_del_mark_or_remove_sec(
 
726
                                        node, thr, index, entry);
 
727
                                if (err != DB_SUCCESS) {
 
728
                                        mem_heap_free(heap);
 
729
 
 
730
                                        return(err);
 
731
                                }
 
732
 
 
733
                                mem_heap_empty(heap);
678
734
                        }
679
735
 
680
736
                        /* We may have to update the delete mark in the
683
739
                        the secondary index record if we updated its fields
684
740
                        but alphabetically they stayed the same, e.g.,
685
741
                        'abc' -> 'aBc'. */
686
 
                        mem_heap_empty(heap);
687
742
                        entry = row_build_index_entry(node->undo_row,
688
743
                                                      node->undo_ext,
689
744
                                                      index, heap);