~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

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
 
UNIV_INTERN
 
32
 
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
 
        rec_offs_init(offsets_);
 
105
        *offsets_ = (sizeof offsets_) / sizeof *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(stderr, entry); */
 
230
                /* dtuple_print(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
 
                        success = err == DB_SUCCESS;
270
 
                        ut_a(success || err == DB_OUT_OF_FILE_SPACE);
 
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
                        }
271
276
                }
272
277
        }
273
278
 
337
342
                index = node->index;
338
343
 
339
344
                /* Build the index entry */
340
 
                entry = row_build_index_entry(node->row, NULL, index, heap);
341
 
                ut_a(entry);
 
345
                entry = row_build_index_entry(node->row, index, heap);
 
346
 
342
347
                row_purge_remove_sec_if_poss(node, index, entry);
343
348
 
344
349
                node->index = dict_table_get_next_index(node->index);
361
366
        mem_heap_t*     heap;
362
367
        dtuple_t*       entry;
363
368
        dict_index_t*   index;
 
369
        upd_field_t*    ufield;
364
370
        ibool           is_insert;
365
371
        ulint           rseg_id;
366
372
        ulint           page_no;
367
373
        ulint           offset;
 
374
        ulint           internal_offset;
 
375
        byte*           data_field;
 
376
        ulint           data_field_len;
368
377
        ulint           i;
369
378
        mtr_t           mtr;
370
379
 
383
392
                if (row_upd_changes_ord_field_binary(NULL, node->index,
384
393
                                                     node->update)) {
385
394
                        /* Build the older version of the index entry */
386
 
                        entry = row_build_index_entry(node->row, NULL,
387
 
                                                      index, heap);
388
 
                        ut_a(entry);
 
395
                        entry = row_build_index_entry(node->row, index, heap);
 
396
 
389
397
                        row_purge_remove_sec_if_poss(node, index, entry);
390
398
                }
391
399
 
398
406
        /* Free possible externally stored fields */
399
407
        for (i = 0; i < upd_get_n_fields(node->update); i++) {
400
408
 
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
 
 
 
409
                ufield = upd_get_nth_field(node->update, i);
 
410
 
 
411
                if (ufield->extern_storage) {
409
412
                        /* We use the fact that new_val points to
410
413
                        node->undo_rec and get thus the offset of
411
 
                        dfield data inside the undo record. Then we
 
414
                        dfield data inside the unod record. Then we
412
415
                        can calculate from node->roll_ptr the file
413
416
                        address of the new_val data */
414
417
 
415
 
                        internal_offset
416
 
                                = ((const byte*)
417
 
                                   dfield_get_data(&ufield->new_val))
 
418
                        internal_offset = ((byte*)ufield->new_val.data)
418
419
                                - node->undo_rec;
419
420
 
420
421
                        ut_a(internal_offset < UNIV_PAGE_SIZE);
445
446
                        /* We assume in purge of externally stored fields
446
447
                        that the space id of the undo log record is 0! */
447
448
 
448
 
                        block = buf_page_get(0, 0, page_no, RW_X_LATCH, &mtr);
 
449
                        data_field = buf_page_get(0, page_no, RW_X_LATCH, &mtr)
 
450
                                + offset + internal_offset;
 
451
 
449
452
#ifdef UNIV_SYNC_DEBUG
450
 
                        buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
 
453
                        buf_page_dbg_add_level(buf_frame_align(data_field),
 
454
                                               SYNC_TRX_UNDO_PAGE);
451
455
#endif /* UNIV_SYNC_DEBUG */
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);
 
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);
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
 
err_exit:
 
531
 
532
532
                row_mysql_unfreeze_data_dictionary(trx);
 
533
 
533
534
                return(FALSE);
534
535
        }
535
536
 
538
539
 
539
540
                node->table = NULL;
540
541
 
541
 
                goto err_exit;
 
542
                row_mysql_unfreeze_data_dictionary(trx);
 
543
 
 
544
                return(FALSE);
542
545
        }
543
546
 
544
547
        clust_index = dict_table_get_first_index(node->table);
546
549
        if (clust_index == NULL) {
547
550
                /* The table was corrupt in the data dictionary */
548
551
 
549
 
                goto err_exit;
 
552
                row_mysql_unfreeze_data_dictionary(trx);
 
553
 
 
554
                return(FALSE);
550
555
        }
551
556
 
552
557
        ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref),
560
565
 
561
566
        if (!(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
562
567
                ptr = trx_undo_rec_get_partial_row(ptr, clust_index,
563
 
                                                   &node->row, node->heap);
 
568
                                                   &(node->row), node->heap);
564
569
        }
565
570
 
566
571
        return(TRUE);
644
649
/***************************************************************
645
650
Does the purge operation for a single undo log record. This is a high-level
646
651
function used in an SQL execution graph. */
647
 
UNIV_INTERN
 
652
 
648
653
que_thr_t*
649
654
row_purge_step(
650
655
/*===========*/