641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
3 |
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify it under
|
|
6 |
the terms of the GNU General Public License as published by the Free Software
|
|
7 |
Foundation; version 2 of the License.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License along with
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
15 |
St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
16 |
|
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/row0upd.ic
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
Update of a row
|
22 |
||
23 |
Created 12/27/1996 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#include "mtr0log.h" |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
27 |
#ifndef UNIV_HOTBACKUP |
28 |
# include "trx0trx.h" |
|
29 |
# include "trx0undo.h" |
|
30 |
# include "row0row.h" |
|
31 |
# include "btr0sea.h" |
|
32 |
#endif /* !UNIV_HOTBACKUP */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
33 |
#include "page0zip.h" |
34 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
35 |
/*********************************************************************//**
|
36 |
Creates an update vector object.
|
|
37 |
@return own: update vector object */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
38 |
UNIV_INLINE
|
39 |
upd_t* |
|
40 |
upd_create( |
|
41 |
/*=======*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
42 |
ulint n, /*!< in: number of fields */ |
43 |
mem_heap_t* heap) /*!< in: heap from which memory allocated */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
44 |
{
|
45 |
upd_t* update; |
|
46 |
||
47 |
update = (upd_t*) mem_heap_alloc(heap, sizeof(upd_t)); |
|
48 |
||
49 |
update->info_bits = 0; |
|
50 |
update->n_fields = n; |
|
51 |
update->fields = (upd_field_t*) |
|
52 |
mem_heap_alloc(heap, sizeof(upd_field_t) * n); |
|
53 |
||
54 |
return(update); |
|
55 |
}
|
|
56 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
57 |
/*********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
58 |
Returns the number of fields in the update vector == number of columns
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
59 |
to be updated by an update vector.
|
60 |
@return number of fields */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
61 |
UNIV_INLINE
|
62 |
ulint
|
|
63 |
upd_get_n_fields( |
|
64 |
/*=============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
65 |
const upd_t* update) /*!< in: update vector */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
66 |
{
|
67 |
ut_ad(update); |
|
68 |
||
69 |
return(update->n_fields); |
|
70 |
}
|
|
71 |
||
72 |
#ifdef UNIV_DEBUG |
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
73 |
/*********************************************************************//**
|
74 |
Returns the nth field of an update vector.
|
|
75 |
@return update vector field */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
76 |
UNIV_INLINE
|
77 |
upd_field_t* |
|
78 |
upd_get_nth_field( |
|
79 |
/*==============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
80 |
const upd_t* update, /*!< in: update vector */ |
81 |
ulint n) /*!< in: field position in update vector */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
82 |
{
|
83 |
ut_ad(update); |
|
84 |
ut_ad(n < update->n_fields); |
|
85 |
||
86 |
return((upd_field_t*) update->fields + n); |
|
87 |
}
|
|
88 |
#endif /* UNIV_DEBUG */ |
|
89 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
90 |
#ifndef UNIV_HOTBACKUP |
91 |
/*********************************************************************//**
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
92 |
Sets an index field number to be updated by an update vector field. */
|
93 |
UNIV_INLINE
|
|
94 |
void
|
|
95 |
upd_field_set_field_no( |
|
96 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
97 |
upd_field_t* upd_field, /*!< in: update vector field */ |
98 |
ulint field_no, /*!< in: field number in a clustered |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
99 |
index */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
100 |
dict_index_t* index, /*!< in: index */ |
101 |
trx_t* trx) /*!< in: transaction */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
102 |
{
|
103 |
upd_field->field_no = field_no; |
|
104 |
upd_field->orig_len = 0; |
|
105 |
||
106 |
if (UNIV_UNLIKELY(field_no >= dict_index_get_n_fields(index))) { |
|
107 |
fprintf(stderr, |
|
108 |
"InnoDB: Error: trying to access field %lu in ", |
|
109 |
(ulong) field_no); |
|
110 |
dict_index_name_print(stderr, trx, index); |
|
111 |
fprintf(stderr, "\n" |
|
112 |
"InnoDB: but index only has %lu fields\n", |
|
113 |
(ulong) dict_index_get_n_fields(index)); |
|
114 |
} |
|
115 |
||
116 |
dict_col_copy_type(dict_index_get_nth_col(index, field_no), |
|
117 |
dfield_get_type(&upd_field->new_val)); |
|
118 |
}
|
|
119 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
120 |
/*********************************************************************//**
|
121 |
Returns a field of an update vector by field_no.
|
|
122 |
@return update vector field, or NULL */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
123 |
UNIV_INLINE
|
124 |
const upd_field_t* |
|
125 |
upd_get_field_by_field_no( |
|
126 |
/*======================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
127 |
const upd_t* update, /*!< in: update vector */ |
128 |
ulint no) /*!< in: field_no */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
129 |
{
|
130 |
ulint i; |
|
131 |
for (i = 0; i < upd_get_n_fields(update); i++) { |
|
132 |
const upd_field_t* uf = upd_get_nth_field(update, i); |
|
133 |
||
134 |
if (uf->field_no == no) { |
|
135 |
||
136 |
return(uf); |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
return(NULL); |
|
141 |
}
|
|
142 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
143 |
/*********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
144 |
Updates the trx id and roll ptr field in a clustered index record when
|
145 |
a row is updated or marked deleted. */
|
|
146 |
UNIV_INLINE
|
|
147 |
void
|
|
148 |
row_upd_rec_sys_fields( |
|
149 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
150 |
rec_t* rec, /*!< in/out: record */ |
151 |
page_zip_des_t* page_zip,/*!< in/out: compressed page whose |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
152 |
uncompressed part will be updated, or NULL */
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
153 |
dict_index_t* index, /*!< in: clustered index */ |
154 |
const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ |
|
155 |
trx_t* trx, /*!< in: transaction */ |
|
156 |
roll_ptr_t roll_ptr)/*!< in: roll ptr of the undo log record */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
157 |
{
|
158 |
ut_ad(dict_index_is_clust(index)); |
|
159 |
ut_ad(rec_offs_validate(rec, index, offsets)); |
|
160 |
#ifdef UNIV_SYNC_DEBUG |
|
161 |
if (!rw_lock_own(&btr_search_latch, RW_LOCK_EX)) { |
|
162 |
ut_ad(!buf_block_align(rec)->is_hashed); |
|
163 |
} |
|
164 |
#endif /* UNIV_SYNC_DEBUG */ |
|
165 |
||
166 |
if (UNIV_LIKELY_NULL(page_zip)) { |
|
167 |
ulint pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID); |
|
168 |
page_zip_write_trx_id_and_roll_ptr(page_zip, rec, offsets, |
|
169 |
pos, trx->id, roll_ptr); |
|
170 |
} else { |
|
171 |
ulint offset = index->trx_id_offset; |
|
172 |
||
173 |
if (!offset) { |
|
174 |
offset = row_get_trx_id_offset(rec, index, offsets); |
|
175 |
} |
|
176 |
||
177 |
#if DATA_TRX_ID + 1 != DATA_ROLL_PTR |
|
178 |
# error "DATA_TRX_ID + 1 != DATA_ROLL_PTR" |
|
179 |
#endif
|
|
180 |
trx_write_trx_id(rec + offset, trx->id); |
|
181 |
trx_write_roll_ptr(rec + offset + DATA_TRX_ID_LEN, roll_ptr); |
|
182 |
} |
|
183 |
}
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
184 |
#endif /* !UNIV_HOTBACKUP */ |