~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • 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:
11
11
#include "trx0undo.h"
12
12
#include "row0row.h"
13
13
#include "btr0sea.h"
14
 
#include "page0zip.h"
15
14
 
16
15
/*************************************************************************
17
16
Creates an update vector object. */
24
23
        mem_heap_t*     heap)   /* in: heap from which memory allocated */
25
24
{
26
25
        upd_t*  update;
 
26
        ulint   i;
27
27
 
28
 
        update = (upd_t*) mem_heap_alloc(heap, sizeof(upd_t));
 
28
        update = mem_heap_alloc(heap, sizeof(upd_t));
29
29
 
30
30
        update->info_bits = 0;
31
31
        update->n_fields = n;
32
 
        update->fields = (upd_field_t*)
33
 
                mem_heap_alloc(heap, sizeof(upd_field_t) * 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
        }
34
37
 
35
38
        return(update);
36
39
}
42
45
ulint
43
46
upd_get_n_fields(
44
47
/*=============*/
45
 
                                /* out: number of fields */
46
 
        const upd_t*    update) /* in: update vector */
 
48
                        /* out: number of fields */
 
49
        upd_t*  update) /* in: update vector */
47
50
{
48
51
        ut_ad(update);
49
52
 
50
53
        return(update->n_fields);
51
54
}
52
55
 
53
 
#ifdef UNIV_DEBUG
54
56
/*************************************************************************
55
57
Returns the nth field of an update vector. */
56
58
UNIV_INLINE
57
59
upd_field_t*
58
60
upd_get_nth_field(
59
61
/*==============*/
60
 
                                /* out: update vector field */
61
 
        const upd_t*    update, /* in: update vector */
62
 
        ulint           n)      /* in: field position in update vector */
 
62
                        /* out: update vector field */
 
63
        upd_t*  update, /* in: update vector */
 
64
        ulint   n)      /* in: field position in update vector */
63
65
{
64
66
        ut_ad(update);
65
67
        ut_ad(n < update->n_fields);
66
68
 
67
 
        return((upd_field_t*) update->fields + n);
 
69
        return(update->fields + n);
68
70
}
69
 
#endif /* UNIV_DEBUG */
70
71
 
71
72
/*************************************************************************
72
73
Sets an index field number to be updated by an update vector field. */
81
82
        trx_t*          trx)            /* in: transaction */
82
83
{
83
84
        upd_field->field_no = field_no;
84
 
        upd_field->orig_len = 0;
85
85
 
86
86
        if (UNIV_UNLIKELY(field_no >= dict_index_get_n_fields(index))) {
87
87
                fprintf(stderr,
94
94
        }
95
95
 
96
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
 
Returns a field of an update vector by field_no. */
102
 
UNIV_INLINE
103
 
const upd_field_t*
104
 
upd_get_field_by_field_no(
105
 
/*======================*/
106
 
                                /* out: update vector field, or NULL */
107
 
        const upd_t*    update, /* in: update vector */
108
 
        ulint           no)     /* in: field_no */
109
 
{
110
 
        ulint   i;
111
 
        for (i = 0; i < upd_get_n_fields(update); i++) {
112
 
                const upd_field_t*      uf = upd_get_nth_field(update, i);
113
 
 
114
 
                if (uf->field_no == no) {
115
 
 
116
 
                        return(uf);
117
 
                }
118
 
        }
119
 
 
120
 
        return(NULL);
 
97
                           dfield_get_type(&(upd_field->new_val)));
121
98
}
122
99
 
123
100
/*************************************************************************
127
104
void
128
105
row_upd_rec_sys_fields(
129
106
/*===================*/
130
 
        rec_t*          rec,    /* in/out: record */
131
 
        page_zip_des_t* page_zip,/* in/out: compressed page whose
132
 
                                uncompressed part will be updated, or NULL */
 
107
        rec_t*          rec,    /* in: record */
133
108
        dict_index_t*   index,  /* in: clustered index */
134
109
        const ulint*    offsets,/* in: rec_get_offsets(rec, index) */
135
110
        trx_t*          trx,    /* in: transaction */
136
111
        dulint          roll_ptr)/* in: roll ptr of the undo log record */
137
112
{
138
 
        ut_ad(dict_index_is_clust(index));
 
113
        ut_ad(index->type & DICT_CLUSTERED);
139
114
        ut_ad(rec_offs_validate(rec, index, offsets));
140
115
#ifdef UNIV_SYNC_DEBUG
141
 
        if (!rw_lock_own(&btr_search_latch, RW_LOCK_EX)) {
142
 
                buf_pool_mutex_enter();
143
 
                ut_ad(!buf_block_align(rec)->is_hashed);
144
 
                buf_pool_mutex_exit();
145
 
        }
 
116
        ut_ad(!buf_block_align(rec)->is_hashed
 
117
              || rw_lock_own(&btr_search_latch, RW_LOCK_EX));
146
118
#endif /* UNIV_SYNC_DEBUG */
147
119
 
148
 
        if (UNIV_LIKELY_NULL(page_zip)) {
149
 
                ulint   pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
150
 
                page_zip_write_trx_id_and_roll_ptr(page_zip, rec, offsets,
151
 
                                                   pos, trx->id, roll_ptr);
152
 
        } else {
153
 
                ulint   offset = index->trx_id_offset;
154
 
 
155
 
                if (!offset) {
156
 
                        offset = row_get_trx_id_offset(rec, index, offsets);
157
 
                }
158
 
 
159
 
#if DATA_TRX_ID + 1 != DATA_ROLL_PTR
160
 
# error "DATA_TRX_ID + 1 != DATA_ROLL_PTR"
161
 
#endif
162
 
                trx_write_trx_id(rec + offset, trx->id);
163
 
                trx_write_roll_ptr(rec + offset + DATA_TRX_ID_LEN, roll_ptr);
164
 
        }
 
120
        row_set_rec_trx_id(rec, index, offsets, trx->id);
 
121
        row_set_rec_roll_ptr(rec, index, offsets, roll_ptr);
165
122
}