MySQL 9.1.0
Source Code Documentation
row0upd.cc File Reference

Update of a row. More...

#include <sys/types.h>
#include "dict0dict.h"
#include "ha_prototypes.h"
#include "my_byteorder.h"
#include "my_dbug.h"
#include "rem0rec.h"
#include "row0upd.h"
#include "trx0undo.h"
#include <algorithm>
#include <debug_sync.h>
#include "btr0btr.h"
#include "btr0cur.h"
#include "buf0lru.h"
#include "current_thd.h"
#include "dict0boot.h"
#include "dict0crea.h"
#include "eval0eval.h"
#include "fts0fts.h"
#include "fts0types.h"
#include "lob0lob.h"
#include "lock0lock.h"
#include "log0chkp.h"
#include "mach0data.h"
#include "pars0sym.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "row0ext.h"
#include "row0ins.h"
#include "row0log.h"
#include "row0row.h"
#include "row0sel.h"
#include "trx0rec.h"
#include "dict0dd.h"

Functions

static bool row_upd_changes_first_fields_binary (dtuple_t *entry, dict_index_t *index, const upd_t *update, ulint n)
 Checks if an update vector changes some of the first ordering fields of an index record. More...
 
static bool row_upd_index_is_referenced (dict_index_t *index)
 Checks if index currently is mentioned as a referenced index in a foreign key constraint. More...
 
static dberr_t row_upd_check_references_constraints (upd_node_t *node, btr_pcur_t *pcur, dict_table_t *table, dict_index_t *index, ulint *offsets, que_thr_t *thr, mtr_t *mtr)
 Checks if possible foreign key constraints hold after a delete of the record under pcur. More...
 
upd_node_tupd_node_create (mem_heap_t *heap)
 Creates an update node for a query graph. 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...
 
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...
 
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...
 
byterow_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...
 
byterow_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_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...
 
byterow_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...
 
upd_trow_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_trow_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...
 
static byterow_upd_ext_fetch (dict_index_t *clust_index, const byte *data, ulint local_len, const page_size_t &page_size, ulint *len, bool is_sdi, mem_heap_t *heap)
 Fetch a prefix of an externally stored column. More...
 
static void row_upd_index_replace_new_col_val_func (const dict_index_t *index, dfield_t *dfield, const dict_field_t *field, const dict_col_t *col, const upd_field_t *uf, mem_heap_t *heap, bool is_sdi, const page_size_t &page_size)
 Replaces the new column value stored in the update vector in the given index entry field. More...
 
static void row_upd_index_replace_new_col_val (const dict_index_t *index, dfield_t *dfield, const dict_field_t *field, const dict_col_t *col, const upd_field_t *uf, mem_heap_t *heap, bool is_sdi, const page_size_t &page_size)
 
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...
 
static void row_upd_set_vcol_data (dtuple_t *row, const byte *field, ulint len, dict_v_col_t *vcol)
 Replaces the virtual 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...
 
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...
 
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...
 
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...
 
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...
 
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...
 
static void row_upd_copy_columns (rec_t *rec, const ulint *offsets, const dict_index_t *index, sym_node_t *column)
 Copies the column values from a record. More...
 
static void row_upd_eval_new_vals (upd_t *update)
 Calculates the new values for fields to update. More...
 
static void row_upd_dup_v_new_vals (const upd_t *update)
 Copies the data pointed to by the new values for virtual fields to update. More...
 
static void row_upd_store_v_row (upd_node_t *node, const upd_t *update, THD *thd, TABLE *mysql_table)
 Stores to the heap the virtual columns that need for any indexes. 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...
 
static void srv_mbr_print (const byte *data)
 Print a MBR data from disk. More...
 
static dberr_t row_upd_del_one_multi_sec_index_entry (dict_index_t *index, dtuple_t *entry, que_thr_t *thr)
 Delete mark a secondary index entry of a row, when the index is built on multi-value field. More...
 
static dberr_t row_upd_multi_sec_index_entry (upd_node_t *node, que_thr_t *thr, bool non_mv_upd)
 Updates secondary index entries of a row, when the index is built on multi-value field. More...
 
