#include "univ.i"
#include "data0data.h"
#include "row0types.h"
#include "btr0types.h"
#include "dict0types.h"
#include "trx0types.h"
#include "btr0pcur.h"
#include "que0types.h"
#include "pars0types.h"
#include "row0upd.ic"
Go to the source code of this file.
Classes | |
struct | upd_field_struct |
struct | upd_struct |
struct | upd_node_struct |
Defines | |
#define | upd_get_nth_field(update, n) ((update)->fields + (n)) |
#define | UPD_NODE_MAGIC_N 1579975 |
#define | UPD_NODE_SET_IX_LOCK 1 |
#define | UPD_NODE_UPDATE_CLUSTERED 2 |
#define | UPD_NODE_INSERT_CLUSTERED 3 |
#define | UPD_NODE_UPDATE_ALL_SEC 4 |
#define | UPD_NODE_UPDATE_SOME_SEC 5 |
#define | UPD_NODE_NO_ORD_CHANGE 1 |
#define | UPD_NODE_NO_SIZE_CHANGE 2 |
Functions | |
UNIV_INLINE upd_t * | upd_create (ulint n, mem_heap_t *heap) |
UNIV_INLINE ulint | upd_get_n_fields (const upd_t *update) |
UNIV_INLINE void | upd_field_set_field_no (upd_field_t *upd_field, ulint field_no, dict_index_t *index, trx_t *trx) |
UNIV_INLINE const upd_field_t * | upd_get_field_by_field_no (const upd_t *update, ulint no) __attribute__((nonnull |
UNIV_INTERN byte * | row_upd_write_sys_vals_to_log (dict_index_t *index, trx_t *trx, roll_ptr_t roll_ptr, byte *log_ptr, mtr_t *mtr) |
UNIV_INLINE void | row_upd_rec_sys_fields (rec_t *rec, page_zip_des_t *page_zip, dict_index_t *index, const ulint *offsets, trx_t *trx, roll_ptr_t roll_ptr) |
UNIV_INTERN void | row_upd_index_entry_sys_field (dtuple_t *entry, dict_index_t *index, ulint type, ib_uint64_t val) |
UNIV_INTERN upd_node_t * | upd_node_create (mem_heap_t *heap) |
UNIV_INTERN void | row_upd_index_write_log (const upd_t *update, byte *log_ptr, mtr_t *mtr) |
UNIV_INTERN ibool | row_upd_changes_field_size_or_external (dict_index_t *index, const ulint *offsets, const upd_t *update) |
UNIV_INTERN void | row_upd_rec_in_place (rec_t *rec, dict_index_t *index, const ulint *offsets, const upd_t *update, page_zip_des_t *page_zip) |
UNIV_INTERN upd_t * | row_upd_build_sec_rec_difference_binary (dict_index_t *index, const dtuple_t *entry, const rec_t *rec, trx_t *trx, mem_heap_t *heap) |
UNIV_INTERN upd_t * | row_upd_build_difference_binary (dict_index_t *index, const dtuple_t *entry, const rec_t *rec, trx_t *trx, mem_heap_t *heap) |
UNIV_INTERN void | row_upd_index_replace_new_col_vals_index_pos (dtuple_t *entry, dict_index_t *index, const upd_t *update, ibool order_only, mem_heap_t *heap) __attribute__((nonnull)) |
UNIV_INTERN void | row_upd_index_replace_new_col_vals (dtuple_t *entry, dict_index_t *index, const upd_t *update, mem_heap_t *heap) __attribute__((nonnull)) |
UNIV_INTERN void | row_upd_replace (dtuple_t *row, row_ext_t **ext, const dict_index_t *index, const upd_t *update, mem_heap_t *heap) |
UNIV_INTERN ibool | row_upd_changes_ord_field_binary (const dtuple_t *row, dict_index_t *index, const upd_t *update) |
UNIV_INTERN ibool | row_upd_changes_some_index_ord_field_binary (const dict_table_t *table, const upd_t *update) |
UNIV_INTERN que_thr_t * | row_upd_step (que_thr_t *thr) |
UNIV_INTERN byte * | row_upd_parse_sys_vals (byte *ptr, byte *end_ptr, ulint *pos, trx_id_t *trx_id, roll_ptr_t *roll_ptr) |
UNIV_INTERN void | row_upd_rec_sys_fields_in_recovery (rec_t *rec, page_zip_des_t *page_zip, const ulint *offsets, ulint pos, trx_id_t trx_id, roll_ptr_t roll_ptr) |
UNIV_INTERN byte * | row_upd_index_parse (byte *ptr, byte *end_ptr, mem_heap_t *heap, upd_t **update_out) |
Variables | |
UNIV_INLINE const upd_field_t * | pure |
UNIV_INTERN upd_t* row_upd_build_difference_binary | ( | dict_index_t * | index, |
const dtuple_t * | entry, | ||
const rec_t * | rec, | ||
trx_t * | trx, | ||
mem_heap_t * | heap | ||
) |
Builds an update vector from those fields, excluding the roll ptr and trx id fields, which in an index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings!
Builds an update vector from those fields, excluding the roll ptr and trx id fields, which in an index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings!
index | in: clustered index |
entry | in: entry to insert |
rec | in: clustered index record |
trx | in: transaction |
heap | in: memory heap from which allocated |
Definition at line 821 of file row0upd.cc.
References dfield_copy(), dfield_is_ext(), dict_index_get_sys_col_pos(), dict_index_is_clust(), dtuple_get_n_fields(), upd_struct::n_fields, upd_field_struct::new_val, rec_offs_nth_extern(), row_upd_build_difference_binary(), upd_create(), upd_field_set_field_no(), and ut_a.
Referenced by row_upd_build_difference_binary().
UNIV_INTERN upd_t* row_upd_build_sec_rec_difference_binary | ( | dict_index_t * | index, |
const dtuple_t * | entry, | ||
const rec_t * | rec, | ||
trx_t * | trx, | ||
mem_heap_t * | heap | ||
) |
Builds an update vector from those fields which in a secondary index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings!
Builds an update vector from those fields which in a secondary index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings!
index | in: index |
entry | in: entry to insert |
rec | in: secondary index record |
trx | in: transaction |
heap | in: memory heap from which allocated |
Definition at line 751 of file row0upd.cc.
References dfield_copy(), dict_index_is_clust(), dtuple_get_n_fields(), upd_struct::n_fields, upd_field_struct::new_val, row_upd_build_sec_rec_difference_binary(), upd_create(), upd_field_set_field_no(), and ut_a.
Referenced by row_upd_build_sec_rec_difference_binary().
UNIV_INTERN ibool row_upd_changes_field_size_or_external | ( | dict_index_t * | index, |
const ulint * | offsets, | ||
const upd_t * | update | ||
) |
Returns TRUE if row update changes size of some field in index or if some field to be updated is stored externally in rec or update.
Returns TRUE if row update changes size of some field in index or if some field to be updated is stored externally in rec or update.
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
update | in: update vector |
Definition at line 418 of file row0upd.cc.
References dfield_get_len(), dfield_is_ext(), dfield_is_null(), dict_col_get_sql_null_size(), dict_index_get_nth_col(), upd_field_struct::field_no, upd_field_struct::new_val, rec_offs_comp(), rec_offs_nth_extern(), rec_offs_nth_size(), rec_offs_nth_sql_null(), rec_offs_validate(), row_upd_changes_field_size_or_external(), upd_get_n_fields(), and ut_ad.
Referenced by btr_cur_optimistic_update(), row_upd_changes_field_size_or_external(), and trx_undo_prev_version_build().
UNIV_INTERN ibool row_upd_changes_ord_field_binary | ( | const dtuple_t * | row, |
dict_index_t * | index, | ||
const upd_t * | update | ||
) |
Checks if an update vector changes an ordering field of an index record.
This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings!
Checks if an update vector changes an ordering field of an index record.
This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings!
row | in: old value of row, or NULL if the row and the data values in update are not known when this function is called, e.g., at compile time |
index | in: index of the record |
update | in: update vector for the row; NOTE: the field numbers in this MUST be clustered index positions! |
Definition at line 1205 of file row0upd.cc.
References dfield_datas_are_binary_equal(), dict_col_get_clust_pos(), dict_col_get_no(), dict_field_get_col(), dict_index_get_n_unique(), upd_field_struct::field_no, upd_field_struct::new_val, dict_field_struct::prefix_len, row_upd_changes_ord_field_binary(), dict_index_struct::table, upd_get_n_fields(), and ut_ad.
Referenced by btr_cur_update_in_place(), and row_upd_changes_ord_field_binary().
UNIV_INTERN ibool row_upd_changes_some_index_ord_field_binary | ( | const dict_table_t * | table, |
const upd_t * | update | ||
) |
Checks if an update vector changes an ordering field of an index record. This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings!
Checks if an update vector changes an ordering field of an index record. NOTE: we compare the fields as binary strings!
table | in: table |
update | in: update vector for the row |
Definition at line 1272 of file row0upd.cc.
References dict_field_get_col(), upd_field_struct::field_no, dict_col_struct::ord_part, row_upd_changes_some_index_ord_field_binary(), and upd_get_n_fields().
Referenced by row_upd_changes_some_index_ord_field_binary().
UNIV_INTERN void row_upd_index_entry_sys_field | ( | dtuple_t * | entry, |
dict_index_t * | index, | ||
ulint | type, | ||
ib_uint64_t | val | ||
) |
Sets the trx id or roll ptr field of a clustered index entry. in: value to write
Sets the trx id or roll ptr field of a clustered index entry.
entry | in/out: index entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to them |
index | in: clustered index |
type | in: DATA_TRX_ID or DATA_ROLL_PTR |
val | in: value to write |
Definition at line 382 of file row0upd.cc.
References dict_index_get_sys_col_pos(), dict_index_is_clust(), row_upd_index_entry_sys_field(), trx_write_roll_ptr(), trx_write_trx_id(), and ut_ad.
Referenced by btr_cur_optimistic_update(), btr_cur_pessimistic_update(), and row_upd_index_entry_sys_field().
UNIV_INTERN byte* row_upd_index_parse | ( | byte * | ptr, |
byte * | end_ptr, | ||
mem_heap_t * | heap, | ||
upd_t ** | update_out | ||
) |
Parses the log data written by row_upd_index_write_log.
Parses the log data written by row_upd_index_write_log.
ptr | in: buffer |
end_ptr | in: buffer end |
heap | in: memory heap where update vector is built |
update_out | out: update vector |
Definition at line 669 of file row0upd.cc.
References dfield_set_data(), dfield_set_null(), upd_field_struct::field_no, upd_struct::info_bits, mach_parse_compressed(), mach_read_from_1(), mem_heap_dup(), upd_field_struct::new_val, row_upd_index_parse(), and upd_create().
Referenced by btr_cur_parse_update_in_place(), and row_upd_index_parse().
UNIV_INTERN void row_upd_index_replace_new_col_vals | ( | dtuple_t * | entry, |
dict_index_t * | index, | ||
const upd_t * | update, | ||
mem_heap_t * | heap | ||
) |
Replaces the new column values stored in the update vector to the index entry given.
entry | in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion (rollback or purge) |
index | in: index; NOTE that this may also be a non-clustered index |
update | in: an update vector built for the CLUSTERED index so that the field number in an upd_field is the clustered index position |
heap | in: memory heap for allocating and copying the new values |
Definition at line 1073 of file row0upd.cc.
References dict_col_get_clust_pos(), dict_field_get_col(), dict_index_get_n_fields(), dict_table_zip_size(), dtuple_set_info_bits(), upd_struct::info_bits, row_upd_index_replace_new_col_vals(), dict_index_struct::table, and upd_get_field_by_field_no().
Referenced by row_upd_index_replace_new_col_vals(), and trx_undo_prev_version_build().
UNIV_INTERN void row_upd_index_replace_new_col_vals_index_pos | ( | dtuple_t * | entry, |
dict_index_t * | index, | ||
const upd_t * | update, | ||
ibool | order_only, | ||
mem_heap_t * | heap | ||
) |
Replaces the new column values stored in the update vector to the index entry given.
entry | in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion (rollback or purge) |
index | in: index; NOTE that this may also be a non-clustered index |
update | in: an update vector built for the index so that the field number in an upd_field is the index position |
order_only | in: if TRUE, limit the replacement to ordering fields of index; note that this does not work for non-clustered indexes. |
heap | in: memory heap for allocating and copying the new values |
Definition at line 1019 of file row0upd.cc.
References dict_field_get_col(), dict_index_get_n_fields(), dict_index_get_n_unique(), dict_table_zip_size(), dtuple_set_info_bits(), upd_struct::info_bits, row_upd_index_replace_new_col_vals_index_pos(), dict_index_struct::table, upd_get_field_by_field_no(), and ut_ad.
Referenced by btr_cur_optimistic_update(), btr_cur_pessimistic_update(), and row_upd_index_replace_new_col_vals_index_pos().
Writes to the redo log the new values of the fields occurring in the index. in: mtr into whose log to write
Writes to the redo log the new values of the fields occurring in the index.
update | in: update vector |
log_ptr | in: pointer to mlog buffer: must contain at least MLOG_BUF_MARGIN bytes of free space; the buffer is closed within this function |
mtr | in: mtr into whose log to write |
Definition at line 596 of file row0upd.cc.
References dfield_get_len(), upd_field_struct::field_no, upd_struct::info_bits, mach_write_compressed(), mach_write_to_1(), mlog_catenate_string(), mlog_close(), mlog_open(), upd_field_struct::new_val, row_upd_index_write_log(), and upd_get_n_fields().
Referenced by row_upd_index_write_log().
UNIV_INTERN byte* row_upd_parse_sys_vals | ( | byte * | ptr, |
byte * | end_ptr, | ||
ulint * | pos, | ||
trx_id_t * | trx_id, | ||
roll_ptr_t * | roll_ptr | ||
) |
Parses the log data of system field values.
Parses the log data of system field values.
ptr | in: buffer |
end_ptr | in: buffer end |
pos | out: TRX_ID position in record |
trx_id | out: trx id |
roll_ptr | out: roll ptr |
Definition at line 563 of file row0upd.cc.
References mach_parse_compressed(), mach_ull_parse_compressed(), row_upd_parse_sys_vals(), and trx_read_roll_ptr().
Referenced by btr_cur_parse_del_mark_set_clust_rec(), btr_cur_parse_update_in_place(), and row_upd_parse_sys_vals().
UNIV_INTERN void row_upd_rec_in_place | ( | rec_t * | rec, |
dict_index_t * | index, | ||
const ulint * | offsets, | ||
const upd_t * | update, | ||
page_zip_des_t * | page_zip | ||
) |
Replaces the new column values stored in the update vector to the record given. No field size changes are allowed. This function is usually invoked on a clustered index. The only use case for a secondary index is row_ins_sec_index_entry_by_modify() or its counterpart in ibuf_insert_to_index_page(). in: compressed page with enough space available, or NULL
Replaces the new column values stored in the update vector to the record given. No field size changes are allowed. This function is usually invoked on a clustered index. The only use case for a secondary index is row_ins_sec_index_entry_by_modify() or its counterpart in ibuf_insert_to_index_page().
rec | in/out: record where replaced |
index | in: the index the record belongs to |
offsets | in: array returned by rec_get_offsets() |
update | in: update vector |
page_zip | in: compressed page with enough space available, or NULL |
Definition at line 486 of file row0upd.cc.
References dfield_get_len(), dfield_is_ext(), upd_field_struct::field_no, upd_struct::info_bits, upd_field_struct::new_val, page_zip_write_rec(), rec_offs_comp(), rec_offs_nth_extern(), rec_offs_validate(), rec_set_info_bits_new(), rec_set_info_bits_old(), rec_set_nth_field(), row_upd_rec_in_place(), upd_get_n_fields(), and ut_ad.
Referenced by btr_cur_parse_update_in_place(), btr_cur_update_in_place(), row_upd_rec_in_place(), and trx_undo_prev_version_build().
UNIV_INLINE void row_upd_rec_sys_fields | ( | rec_t * | rec, |
page_zip_des_t * | page_zip, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
trx_t * | trx, | ||
roll_ptr_t | roll_ptr | ||
) |
Updates the trx id and roll ptr field in a clustered index record when a row is updated or marked deleted. in: roll ptr of the undo log record
rec | in/out: record |
page_zip | in/out: compressed page whose uncompressed part will be updated, or NULL |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
trx | in: transaction |
Referenced by btr_cur_del_mark_set_clust_rec(), and btr_cur_update_in_place().
UNIV_INTERN void row_upd_rec_sys_fields_in_recovery | ( | rec_t * | rec, |
page_zip_des_t * | page_zip, | ||
const ulint * | offsets, | ||
ulint | pos, | ||
trx_id_t | trx_id, | ||
roll_ptr_t | roll_ptr | ||
) |
Updates the trx id and roll ptr field in a clustered index record in database recovery. in: roll ptr of the undo log record
Updates the trx id and roll ptr field in a clustered index record in database recovery.
rec | in/out: record |
page_zip | in/out: compressed page, or NULL |
offsets | in: array returned by rec_get_offsets() |
pos | in: TRX_ID position in rec |
trx_id | in: transaction id |
roll_ptr | in: roll ptr of the undo log record |
Definition at line 349 of file row0upd.cc.
References page_zip_write_trx_id_and_roll_ptr(), rec_offs_validate(), row_upd_rec_sys_fields_in_recovery(), trx_write_roll_ptr(), trx_write_trx_id(), and ut_ad.
Referenced by btr_cur_parse_del_mark_set_clust_rec(), btr_cur_parse_update_in_place(), and row_upd_rec_sys_fields_in_recovery().
UNIV_INTERN void row_upd_replace | ( | dtuple_t * | row, |
row_ext_t ** | ext, | ||
const dict_index_t * | index, | ||
const upd_t * | update, | ||
mem_heap_t * | heap | ||
) |
Replaces the new column values stored in the update vector. in: memory heap
Replaces the new column values stored in the update vector.
row | in/out: row where replaced, indexed by col_no; the clustered index record must be covered by a lock or a page latch to prevent deletion (rollback or purge) |
ext | out, own: NULL, or externally stored column prefixes |
index | in: clustered index |
update | in: an update vector built for the clustered index |
heap | in: memory heap |
Definition at line 1117 of file row0upd.cc.
References dfield_copy_data(), dfield_is_ext(), dict_col_get_clust_pos(), dict_index_is_clust(), dict_table_get_n_cols(), dict_table_zip_size(), dtuple_get_n_fields(), dtuple_set_info_bits(), upd_field_struct::field_no, upd_struct::info_bits, mem_heap_alloc(), upd_field_struct::new_val, dict_col_struct::ord_part, row_ext_create(), row_upd_replace(), dict_index_struct::table, upd_get_n_fields(), and ut_ad.
Referenced by row_undo_search_clust_to_pcur(), and row_upd_replace().
Updates a row in a table. This is a high-level function used in SQL execution graphs.
Updates a row in a table. This is a high-level function used in SQL execution graphs.
thr | in: query thread |
Definition at line 2141 of file row0upd.cc.
References trx_struct::error_state, lock_table(), que_thr_struct::prev_node, que_node_get_parent(), que_node_get_type(), row_upd_step(), que_thr_struct::run_node, SEL_NODE_FETCH, SEL_NODE_NO_MORE_ROWS, SEL_NODE_OPEN, upd_node_struct::select, sel_node_struct::state, upd_node_struct::state, upd_node_struct::table, thr_get_trx(), trx_start_if_not_started(), ut_ad, and ut_error.
Referenced by row_upd_step(), row_update_cascade_for_mysql(), and row_update_for_mysql().
UNIV_INTERN byte* row_upd_write_sys_vals_to_log | ( | dict_index_t * | index, |
trx_t * | trx, | ||
roll_ptr_t | roll_ptr, | ||
byte * | log_ptr, | ||
mtr_t * | |||
) |
Writes into the redo log the values of trx id and roll ptr and enough info to determine their positions within a clustered index record.
Writes into the redo log the values of trx id and roll ptr and enough info to determine their positions within a clustered index record.
index | in: clustered index |
trx | in: transaction |
roll_ptr | in: roll ptr of the undo log record |
log_ptr | pointer to a buffer of size > 20 opened in mlog |
Definition at line 533 of file row0upd.cc.
References dict_index_get_sys_col_pos(), dict_index_is_clust(), trx_struct::id, mach_ull_write_compressed(), mach_write_compressed(), row_upd_write_sys_vals_to_log(), trx_write_roll_ptr(), and ut_ad.
Referenced by row_upd_write_sys_vals_to_log().
UNIV_INLINE upd_t* upd_create | ( | ulint | n, |
mem_heap_t * | heap | ||
) |
Creates an update vector object.
n | in: number of fields |
Referenced by row_create_update_node_for_mysql(), row_upd_build_difference_binary(), row_upd_build_sec_rec_difference_binary(), row_upd_index_parse(), and trx_undo_update_rec_get_update().
UNIV_INLINE void upd_field_set_field_no | ( | upd_field_t * | upd_field, |
ulint | field_no, | ||
dict_index_t * | index, | ||
trx_t * | trx | ||
) |
Sets an index field number to be updated by an update vector field. in: transaction
upd_field | in: update vector field |
field_no | in: field number in a clustered index |
index | in: index |
Referenced by row_upd_build_difference_binary(), row_upd_build_sec_rec_difference_binary(), and trx_undo_update_rec_get_update().
UNIV_INLINE const upd_field_t* upd_get_field_by_field_no | ( | const upd_t * | update, |
ulint | no | ||
) |
Returns a field of an update vector by field_no.
update | in: update vector |
no | in: field_no |
Referenced by row_upd_index_replace_new_col_vals(), and row_upd_index_replace_new_col_vals_index_pos().
UNIV_INLINE ulint upd_get_n_fields | ( | const upd_t * | update | ) |
Returns the number of fields in the update vector == number of columns to be updated by an update vector.
Referenced by btr_cur_mark_dtuple_inherited_extern(), btr_cur_mark_extern_inherited_fields(), btr_cur_optimistic_update(), btr_push_update_extern_fields(), row_upd_changes_field_size_or_external(), row_upd_changes_ord_field_binary(), row_upd_changes_some_index_ord_field_binary(), row_upd_index_write_log(), row_upd_rec_in_place(), and row_upd_replace().
UNIV_INTERN upd_node_t* upd_node_create | ( | mem_heap_t * | heap | ) |
Creates an update node for a query graph.
Creates an update node for a query graph.
heap | in: mem heap where created |
Definition at line 310 of file row0upd.cc.
References upd_node_struct::common, upd_node_struct::ext, upd_node_struct::heap, upd_node_struct::index, mem_heap_alloc(), mem_heap_create, upd_node_struct::row, upd_node_struct::select, upd_node_struct::state, que_common_struct::type, upd_node_create(), and upd_node_struct::update.
Referenced by pars_update_statement_start(), row_create_update_node_for_mysql(), and upd_node_create().