MySQL 9.1.0
Source Code Documentation
|
Update of a row. More...
#include <stack>
#include "btr0types.h"
#include "data0data.h"
#include "dict0types.h"
#include "lob0lob.h"
#include "row0types.h"
#include "table.h"
#include "trx0types.h"
#include "univ.i"
#include "btr0pcur.h"
#include "pars0types.h"
#include "que0types.h"
#include "row0upd.ic"
Go to the source code of this file.
Classes | |
struct | lob_index_diff_t |
This structure is used for undo logging of LOB index changes. More... | |
struct | Lob_diff |
The modification done to the LOB. More... | |
struct | upd_field_t |
struct | upd_t |
struct | upd_node_t |
Typedefs | |
using | Lob_index_diff_vec = std::vector< lob_index_diff_t, mem_heap_allocator< lob_index_diff_t > > |
using | Lob_diff_vector = std::vector< Lob_diff, mem_heap_allocator< Lob_diff > > |
Functions | |
static upd_t * | upd_create (ulint n, mem_heap_t *heap) |
Creates an update vector object. More... | |
static 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. More... | |
static upd_field_t * | upd_get_nth_field (const upd_t *update, ulint n) |
Returns the nth field of an update vector. More... | |
static void | upd_field_set_field_no (upd_field_t *upd_field, ulint field_no, const dict_index_t *index) |
Sets an index field number to be updated by an update vector field. More... | |
static void | upd_field_set_v_field_no (upd_field_t *upd_field, ulint field_no, const dict_index_t *index) |
set field number to a update vector field, marks this field is updated More... | |
static const upd_field_t * | upd_get_field_by_field_no (const upd_t *update, ulint no, bool is_virtual) |
Returns a field of an update vector by field_no. More... | |
byte * | row_upd_write_sys_vals_to_log (dict_index_t *index, trx_id_t trx_id, roll_ptr_t roll_ptr, byte *log_ptr, mtr_t *mtr) |
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. More... | |
static void | row_upd_rec_sys_fields (rec_t *rec, page_zip_des_t *page_zip, const dict_index_t *index, const ulint *offsets, const 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. More... | |
void | row_upd_index_entry_sys_field (dtuple_t *entry, dict_index_t *index, ulint type, uint64_t val) |
Sets the trx id or roll ptr field of a clustered index entry. More... | |
upd_node_t * | upd_node_create (mem_heap_t *heap) |
Creates an update node for a query graph. More... | |
void | row_upd_index_write_log (dict_index_t *index, const upd_t *update, byte *log_ptr, mtr_t *mtr) |
Writes to the redo log the new values of the fields occurring in the index. More... | |
bool | row_upd_changes_field_size_or_external (const 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. More... | |
bool | row_upd_changes_disowned_external (const upd_t *update) |
Returns true if row update contains disowned external fields. More... | |
void | row_upd_rec_in_place (rec_t *rec, const 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. More... | |
upd_t * | row_upd_build_sec_rec_difference_binary (const rec_t *rec, dict_index_t *index, const ulint *offsets, const dtuple_t *entry, 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. More... | |
upd_t * | row_upd_build_difference_binary (dict_index_t *index, const dtuple_t *entry, const rec_t *rec, const ulint *offsets, bool no_sys, trx_t *trx, mem_heap_t *heap, TABLE *mysql_table, dberr_t *error) |
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. More... | |
void | row_upd_index_replace_new_col_vals_index_pos (dtuple_t *entry, const dict_index_t *index, const upd_t *update, bool order_only, mem_heap_t *heap) |
Replaces the new column values stored in the update vector to the index entry given. More... | |
void | row_upd_index_replace_new_col_vals (dtuple_t *entry, const 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. More... | |
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. More... | |
void | row_upd_replace_vcol (dtuple_t *row, const dict_table_t *table, const upd_t *update, bool upd_new, dtuple_t *undo_row, const byte *ptr) |
Replaces the virtual column values stored in a dtuple with that of a update vector. More... | |
bool | row_upd_changes_ord_field_binary_func (dict_index_t *index, const upd_t *update, const que_thr_t *thr, const dtuple_t *row, const row_ext_t *ext, bool *non_mv_upd, ulint flag) |
Checks if an update vector changes an ordering field of an index record. More... | |
static bool | row_upd_changes_ord_field_binary (dict_index_t *index, const upd_t *update, const que_thr_t *thr, const dtuple_t *row, const row_ext_t *ext, bool *non_mv_upd) |
ulint | row_upd_changes_fts_column (dict_table_t *table, upd_field_t *upd_field) |
Checks if an FTS indexed column is affected by an UPDATE. More... | |
bool | row_upd_changes_doc_id (dict_table_t *table, upd_field_t *upd_field) |
Checks if an FTS Doc ID column is affected by an UPDATE. More... | |
bool | 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. More... | |
void | row_upd_store_row (upd_node_t *node, THD *thd, TABLE *mysql_table) |
Stores to the heap the row on which the node->pcur is positioned. More... | |
que_thr_t * | row_upd_step (que_thr_t *thr) |
Updates a row in a table. More... | |
byte * | row_upd_parse_sys_vals (const byte *ptr, const byte *end_ptr, ulint *pos, trx_id_t *trx_id, roll_ptr_t *roll_ptr) |
Parses the log data of system field values. More... | |
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. More... | |
byte * | row_upd_index_parse (const byte *ptr, const byte *end_ptr, mem_heap_t *heap, upd_t **update_out) |
Parses the log data written by row_upd_index_write_log. More... | |
uint64_t | row_upd_get_new_autoinc_counter (const upd_t *update, ulint autoinc_field_no) |
Get the new autoinc counter from the update vector when there is an autoinc field defined in this table. More... | |
std::ostream & | operator<< (std::ostream &out, const lob_index_diff_t &obj) |
Overloading the global output operator to print lob_index_diff_t object. More... | |
std::ostream & | operator<< (std::ostream &out, const Lob_diff &obj) |
std::ostream & | operator<< (std::ostream &out, const upd_field_t &obj) |
static bool | upd_fld_is_virtual_col (const upd_field_t *upd_fld) |
static bool | upd_fld_is_multi_value_col (const upd_field_t *upd_fld) |
static void | upd_fld_set_virtual_col (upd_field_t *upd_fld) |
std::ostream & | print_binary_diff (std::ostream &out, const Binary_diff *bdiff, const dict_table_t *table, const Field *field, bool print_old) |
Print the given binary diff into the given output stream. More... | |
std::ostream & | print_binary_diff (std::ostream &out, const Binary_diff *bdiff) |
std::ostream & | operator<< (std::ostream &out, const upd_t &obj) |
std::ostream & | operator<< (std::ostream &out, const Binary_diff_vector &) |
Variables | |
constexpr uint32_t | UPD_NODE_MAGIC_N = 1579975 |
constexpr uint32_t | UPD_NODE_SET_IX_LOCK = 1 |
execution came to the node from a node above and if the field has_clust_rec_x_lock is false, we should set an intention x-lock on the table More... | |
constexpr uint32_t | UPD_NODE_UPDATE_CLUSTERED = 2 |
clustered index record should be updated More... | |
constexpr uint32_t | UPD_NODE_INSERT_CLUSTERED = 3 |
constexpr uint32_t | UPD_NODE_UPDATE_ALL_SEC = 5 |
an ordering field of the clustered index record was changed, or this is a delete operation: should update all the secondary index records More... | |
constexpr uint32_t | UPD_NODE_UPDATE_SOME_SEC = 6 |
secondary index entries should be looked at and updated if an ordering field changed More... | |
constexpr uint32_t | UPD_NODE_NO_ORD_CHANGE = 1 |
no secondary index record will be changed in the update and no ordering field of the clustered index More... | |
constexpr uint32_t | UPD_NODE_NO_SIZE_CHANGE = 2 |
no record field size will be changed in the update More... | |
Update of a row.
Created 12/27/1996 Heikki Tuuri
using Lob_diff_vector = std::vector<Lob_diff, mem_heap_allocator<Lob_diff> > |
using Lob_index_diff_vec = std::vector<lob_index_diff_t, mem_heap_allocator<lob_index_diff_t> > |
|
inline |
|
inline |
|
inline |
Overloading the global output operator to print lob_index_diff_t object.
[in,out] | out | the output stream. |
[in] | obj | the object to be printed. |
|
inline |
|
inline |
std::ostream & print_binary_diff | ( | std::ostream & | out, |
const Binary_diff * | bdiff | ||
) |
std::ostream & print_binary_diff | ( | std::ostream & | out, |
const Binary_diff * | bdiff, | ||
const dict_table_t * | table, | ||
const Field * | field, | ||
bool | print_old | ||
) |
Print the given binary diff into the given output stream.
[in] | out | the output stream |
[in] | bdiff | binary diff to be printed. |
[in] | table | the table dictionary object. |
[in] | field | mysql field object. |
[in] | print_old | prints old data of the updated field |
upd_t * row_upd_build_difference_binary | ( | dict_index_t * | index, |
const dtuple_t * | entry, | ||
const rec_t * | rec, | ||
const ulint * | offsets, | ||
bool | no_sys, | ||
trx_t * | trx, | ||
mem_heap_t * | heap, | ||
TABLE * | mysql_table, | ||
dberr_t * | error | ||
) |
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!
[in] | index | clustered index |
[in] | entry | clustered index entry to insert |
[in] | rec | clustered index record |
[in] | offsets | rec_get_offsets(rec,index), or NULL |
[in] | no_sys | skip the system columns DB_TRX_ID and DB_ROLL_PTR |
[in] | trx | transaction (for diagnostics), or NULL |
[in] | heap | memory heap from which allocated |
[in] | mysql_table | NULL, or mysql table object when user thread invokes dml |
[out] | error | error number in case of failure |
upd_t * row_upd_build_sec_rec_difference_binary | ( | const rec_t * | rec, |
dict_index_t * | index, | ||
const ulint * | offsets, | ||
const dtuple_t * | entry, | ||
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!
NOTE: we compare the fields as binary strings!
rec | in: secondary index record |
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
entry | in: entry to insert |
heap | in: memory heap from which allocated |
bool row_upd_changes_disowned_external | ( | const upd_t * | update | ) |
Returns true if row update contains disowned external fields.
update | in: update vector |
bool row_upd_changes_doc_id | ( | dict_table_t * | table, |
upd_field_t * | upd_field | ||
) |
Checks if an FTS Doc ID column is affected by an UPDATE.
table | in: table |
upd_field | in: field to check |
bool row_upd_changes_field_size_or_external | ( | const 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.
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
update | in: update vector |
ulint row_upd_changes_fts_column | ( | dict_table_t * | table, |
upd_field_t * | upd_field | ||
) |
Checks if an FTS indexed column is affected by an UPDATE.
table | in: table |
upd_field | in: field to check |
|
inlinestatic |
bool row_upd_changes_ord_field_binary_func | ( | dict_index_t * | index, |
const upd_t * | update, | ||
const que_thr_t * | thr, | ||
const dtuple_t * | row, | ||
const row_ext_t * | ext, | ||
bool * | non_mv_upd, | ||
ulint | flag | ||
) |
Checks if an update vector changes an ordering field of an index record.
It will also help check if any non-multi-value field on the multi-value index gets updated or not.
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!
[in] | index | index of the record |
[in] | update | update vector for the row; NOTE: the field numbers in this MUST be clustered index positions! |
[in] | thr | query thread, or NULL |
[in] | row | 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 |
[in] | ext | NULL, or prefixes of the externally stored columns in the old row |
[in,out] | non_mv_upd | NULL, or not NULL pointer to get the information about whether any non-multi-value field on the multi-value index gets updated |
[in] | flag | ROW_BUILD_NORMAL, ROW_BUILD_FOR_PURGE or ROW_BUILD_FOR_UNDO |
bool 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!
NOTE: we compare the fields as binary strings!
table | in: table |
update | in: update vector for the row |
Get the new autoinc counter from the update vector when there is an autoinc field defined in this table.
[in] | update | update vector for the clustered index |
[in] | autoinc_field_no | autoinc field's order in clustered index |
void row_upd_index_entry_sys_field | ( | dtuple_t * | entry, |
dict_index_t * | index, | ||
ulint | type, | ||
uint64_t | val | ||
) |
Sets the trx id or roll ptr field of a clustered index entry.
[in,out] | entry | Index entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to them |
[in] | index | Clustered index |
[in] | type | Data_trx_id or data_roll_ptr |
[in] | val | Value to write |
byte * row_upd_index_parse | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
mem_heap_t * | heap, | ||
upd_t ** | update_out | ||
) |
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 |
void row_upd_index_replace_new_col_vals | ( | dtuple_t * | entry, |
const 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.
[in,out] | entry | Index entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion (rollback or purge) |
[in] | index | Index; note that this may also be a non-clustered index |
[in] | update | An update vector built for the clustered index so that the field number in an upd_field is the clustered index position |
[in] | heap | Memory heap for allocating and copying the new values |
void row_upd_index_replace_new_col_vals_index_pos | ( | dtuple_t * | entry, |
const dict_index_t * | index, | ||
const upd_t * | update, | ||
bool | order_only, | ||
mem_heap_t * | heap | ||
) |
Replaces the new column values stored in the update vector to the index entry given.
[in,out] | entry | Index entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion [rollback or purge] |
[in] | index | Index; note that this may also be a non-clustered index |
[in] | update | An update vector built for the index so that the field number in an upd_field is the index position |
[in] | order_only | If true, limit the replacement to ordering fields of index; note that this does not work for non-clustered indexes. |
[in] | heap | Memory heap for allocating and copying the new values |
void row_upd_index_write_log | ( | dict_index_t * | index, |
const upd_t * | update, | ||
byte * | log_ptr, | ||
mtr_t * | mtr | ||
) |
Writes to the redo log the new values of the fields occurring in the index.
[in] | index | index which to be updated |
[in] | update | update vector |
[in] | log_ptr | pointer to mlog buffer: must contain at least MLOG_BUF_MARGIN bytes of free space; the buffer is closed within this function |
[in] | mtr | mtr into whose log to write |
byte * row_upd_parse_sys_vals | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
ulint * | pos, | ||
trx_id_t * | trx_id, | ||
roll_ptr_t * | roll_ptr | ||
) |
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 |
void row_upd_rec_in_place | ( | rec_t * | rec, |
const 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
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 |
|
inlinestatic |
Updates the trx id and roll ptr field in a clustered index record when a row is updated or marked deleted.
[in,out] | rec | record |
[in,out] | page_zip | compressed page whose uncompressed part will be updated, or NULL |
[in] | index | clustered index |
[in] | offsets | rec_get_offsets(rec, index) |
[in] | trx | transaction |
[in] | roll_ptr | roll ptr of the undo log record, can be 0 during IMPORT |
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,out] | rec | Record |
[in,out] | page_zip | Compressed page, or null |
[in] | offsets | Array returned by rec_get_offsets() |
[in] | pos | Trx_id position in rec |
[in] | trx_id | Transaction id |
[in] | roll_ptr | Roll ptr of the undo log record |
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,out] | row | 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) |
[in,out] | ext | Null, or externally stored column prefixes |
[in] | index | Clustered index |
[in] | update | An update vector built for the clustered index |
[in] | heap | Memory heap |
void row_upd_replace_vcol | ( | dtuple_t * | row, |
const dict_table_t * | table, | ||
const upd_t * | update, | ||
bool | upd_new, | ||
dtuple_t * | undo_row, | ||
const byte * | ptr | ||
) |
Replaces the virtual column values stored in a dtuple with that of a update vector.
[in,out] | row | dtuple whose column to be updated |
[in] | table | table |
[in] | update | an update vector built for the clustered index |
[in] | upd_new | update to new or old value |
[in,out] | undo_row | undo row (if needs to be updated) |
[in] | ptr | remaining part in update undo log |
Updates a row in a table.
This is a high-level function used in SQL execution graphs.
This is a high-level function used in SQL execution graphs.
thr | in: query thread |
void row_upd_store_row | ( | upd_node_t * | node, |
THD * | thd, | ||
TABLE * | mysql_table | ||
) |
Stores to the heap the row on which the node->pcur is positioned.
[in] | node | row update node |
[in] | thd | mysql thread handle |
[in,out] | mysql_table | NULL, or mysql table object when user thread invokes dml |
byte * row_upd_write_sys_vals_to_log | ( | dict_index_t * | index, |
trx_id_t | trx_id, | ||
roll_ptr_t | roll_ptr, | ||
byte * | log_ptr, | ||
mtr_t * | mtr | ||
) |
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.
[in] | index | Clustered index. |
[in] | trx_id | Transaction ID. |
[in] | roll_ptr | Roll ptr of the undo log record. |
[in] | log_ptr | Pointer to a buffer of size > 20 opened in mlog. |
[in] | mtr | Mini-transaction. |
|
inlinestatic |
Creates an update vector object.
[in] | n | number of fields |
[in] | heap | heap from which memory allocated |
|
inlinestatic |
Sets an index field number to be updated by an update vector field.
[in] | upd_field | update vector field |
[in] | field_no | field number in a clustered index |
[in] | index | index |
|
inlinestatic |
set field number to a update vector field, marks this field is updated
[in,out] | upd_field | update vector field |
[in] | field_no | virtual column sequence num |
[in] | index | index |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Returns a field of an update vector by field_no.
[in] | update | Update vector. |
[in] | no | Field no. |
[in] | is_virtual | If it is a virtual column. |
Returns the number of fields in the update vector == number of columns to be updated by an update vector.
|
inlinestatic |
Returns the nth field of an update vector.
[in] | update | update vector |
[in] | n | field position in update vector |
upd_node_t * upd_node_create | ( | mem_heap_t * | heap | ) |
Creates an update node for a query graph.
heap | in: mem heap where created |
|
constexpr |
|
constexpr |
|
constexpr |
no secondary index record will be changed in the update and no ordering field of the clustered index
|
constexpr |
no record field size will be changed in the update
|
constexpr |
execution came to the node from a node above and if the field has_clust_rec_x_lock is false, we should set an intention x-lock on the table
|
constexpr |
an ordering field of the clustered index record was changed, or this is a delete operation: should update all the secondary index records
|
constexpr |
clustered index record should be updated
|
constexpr |
secondary index entries should be looked at and updated if an ordering field changed