~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/row0upd.ic

  • Committer: Brian Aker
  • Date: 2009-07-11 19:23:04 UTC
  • mfrom: (1089.1.14 merge)
  • Revision ID: brian@gaz-20090711192304-ootijyl5yf9jq9kd
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************
2
 
Update of a row
3
 
 
4
 
(c) 1996 Innobase Oy
5
 
 
6
 
Created 12/27/1996 Heikki Tuuri
7
 
*******************************************************/
8
 
 
9
 
#include "mtr0log.h"
10
 
#include "trx0trx.h"
11
 
#include "trx0undo.h"
12
 
#include "row0row.h"
13
 
#include "btr0sea.h"
14
 
 
15
 
/*************************************************************************
16
 
Creates an update vector object. */
17
 
UNIV_INLINE
18
 
upd_t*
19
 
upd_create(
20
 
/*=======*/
21
 
                                /* out, own: update vector object */
22
 
        ulint           n,      /* in: number of fields */
23
 
        mem_heap_t*     heap)   /* in: heap from which memory allocated */
24
 
{
25
 
        upd_t*  update;
26
 
        ulint   i;
27
 
 
28
 
        update = mem_heap_alloc(heap, sizeof(upd_t));
29
 
 
30
 
        update->info_bits = 0;
31
 
        update->n_fields = n;
32
 
        update->fields = mem_heap_alloc(heap, sizeof(upd_field_t) * n);
33
 
 
34
 
        for (i = 0; i < n; i++) {
35
 
                update->fields[i].extern_storage = 0;
36
 
        }
37
 
 
38
 
        return(update);
39
 
}
40
 
 
41
 
/*************************************************************************
42
 
Returns the number of fields in the update vector == number of columns
43
 
to be updated by an update vector. */
44
 
UNIV_INLINE
45
 
ulint
46
 
upd_get_n_fields(
47
 
/*=============*/
48
 
                        /* out: number of fields */
49
 
        upd_t*  update) /* in: update vector */
50
 
{
51
 
        ut_ad(update);
52
 
 
53
 
        return(update->n_fields);
54
 
}
55
 
 
56
 
/*************************************************************************
57
 
Returns the nth field of an update vector. */
58
 
UNIV_INLINE
59
 
upd_field_t*
60
 
upd_get_nth_field(
61
 
/*==============*/
62
 
                        /* out: update vector field */
63
 
        upd_t*  update, /* in: update vector */
64
 
        ulint   n)      /* in: field position in update vector */
65
 
{
66
 
        ut_ad(update);
67
 
        ut_ad(n < update->n_fields);
68
 
 
69
 
        return(update->fields + n);
70
 
}
71
 
 
72
 
/*************************************************************************
73
 
Sets an index field number to be updated by an update vector field. */
74
 
UNIV_INLINE
75
 
void
76
 
upd_field_set_field_no(
77
 
/*===================*/
78
 
        upd_field_t*    upd_field,      /* in: update vector field */
79
 
        ulint           field_no,       /* in: field number in a clustered
80
 
                                        index */
81
 
        dict_index_t*   index,          /* in: index */
82
 
        trx_t*          trx)            /* in: transaction */
83
 
{
84
 
        upd_field->field_no = field_no;
85
 
 
86
 
        if (UNIV_UNLIKELY(field_no >= dict_index_get_n_fields(index))) {
87
 
                fprintf(stderr,
88
 
                        "InnoDB: Error: trying to access field %lu in ",
89
 
                        (ulong) field_no);
90
 
                dict_index_name_print(stderr, trx, index);
91
 
                fprintf(stderr, "\n"
92
 
                        "InnoDB: but index only has %lu fields\n",
93
 
                        (ulong) dict_index_get_n_fields(index));
94
 
        }
95
 
 
96
 
        dict_col_copy_type(dict_index_get_nth_col(index, field_no),
97
 
                           dfield_get_type(&(upd_field->new_val)));
98
 
}
99
 
 
100
 
/*************************************************************************
101
 
Updates the trx id and roll ptr field in a clustered index record when
102
 
a row is updated or marked deleted. */
103
 
UNIV_INLINE
104
 
void
105
 
row_upd_rec_sys_fields(
106
 
/*===================*/
107
 
        rec_t*          rec,    /* in: record */
108
 
        dict_index_t*   index,  /* in: clustered index */
109
 
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
110
 
        trx_t*          trx,    /* in: transaction */
111
 
        dulint          roll_ptr)/* in: roll ptr of the undo log record */
112
 
{
113
 
        ut_ad(index->type & DICT_CLUSTERED);
114
 
        ut_ad(rec_offs_validate(rec, index, offsets));
115
 
#ifdef UNIV_SYNC_DEBUG
116
 
        ut_ad(!buf_block_align(rec)->is_hashed
117
 
              || rw_lock_own(&btr_search_latch, RW_LOCK_EX));
118
 
#endif /* UNIV_SYNC_DEBUG */
119
 
 
120
 
        row_set_rec_trx_id(rec, index, offsets, trx->id);
121
 
        row_set_rec_roll_ptr(rec, index, offsets, roll_ptr);
122
 
}