MySQL  8.0.19
Source Code Documentation
rem0rec.cc File Reference
#include "rem0rec.h"
#include <sys/types.h>
#include "data0data.h"
#include "fts0fts.h"
#include "gis0geo.h"
#include "mach0data.h"
#include "mtr0log.h"
#include "mtr0mtr.h"
#include "page0page.h"
#include "trx0sys.h"
#include "my_dbug.h"

Functions

static ibool 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...
 
ulint rec_get_nth_field_offs_old (const rec_t *rec, ulint n, ulint *len)
 The following function is used to get the offset to the nth data field in an old-style record. More...
 
UNIV_INLINE 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)
 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...
 
void rec_set_nth_field_null_bit (rec_t *rec, ulint i, ibool val)
 Sets the value of the ith field SQL null bit of an old-style record. More...
 
void rec_set_nth_field_sql_null (rec_t *rec, ulint n)
 Sets an old-style record field to SQL null. More...
 
static rec_trec_convert_dtuple_to_rec_old (byte *buf, const dtuple_t *dtuple, ulint n_ext)
 Builds an old-style physical record out of a data tuple and stores it beginning from the start of the given buffer. More...
 
UNIV_INLINE bool 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)
 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, ulint n_ext)
 Builds a physical record out of a data tuple and stores it beginning from the start of the given buffer. More...
 
ulint rec_get_converted_size_temp (const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry, ulint *extra)
 Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. More...
 
void rec_init_offsets_temp (const rec_t *rec, const dict_index_t *index, ulint *offsets)
 Determine the offset to each field in temporary file. More...
 
void rec_convert_dtuple_to_temp (rec_t *rec, const dict_index_t *index, const dfield_t *fields, ulint n_fields, const dtuple_t *v_entry)
 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...
 
ibool 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...
 
void rec_offs_make_nth_extern (ulint *offsets, const ulint n)
 Mark the nth field as externally stored. More...
 

Detailed Description

Record manager

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ 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,
ulint  n_ext 
)

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
n_extin: number of externally stored columns

◆ rec_convert_dtuple_to_rec_comp()

UNIV_INLINE bool 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 
)

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

Parameters
[in]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
Returns
true if this record is an instant record on leaf page
Return values
falseif not an instant record

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

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

static rec_t* rec_convert_dtuple_to_rec_old ( byte buf,
const dtuple_t dtuple,
ulint  n_ext 
)
static

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

Returns
pointer to the origin of physical record
Parameters
bufin: start address of the physical record
dtuplein: data tuple
n_extin: number of externally stored columns

◆ rec_convert_dtuple_to_temp()

void rec_convert_dtuple_to_temp ( rec_t rec,
const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry 
)

Builds a temporary file record out of a data tuple.

See also
rec_init_offsets_temp()
Parameters
recout: record
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of fields
v_entryin: dtuple contains virtual column data

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

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.

Returns
own: copied record
Parameters
recin: physical record
n_fieldsin: number of fields to copy
area_endin: end of the prefix data
bufin/out: memory buffer for the copied prefix, or NULL
buf_sizein/out: buffer size

◆ 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_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()

UNIV_INLINE 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 
)

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

Returns
total size
Parameters
indexin: record descriptor; dict_table_is_comp() is assumed to hold, even if it does not
fieldsin: array of data fields
n_fieldsin: number of data fields
v_entryin: dtuple contains virtual column data
extraout: extra size
statusin: status bits of the record, can be nullptr if unnecessary
tempin: whether this is a temporary file record

◆ rec_get_converted_size_temp()

ulint rec_get_converted_size_temp ( const dict_index_t index,
const dfield_t fields,
ulint  n_fields,
const dtuple_t v_entry,
ulint *  extra 
)

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
Parameters
indexin: record descriptor
fieldsin: array of data fields
n_fieldsin: number of data fields
v_entryin: dtuple contains virtual column data
extraout: extra 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_nth_field_offs_old()

ulint rec_get_nth_field_offs_old ( const rec_t rec,
ulint  n,
ulint *  len 
)

The following function is used to get the offset to the nth data field in an old-style record.

Returns
offset to the field
Parameters
recin: record
nin: index of the field
lenout: length of the field; UNIV_SQL_NULL if SQL null

◆ 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_init_offsets_temp()

void rec_init_offsets_temp ( const rec_t rec,
const dict_index_t index,
ulint *  offsets 
)

Determine the offset to each field in temporary file.

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

◆ rec_offs_make_nth_extern()

void rec_offs_make_nth_extern ( ulint *  offsets,
const ulint  n 
)

Mark the nth field as externally stored.

Parameters
[in]offsetsarray returned by rec_get_offsets()
[in]nnth field

◆ rec_print() [1/2]

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

Prints a physical record.

in: record descriptor

Parameters
filein: file where to print
recin: physical record
indexin: record 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.

in: array returned by rec_get_offsets()

Parameters
filein: file where to print
recin: physical record
offsetsin: array 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.

Prints a physical record.

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.

in: physical record

Parameters
filein: file where to print
recin: physical record

◆ rec_set_nth_field_null_bit()

void rec_set_nth_field_null_bit ( rec_t rec,
ulint  i,
ibool  val 
)

Sets the value of the ith field SQL null bit of an old-style record.

Parameters
recin: record
iin: ith field
valin: value to set

◆ rec_set_nth_field_sql_null()

void rec_set_nth_field_sql_null ( rec_t rec,
ulint  n 
)

Sets an old-style record field to SQL null.

The physical size of the field is not changed.

Parameters
recin: record
nin: index of the field

◆ rec_validate()

ibool rec_validate ( const rec_t rec,
const ulint *  offsets 
)

Validates the consistency of a physical record.

Returns
true if ok
Parameters
recin: physical record
offsetsin: array returned by rec_get_offsets()

◆ rec_validate_old()

static ibool rec_validate_old ( const rec_t rec)
static

Validates the consistency of an old-style physical record.

Returns
true if ok in: physical record
true if ok
Parameters
recin: physical record