static dberr_t row_upd_sec_index_entry_low (upd_node_t *node, dtuple_t *old_entry, que_thr_t *thr)
 Updates a secondary index entry of a row. More...
 
static dberr_t row_upd_sec_index_entry (upd_node_t *node, que_thr_t *thr)
 Updates a secondary index entry of a row. More...
 
static dberr_t row_upd_del_multi_sec_index_entry (upd_node_t *node, que_thr_t *thr)
 Delete secondary index entries of a row, when the index is built on multi-value field. More...
 
static dberr_t row_upd_sec_step (upd_node_t *node, que_thr_t *thr)
 Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. More...
 
static bool row_upd_clust_rec_by_insert_inherit_func (const dict_index_t *index, const rec_t *rec, const ulint *offsets, dtuple_t *entry, const upd_t *update)
 Mark non-updated off-page columns inherited when the primary key is updated. More...
 
static bool row_upd_clust_rec_by_insert_inherit (const dict_index_t *index, const rec_t *rec, const ulint *offsets, dtuple_t *entry, const upd_t *update)
 
static dberr_t row_upd_clust_rec_by_insert (ulint flags, upd_node_t *node, dict_index_t *index, que_thr_t *thr, bool referenced, mtr_t *mtr)
 Marks the clustered index record deleted and inserts the updated version of the record to the index. 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...
 
static bool row_upd_check_autoinc_counter (const upd_node_t *node, mtr_t *mtr)
 If the table has autoinc column and the counter is updated to some bigger value, we need to log the new autoinc counter. More...
 
static dberr_t row_upd_clust_rec (ulint flags, upd_node_t *node, dict_index_t *index, ulint *offsets, mem_heap_t **offsets_heap, que_thr_t *thr, mtr_t *mtr)
 Updates a clustered index record of a row when the ordering fields do not change. More...
 
static dberr_t row_upd_del_mark_clust_rec (ulint flags, upd_node_t *node, dict_index_t *index, ulint *offsets, que_thr_t *thr, bool referenced, mtr_t *mtr)
 Delete marks a clustered index record. More...
 
static dberr_t row_upd_clust_step (upd_node_t *node, que_thr_t *const thr)
 Updates the clustered index record. More...
 
static dberr_t row_upd (upd_node_t *node, que_thr_t *thr)
 Updates the affected index records of a row. More...
 
que_thr_trow_upd_step (que_thr_t *thr)
 Updates a row in a table. More...
 
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, Field *fld)
 

Detailed Description

Update of a row.

Created 12/27/1996 Heikki Tuuri

Function Documentation

◆ print_binary_diff() [1/2]

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.

Parameters
[in]outthe output stream
[in]bdiffbinary diff to be printed.
[in]tablethe table dictionary object.
[in]fieldmysql field object.
[in]print_oldprints old data of the updated field
Returns
the output stream

◆ print_binary_diff() [2/2]

std::ostream & print_binary_diff ( std::ostream &  out,
const Binary_diff bdiff,
Field fld 
)

◆ row_upd()

static dberr_t row_upd ( upd_node_t node,
que_thr_t thr 
)
static

Updates the affected index records of a row.

When the control is transferred to this node, we assume that we have a persistent cursor which was on a record, and the position of the cursor is stored in the cursor.

Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT
Parameters
nodein: row update node
thrin: query thread

◆ row_upd_build_difference_binary()

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!

Parameters
[in]indexclustered index
[in]entryclustered index entry to insert
[in]recclustered index record
[in]offsetsrec_get_offsets(rec,index), or NULL
[in]no_sysskip the system columns DB_TRX_ID and DB_ROLL_PTR
[in]trxtransaction (for diagnostics), or NULL
[in]heapmemory heap from which allocated
[in]mysql_tableNULL, or mysql table object when user thread invokes dml
[out]errorerror number in case of failure
Returns
own: update vector of differing fields, excluding roll ptr and trx id

◆ row_upd_build_sec_rec_difference_binary()

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!

Returns
own: update vector of differing fields
Parameters
recin: secondary index record
indexin: index
offsetsin: rec_get_offsets(rec, index)
entryin: entry to insert
heapin: memory heap from which allocated

◆ row_upd_changes_disowned_external()

