MySQL 9.1.0
Source Code Documentation
rem0rec.cc File Reference

Record manager. More...

#include "rem0rec.h"
#include "rem0lrec.h"
#include <sys/types.h>
#include "data0data.h"
#include "fts0fts.h"
#include "gis0geo.h"
#include "lob0lob.h"
#include "mach0data.h"
#include "mtr0log.h"
#include "mtr0mtr.h"
#include "page0page.h"
#include "trx0sys.h"
#include "my_dbug.h"

Functions

static bool rec_validate_old (const rec_t *rec)
 Validates the consistency of an old-style physical record. 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...
 
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...
 
static size_t get_nullable_fields_for_rec (const dict_index_t *index, const size_t n_fields, row_version_t &rec_version)
 
static ulint rec_get_converted_size_comp_prefix_low (const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, ulint *extra, ulint *status, bool temp, row_version_t rec_version)
 Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. 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 rec_trec_convert_dtuple_to_rec_old (byte *buf, const dict_index_t *index, const dtuple_t *dtuple)
 Builds an old-style physical record out of a data tuple and stores it beginning from the start of the given buffer. More...
 
size_t get_extra_bytes_for_temp_redundant (const dict_index_t *index, bool valid_version)
 
static Rec_instant_state rec_convert_dtuple_to_rec_comp (rec_t *rec, const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, ulint status, bool temp, row_version_t rec_version)
 Builds a ROW_FORMAT=COMPACT record out of a data tuple. More...
 
static rec_trec_convert_dtuple_to_rec_new (byte *buf, const dict_index_t *index, const dtuple_t *dtuple)
 Builds a new-style physical record out of a data tuple and stores it beginning from the start of the given buffer. More...
 
rec_trec_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 beginning from the start of the given 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, row_version_t rec_version)
 Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. 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, row_version_t rec_version)
 Builds a temporary file record out of a data tuple. 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 rec_trec_copy_prefix_to_buf_old (const rec_t *rec, ulint n_fields, ulint area_end, byte **buf, size_t *buf_size)
 Copies the first n fields of an old-style physical record to a new physical record in a buffer. More...
 
rec_trec_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...
 
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...
 
static void rec_print_comp (FILE *file, const rec_t *rec, const ulint *offsets)
 Prints a physical record in ROW_FORMAT=COMPACT. More...
 
static void rec_print_mbr_old (FILE *file, const rec_t *rec)
 Prints an old-style spatial index 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...
 

Detailed Description

Record manager.

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ get_extra_bytes_for_temp_redundant()

size_t get_extra_bytes_for_temp_redundant ( const dict_index_t index,
bool  valid_version 
)

◆ get_nullable_fields_for_rec()

static size_t get_nullable_fields_for_rec ( const dict_index_t index,
const size_t  n_fields,
row_version_t rec_version 
)
static

◆ is_store_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.

Parameters
[in]indexclustered index
[in]n_tuple_fieldsnumber of fields in tuple
Returns
true, if version is to be stored

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  o,
const rec_index_print r 
)

Display a record.

Parameters
[in,out]ooutput stream
[in]rrecord to display
Returns
the output stream

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  o,
const rec_offsets_print r 
)

Display a record.

Parameters
[in,out]ooutput stream
[in]rrecord to display
Returns
the output stream

◆ rec_convert_dtuple_to_rec()

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 beginning from the start of the given buffer.

Builds a physical record out of a data tuple and stores it into the given buffer.

Returns
pointer to the origin of physical record
Parameters
bufin: start address of the physical record
indexin: record descriptor
dtuplein: data tuple

◆ rec_convert_dtuple_to_rec_comp()

static Rec_instant_state rec_convert_dtuple_to_rec_comp ( rec_t rec,
const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
ulint  status,
bool  temp,
row_version_t  rec_version 
)
inlinestatic

Builds a ROW_FORMAT=COMPACT record out of a data tuple.

Parameters
[in,out]recorigin of record
[in]indexrecord descriptor
[in]fieldsarray of data fields
[in]n_fieldsnumber of data fields
[in]v_entrydtuple contains virtual column data
[in]statusstatus bits of the record
[in]tempwhether to use the format for temporary files in index creation
[in]rec_versionrec version (could be 0 also)
Returns
record instant information for record on leaf page

◆ rec_convert_dtuple_to_rec_new()

static rec_t * rec_convert_dtuple_to_rec_new ( byte buf,
const dict_index_t index,
const dtuple_t dtuple 
)
static

Builds a new-style physical record out of a data tuple and stores it beginning from the start of the given buffer.

Parameters
[in]bufstart address of the physical record
[in]indexrecord descriptor
[in]dtupledata tuple
Returns
pointer to the origin of physical record

◆ rec_convert_dtuple_to_rec_old()

static rec_t * rec_convert_dtuple_to_rec_old ( byte buf,
const dict_index_t index,
const dtuple_t dtuple 
)
static

Builds an old-style physical record out of a data tuple and stores it beginning from the start of the given buffer.

Parameters
[in]bufstart address of the physical record
[in]indexrecord descriptor
[in]dtupledata tuple
Returns
pointer to the origin of physical record

◆ rec_copy_prefix_to_buf()

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.

Parameters
[in]recphysical record
[in]indexrecord descriptor
[in]n_fieldsnumber of fields to copy
[in,out]bufmemory buffer for the copied prefix, or NULL
[in,out]buf_sizebuffer size
Returns
own: copied record

