~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/row/row0purge.c

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
/************************************************************************
31
31
Creates a purge node to a query graph. */
32
 
 
 
32
UNIV_INTERN
33
33
purge_node_t*
34
34
row_purge_node_create(
35
35
/*==================*/
102
102
        rec_t*          rec;
103
103
        mem_heap_t*     heap            = NULL;
104
104
        ulint           offsets_[REC_OFFS_NORMAL_SIZE];
105
 
        *offsets_ = (sizeof offsets_) / sizeof *offsets_;
 
105
        rec_offs_init(offsets_);
106
106
 
107
107
        index = dict_table_get_first_index(node->table);
108
108
 
227
227
                /* Not found */
228
228
 
229
229
                /* fputs("PURGE:........sec entry not found\n", stderr); */
230
 
                /* dtuple_print(entry); */
 
230
                /* dtuple_print(stderr, entry); */
231
231
 
232
232
                btr_pcur_close(&pcur);
233
233
                mtr_commit(&mtr);
266
266
                        ut_ad(mode == BTR_MODIFY_TREE);
267
267
                        btr_cur_pessimistic_delete(&err, FALSE, btr_cur,
268
268
                                                   FALSE, &mtr);
269
 
                        if (err == DB_SUCCESS) {
270
 
                                success = TRUE;
271
 
                        } else if (err == DB_OUT_OF_FILE_SPACE) {
272
 
                                success = FALSE;
273
 
                        } else {
274
 
                                ut_error;
275
 
                        }
 
269
                        success = err == DB_SUCCESS;
 
270
                        ut_a(success || err == DB_OUT_OF_FILE_SPACE);
276
271
                }
277
272
        }
278
273
 
342
337
                index = node->index;
343
338
 
344
339
                /* Build the index entry */
345
 
                entry = row_build_index_entry(node->row, index, heap);
346
 
 
 
340
                entry = row_build_index_entry(node->row, NULL, index, heap);
 
341
                ut_a(entry);
347
342
                row_purge_remove_sec_if_poss(node, index, entry);
348
343
 
349
344
                node->index = dict_table_get_next_index(node->index);
366
361
        mem_heap_t*     heap;
367
362
        dtuple_t*       entry;
368
363
        dict_index_t*   index;
369
 
        upd_field_t*    ufield;
370
364
        ibool           is_insert;
371
365
        ulint           rseg_id;
372
366
        ulint           page_no;
373
367
        ulint           offset;
374
 
        ulint           internal_offset;
375
 
        byte*           data_field;
376
 
        ulint           data_field_len;
377
368
        ulint           i;
378
369
        mtr_t           mtr;
379
370
 
392
383
                if (row_upd_changes_ord_field_binary(NULL, node->index,
393
384
                                                     node->update)) {
394
385
                        /* Build the older version of the index entry */
395
 
                        entry = row_build_index_entry(node->row, index, heap);
396
 
 
 
386
                        entry = row_build_index_entry(node->row, NULL,
 
387
                                                      index, heap);
 
388
                        ut_a(entry);
397
389
                        row_purge_remove_sec_if_poss(node, index, entry);
398
390
                }
399
391
 
406
398
        /* Free possible externally stored fields */
407
399
        for (i = 0; i < upd_get_n_fields(node->update); i++) {
408
400
 
409
 
                ufield = upd_get_nth_field(node->update, i);
410
 
 
411
 
                if (ufield->extern_storage) {
 
401
                const upd_field_t*      ufield
 
402
                        = upd_get_nth_field(node->update, i);
 
403
 
 
404
                if (dfield_is_ext(&ufield->new_val)) {
 
405
                        buf_block_t*    block;
 
406
                        ulint           internal_offset;
 
407
                        byte*           data_field;
 
408
 
412
409
                        /* We use the fact that new_val points to
413
410
                        node->undo_rec and get thus the offset of
414
 
                        dfield data inside the unod record. Then we
 
411
                        dfield data inside the undo record. Then we
415
412
                        can calculate from node->roll_ptr the file
416
413
                        address of the new_val data */
417
414
 
418
 
                        internal_offset = ((byte*)ufield->new_val.data)
 
415
                        internal_offset
 
416
                                = ((const byte*)
 
417
                                   dfield_get_data(&ufield->new_val))
419
418
                                - node->undo_rec;
420
419
 
421
420
                        ut_a(internal_offset < UNIV_PAGE_SIZE);
446
445
                        /* We assume in purge of externally stored fields
447
446
                        that the space id of the undo log record is 0! */
448
447
 
449
 
                        data_field = buf_page_get(0, page_no, RW_X_LATCH, &mtr)
450
 
                                + offset + internal_offset;
451
 
 
 
448
                        block = buf_page_get(0, 0, page_no, RW_X_LATCH, &mtr);
452
449
#ifdef UNIV_SYNC_DEBUG
453
 
                        buf_page_dbg_add_level(buf_frame_align(data_field),
454
 
                                               SYNC_TRX_UNDO_PAGE);
 
450
                        buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
455
451
#endif /* UNIV_SYNC_DEBUG */
456
 
 
457
 
                        data_field_len = ufield->new_val.len;
458
 
 
459
 
                        btr_free_externally_stored_field(index, data_field,
460
 
                                                         data_field_len,
461
 
                                                         FALSE, &mtr);
 
452
                        data_field = buf_block_get_frame(block)
 
453
                                + offset + internal_offset;
 
454
 
 
455
                        ut_a(dfield_get_len(&ufield->new_val)
 
456
                             >= BTR_EXTERN_FIELD_REF_SIZE);
 
457
                        btr_free_externally_stored_field(
 
458
                                index,
 
459
                                data_field + dfield_get_len(&ufield->new_val)
 
460
                                - BTR_EXTERN_FIELD_REF_SIZE,
 
461
                                NULL, NULL, NULL, 0, FALSE, &mtr);
462
462
                        mtr_commit(&mtr);
463
463
                }
464
464
        }
528
528
 
529
529
        if (node->table == NULL) {
530
530
                /* The table has been dropped: no need to do purge */
531
 
 
 
531
err_exit:
532
532
                row_mysql_unfreeze_data_dictionary(trx);
533
 
 
534
533
                return(FALSE);
535
534
        }
536
535
 
539
538
 
540
539
                node->table = NULL;
541
540
 
542
 
                row_mysql_unfreeze_data_dictionary(trx);
543
 
 
544
 
                return(FALSE);
 
541
                goto err_exit;
545
542
        }
546
543
 
547
544
        clust_index = dict_table_get_first_index(node->table);
549
546
        if (clust_index == NULL) {
550
547
                /* The table was corrupt in the data dictionary */
551
548
 
552
 
                row_mysql_unfreeze_data_dictionary(trx);
553
 
 
554
 
                return(FALSE);
 
549
                goto err_exit;
555
550
        }
556
551
 
557
552
        ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref),
565
560
 
566
561
        if (!(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
567
562
                ptr = trx_undo_rec_get_partial_row(ptr, clust_index,
568
 
                                                   &(node->row), node->heap);
 
563
                                                   &node->row, node->heap);
569
564
        }
570
565
 
571
566
        return(TRUE);
649
644
/***************************************************************
650
645
Does the purge operation for a single undo log record. This is a high-level
651
646
function used in an SQL execution graph. */
652
 
 
 
647
UNIV_INTERN
653
648
que_thr_t*
654
649
row_purge_step(
655
650
/*===========*/