bool row_upd_changes_disowned_external ( const upd_t update)

Returns true if row update contains disowned external fields.

Returns
true if the update contains disowned external fields.
Parameters
updatein: update vector

◆ row_upd_changes_doc_id()

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.

Returns
whether the Doc ID column is changed
Parameters
tablein: table
upd_fieldin: field to check

◆ row_upd_changes_field_size_or_external()

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.

Returns
true if the update changes the size of some field in index or the field is external in rec or update
Parameters
indexin: index
offsetsin: rec_get_offsets(rec, index)
updatein: update vector

◆ row_upd_changes_first_fields_binary()

static bool row_upd_changes_first_fields_binary ( dtuple_t entry,
dict_index_t index,
const upd_t update,
ulint  n 
)
static

Checks if an update vector changes some of the first ordering fields of an index record.

This is only used in foreign key checks and we can assume that index does not contain column prefixes.

Returns
true if changes in: how many first fields to check

This is only used in foreign key checks and we can assume that index does not contain column prefixes.

Returns
true if changes
Parameters
entryin: old value of index entry
indexin: index of entry
updatein: update vector for the row
nin: how many first fields to check

◆ row_upd_changes_fts_column()

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.

Returns
offset within fts_t::indexes if FTS indexed column updated else ULINT_UNDEFINED
Parameters
tablein: table
upd_fieldin: field to check

◆ row_upd_changes_ord_field_binary_func()

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!

Parameters
[in]indexindex of the record
[in]updateupdate vector for the row; NOTE: the field numbers in this MUST be clustered index positions!
[in]thrquery thread, or NULL
[in]rowold 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]extNULL, or prefixes of the externally stored columns in the old row
[in,out]non_mv_updNULL, or not NULL pointer to get the information about whether any non-multi-value field on the multi-value index gets updated
[in]flagROW_BUILD_NORMAL, ROW_BUILD_FOR_PURGE or ROW_BUILD_FOR_UNDO
Returns
true if update vector changes an ordering field in the index record

◆ row_upd_changes_some_index_ord_field_binary()

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.

NOTE: we compare the fields as binary strings!

Returns
true if update vector may change an ordering field in an index record
Parameters
tablein: table
updatein: update vector for the row

◆ row_upd_check_autoinc_counter()

static bool row_upd_check_autoinc_counter ( const upd_node_t node,
mtr_t mtr 
)
static

If the table has autoinc column and the counter is updated to some bigger value, we need to log the new autoinc counter.

We will use the given mtr to do logging for performance reasons.

Parameters
[in]nodeRow update node
[in,out]mtrMini-transaction
Returns
true if auto increment needs to be persisted to DD table buffer.

◆ row_upd_check_references_constraints()

static dberr_t row_upd_check_references_constraints ( upd_node_t node,
btr_pcur_t pcur,
dict_table_t table,
dict_index_t index,
ulint offsets,
que_thr_t thr,
mtr_t mtr 
)
static

Checks if possible foreign key constraints hold after a delete of the record under pcur.

NOTE that this function will temporarily commit mtr and lose the pcur position!

Returns
DB_SUCCESS or an error code
Parameters
nodein: row update node
pcurin: cursor positioned on a record; NOTE: the cursor position is lost in this function!
tablein: table in question
indexin: index of the cursor
offsetsin/out: rec_get_offsets(pcur.rec, index)
thrin: query thread
mtrin: mtr

◆ row_upd_clust_rec()

static dberr_t row_upd_clust_rec ( ulint  flags,
upd_node_t node,
dict_index_t index,
ulint offsets,
mem_heap_t **  offsets_heap,
que_thr_t thr,
mtr_t mtr 
)
static

Updates a clustered index record of a row when the ordering fields do not change.

Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT
Parameters
flagsin: undo logging and locking flags
nodein: row update node
indexin: clustered index
offsetsin: rec_get_offsets() on node->pcur
offsets_heapin/out: memory heap, can be emptied
thrin: query thread
mtrin: mtr; gets committed here

◆ row_upd_clust_rec_by_insert()

static dberr_t row_upd_clust_rec_by_insert ( ulint  flags,
upd_node_t node,
dict_index_t index,
que_thr_t thr,
bool  referenced,
mtr_t mtr 
)
static

