MySQL 9.0.0
Source Code Documentation
|
Record manager. More...
#include <ostream>
#include <sstream>
#include "univ.i"
#include "data0data.h"
#include "mtr0types.h"
#include "page0types.h"
#include "rem/rec.h"
#include "rem0types.h"
#include "trx0types.h"
#include "ut0class_life_cycle.h"
#include "rem0wrec.h"
#include "rem0rec.ic"
Go to the source code of this file.
Classes | |
class | Rec_offsets |
A helper RAII wrapper for otherwise difficult to use sequence of: More... | |
struct | rec_index_print |
Wrapper for pretty-printing a record. More... | |
struct | rec_offsets_print |
Wrapper for pretty-printing a record. More... | |
class | rec_printer |
Pretty-printer of records and tuples. More... | |
Macros | |
#define | rec_offs_init(offsets) rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets) |
Functions | |
static const rec_t * | rec_get_next_ptr_const (const rec_t *rec, ulint comp) |
The following function is used to get the pointer of the next chained record on the same page. More... | |
static rec_t * | rec_get_next_ptr (rec_t *rec, ulint comp) |
The following function is used to get the pointer of the next chained record on the same page. More... | |
static ulint | rec_get_next_offs (const rec_t *rec, ulint comp) |
The following function is used to get the offset of the next chained record on the same page. More... | |
static void | rec_set_next_offs_old (rec_t *rec, ulint next) |
The following function is used to set the next record offset field of an old-style record. More... | |
static void | rec_set_next_offs_new (rec_t *rec, ulint next) |
The following function is used to set the next record offset field of a new-style record. More... | |
static ulint | rec_get_n_owned_old (const rec_t *rec) |
The following function is used to get the number of records owned by the previous directory record. More... | |
static void | rec_set_n_owned_old (rec_t *rec, ulint n_owned) |
The following function is used to set the number of owned records. More... | |
static ulint | rec_get_n_owned_new (const rec_t *rec) |
The following function is used to get the number of records owned by the previous directory record. More... | |
static void | rec_set_n_owned_new (rec_t *rec, page_zip_des_t *page_zip, ulint n_owned) |
The following function is used to set the number of owned records. More... | |
static void | rec_set_info_bits_old (rec_t *rec, ulint bits) |
The following function is used to set the info bits of a record. More... | |
static void | rec_set_info_bits_new (rec_t *rec, ulint bits) |
The following function is used to set the info bits of a record. More... | |
static void | rec_set_status (rec_t *rec, ulint bits) |
The following function is used to set the status bits of a new-style record. More... | |
static ulint | rec_get_info_and_status_bits (const rec_t *rec, bool comp) |
The following function is used to retrieve the info and status bits of a record. More... | |
static void | rec_set_info_and_status_bits (rec_t *rec, ulint bits) |
The following function is used to set the info and status bits of a record. More... | |
static bool | rec_get_deleted_flag (const rec_t *rec, bool comp) |
The following function tells if record is delete marked. More... | |
static void | rec_set_deleted_flag_old (rec_t *rec, bool flag) |
The following function is used to set the deleted bit. More... | |
static void | rec_set_deleted_flag_new (rec_t *rec, page_zip_des_t *page_zip, bool flag) |
The following function is used to set the deleted bit. More... | |
static void | rec_new_set_instant (rec_t *rec) |
The following function is used to set the instant bit. More... | |
static void | rec_new_set_versioned (rec_t *rec) |
The following function is used to set the row version bit. More... | |
static void | rec_new_reset_instant_version (rec_t *rec) |
The following function is used to reset the instant bit and the row version bit. More... | |
static void | rec_old_set_versioned (rec_t *rec, bool flag) |
The following function is used to set the instant bit. More... | |
static bool | rec_get_node_ptr_flag (const rec_t *rec) |
The following function tells if a new-style record is a node pointer. More... | |
static ulint | rec_get_heap_no_old (const rec_t *rec) |
The following function is used to get the order number of an old-style record in the heap of the index page. More... | |
static void | rec_set_heap_no_old (rec_t *rec, ulint heap_no) |
The following function is used to set the heap number field in an old-style record. More... | |
static ulint | rec_get_heap_no_new (const rec_t *rec) |
The following function is used to get the order number of a new-style record in the heap of the index page. More... | |
static void | rec_set_heap_no_new (rec_t *rec, ulint heap_no) |
The following function is used to set the heap number field in a new-style record. More... | |
static void | rec_set_1byte_offs_flag (rec_t *rec, bool flag) |
The following function is used to set the 1-byte offsets flag. More... | |
ulint | rec_get_n_extern_new (const rec_t *rec, const dict_index_t *index, ulint n) |
Determine how many of the first n columns in a compact physical record are stored externally. More... | |
static const byte * | rec_get_nth_field_old_instant (const rec_t *rec, uint16_t n, const dict_index_t *index, ulint *len) |
Gets the value of the specified field in the record in old style. More... | |
static const byte * | rec_get_nth_field_instant (const rec_t *rec, const ulint *offsets, ulint n, const dict_index_t *index, ulint *len) |
Gets the value of the specified field in the record. More... | |
static bool | rec_field_not_null_not_add_col_def (ulint len) |
Determine if the field is not NULL and not having default value after instant ADD COLUMN. More... | |
static bool | rec_offs_comp (const ulint *offsets) |
Determine if the offsets are for a record in the new compact format. More... | |
static bool | rec_offs_any_extern (const ulint *offsets) |
Determine if the offsets are for a record containing externally stored columns. More... | |
static const byte * | rec_offs_any_null_extern (const dict_index_t *index, const rec_t *rec, const ulint *offsets) |
Determine if the offsets are for a record containing null BLOB pointers. More... | |
static ulint | rec_offs_n_extern (const dict_index_t *index, const ulint *offsets) |
Returns the number of extern bits set in a record. More... | |
static ulint | rec_offs_data_size (const ulint *offsets) |
The following function returns the data size of a physical record, that is the sum of field lengths. More... | |
static ulint | rec_offs_extra_size (const ulint *offsets) |
Returns the total size of record minus data size of record. More... | |
static ulint | rec_offs_size (const ulint *offsets) |
Returns the total size of a physical record. More... | |
static byte * | rec_get_start (const rec_t *rec, const ulint *offsets) |
Returns a pointer to the start of the record. More... | |
static byte * | rec_get_end (const rec_t *rec, const ulint *offsets) |
Returns a pointer to the end of the record. More... | |
static rec_t * | rec_copy (void *buf, const rec_t *rec, const ulint *offsets) |
Copy a physical record to a buffer. More... | |
ulint | rec_get_serialize_size (const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, ulint *extra, uint8_t rec_version) |
Determines the size of a data tuple prefix in a temporary file. More... | |
void | rec_deserialize_init_offsets (const rec_t *rec, const dict_index_t *index, ulint *offsets) |
Determine the offset to each field in temporary file. More... | |
void | rec_serialize_dtuple (rec_t *rec, const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, uint8_t rec_version) |
Builds a temporary file record out of a data tuple. More... | |
rec_t * | rec_copy_prefix_to_buf (const rec_t *rec, const dict_index_t *index, ulint n_fields, byte **buf, size_t *buf_size) |
Copies the first n fields of a physical record to a new physical record in a buffer. More... | |
static uint64_t | rec_hash (const rec_t *rec, const ulint *offsets, ulint n_fields, ulint n_bytes, uint64_t hashed_value, const dict_index_t *index) |
Compute a hash value of a prefix of a leaf page record. More... | |
rec_t * | rec_convert_dtuple_to_rec (byte *buf, const dict_index_t *index, const dtuple_t *dtuple) |
Builds a physical record out of a data tuple and stores it into the given buffer. More... | |
static ulint | rec_get_converted_extra_size (ulint data_size, ulint n_fields, bool has_ext) |
Returns the extra size of an old-style physical record if we know its data size and number of fields. More... | |
ulint | rec_get_converted_size_comp_prefix (const dict_index_t *index, const dfield_t *fields, ulint n_fields, ulint *extra) |
Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. More... | |
ulint | rec_get_converted_size_comp (const dict_index_t *index, ulint status, const dfield_t *fields, ulint n_fields, ulint *extra) |
Determines the size of a data tuple in ROW_FORMAT=COMPACT. More... | |
static ulint | rec_get_converted_size (const dict_index_t *index, const dtuple_t *dtuple) |
The following function returns the size of a data tuple when converted to a physical record. More... | |
void | rec_copy_prefix_to_dtuple (dtuple_t *tuple, const rec_t *rec, const dict_index_t *index, ulint n_fields, mem_heap_t *heap) |
Copies the first n fields of a physical record to a data tuple. More... | |
static uint8_t | rec_get_n_fields_length (ulint n_fields) |
Get the length of the number of fields for any new style record. More... | |
static void | rec_set_instant_row_version_new (rec_t *rec, uint8_t version) |
Set the row version on one new style leaf page record. More... | |
static void | rec_set_instant_row_version_old (rec_t *rec, uint8_t version) |
Set the row version on one old style leaf page record. More... | |
bool | rec_validate (const rec_t *rec, const ulint *offsets) |
Validates the consistency of a physical record. More... | |
void | rec_print_old (FILE *file, const rec_t *rec) |
Prints an old-style physical record. More... | |
void | rec_print_mbr_rec (FILE *file, const rec_t *rec, const ulint *offsets) |
Prints a spatial index record. More... | |
void | rec_print_new (FILE *file, const rec_t *rec, const ulint *offsets) |
Prints a physical record. More... | |
void | rec_print (FILE *file, const rec_t *rec, const dict_index_t *index) |
Prints a physical record. More... | |
void | rec_print (std::ostream &o, const rec_t *rec, ulint info, const ulint *offsets) |
Pretty-print a record. More... | |
std::ostream & | operator<< (std::ostream &o, const rec_index_print &r) |
Display a record. More... | |
std::ostream & | operator<< (std::ostream &o, const rec_offsets_print &r) |
Display a record. More... | |
trx_id_t | rec_get_trx_id (const rec_t *rec, const dict_index_t *index) |
Reads the DB_TRX_ID of a clustered index record. More... | |
bool | is_store_version (const dict_index_t *index, size_t n_tuple_fields) |
For a given clustered index, version is to be stored on physical record. More... | |
size_t | get_extra_bytes_for_temp_redundant (const dict_index_t *index, bool valid_version) |
Variables | |
constexpr ulint | REC_1BYTE_OFFS_LIMIT = 0x7FUL |
constexpr ulint | REC_2BYTE_OFFS_LIMIT = 0x7FFFUL |
constexpr ulint | REC_MAX_DATA_SIZE = 16384 |
Record manager.
Created 5/30/1994 Heikki Tuuri
#define rec_offs_init | ( | offsets | ) | rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets) |
size_t get_extra_bytes_for_temp_redundant | ( | const dict_index_t * | index, |
bool | valid_version | ||
) |
bool is_store_version | ( | const dict_index_t * | index, |
size_t | n_tuple_fields | ||
) |
For a given clustered index, version is to be stored on physical record.
[in] | index | clustered index |
[in] | n_tuple_fields | number of fields in tuple |
std::ostream & operator<< | ( | std::ostream & | o, |
const rec_index_print & | r | ||
) |
Display a record.
[in,out] | o | output stream |
[in] | r | record to display |
std::ostream & operator<< | ( | std::ostream & | o, |
const rec_offsets_print & | r | ||
) |
Display a record.
[in,out] | o | output stream |
[in] | r | record to display |
rec_t * rec_convert_dtuple_to_rec | ( | byte * | buf, |
const dict_index_t * | index, | ||
const dtuple_t * | dtuple | ||
) |
Builds a physical record out of a data tuple and stores it into the given buffer.
[in] | buf | start address of the physical record |
[in] | index | record descriptor |
[in] | dtuple | data tuple |
Builds a physical record out of a data tuple and stores it into the given buffer.
buf | in: start address of the physical record |
index | in: record descriptor |
dtuple | in: data tuple |
Copy a physical record to a buffer.
[in] | buf | buffer |
[in] | rec | physical record |
[in] | offsets | array returned by rec_get_offsets() |
rec_t * rec_copy_prefix_to_buf | ( | const rec_t * | rec, |
const dict_index_t * | index, | ||
ulint | n_fields, | ||
byte ** | buf, | ||
size_t * | buf_size | ||
) |
Copies the first n fields of a physical record to a new physical record in a buffer.
[in] | rec | physical record |
[in] | index | record descriptor |
[in] | n_fields | number of fields to copy |
[in,out] | buf | memory buffer for the copied prefix, or NULL |
[in,out] | buf_size | buffer size |
void rec_copy_prefix_to_dtuple | ( | dtuple_t * | tuple, |
const rec_t * | rec, | ||
const dict_index_t * | index, | ||
ulint | n_fields, | ||
mem_heap_t * | heap | ||
) |
Copies the first n fields of a physical record to a data tuple.
The fields are copied to the memory heap.
[out] | tuple | data tuple |
[in] | rec | physical record |
[in] | index | record descriptor |
[in] | n_fields | number of fields to copy |
[in] | heap | memory heap |
The fields are copied to the memory heap.
tuple | out: data tuple |
rec | in: physical record |
index | in: record descriptor |
n_fields | in: number of fields to copy |
heap | in: memory heap |
void rec_deserialize_init_offsets | ( | const rec_t * | rec, |
const dict_index_t * | index, | ||
ulint * | offsets | ||
) |
Determine the offset to each field in temporary file.
[in] | rec | temporary file record |
[in] | index | record descriptor |
[in,out] | offsets | array of offsets |
rec | in: temporary file record |
index | in: record descriptor |
offsets | in/out: array of offsets; in: n=rec_offs_n_fields(offsets) |
|
inlinestatic |
Determine if the field is not NULL and not having default value after instant ADD COLUMN.
[in] | len | length of a field |
|
inlinestatic |
Returns the extra size of an old-style physical record if we know its data size and number of fields.
[in] | data_size | data size |
[in] | n_fields | number of fields |
[in] | has_ext | true if tuple has ext fields |
|
inlinestatic |
The following function returns the size of a data tuple when converted to a physical record.
[in] | index | record descriptor |
[in] | dtuple | data tuple |
ulint rec_get_converted_size_comp | ( | const dict_index_t * | index, |
ulint | status, | ||
const dfield_t * | fields, | ||
ulint | n_fields, | ||
ulint * | extra | ||
) |
Determines the size of a data tuple in ROW_FORMAT=COMPACT.
[in] | index | record descriptor; dict_table_is_comp() is assumed to hold, even if it does not |
[in] | status | status bits of the record |
[in] | fields | array of data fields |
[in] | n_fields | number of data fields |
[out] | extra | extra size |
index | in: record descriptor; dict_table_is_comp() is assumed to hold, even if it does not |
status | in: status bits of the record |
fields | in: array of data fields |
n_fields | in: number of data fields |
extra | out: extra size |
ulint rec_get_converted_size_comp_prefix | ( | const dict_index_t * | index, |
const dfield_t * | fields, | ||
ulint | n_fields, | ||
ulint * | extra | ||
) |
Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT.
[in] | index | record descriptor |
[in] | fields | array of data fields |
[in] | n_fields | number of data fields |
[out] | extra | extra size |
index | in: record descriptor |
fields | in: array of data fields |
n_fields | in: number of data fields |
extra | out: extra size |
|
inlinestatic |
The following function tells if record is delete marked.
[in] | rec | Physical record. |
[in] | comp | Nonzero=compact page format. |
Returns a pointer to the end of the record.
[in] | rec | pointer to record |
[in] | offsets | array returned by rec_get_offsets() |
The following function is used to get the order number of a new-style record in the heap of the index page.
[in] | rec | physical record |
The following function is used to get the order number of an old-style record in the heap of the index page.
[in] | rec | physical record |
The following function is used to retrieve the info and status bits of a record.
(Only compact records have status bits.)
[in] | rec | Physical record. |
[in] | comp | Nonzero=compact page format. |
ulint rec_get_n_extern_new | ( | const rec_t * | rec, |
const dict_index_t * | index, | ||
ulint | n | ||
) |
Determine how many of the first n columns in a compact physical record are stored externally.
[in] | rec | compact physical record |
[in] | index | record descriptor |
[in] | n | number of columns to scan |
rec | in: compact physical record |
index | in: record descriptor |
n | in: number of columns to scan |
|
inlinestatic |
Get the length of the number of fields for any new style record.
[in] | n_fields | number of fields in the record |
The following function is used to get the number of records owned by the previous directory record.
The following function is used to get the number of records owned by the previous directory record.
The following function is used to get the offset of the next chained record on the same page.
[in] | rec | Physical record. |
[in] | comp | Nonzero=compact page format. |
The following function is used to get the pointer of the next chained record on the same page.
[in] | rec | Physical record. |
[in] | comp | Nonzero=compact page format. |
The following function is used to get the pointer of the next chained record on the same page.
[in] | rec | Physical record. |
[in] | comp | Nonzero=compact page format. |
|
inlinestatic |
The following function tells if a new-style record is a node pointer.
|
inlinestatic |
Gets the value of the specified field in the record.
This is only used when there is possibility that the record comes from the clustered index, which has some instantly added columns.
[in] | rec | physical record |
[in] | offsets | array returned by rec_get_offsets() |
[in] | n | index of the field |
[in] | index | clustered index where the record resides, or nullptr if the record doesn't have instantly added columns for sure |
[out] | len | length of the field, UNIV_SQL_NULL if SQL null |
|
inlinestatic |
Gets the value of the specified field in the record in old style.
This is only used for record from instant index, which is clustered index and has some instantly added columns.
[in] | rec | physical record |
[in] | n | index of the field |
[in] | index | clustered index where the record resides |
[out] | len | length of the field, UNIV_SQL if SQL null |
ulint rec_get_serialize_size | ( | const dict_index_t * | index, |
const dfield_t * | fields, | ||
ulint | n_fields, | ||
const dtuple_t * | v_entry, | ||
ulint * | extra, | ||
uint8_t | rec_version | ||
) |
Determines the size of a data tuple prefix in a temporary file.
[in] | index | record descriptor |
[in] | fields | array of data fields |
[in] | n_fields | number of data fields |
[in] | v_entry | dtuple contains virtual column data |
[out] | extra | extra size |
[in] | rec_version | row version of record |
Determines the size of a data tuple prefix in a temporary file.
Returns a pointer to the start of the record.
[in] | rec | pointer to record |
[in] | offsets | array returned by rec_get_offsets() |
trx_id_t rec_get_trx_id | ( | const rec_t * | rec, |
const dict_index_t * | index | ||
) |
Reads the DB_TRX_ID of a clustered index record.
[in] | rec | record |
[in] | index | clustered index |
rec | in: record |
index | in: clustered index |
|
inlinestatic |
Compute a hash value of a prefix of a leaf page record.
[in] | rec | leaf page record |
[in] | offsets | rec_get_offsets(rec) |
[in] | n_fields | number of complete fields to hash |
[in] | n_bytes | number of bytes to hash in the last field |
[in] | hashed_value | hash value of the index identifier |
[in] | index | index where the record resides |
|
inlinestatic |
The following function is used to reset the instant bit and the row version bit.
[in,out] | rec | new-style (COMPACT/DYNAMIC) physical record |
|
inlinestatic |
The following function is used to set the instant bit.
[in,out] | rec | new-style physical record |
|
inlinestatic |
The following function is used to set the row version bit.
[in,out] | rec | new-style (COMPACT/DYNAMIC) physical record |
|
inlinestatic |
Determine if the offsets are for a record containing externally stored columns.
[in] | offsets | array returned by rec_get_offsets() |
|
inlinestatic |
Determine if the offsets are for a record containing null BLOB pointers.
[in] | index | record descriptor |
[in] | rec | record |
[in] | offsets | array returned by rec_get_offsets() |
|
inlinestatic |
Determine if the offsets are for a record in the new compact format.
[in] | offsets | array returned by rec_get_offsets() |
The following function returns the data size of a physical record, that is the sum of field lengths.
SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes.
[in] | offsets | array returned by rec_get_offsets() |
Returns the total size of record minus data size of record.
The value returned by the function is the distance from record start to record origin in bytes.
[in] | offsets | array returned by rec_get_offsets() |
|
inlinestatic |
Returns the number of extern bits set in a record.
[in] | index | record descriptor |
[in] | offsets | array returned by rec_get_offsets() |
Returns the total size of a physical record.
[in] | offsets | array returned by rec_get_offsets() |
|
inlinestatic |
The following function is used to set the instant bit.
[in,out] | rec | old-style (REDUNDANT) physical record |
[in] | flag | set the bit to this flag |
void rec_print | ( | FILE * | file, |
const rec_t * | rec, | ||
const dict_index_t * | index | ||
) |
Prints a physical record.
[in] | file | File where to print |
[in] | rec | Physical record |
[in] | index | Record descriptor |
Pretty-print a record.
[in,out] | o | output stream |
[in] | rec | physical record |
[in] | info | rec_get_info_bits(rec) |
[in] | offsets | rec_get_offsets(rec) |
Prints a spatial index record.
[in] | file | File where to print |
[in] | rec | Physical record |
[in] | offsets | Array returned by rec_get_offsets() |
Prints a physical record.
[in] | file | file where to print |
[in] | rec | physical record |
[in] | offsets | array returned by rec_get_offsets() |
file | in: file where to print |
rec | in: physical record |
offsets | in: array returned by rec_get_offsets() |
void rec_print_old | ( | FILE * | file, |
const rec_t * | rec | ||
) |
Prints an old-style physical record.
[in] | file | File where to print |
[in] | rec | Physical record |
void rec_serialize_dtuple | ( | rec_t * | rec, |
const dict_index_t * | index, | ||
const dfield_t * | fields, | ||
ulint | n_fields, | ||
const dtuple_t * | v_entry, | ||
uint8_t | rec_version | ||
) |
Builds a temporary file record out of a data tuple.
[out] | rec | record |
[in] | index | record descriptor |
[in] | fields | array of data fields |
[in] | n_fields | number of fields |
[in] | v_entry | dtuple contains virtual column data |
[in] | rec_version | rec version |
|
inlinestatic |
The following function is used to set the 1-byte offsets flag.
[in] | rec | physical record |
[in] | flag | true if 1byte form |
|
inlinestatic |
The following function is used to set the deleted bit.
[in,out] | rec | new-style physical record |
[in,out] | page_zip | compressed page, or NULL |
[in] | flag | true if delete marked |
|
inlinestatic |
The following function is used to set the deleted bit.
[in] | rec | old-style physical record |
[in] | flag | true if delete marked |
The following function is used to set the heap number field in a new-style record.
[in,out] | rec | physical record |
[in] | heap_no | the heap number |
The following function is used to set the heap number field in an old-style record.
[in] | rec | physical record |
[in] | heap_no | the heap number |
The following function is used to set the info and status bits of a record.
(Only compact records have status bits.)
[in,out] | rec | compact physical record |
[in] | bits | info bits |
The following function is used to set the info bits of a record.
[in,out] | rec | new-style physical record |
[in] | bits | info bits |
The following function is used to set the info bits of a record.
[in] | rec | old-style physical record |
[in] | bits | info bits |
|
inlinestatic |
Set the row version on one new style leaf page record.
This is only needed for table after instant ADD/DROP COLUMN.
[in,out] | rec | leaf page record |
[in] | version | row version |
|
inlinestatic |
Set the row version on one old style leaf page record.
This is only needed for table after instant ADD/DROP COLUMN.
[in,out] | rec | leaf page record |
[in] | version | row version |
|
inlinestatic |
The following function is used to set the number of owned records.
[in,out] | rec | new-style physical record |
[in,out] | page_zip | compressed page, or NULL |
[in] | n_owned | the number of owned |
The following function is used to set the number of owned records.
[in] | rec | old-style physical record |
[in] | n_owned | the number of owned |
The following function is used to set the next record offset field of a new-style record.
The following function is used to set the next record offset field of an old-style record.
[in] | rec | old-style physical record |
[in] | next | offset of the next record |
The following function is used to set the status bits of a new-style record.
[in,out] | rec | physical record |
[in] | bits | info bits |
Validates the consistency of a physical record.
[in] | rec | physical record |
[in] | offsets | array returned by rec_get_offsets() |
|
constexpr |
|
constexpr |
|
constexpr |