◆ rec_copy_prefix_to_buf_old()

static rec_t * rec_copy_prefix_to_buf_old ( const rec_t rec,
ulint  n_fields,
ulint  area_end,
byte **  buf,
size_t *  buf_size 
)
static

Copies the first n fields of an old-style physical record to a new physical record in a buffer.

Parameters
[in]recphysical record
[in]n_fieldsnumber of fields to copy
[in]area_endend of the prefix data
[in,out]bufmemory buffer for the copied prefix, or NULL
[in,out]buf_sizebuffer size
Returns
own: copied record

◆ rec_copy_prefix_to_dtuple()

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.

Parameters
tupleout: data tuple
recin: physical record
indexin: record descriptor
n_fieldsin: number of fields to copy
heapin: memory heap

◆ rec_deserialize_init_offsets()

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.

See also
rec_serialize_dtuple()
Parameters
recin: temporary file record
indexin: record descriptor
offsetsin/out: array of offsets; in: n=rec_offs_n_fields(offsets)

◆ rec_get_converted_size_comp()

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.

Returns
total size
Parameters
indexin: record descriptor; dict_table_is_comp() is assumed to hold, even if it does not
statusin: status bits of the record
fieldsin: array of data fields
n_fieldsin: number of data fields
extraout: extra size

◆ rec_get_converted_size_comp_prefix()

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.

Returns
total size
Parameters
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of data fields
extraout: extra size

◆ rec_get_converted_size_comp_prefix_low()

static ulint rec_get_converted_size_comp_prefix_low ( const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
ulint extra,
ulint status,
bool  temp,
row_version_t  rec_version 
)
inlinestatic

Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT.

Parameters
[in]indexrecord descriptor, dict_table_is_comp() is assumed to hold, even if it does not
[in]fieldsarray of data fields
[in]n_fieldsnumber of data fields
[in]v_entrydtuple contains virtual column data
[out]extraextra size
[in]statusstatus bits of the record, can be nullptr if unnecessary
[in]tempwhether this is a temporary file record
[in]rec_versionrec version if INSTANT
Returns
total size

◆ rec_get_n_extern_new()

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.

Returns
number of externally stored columns
Parameters
recin: compact physical record
indexin: record descriptor
nin: number of columns to scan

◆ rec_get_serialize_size()

ulint rec_get_serialize_size ( const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
ulint extra,
row_version_t  rec_version 
)

Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT.

Determines the size of a data tuple prefix in a temporary file.

Returns
total size

◆ rec_get_trx_id()

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.

Returns
the value of DB_TRX_ID
Parameters
recin: record
indexin: clustered index

◆ rec_print() [1/2]

void rec_print ( FILE *  file,
const rec_t rec,
const dict_index_t index 
)

Prints a physical record.

Parameters
[in]fileFile where to print
[in]recPhysical record
[in]indexRecord descriptor

◆ rec_print() [2/2]

void rec_print ( std::ostream &  o,
const rec_t rec,
ulint  info,
const ulint offsets 
)

Pretty-print a record.

Parameters
[in,out]ooutput stream
[in]recphysical record
[in]inforec_get_info_bits(rec)
[in]offsetsrec_get_offsets(rec)

◆ rec_print_comp()

static void rec_print_comp ( FILE *  file,
const rec_t rec,
const ulint offsets 
)
static

Prints a physical record in ROW_FORMAT=COMPACT.

Ignores the record header.

Parameters
filein: file where to print
recin: physical record
offsetsin: array returned by rec_get_offsets()

◆ rec_print_mbr_old()

static void rec_print_mbr_old ( FILE *  file,
const rec_t rec 
)
static

Prints an old-style spatial index record.

Parameters
filein: file where to print
recin: physical record

◆ rec_print_mbr_rec()

void rec_print_mbr_rec ( FILE *  file,
const rec_t rec,
const ulint offsets 
)

Prints a spatial index record.

Parameters
[in]fileFile where to print
[in]recPhysical record
[in]offsetsArray returned by rec_get_offsets()

◆ rec_print_new()

void rec_print_new ( FILE *  file,
const rec_t rec,
const ulint offsets 
)

Prints a physical record.

Parameters
[in]filefile where to print
[in]recphysical record
[in]offsetsarray returned by rec_get_offsets()
Parameters
filein: file where to print
recin: physical record
offsetsin: array returned by rec_get_offsets()

◆ rec_print_old()

void rec_print_old ( FILE *  file,
const rec_t rec 
)

Prints an old-style physical record.

Parameters
[in]fileFile where to print
[in]recPhysical record

◆ rec_serialize_dtuple()

void rec_serialize_dtuple ( rec_t rec,
const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
row_version_t  rec_version 
)

Builds a temporary file record out of a data tuple.

Parameters
[out]recrecord
[in]indexrecord descriptor
[in]fieldsarray of data fields
[in]n_fieldsnumber of fields
[in]v_entrydtuple contains virtual column data
[in]rec_versionrec version
See also
rec_deserialize_init_offsets()

◆ rec_validate()

bool rec_validate ( const rec_t rec,
const ulint offsets 
)

Validates the consistency of a physical record.

Parameters
[in]recphysical record
[in]offsetsarray returned by rec_get_offsets()
Returns
true if ok

◆ rec_validate_old()

static bool rec_validate_old ( const rec_t rec)
static

Validates the consistency of an old-style physical record.

Parameters
[in]recphysical record
Returns
true if ok