Marks the clustered index record deleted and inserts the updated version of the record to the index.

This function should be used when the ordering fields of the clustered index record change. This should be quite rare in database applications.

Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT
Parameters
flagsin: undo logging and locking flags
nodein/out: row update node
indexin: clustered index of the record
thrin: query thread
referencedin: true if index may be referenced in a foreign key constraint
mtrin/out: mtr; gets committed here

◆ row_upd_clust_rec_by_insert_inherit()

static bool row_upd_clust_rec_by_insert_inherit ( const dict_index_t index,
const rec_t rec,
const ulint offsets,
dtuple_t entry,
const upd_t update 
)
inlinestatic

◆ row_upd_clust_rec_by_insert_inherit_func()

static bool row_upd_clust_rec_by_insert_inherit_func ( const dict_index_t index,
const rec_t rec,
const ulint offsets,
dtuple_t entry,
const upd_t update 
)
static

Mark non-updated off-page columns inherited when the primary key is updated.

We must mark them as inherited in entry, so that they are not freed in a rollback. A limited version of this function used to be called btr_cur_mark_dtuple_inherited_extern().

Parameters
[in]indexIndex describing record's fields.
[in]recold record, or NULL
[in]offsetsrec_get_offsets(rec), or NULL
[in,out]entryupdated entry to be inserted into the clustered index
[in]updateupdate vector
Returns
whether any columns were inherited

◆ row_upd_clust_step()

static dberr_t row_upd_clust_step ( upd_node_t node,
que_thr_t *const  thr 
)
static

Updates the clustered index record.

Returns
DB_SUCCESS if operation successfully completed, DB_LOCK_WAIT in case of a lock wait, else error code
Parameters
nodein: row update node
thrin: query thread

◆ row_upd_copy_columns()

static void row_upd_copy_columns ( rec_t rec,
const ulint offsets,
const dict_index_t index,
sym_node_t column 
)
inlinestatic

Copies the column values from a record.

Parameters
[in]recrecord in a clustered index
[in]offsetsarray returned by rec_get_offsets()
[in]indexclustered index where record resides
[in]columnfirst column in a column list, or nullptr

◆ row_upd_del_mark_clust_rec()

static dberr_t row_upd_del_mark_clust_rec ( ulint  flags,
upd_node_t node,
dict_index_t index,
ulint offsets,
que_thr_t thr,
bool  referenced,
mtr_t mtr 
)
static

Delete marks a clustered index record.

Returns
DB_SUCCESS if operation successfully completed, else error code
Parameters
flagsin: undo logging and locking flags
nodein: row update node
indexin: clustered index
offsetsin/out: rec_get_offsets() for the record under the cursor
thrin: query thread
referencedin: true if index may be referenced in a foreign key constraint
mtrin: mtr; gets committed here

◆ row_upd_del_multi_sec_index_entry()

static dberr_t row_upd_del_multi_sec_index_entry ( upd_node_t node,
que_thr_t thr 
)
inlinestatic

Delete secondary index entries of a row, when the index is built on multi-value field.

Parameters
[in,out]noderow update node
[in]thrquery thread
Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT

◆ row_upd_del_one_multi_sec_index_entry()

static dberr_t row_upd_del_one_multi_sec_index_entry ( dict_index_t index,
dtuple_t entry,
que_thr_t thr 
)
inlinestatic

Delete mark a secondary index entry of a row, when the index is built on multi-value field.

Parameters
[in]indexthe multi-value index
[in]entrythe entry to handle on the index
[in]thrquery thread
Returns
DB_SUCCESS on success, otherwise error code

◆ row_upd_dup_v_new_vals()

static void row_upd_dup_v_new_vals ( const upd_t update)
static

Copies the data pointed to by the new values for virtual fields to update.

Parameters
[in,out]updatean update vector

◆ row_upd_eval_new_vals()

static void row_upd_eval_new_vals ( upd_t update)
inlinestatic

Calculates the new values for fields to update.

Note that row_upd_copy_columns must have been called first.

Parameters
updatein/out: update vector

◆ row_upd_ext_fetch()

