MySQL 8.4.2
Source Code Documentation
|
General row routines. More...
#include "row0row.h"
#include <sys/types.h>
#include "btr0btr.h"
#include "data0type.h"
#include "dict0boot.h"
#include "dict0dict.h"
#include "ha_prototypes.h"
#include "lob0lob.h"
#include "mach0data.h"
#include "que0que.h"
#include "read0read.h"
#include "rem0cmp.h"
#include "row0ext.h"
#include "row0mysql.h"
#include "row0upd.h"
#include "trx0purge.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "trx0undo.h"
#include "ut0mem.h"
Functions | |
dtuple_t * | row_build_index_entry_low (const dtuple_t *row, const row_ext_t *ext, const dict_index_t *index, mem_heap_t *heap, ulint flag) |
When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. More... | |
static dtuple_t * | row_build_low (ulint type, const dict_index_t *index, const rec_t *rec, const ulint *offsets, const dict_table_t *col_table, const dtuple_t *add_cols, const dict_add_v_col_t *add_v, const ulint *col_map, row_ext_t **ext, mem_heap_t *heap) |
An inverse function to row_build_index_entry. More... | |
dtuple_t * | row_build (ulint type, const dict_index_t *index, const rec_t *rec, const ulint *offsets, const dict_table_t *col_table, const dtuple_t *add_cols, const ulint *col_map, row_ext_t **ext, mem_heap_t *heap) |
An inverse function to row_build_index_entry. More... | |
dtuple_t * | row_build_w_add_vcol (ulint type, const dict_index_t *index, const rec_t *rec, const ulint *offsets, const dict_table_t *col_table, const dtuple_t *add_cols, const dict_add_v_col_t *add_v, const ulint *col_map, row_ext_t **ext, mem_heap_t *heap) |
An inverse function to row_build_index_entry. More... | |
dtuple_t * | row_rec_to_index_entry_low (const rec_t *rec, const dict_index_t *index, const ulint *offsets, mem_heap_t *heap) |
Converts an index record to a typed data tuple. More... | |
dtuple_t * | row_rec_to_index_entry (const rec_t *rec, const dict_index_t *index, const ulint *offsets, mem_heap_t *heap) |
Converts an index record to a typed data tuple. More... | |
dtuple_t * | row_build_row_ref (ulint type, const dict_index_t *index, const rec_t *rec, mem_heap_t *heap) |
Builds from a secondary index record a row reference with which we can search the clustered index record. More... | |
void | row_build_row_ref_in_tuple (dtuple_t *ref, const rec_t *rec, const dict_index_t *index, ulint *offsets) |
Builds from a secondary index record a row reference with which we can search the clustered index record. More... | |
bool | row_search_on_row_ref (btr_pcur_t *pcur, ulint mode, dict_table_t *table, const dtuple_t *ref, mtr_t *mtr) |
Searches the clustered index record for a row, if we have the row reference. More... | |
rec_t * | row_get_clust_rec (ulint mode, const rec_t *rec, const dict_index_t *index, dict_index_t **clust_index, mtr_t *mtr) |
Fetches the clustered index record for a secondary index record. More... | |
uint64_t | row_parse_int_from_field (const dfield_t *field) |
Parse the integer data from specified field, which could be DATA_INT, DATA_FLOAT or DATA_DOUBLE. More... | |
uint64_t | row_get_autoinc_counter (const dtuple_t *row, ulint n) |
Read the autoinc counter from the clustered index row. More... | |
enum row_search_result | row_search_index_entry (dict_index_t *index, const dtuple_t *entry, ulint mode, btr_pcur_t *pcur, mtr_t *mtr) |
Searches an index record. More... | |
static ulint | row_raw_format_int (const char *data, ulint data_len, ulint prtype, char *buf, ulint buf_size, bool *format_in_hex) |
Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_INT using "prtype" and writes the result to "buf". More... | |
static ulint | row_raw_format_str (const char *data, ulint data_len, ulint prtype, char *buf, ulint buf_size, bool *format_in_hex) |
Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "prtype" and writes the result to "buf". More... | |
ulint | row_raw_format (const char *data, ulint data_len, const dict_field_t *dict_field, char *buf, ulint buf_size) |
Formats the raw data in "data" (in InnoDB on-disk format) using "dict_field" and writes the result to "buf". More... | |
General row routines.
Created 4/20/1996 Heikki Tuuri
dtuple_t * row_build | ( | ulint | type, |
const dict_index_t * | index, | ||
const rec_t * | rec, | ||
const ulint * | offsets, | ||
const dict_table_t * | col_table, | ||
const dtuple_t * | add_cols, | ||
const ulint * | col_map, | ||
row_ext_t ** | ext, | ||
mem_heap_t * | heap | ||
) |
An inverse function to row_build_index_entry.
Builds a row from a record in a clustered index.
[in] | type | ROW_COPY_POINTERS or ROW_COPY_DATA; the latter copies also the data fields to heap while the first only places pointers to data fields on the index page, and thus is more efficient. |
[in] | index | Clustered index. |
[in] | rec | Record in the clustered index; NOTE: in the case ROW_COPY_POINTERS the data fields in the row will point directly into this record, therefore, the buffer page of this record must be at least s-latched and the latch held as long as the row dtuple is used! |
[in] | offsets | rec_get_offsets(rec,index) or nullptr, in which case this function will invoke rec_get_offsets(). |
[in] | col_table | Table, to check which externally stored columns occur in the ordering columns of an index, or nullptr if index->table should be consulted instead; the user columns in this table should be the same columns as in index->table. |
[in] | add_cols | Default values of added columns, or nullptr. |
[in] | col_map | Mapping of old column numbers to new ones, or nullptr. |
[out] | ext | cache of externally stored column prefixes, or nullptr. |
[in] | heap | Memory heap from which the memory needed is allocated. |
dtuple_t * row_build_index_entry_low | ( | const dtuple_t * | row, |
const row_ext_t * | ext, | ||
const dict_index_t * | index, | ||
mem_heap_t * | heap, | ||
ulint | flag | ||
) |
When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table.
[in] | row | Row which should be inserted or purged. |
[in] | ext | Externally stored column prefixes, or nullptr. |
[in] | index | Index on the table. |
[in] | heap | Memory heap from which the memory for the index entry is allocated. |
[in] | flag | ROW_BUILD_NORMAL, ROW_BUILD_FOR_PURGE or ROW_BUILD_FOR_UNDO. |
NULL | if the externally stored columns in the clustered index record are unavailable and ext != nullptr, or row is missing some needed columns. |
|
inlinestatic |
An inverse function to row_build_index_entry.
Builds a row from a record in a clustered index, with possible indexing on ongoing addition of new virtual columns.
[in] | type | ROW_COPY_POINTERS or ROW_COPY_DATA; |
[in] | index | clustered index |
[in] | rec | record in the clustered index |
[in] | offsets | rec_get_offsets(rec,index) or NULL |
[in] | col_table | table, to check which externally stored columns occur in the ordering columns of an index, or NULL if index->table should be consulted instead |
[in] | add_cols | default values of added columns, or NULL |
[in] | add_v | new virtual columns added along with new indexes |
[in] | col_map | mapping of old column numbers to new ones, or NULL |
[in] | ext | cache of externally stored column prefixes, or NULL |
[in] | heap | memory heap from which the memory needed is allocated |
dtuple_t * row_build_row_ref | ( | ulint | type, |
const dict_index_t * | index, | ||
const rec_t * | rec, | ||
mem_heap_t * | heap | ||
) |
Builds from a secondary index record a row reference with which we can search the clustered index record.
type | in: ROW_COPY_DATA, or ROW_COPY_POINTERS: the former copies also the data fields to heap, whereas the latter only places pointers to data fields on the index page |
index | in: secondary index |
rec | in: record in the index; NOTE: in the case ROW_COPY_POINTERS the data fields in the row will point directly into this record, therefore, the buffer page of this record must be at least s-latched and the latch held as long as the row reference is used! |
heap | in: memory heap from which the memory needed is allocated |
void row_build_row_ref_in_tuple | ( | dtuple_t * | ref, |
const rec_t * | rec, | ||
const dict_index_t * | index, | ||
ulint * | offsets | ||
) |
Builds from a secondary index record a row reference with which we can search the clustered index record.
[in,out] | ref | Row reference built; see the note below! |
[in,out] | rec | Record in the index; note: the data fields in ref will point directly into this record, therefore, the buffer page of this record must be at least s-latched and the latch held as long as the row reference is used! |
[in] | index | Secondary index |
[in] | offsets | Rec_get_offsets(rec, index) or null |
dtuple_t * row_build_w_add_vcol | ( | ulint | type, |
const dict_index_t * | index, | ||
const rec_t * | rec, | ||
const ulint * | offsets, | ||
const dict_table_t * | col_table, | ||
const dtuple_t * | add_cols, | ||
const dict_add_v_col_t * | add_v, | ||
const ulint * | col_map, | ||
row_ext_t ** | ext, | ||
mem_heap_t * | heap | ||
) |
An inverse function to row_build_index_entry.
Builds a row from a record in a clustered index, with possible indexing on ongoing addition of new virtual columns.
[in] | type | ROW_COPY_POINTERS or ROW_COPY_DATA; |
[in] | index | clustered index |
[in] | rec | record in the clustered index |
[in] | offsets | rec_get_offsets(rec,index) or NULL |
[in] | col_table | table, to check which externally stored columns occur in the ordering columns of an index, or NULL if index->table should be consulted instead |
[in] | add_cols | default values of added columns, or NULL |
[in] | add_v | new virtual columns added along with new indexes |
[in] | col_map | mapping of old column numbers to new ones, or NULL |
[in] | ext | cache of externally stored column prefixes, or NULL |
[in] | heap | memory heap from which the memory needed is allocated |
Read the autoinc counter from the clustered index row.
[in] | row | row to read the autoinc counter |
[in] | n | autoinc counter is in the nth field |
rec_t * row_get_clust_rec | ( | ulint | mode, |
const rec_t * | rec, | ||
const dict_index_t * | index, | ||
dict_index_t ** | clust_index, | ||
mtr_t * | mtr | ||
) |
Fetches the clustered index record for a secondary index record.
The latches on the secondary index record are preserved.
mode | in: BTR_MODIFY_LEAF, ... |
rec | in: record in a secondary index |
index | in: secondary index |
clust_index | out: clustered index |
mtr | in: mtr |
uint64_t row_parse_int_from_field | ( | const dfield_t * | field | ) |
Parse the integer data from specified field, which could be DATA_INT, DATA_FLOAT or DATA_DOUBLE.
We could return 0 if 1) the value is less than 0 and the type is not unsigned or 2) the field is null.
[in] | field | field to read the int value |
ulint row_raw_format | ( | const char * | data, |
ulint | data_len, | ||
const dict_field_t * | dict_field, | ||
char * | buf, | ||
ulint | buf_size | ||
) |
Formats the raw data in "data" (in InnoDB on-disk format) using "dict_field" and writes the result to "buf".
Not more than "buf_size" bytes are written to "buf". The result is always NUL-terminated (provided buf_size is positive) and the number of bytes that were written to "buf" is returned (including the terminating NUL).
data | in: raw data |
data_len | in: raw data length in bytes |
dict_field | in: index field |
buf | out: output buffer |
buf_size | in: output buffer size in bytes |
|
static |
Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_INT using "prtype" and writes the result to "buf".
If the data is in unknown format, then nothing is written to "buf", 0 is returned and "format_in_hex" is set to true, otherwise "format_in_hex" is left untouched. Not more than "buf_size" bytes are written to "buf". The result is always '\0'-terminated (provided buf_size > 0) and the number of bytes that were written to "buf" is returned (including the terminating '\0').
data | in: raw data |
data_len | in: raw data length in bytes |
prtype | in: precise type |
buf | out: output buffer |
buf_size | in: output buffer size in bytes |
format_in_hex | out: should the data be formatted in hex |
|
static |
Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "prtype" and writes the result to "buf".
If the data is in binary format, then nothing is written to "buf", 0 is returned and "format_in_hex" is set to true, otherwise "format_in_hex" is left untouched. Not more than "buf_size" bytes are written to "buf". The result is always '\0'-terminated (provided buf_size > 0) and the number of bytes that were written to "buf" is returned (including the terminating '\0').
data | in: raw data |
data_len | in: raw data length in bytes |
prtype | in: precise type |
buf | out: output buffer |
buf_size | in: output buffer size in bytes |
format_in_hex | out: should the data be formatted in hex |
dtuple_t * row_rec_to_index_entry | ( | const rec_t * | rec, |
const dict_index_t * | index, | ||
const ulint * | offsets, | ||
mem_heap_t * | heap | ||
) |
Converts an index record to a typed data tuple.
NOTE that externally stored (often big) fields are NOT copied to heap.
rec | in: record in the index |
index | in: index |
offsets | in: rec_get_offsets(rec) |
heap | in: memory heap from which the memory needed is allocated |
dtuple_t * row_rec_to_index_entry_low | ( | const rec_t * | rec, |
const dict_index_t * | index, | ||
const ulint * | offsets, | ||
mem_heap_t * | heap | ||
) |
Converts an index record to a typed data tuple.
rec | in: record in the index |
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
heap | in: memory heap from which the memory needed is allocated |
enum row_search_result row_search_index_entry | ( | dict_index_t * | index, |
const dtuple_t * | entry, | ||
ulint | mode, | ||
btr_pcur_t * | pcur, | ||
mtr_t * | mtr | ||
) |
Searches an index record.
index | in: index |
entry | in: index entry |
mode | in: BTR_MODIFY_LEAF, ... |
pcur | in/out: persistent cursor, which must be closed by the caller |
mtr | in: mtr |
bool row_search_on_row_ref | ( | btr_pcur_t * | pcur, |
ulint | mode, | ||
dict_table_t * | table, | ||
const dtuple_t * | ref, | ||
mtr_t * | mtr | ||
) |
Searches the clustered index record for a row, if we have the row reference.
pcur | out: persistent cursor, which must be closed by the caller |
mode | in: BTR_MODIFY_LEAF, ... |
table | in: table |
ref | in: row reference |
mtr | in/out: mtr |