static byte * row_upd_ext_fetch ( dict_index_t clust_index,
const byte data,
ulint  local_len,
const page_size_t page_size,
ulint len,
bool  is_sdi,
mem_heap_t heap 
)
static

Fetch a prefix of an externally stored column.

This is similar to row_ext_lookup(), but the row_ext_t holds the old values of the column and must not be poisoned with the new values.

Parameters
[in]clust_indexthe clustered index.
[in]data'internally' stored part of the field containing also the reference to the external part
[in]local_lenlength of data, in bytes
[in]page_sizeBLOB page size
[in,out]leninput - length of prefix to fetch; output: fetched length of the prefix
[in]is_sditrue for SDI indexes
[in,out]heapheap where to allocate
Returns
BLOB prefix

◆ row_upd_get_new_autoinc_counter()

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.

Parameters
[in]updateupdate vector for the clustered index
[in]autoinc_field_noautoinc field's order in clustered index
Returns
the new counter if we find it in the update vector, otherwise 0. We don't mind that the new counter happens to be 0, we just care about non-zero counters.

◆ row_upd_index_entry_sys_field()

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.

Parameters
[in,out]entryIndex entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to them
[in]indexClustered index
[in]typeData_trx_id or data_roll_ptr
[in]valValue to write

◆ row_upd_index_is_referenced()

static bool row_upd_index_is_referenced ( dict_index_t index)
static

Checks if index currently is mentioned as a referenced index in a foreign key constraint.

NOTE that since we do not hold dict_operation_lock when leaving the function, it may be that the referencing table has been dropped when we leave this function: this function is only for heuristic use!

Returns
true if referenced
Parameters
indexin: index

◆ row_upd_index_parse()

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.

Returns
log data end or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
heapin: memory heap where update vector is built
update_outout: update vector

◆ row_upd_index_replace_new_col_val()

static void row_upd_index_replace_new_col_val ( const dict_index_t index,
dfield_t dfield,
const dict_field_t field,
const dict_col_t col,
const upd_field_t uf,
mem_heap_t heap,
bool  is_sdi,
const page_size_t page_size 
)
inlinestatic

◆ row_upd_index_replace_new_col_val_func()

static void row_upd_index_replace_new_col_val_func ( const dict_index_t index,
dfield_t dfield,
const dict_field_t field,
const dict_col_t col,
const upd_field_t uf,
mem_heap_t heap,
bool  is_sdi,
const page_size_t page_size 
)
static

Replaces the new column value stored in the update vector in the given index entry field.

Parameters
[in]indexindex dictionary object.
[in,out]dfielddata field of the index entry
[in]fieldindex field
[in]colfield->col
[in]ufupdate field
[in,out]heapmemory heap for allocating and copying the new value
[in]is_sditrue for SDI indexes
[in]page_sizepage size

◆ row_upd_index_replace_new_col_vals()

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.

Parameters
[in,out]entryIndex entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion (rollback or purge)
[in]indexIndex; note that this may also be a non-clustered index
[in]updateAn update vector built for the clustered index so that the field number in an upd_field is the clustered index position
[in]heapMemory heap for allocating and copying the new values

◆ row_upd_index_replace_new_col_vals_index_pos()

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.

Parameters
[in,out]entryIndex entry where replaced; the clustered index record must be covered by a lock or a page latch to prevent deletion [rollback or purge]
[in]indexIndex; note that this may also be a non-clustered index
[in]updateAn update vector built for the index so that the field number in an upd_field is the index position
[in]order_onlyIf true, limit the replacement to ordering fields of index; note that this does not work for non-clustered indexes.
[in]heapMemory heap for allocating and copying the new values

◆ row_upd_index_write_log()

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.

Parameters
[in]indexindex which to be updated
[in]updateupdate vector
[in]log_ptrpointer to mlog buffer: must contain at least MLOG_BUF_MARGIN bytes of free space; the buffer is closed within this function
[in]mtrmtr into whose log to write

◆ row_upd_multi_sec_index_entry()

static dberr_t row_upd_multi_sec_index_entry ( upd_node_t node,
que_thr_t thr,
bool  non_mv_upd 
)
static

Updates secondary index entries of a row, when the index is built on multi-value field.

Parameters
[in,out]noderow update node
[in]thrquery thread
[in]non_mv_updtrue if any non-multi-value field on the index gets updated too
Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT

◆ row_upd_parse_sys_vals()

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.

Returns
log data end or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
posout: TRX_ID position in record
trx_idout: trx id
roll_ptrout: roll ptr

◆ row_upd_rec_in_place()

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().

Parameters
recin/out: record where replaced
indexin: the index the record belongs to
offsetsin: array returned by rec_get_offsets()
updatein: update vector
page_zipin: compressed page with enough space available, or NULL

◆ row_upd_rec_sys_fields_in_recovery()

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.

Parameters
[in,out]recRecord
[in,out]page_zipCompressed page, or null
[in]offsetsArray returned by rec_get_offsets()
[in]posTrx_id position in rec
[in]trx_idTransaction id
[in]roll_ptrRoll ptr of the undo log record

◆ row_upd_replace()

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.

Parameters
[in,out]rowRow 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]extNull, or externally stored column prefixes
[in]indexClustered index
[in]updateAn update vector built for the clustered index
[in]heapMemory heap

◆ row_upd_replace_vcol()

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.

Parameters
[in,out]rowdtuple whose column to be updated
[in]tabletable
[in]updatean update vector built for the clustered index
[in]upd_newupdate to new or old value
[in,out]undo_rowundo row (if needs to be updated)
[in]ptrremaining part in update undo log

◆ row_upd_sec_index_entry()

static dberr_t row_upd_sec_index_entry ( upd_node_t node,
que_thr_t thr 
)
inlinestatic

Updates a secondary index entry of a row.

Parameters
[in]noderow update node
[in]thrquery thread
Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT

◆ row_upd_sec_index_entry_low()

static dberr_t row_upd_sec_index_entry_low ( upd_node_t node,
dtuple_t old_entry,
que_thr_t thr 
)
static

Updates a secondary index entry of a row.

Parameters
[in]noderow update node
[in]old_entrythe old entry to search, or nullptr then it has to be created in this function
[in]thrquery thread
Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT

◆ row_upd_sec_step()

static dberr_t row_upd_sec_step ( upd_node_t node,
que_thr_t thr 
)
static

Updates the secondary index record if it is changed in the row update or deletes it if this is a delete.

Returns
DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT
Parameters
nodein: row update node
thrin: query thread

◆ row_upd_set_vcol_data()

static void row_upd_set_vcol_data ( dtuple_t row,
const byte field,
ulint  len,
dict_v_col_t vcol 
)
static

Replaces the virtual column values stored in the update vector.

Parameters
[in,out]rowrow whose column to be set
[in]fielddata to set
[in]lendata length
[in]vcolvirtual column info

◆ row_upd_step()

que_thr_t * row_upd_step ( que_thr_t thr)

Updates a row in a table.

This is a high-level function used in SQL execution graphs.

Returns
query thread to run next or NULL
Parameters
thrin: query thread

◆ row_upd_store_row()

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.

Parameters
[in]noderow update node
[in]thdmysql thread handle
[in,out]mysql_tableNULL, or mysql table object when user thread invokes dml

◆ row_upd_store_v_row()

static void row_upd_store_v_row ( upd_node_t node,
const upd_t update,
THD thd,
TABLE mysql_table 
)
static

Stores to the heap the virtual columns that need for any indexes.

Parameters
[in,out]noderow update node
[in,out]updatean update vector if it is update
[in]thdmysql thread handle
[in,out]mysql_tablemysql table object

◆ row_upd_write_sys_vals_to_log()

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.

Parameters
[in]indexClustered index.
[in]trx_idTransaction ID.
[in]roll_ptrRoll ptr of the undo log record.
[in]log_ptrPointer to a buffer of size > 20 opened in mlog.
[in]mtrMini-transaction.
Returns
new pointer to mlog

◆ srv_mbr_print()

static void srv_mbr_print ( const byte data)
static

Print a MBR data from disk.

◆ upd_node_create()

upd_node_t * upd_node_create ( mem_heap_t heap)

Creates an update node for a query graph.

Returns
own: update node
Parameters
heapin: mem heap where created